-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTchaAgro.html
More file actions
2952 lines (2720 loc) · 176 KB
/
TchaAgro.html
File metadata and controls
2952 lines (2720 loc) · 176 KB
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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="theme-color" content="#0a0f1a">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="description" content="TchaAgro — Agricultural Trade Management: Income/Expense Tracking and Activity Management for Chadian Agri-Export.">
<meta property="og:type" content="website">
<meta property="og:title" content="TchaAgro — Agricultural Trade Management">
<meta property="og:description" content="Offline-first trade management for African agricultural exports. Income tracking, inventory and activity management.">
<meta property="og:url" content="https://rawkeep.github.io/TchaAgro/">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="TchaAgro — Agri-Export Management">
<title>TchaAgro — Agricultural Trade Management</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='8' fill='%23d97706'/><text x='16' y='23' font-family='system-ui' font-weight='bold' font-size='20' fill='white' text-anchor='middle'>TA</text></svg>">
<link rel="manifest" href="data:application/json;base64,eyJuYW1lIjoiVGNoYSBBZ3JvIiwic2hvcnRfbmFtZSI6IlRjaGEgQWdybyIsImRlc2NyaXB0aW9uIjoiS2Fzc2VuYnVjaCB1bmQgTGFnZXJ2ZXJ3YWx0dW5nIiwidGhlbWVfY29sb3IiOiIjMGEwZjFhIiwiYmFja2dyb3VuZF9jb2xvciI6IiMwYTBmMWEiLCJkaXNwbGF5Ijoic3RhbmRhbG9uZSIsIm9yaWVudGF0aW9uIjoicG9ydHJhaXQtcHJpbWFyeSIsInN0YXJ0X3VybCI6Ii4vIiwiaWNvbnMiOlt7InNyYyI6ImRhdGE6aW1hZ2Uvc3ZnK3htbCwlM0NzdmcgeG1sbnM9JTI3aHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmclMjcgdmlld0JveD0lMjcwIDAgNTEyIDUxMiUyNyUzRSUzQ3JlY3Qgd2lkdGg9JTI3NTEyJTI3IGhlaWdodD0lMjc1MTIlMjcgcng9JTI3OTYlMjcgZmlsbD0lMjclMjNkOTc3MDYlMjcvJTNFJTNDdGV4dCB4PSUyNzI1NiUyNyB5PSUyNzM3MCUyNyBmb250LWZhbWlseT0lMjdzeXN0ZW0tdWklMjcgZm9udC13ZWlnaHQ9JTI3Ym9sZCUyNyBmb250LXNpemU9JTI3MzIwJTI3IGZpbGw9JTI3d2hpdGUlMjcgdGV4dC1hbmNob3I9JTI3bWlkZGxlJTI3JTNFVEElM0MvdGV4dCUzRSUzQy9zdmclM0UiLCJzaXplcyI6IjUxMng1MTIiLCJ0eXBlIjoiaW1hZ2Uvc3ZnK3htbCIsInB1cnBvc2UiOiJhbnkgbWFza2FibGUifV19">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:opsz,[email protected],300..700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
/* Reset & Base */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{font-family:'DM Sans',system-ui,-apple-system,sans-serif;background:#0a0f1a;color:#e2e8f0;
-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;
overscroll-behavior:none;padding-bottom:env(safe-area-inset-bottom);min-height:100dvh}
input,select,textarea,button{font:inherit;color:inherit}
a{color:inherit;text-decoration:none}
*{-webkit-tap-highlight-color:transparent}
::-webkit-scrollbar{width:5px}::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#1e293b;border-radius:3px}
input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}
input[type=number]{-moz-appearance:textfield}
/* CSS Variables */
:root{
--bg:#0a0f1a;--bg1:#0f1629;--bg2:#151d30;--bg3:#1a2540;
--border:#1e2d4a;--border2:#243656;
--text:#e2e8f0;--text2:#94a3b8;--text3:#64748b;--text4:#475569;
--blue:#3b82f6;--blue2:#2563eb;--brand1:#d97706;--brand2:#15803d;
--green:#34d399;--green2:#10b981;--red:#f87171;--red2:#ef4444;
--amber:#fbbf24;--violet:#a78bfa;--sky:#38bdf8;
--mono:'JetBrains Mono',monospace;--radius:12px;--radius-sm:8px;
--toast-green:#059669;--toast-red:#dc2626;--toast-blue:#2563eb;
}
/* App Shell */
#app{display:flex;flex-direction:column;height:100dvh;max-width:600px;margin:0 auto;position:relative}
.topbar{flex:none;display:flex;align-items:center;justify-content:space-between;
padding:10px 16px;background:rgba(15,22,41,.85);backdrop-filter:blur(20px);
border-bottom:1px solid var(--border);z-index:30;position:sticky;top:0}
.topbar-left{display:flex;align-items:center;gap:10px}
.topbar-logo{width:32px;height:32px;border-radius:10px;background:linear-gradient(135deg,#d97706,#15803d);
display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:14px}
.topbar-info h1{font-size:13px;font-weight:600;line-height:1}
.topbar-info p{font-size:10px;color:var(--text3);margin-top:2px}
.topbar-right{display:flex;align-items:center;gap:6px}
.main{flex:1;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch}
.navbar{flex:none;display:flex;background:rgba(15,22,41,.92);backdrop-filter:blur(20px);
border-top:1px solid var(--border);padding-bottom:env(safe-area-inset-bottom);z-index:30}
.nav-item{flex:1;display:flex;flex-direction:column;align-items:center;gap:1px;padding:6px 0;
color:var(--text4);transition:color .15s;cursor:pointer;border:none;background:none;font-size:9px;font-weight:500}
.nav-item.active{color:var(--blue)}
.nav-item svg{width:18px;height:18px}
/* Common UI */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 16px;
border-radius:var(--radius);font-size:14px;font-weight:600;border:none;cursor:pointer;transition:all .15s}
.btn-primary{background:var(--blue);color:#fff}.btn-primary:hover{background:var(--blue2)}
.btn-primary:disabled{opacity:.4;pointer-events:none}
.btn-sm{padding:7px 12px;font-size:12px;border-radius:var(--radius-sm)}
.btn-ghost{background:transparent;color:var(--text2)}.btn-ghost:hover{background:var(--bg3);color:var(--text)}
.btn-danger{background:transparent;color:var(--red);border:1px solid rgba(248,113,113,.2)}
.btn-danger:hover{background:rgba(248,113,113,.08)}
.input{width:100%;padding:12px 14px;background:var(--bg2);border:1px solid var(--border);
border-radius:var(--radius);font-size:14px;color:var(--text);outline:none;transition:border-color .15s}
.input:focus{border-color:rgba(59,130,246,.5)}
.input::placeholder{color:var(--text4)}
.input-icon{position:relative}.input-icon svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--text4);width:16px;height:16px}
.input-icon .input{padding-left:38px}
select.input{-webkit-appearance:none;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
background-repeat:no-repeat;background-position:right 12px center}
.card{padding:16px;border-radius:var(--radius);background:var(--bg2);border:1px solid var(--border)}
.badge{display:inline-flex;padding:2px 8px;border-radius:6px;font-size:10px;font-weight:600}
.badge-green{background:rgba(52,211,153,.12);color:var(--green)}
.badge-red{background:rgba(248,113,113,.12);color:var(--red)}
.badge-blue{background:rgba(59,130,246,.12);color:var(--blue)}
.badge-sky{background:rgba(56,189,248,.12);color:var(--sky)}
.badge-violet{background:rgba(167,139,250,.12);color:var(--violet)}
.badge-amber{background:rgba(251,191,36,.12);color:var(--amber)}
.badge-gray{background:rgba(100,116,139,.15);color:var(--text3)}
.page{padding:16px 16px 20px;animation:pageIn .25s ease-out}
@keyframes pageIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
@keyframes fadeUp{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}
@keyframes spin{to{transform:rotate(360deg)}}
@keyframes slideInRight{from{opacity:0;transform:translateX(40px)}to{opacity:1;transform:translateX(0)}}
@keyframes slideOutRight{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(40px)}}
@keyframes modalIn{from{opacity:0;transform:scale(.95) translateY(10px)}to{opacity:1;transform:scale(1) translateY(0)}}
@keyframes modalOut{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}
@keyframes backdropIn{from{opacity:0}to{opacity:1}}
@keyframes shimmer{0%{background-position:-200% 0}100%{background-position:200% 0}}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}
.label{font-size:11px;color:var(--text3);margin-bottom:6px;display:block;font-weight:500}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
.space-y>*+*{margin-top:12px}
.space-y-sm>*+*{margin-top:8px}
.flex-between{display:flex;align-items:center;justify-content:space-between}
.text-mono{font-family:var(--mono)}
.tabular{font-variant-numeric:tabular-nums}
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.text-center{text-align:center}
.text-right{text-align:right}
.hidden{display:none!important}
.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}
.helper-note{padding:10px 12px;border-radius:var(--radius-sm);background:rgba(59,130,246,.08);border:1px solid rgba(59,130,246,.18);font-size:12px;color:var(--text2)}
.helper-note b{color:var(--text)}
.guide-strip{padding:8px 16px;border-bottom:1px solid var(--border);background:rgba(21,29,48,.65);font-size:12px;color:var(--text2)}
.guide-strip b{color:var(--blue)}
.lang-btn{padding:4px 8px;border-radius:6px;font-size:10px;font-weight:600;border:1px solid var(--border);background:transparent;color:var(--text3);cursor:pointer}
.lang-btn.active{border-color:var(--blue);color:var(--blue);background:rgba(59,130,246,.1)}
.admin-lock{padding:12px;border-radius:var(--radius);background:rgba(248,113,113,.06);border:1px solid rgba(248,113,113,.15);margin-bottom:12px}
.admin-lock p{font-size:12px;color:var(--red)}
/* Chip selectors */
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{padding:9px 14px;border-radius:var(--radius);font-size:13px;font-weight:500;
border:1px solid var(--border);color:var(--text3);cursor:pointer;transition:all .15s;background:transparent}
.chip.active{border-color:rgba(59,130,246,.4);background:rgba(59,130,246,.12);color:var(--blue)}
.chip-green.active{border-color:rgba(52,211,153,.4);background:rgba(52,211,153,.12);color:var(--green)}
.chip-red.active{border-color:rgba(248,113,113,.4);background:rgba(248,113,113,.12);color:var(--red)}
.chip-sky.active{border-color:rgba(56,189,248,.4);background:rgba(56,189,248,.12);color:var(--sky)}
.chip-violet.active{border-color:rgba(167,139,250,.4);background:rgba(167,139,250,.12);color:var(--violet)}
.chip-amber.active{border-color:rgba(251,191,36,.4);background:rgba(251,191,36,.12);color:var(--amber)}
.chip-gray.active{border-color:rgba(100,116,139,.4);background:rgba(100,116,139,.2);color:var(--text2)}
/* Summary cards */
.stat-card{padding:14px;border-radius:var(--radius);border:1px solid}
.stat-card .stat-icon{display:flex;align-items:center;gap:6px;margin-bottom:6px}
.stat-card .stat-icon svg{width:14px;height:14px}
.stat-card .stat-icon span{font-size:10px;font-weight:500}
.stat-card .stat-val{font-size:15px;font-weight:700}
.sc-green{background:linear-gradient(135deg,rgba(52,211,153,.08),rgba(52,211,153,.03));border-color:rgba(52,211,153,.12)}
.sc-green .stat-icon svg,.sc-green .stat-icon span{color:var(--green)}
.sc-red{background:linear-gradient(135deg,rgba(248,113,113,.08),rgba(248,113,113,.03));border-color:rgba(248,113,113,.12)}
.sc-red .stat-icon svg,.sc-red .stat-icon span{color:var(--red)}
.sc-blue{background:linear-gradient(135deg,rgba(59,130,246,.08),rgba(59,130,246,.03));border-color:rgba(59,130,246,.12)}
.sc-blue .stat-icon svg,.sc-blue .stat-icon span{color:var(--blue)}
.sc-violet{background:linear-gradient(135deg,rgba(167,139,250,.08),rgba(167,139,250,.03));border-color:rgba(167,139,250,.12)}
.sc-violet .stat-icon svg,.sc-violet .stat-icon span{color:var(--violet)}
/* Quick action cards */
.qaction{display:flex;align-items:center;gap:12px;padding:14px;border-radius:var(--radius);
border:1px solid;cursor:pointer;transition:all .15s;background:transparent}
.qaction:hover{border-color:rgba(59,130,246,.3)}
.qaction-icon{width:40px;height:40px;border-radius:10px;display:flex;align-items:center;justify-content:center;flex:none}
.qaction h4{font-size:13px;font-weight:600;color:var(--text)}
.qaction p{font-size:10px;color:var(--text3);margin-top:1px}
/* List items */
.list-item{display:flex;align-items:center;justify-content:space-between;padding:12px;
border-radius:var(--radius);background:var(--bg2);border:1px solid var(--border);
cursor:pointer;transition:background .12s}
.list-item:hover{background:var(--bg3)}
.list-item+.list-item{margin-top:6px}
/* Line items table */
.line-item{padding:12px;border-radius:var(--radius);background:var(--bg1);border:1px solid var(--border);margin-top:8px}
.line-row{display:grid;gap:8px}
.line-row-3{grid-template-columns:2fr 1fr}
.line-row-4{grid-template-columns:1fr 1fr 1fr auto}
.line-hdr{display:flex;align-items:center;justify-content:space-between}
.line-num{font-size:10px;color:var(--text4);font-family:var(--mono)}
/* Login */
.login-wrap{min-height:100dvh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px;position:relative}
.login-glow{position:fixed;top:20%;left:50%;transform:translateX(-50%);width:400px;height:400px;
border-radius:50%;background:rgba(59,130,246,.06);filter:blur(100px);pointer-events:none}
.login-box{width:100%;max-width:360px;position:relative;z-index:1}
.login-logo{display:flex;flex-direction:column;align-items:center;margin-bottom:40px}
.login-logo-icon{width:56px;height:56px;border-radius:16px;background:linear-gradient(135deg,#d97706,#15803d);
display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:24px;margin-bottom:16px;
box-shadow:0 8px 30px rgba(217,119,6,.25)}
.login-logo h1{font-size:22px;font-weight:700}.login-logo p{font-size:13px;color:var(--text3);margin-top:4px}
.demo-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
.demo-btn{padding:10px;border-radius:10px;background:var(--bg3);border:1px solid var(--border);
cursor:pointer;text-align:center;transition:background .12s}
.demo-btn:hover{background:var(--bg2)}
.demo-btn .name{font-size:12px;font-weight:500;color:var(--text2)}
.demo-btn .pin{font-size:10px;color:var(--text4);font-family:var(--mono);margin-top:2px}
/* Sync indicator */
.sync-btn{display:flex;align-items:center;gap:5px;padding:5px 10px;border-radius:8px;border:none;
background:transparent;cursor:pointer;font-size:11px;color:var(--text3);transition:background .12s}
.sync-btn:hover{background:var(--bg3)}
.sync-dot{width:7px;height:7px;border-radius:50%}
.sync-dot.online{background:var(--green)}.sync-dot.offline{background:var(--amber)}
.sync-dot.syncing{background:var(--blue);animation:spin .8s linear infinite}
.pending-badge{background:rgba(251,191,36,.15);color:var(--amber);padding:1px 6px;border-radius:10px;font-size:9px;font-weight:600}
/* Activity timeline */
.timeline-item{display:flex;gap:10px;padding:8px 0}
.timeline-dot{display:flex;flex-direction:column;align-items:center;flex:none;padding-top:5px}
.timeline-dot span{width:6px;height:6px;border-radius:50%;background:var(--text4)}
.timeline-dot .line{width:1px;flex:1;background:var(--border);margin-top:4px}
.timeline-body{flex:1;padding-bottom:4px}
.timeline-body .who{font-size:12px;color:var(--text2)}
.timeline-body .who b{color:var(--text);font-weight:500}
.timeline-body .when{font-size:10px;color:var(--text4);margin-top:2px}
.timeline-body .detail{font-size:10px;color:var(--text4);font-family:var(--mono);margin-top:2px}
/* Modal & Toast */
.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.6);backdrop-filter:blur(8px);z-index:100;
display:flex;align-items:center;justify-content:center;padding:20px;animation:backdropIn .2s ease-out}
.modal-backdrop.closing{animation:backdropIn .15s ease-in reverse forwards}
.modal-box{width:100%;max-width:380px;background:var(--bg2);border:1px solid var(--border2);
border-radius:16px;padding:24px;animation:modalIn .25s ease-out;box-shadow:0 25px 60px rgba(0,0,0,.5)}
.modal-backdrop.closing .modal-box{animation:modalOut .15s ease-in forwards}
.modal-title{font-size:16px;font-weight:700;margin-bottom:8px}
.modal-msg{font-size:13px;color:var(--text2);line-height:1.5;margin-bottom:20px;white-space:pre-line}
.modal-input{width:100%;padding:12px 14px;background:var(--bg1);border:1px solid var(--border);
border-radius:var(--radius);font-size:14px;color:var(--text);outline:none;margin-bottom:16px}
.modal-input:focus{border-color:rgba(59,130,246,.5)}
.modal-btns{display:flex;gap:10px;justify-content:flex-end}
.modal-btns .btn{min-width:80px}
.toast-container{position:fixed;top:60px;right:16px;z-index:200;display:flex;flex-direction:column;gap:8px;pointer-events:none;max-width:340px}
.toast{pointer-events:auto;display:flex;align-items:center;gap:10px;padding:12px 16px;border-radius:12px;
font-size:13px;font-weight:500;box-shadow:0 8px 30px rgba(0,0,0,.4);animation:slideInRight .3s ease-out;
backdrop-filter:blur(12px)}
.toast.removing{animation:slideOutRight .25s ease-in forwards}
.toast-success{background:rgba(5,150,105,.92);color:#fff}
.toast-error{background:rgba(220,38,38,.92);color:#fff}
.toast-info{background:rgba(37,99,235,.92);color:#fff}
.toast svg{width:16px;height:16px;flex-shrink:0}
/* Skeleton loading */
.skeleton{background:linear-gradient(90deg,var(--bg3) 25%,var(--bg2) 50%,var(--bg3) 75%);
background-size:200% 100%;animation:shimmer 1.5s infinite;border-radius:var(--radius-sm)}
.skeleton-line{height:14px;margin-bottom:8px;border-radius:4px}
.skeleton-circle{border-radius:50%}
/* Empty states */
.empty-state{text-align:center;padding:48px 20px;color:var(--text4)}
.empty-state .empty-icon{font-size:48px;margin-bottom:16px;opacity:.6}
.empty-state .empty-title{font-size:15px;font-weight:600;color:var(--text3);margin-bottom:6px}
.empty-state .empty-desc{font-size:12px;line-height:1.5}
/* Photo attachment */
.photo-thumb{width:60px;height:60px;border-radius:8px;object-fit:cover;border:1px solid var(--border);cursor:pointer}
.photo-full-modal img{max-width:100%;max-height:70vh;border-radius:12px}
/* Onboarding overlay */
.onboarding-backdrop{position:fixed;inset:0;background:rgba(10,15,26,.95);z-index:300;display:flex;
align-items:center;justify-content:center;padding:24px;animation:backdropIn .4s ease-out}
.onboarding-box{max-width:360px;text-align:center}
.onboarding-step{animation:fadeUp .4s ease-out}
.onboarding-emoji{font-size:64px;margin-bottom:20px}
.onboarding-title{font-size:20px;font-weight:700;margin-bottom:10px}
.onboarding-desc{font-size:14px;color:var(--text2);line-height:1.6;margin-bottom:24px}
.onboarding-dots{display:flex;gap:8px;justify-content:center;margin-bottom:20px}
.onboarding-dots span{width:8px;height:8px;border-radius:50%;background:var(--bg3);transition:all .2s}
.onboarding-dots span.active{background:var(--blue);width:24px;border-radius:4px}
/* Version badge */
.version-badge{display:inline-flex;padding:2px 8px;border-radius:6px;font-size:10px;font-weight:600;
background:rgba(59,130,246,.1);color:var(--blue);border:1px solid rgba(59,130,246,.2)}
/* PIN strength */
.pin-strength{height:4px;border-radius:2px;margin-top:6px;background:var(--bg3);overflow:hidden}
.pin-strength-bar{height:100%;border-radius:2px;transition:width .3s,background .3s}
/* Template cards */
.template-card{padding:12px;border-radius:var(--radius);background:var(--bg2);border:1px dashed var(--border);
cursor:pointer;transition:all .15s;text-align:center}
.template-card:hover{border-color:var(--blue);background:rgba(59,130,246,.05)}
/* Pull to refresh indicator */
.ptr-indicator{text-align:center;padding:8px;font-size:11px;color:var(--text4);display:none}
/* Print */
@media print{
.topbar,.navbar,.no-print{display:none!important}
body{background:#fff;color:#000}
.main{overflow:visible}
.card{background:#fff;border-color:#ccc}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="toast-container" id="toast-container"></div>
<script>
// ==================================================================
// Tcha Agro v2.0 — Single-File Offline-First PWA
// ==================================================================
// --- SVG Icons (inline, zero dependencies) ---
const I = {
dashboard: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>`,
cash: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M17 1l4 4-4 4"/><path d="M3 11V9a4 4 0 014-4h14"/><path d="M7 23l-4-4 4-4"/><path d="M21 13v2a4 4 0 01-4 4H3"/></svg>`,
truck: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 18V6a2 2 0 00-2-2H4a2 2 0 00-2 2v11a1 1 0 001 1h1"/><path d="M15 18h2l3-3V8h-5"/><circle cx="7" cy="18" r="2"/><circle cx="18.5" cy="18" r="2"/></svg>`,
chart: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg>`,
settings: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M12 1v2m0 18v2M4.22 4.22l1.42 1.42m12.72 12.72l1.42 1.42M1 12h2m18 0h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>`,
contacts: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 00-3-3.87"/><path d="M16 3.13a4 4 0 010 7.75"/></svg>`,
plus: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,
back: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>`,
search: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>`,
filter: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>`,
check: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`,
trash: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/><path d="M9 6V4a1 1 0 011-1h4a1 1 0 011 1v2"/></svg>`,
edit: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,
print: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>`,
clock: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>`,
user: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>`,
lock: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg>`,
logout: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>`,
up: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="12" y1="19" x2="12" y2="5"/><polyline points="5 12 12 5 19 12"/></svg>`,
down: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><polyline points="19 12 12 19 5 12"/></svg>`,
wallet: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12V7H5a2 2 0 010-4h14v4"/><path d="M3 5v14a2 2 0 002 2h16v-5"/><path d="M18 12a2 2 0 100 4 2 2 0 000-4z"/></svg>`,
pkg: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M16.5 9.4l-9-5.19M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg>`,
download: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`,
upload: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>`,
x: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`,
arrow: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>`,
shield: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>`,
cal: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>`,
pie: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21.21 15.89A10 10 0 118 2.83"/><path d="M22 12A10 10 0 0012 2v10z"/></svg>`,
info: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`,
db: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"/><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"/></svg>`,
wifi: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.55a11 11 0 0114.08 0"/><path d="M1.42 9a16 16 0 0121.16 0"/><path d="M8.53 16.11a6 6 0 016.95 0"/><line x1="12" y1="20" x2="12.01" y2="20"/></svg>`,
wifiOff: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="1" y1="1" x2="23" y2="23"/><path d="M16.72 11.06A10.94 10.94 0 0119 12.55"/><path d="M5 12.55a10.94 10.94 0 015.17-2.39"/><path d="M10.71 5.05A16 16 0 0122.56 9"/><path d="M1.42 9a15.91 15.91 0 014.7-2.88"/><path d="M8.53 16.11a6 6 0 016.95 0"/><line x1="12" y1="20" x2="12.01" y2="20"/></svg>`,
refresh: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg>`,
users: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 00-3-3.87"/><path d="M16 3.13a4 4 0 010 7.75"/></svg>`,
alert: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>`,
camera: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"/><circle cx="12" cy="13" r="4"/></svg>`,
copy: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>`,
phone: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6A19.79 19.79 0 012.12 4.18 2 2 0 014.11 2h3a2 2 0 012 1.72c.127.96.362 1.903.7 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.574 2.81.7A2 2 0 0122 16.92z"/></svg>`,
mail: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22 6 12 13 2 6"/></svg>`,
bookmark: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21l-7-5-7 5V5a2 2 0 012-2h10a2 2 0 012 2z"/></svg>`,
};
// --- Utility Functions ---
const $ = s => document.querySelector(s);
const h = (tag, attrs, ...children) => {
const el = document.createElement(tag);
if (attrs) Object.entries(attrs).forEach(([k, v]) => {
if (k === 'className') el.className = v;
else if (k === 'innerHTML') el.innerHTML = v;
else if (k.startsWith('on')) el.addEventListener(k.slice(2).toLowerCase(), v);
else if (k === 'style' && typeof v === 'object') Object.assign(el.style, v);
else el.setAttribute(k, v);
});
children.flat(Infinity).forEach(c => {
if (c == null || c === false) return;
el.appendChild(typeof c === 'string' || typeof c === 'number' ? document.createTextNode(c) : c);
});
return el;
};
const uuid = () => crypto.randomUUID ? crypto.randomUUID() : 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,c=>{const r=Math.random()*16|0;return(c==='x'?r:(r&3|8)).toString(16)});
const now = () => new Date().toISOString();
const today = () => now().slice(0,10);
const timeNow = () => new Date().toTimeString().slice(0,5);
function fmtCur(n) { return new Intl.NumberFormat('fr-FR',{style:'decimal',maximumFractionDigits:0}).format(Math.round(n))+' FCFA' }
function fmtDate(d) {
if (!d) return '';
const tdy = today();
if (d === tdy) return t('today');
const y = new Date(Date.now()-86400000).toISOString().slice(0,10);
if (d === y) return t('yesterday');
const p = d.split('-'); return `${p[2]}.${p[1]}.${p[0]}`;
}
function fmtRelative(iso) {
if (!iso) return '';
const ms = Date.now() - new Date(iso).getTime();
const min = Math.floor(ms/60000);
if (min < 1) return t('justNow');
if (min < 60) return t('minAgo',{n:min});
const hr = Math.floor(min/60);
if (hr < 24) return t('hrAgo',{n:hr});
return fmtDate(iso.slice(0,10));
}
function haptic() { try { navigator.vibrate && navigator.vibrate(10); } catch(e){} }
// --- Modal & Toast System ---
function showToast(msg, type='success') {
const container = document.getElementById('toast-container');
const icons = {
success: I.check,
error: I.alert,
info: I.info
};
const toast = h('div', {className: `toast toast-${type}`, innerHTML: icons[type] || ''});
toast.appendChild(h('span', null, msg));
container.appendChild(toast);
setTimeout(() => {
toast.classList.add('removing');
setTimeout(() => toast.remove(), 300);
}, 3000);
}
function showModal(title, message, buttons) {
return new Promise(resolve => {
const backdrop = h('div', {className: 'modal-backdrop', onClick: e => {
if (e.target === backdrop) { closeM(null); }
}});
const box = h('div', {className: 'modal-box'});
if (title) box.appendChild(h('div', {className: 'modal-title'}, title));
if (message) box.appendChild(h('div', {className: 'modal-msg'}, message));
const btns = h('div', {className: 'modal-btns'});
(buttons || [{label: 'OK', value: true, primary: true}]).forEach(b => {
btns.appendChild(h('button', {
className: `btn ${b.primary ? 'btn-primary' : 'btn-ghost'} btn-sm`,
onClick: () => closeM(b.value)
}, b.label));
});
box.appendChild(btns);
backdrop.appendChild(box);
document.body.appendChild(backdrop);
function closeM(val) {
backdrop.classList.add('closing');
setTimeout(() => { backdrop.remove(); resolve(val); }, 180);
}
});
}
function showConfirm(title, message) {
return showModal(title, message, [
{label: t('cancel'), value: false, primary: false},
{label: 'OK', value: true, primary: true}
]);
}
function showPrompt(title, message, defaultVal) {
return new Promise(resolve => {
const backdrop = h('div', {className: 'modal-backdrop', onClick: e => {
if (e.target === backdrop) closeM(null);
}});
const box = h('div', {className: 'modal-box'});
if (title) box.appendChild(h('div', {className: 'modal-title'}, title));
if (message) box.appendChild(h('div', {className: 'modal-msg'}, message));
const inp = h('input', {className: 'modal-input', type: 'text', value: defaultVal || '', autofocus: true});
box.appendChild(inp);
const btns = h('div', {className: 'modal-btns'});
btns.appendChild(h('button', {className: 'btn btn-ghost btn-sm', onClick: () => closeM(null)}, t('cancel')));
btns.appendChild(h('button', {className: 'btn btn-primary btn-sm', onClick: () => closeM(inp.value)}, 'OK'));
box.appendChild(btns);
backdrop.appendChild(box);
document.body.appendChild(backdrop);
setTimeout(() => inp.focus(), 50);
inp.addEventListener('keydown', e => { if (e.key === 'Enter') closeM(inp.value); });
function closeM(val) {
backdrop.classList.add('closing');
setTimeout(() => { backdrop.remove(); resolve(val); }, 180);
}
});
}
// --- Translations ---
const LANG = {
de: {
start:'Start',dashboard:'Dashboard',cash:'Kasse',warehouse:'Lager',delivery:'Lieferung',more:'Mehr',
save:'Speichern',cancel:'Abbrechen',delete:'L\u00f6schen',edit:'Bearbeiten',back:'Zur\u00fcck',search:'Suchen\u2026',
new:'Neu',all:'Alle',today:'Heute',yesterday:'Gestern',justNow:'gerade eben',minAgo:'vor {n} Min',hrAgo:'vor {n} Std',
username:'Benutzername',pin:'PIN',login:'Anmelden',logout:'Abmelden',wrongCredentials:'Benutzername oder PIN falsch',
enterBoth:'Bitte beides eingeben',demoAccess:'Demo-Zug\u00e4nge',
hello:'Hallo',businessCenter:'Tcha Agro Business Center',todayIn3Steps:'Heute in 3 Schritten',
step1:'Einnahme oder Ausgabe erfassen',step2:'Lagerbestand kurz pr\u00fcfen',step3:'Am Ende des Tages synchronisieren',
booking:'Buchung',sync:'Sync',income:'Einnahmen',expenses:'Ausgaben',cashBalance:'Kasse (Bar)',warehouseVal:'Lager',
empty:'Leer',recentBookings:'Letzte Buchungen',noBookingsToday:'Noch keine Buchungen heute',activities:'Aktivit\u00e4ten',
transactions:'Transaktionen',newBooking:'Neue Buchung',editBooking:'Buchung bearbeiten',amount:'Betrag (FCFA)',
category:'Kategorie',paymentMethod:'Zahlungsart',description:'Beschreibung',date:'Datum',time:'Uhrzeit',
sale:'Verkauf',incomeType:'Einnahme',expense:'Ausgabe',cash:'Bar',card:'Karte',transfer:'\u00dcberw.',
book:'Buchen',void:'Stornieren',voidConfirm:'Buchung stornieren?',entries:'Eintr\u00e4ge',
fillAmountCat:'Bitte Betrag und Kategorie ausf\u00fcllen.',requiredFields:'Pflichtfelder',
optional:'Optional',descExample:'z.B. 20 H\u00fchner an Mme Ablavi',
shipments:'Lieferscheine',newShipment:'Neuer Lieferschein',editShipment:'Lieferschein bearbeiten',
inbound:'Einlieferung',outbound:'Auslieferung',supplier:'Lieferant',customer:'Kunde',reference:'Referenz',
status:'Status',draft:'Entwurf',delivered:'Geliefert',cancelled:'Storniert',stored:'Eingelagert',sold:'Verkauft',
positions:'Positionen',addLine:'Zeile',article:'Artikel',quantity:'Menge',price:'Preis',total:'Gesamt',
units:'Einh.',notes:'Notizen',createShipment:'Lieferschein erstellen',
fillPartner:'Bitte Lieferant oder Kunde eingeben.',fillPosition:'Bitte mindestens eine Position mit Artikel und Menge > 0 eingeben.',
documents:'Dokumente',noShipments:'Keine Lieferscheine',
inStock:'Im Lager',stockValue:'Lagerwert',soldItems:'Verkauft',items:'Posten',unitsLabel:'Einheiten',
waitingForPrice:'Posten warten auf besseren Preis',warehouseEmpty:'Lager ist leer',
createStoredShipment:'Lieferschein mit Status "Eingelagert" erstellen',storedSince:'seit {n} Tagen',
purchaseValue:'Einkaufswert',sell:'Verkaufen',sellPrice:'Verkaufspreis (FCFA):',sellConfirm:'Verkaufen f\u00fcr {price}?',
profit:'Gewinn',loss:'Verlust',showSold:'verkaufte Posten anzeigen',hideSold:'Verkauft ausblenden',
reports:'Reports & Auswertungen',periodAnalysis:'Zeitraum-Analyse nach Kategorie und Zahlungsart',
balance:'Saldo',bookings:'Buchungen',totalLabel:'gesamt',byCategory:'Nach Kategorie',byPayment:'Nach Zahlungsart',noData:'Keine Daten',
settings:'Einstellungen',interface:'Bedienung',simpleMode:'Einfach-Modus',
simpleModeDesc:'Zeigt kurze Schritt-Hinweise und klarere Eingaben f\u00fcr Laien.',
simpleModeActive:'Einfach-Modus aktiv',enableSimpleMode:'Einfach-Modus einschalten',
language:'Sprache',synchronization:'Synchronisation',online:'Online',offline:'Offline',
lastSync:'Letzter Sync',pending:'Ausstehend',changes:'\u00c4nderungen',syncNow:'Jetzt synchronisieren',
users:'Benutzer',deactivate:'Deaktiv.',activate:'Aktivieren',admin:'Admin',
data:'Daten',exportCSV:'CSV exportieren',deleteAllData:'Alle Daten l\u00f6schen',deleteConfirm:'ALLE lokalen Daten l\u00f6schen?',
info:'Info',loggedInAs:'Angemeldet',
googleSync:'Google Sheets Sync',sheetId:'Sheet ID',apiEndpoint:'API Endpoint (Apps Script URL)',
apiKey:'API-Schl\u00fcssel',testConnection:'Verbindung testen',saveConfig:'Konfiguration speichern',
notConfigured:'Nicht konfiguriert',configured:'Konfiguriert',connectionOk:'Verbindung OK',
connectionFailed:'Verbindung fehlgeschlagen',
adminArea:'Admin-Bereich',adminPinRequired:'Admin-PIN erforderlich',enterAdminPin:'Bitte Admin-PIN eingeben:',
wrongPin:'Falscher PIN',adminOnly:'Nur f\u00fcr Administratoren',
guideStart:'Heute starten: <b>1)</b> Buchung anlegen, <b>2)</b> Lager pr\u00fcfen, <b>3)</b> Abends synchronisieren.',
guideCash:'Kasse: Betrag eingeben, Kategorie w\u00e4hlen und dann auf <b>Buchen</b> tippen.',
guideWarehouse:'Lager: Eingelagerte Ware pr\u00fcfen und bei Verkauf den Verkaufspreis eintragen.',
guideShipments:'Lieferschein: Partner eintragen, Positionen erg\u00e4nzen und speichern.',
guideSettings:'Mehr: Synchronisieren, Export und grundlegende App-Einstellungen.',
simpleModeHint:'Einfach-Modus aktiv: nur die wichtigsten Schritte anzeigen.',
changeHistory:'\u00c4nderungsverlauf',
actionCreate:'erstellt',actionUpdate:'ge\u00e4ndert',actionDelete:'gel\u00f6scht',actionVoid:'storniert',
entityTransaction:'Transaktion',entityShipment:'Lieferschein',entityItem:'Position',entityUser:'Benutzer',
noTransactions:'Keine Transaktionen gefunden',voided:'Storniert',createdBy:'Erstellt von',partner:'Partner',
addToStock:'Einlagern',sum:'Summe',deliveryNote:'Lieferhinweis',warehouseEmptyHint:'Lieferschein mit Status \u201eEingelagert\u201c erstellen',
waitItems:'{n} Posten warten auf besseren Preis',sinceXDays:'seit {n} Tagen',items_units:'{items} Posten \u00b7 {units} Einheiten',
// New v2 strings
contacts:'Kontakte',contactName:'Name',contactType:'Typ',contactPhone:'Telefon',contactEmail:'E-Mail',
contactAddress:'Adresse',contactNotes:'Notizen',newContact:'Neuer Kontakt',editContact:'Kontakt bearbeiten',
supplierType:'Lieferant',customerType:'Kunde',bothType:'Beides',noContacts:'Keine Kontakte',
contactTransactions:'Transaktionen',contactShipments:'Lieferscheine',
backup:'Backup',exportBackup:'Backup exportieren',importBackup:'Backup importieren',
mergeImport:'Zusammenf\u00fchren',replaceImport:'Ersetzen',importSuccess:'Import erfolgreich',
exportSuccess:'Backup exportiert',importError:'Importfehler',
attachPhoto:'Foto anh\u00e4ngen',removePhoto:'Foto entfernen',viewPhoto:'Foto ansehen',
changePin:'PIN \u00e4ndern',oldPin:'Alter PIN',newPin:'Neuer PIN',confirmPin:'PIN best\u00e4tigen',
pinChanged:'PIN ge\u00e4ndert',pinMismatch:'PINs stimmen nicht \u00fcberein',pinWeak:'PIN zu kurz',
pinStrength:'PIN-St\u00e4rke',weak:'Schwach',medium:'Mittel',strong:'Stark',
templates:'Vorlagen',newTemplate:'Als Vorlage speichern',templateName:'Vorlagenname',
noTemplates:'Keine Vorlagen',useTemplate:'Vorlage verwenden',deleteTemplate:'Vorlage l\u00f6schen',
quickTemplates:'Schnellvorlagen',
welcome:'Willkommen',welcomeDesc:'Tcha Agro hilft Ihnen, Ihre Kasse und Ihr Lager zu verwalten.',
onbStep1Title:'Buchungen erfassen',onbStep1Desc:'Erfassen Sie schnell Einnahmen und Ausgaben mit wenigen Klicks.',
onbStep2Title:'Lager verwalten',onbStep2Desc:'Behalten Sie den \u00dcberblick \u00fcber Ihren Warenbestand.',
onbStep3Title:'Berichte erstellen',onbStep3Desc:'Analysieren Sie Ihre Gesch\u00e4ftszahlen mit detaillierten Reports.',
gotIt:'Verstanden',next:'Weiter',
weekDays:'Mo,Di,Mi,Do,Fr,Sa,So',
prevPeriod:'Vorherige Periode',comparison:'Vergleich',
dailyTrend:'T\u00e4glicher Verlauf',categoryBreakdown:'Kategorie-Aufteilung',
last7days:'Letzte 7 Tage'
},
fr: {
start:'Accueil',dashboard:'Tableau de bord',cash:'Caisse',warehouse:'Stock',delivery:'Livraison',more:'Plus',
save:'Enregistrer',cancel:'Annuler',delete:'Supprimer',edit:'Modifier',back:'Retour',search:'Rechercher\u2026',
new:'Nouveau',all:'Tous',today:"Aujourd'hui",yesterday:'Hier',justNow:"a l'instant",minAgo:'il y a {n} min',hrAgo:'il y a {n} h',
username:"Nom d'utilisateur",pin:'PIN',login:'Connexion',logout:'D\u00e9connexion',wrongCredentials:"Nom d'utilisateur ou PIN incorrect",
enterBoth:'Veuillez remplir les deux champs',demoAccess:'Acc\u00e8s d\u00e9mo',
hello:'Bonjour',businessCenter:'Tcha Agro Business Center',todayIn3Steps:"Aujourd'hui en 3 \u00e9tapes",
step1:'Enregistrer une recette ou d\u00e9pense',step2:'V\u00e9rifier le stock',step3:'Synchroniser en fin de journ\u00e9e',
booking:'Op\u00e9ration',sync:'Sync',income:'Recettes',expenses:'D\u00e9penses',cashBalance:'Caisse (esp\u00e8ces)',warehouseVal:'Stock',
empty:'Vide',recentBookings:'Derni\u00e8res op\u00e9rations',noBookingsToday:"Pas encore d'op\u00e9rations aujourd'hui",activities:'Activit\u00e9s',
transactions:'Transactions',newBooking:'Nouvelle op\u00e9ration',editBooking:"Modifier l'op\u00e9ration",amount:'Montant (FCFA)',
category:'Cat\u00e9gorie',paymentMethod:'Mode de paiement',description:'Description',date:'Date',time:'Heure',
sale:'Vente',incomeType:'Recette',expense:'D\u00e9pense',cash:'Esp\u00e8ces',card:'Carte',transfer:'Virement',
book:'Enregistrer',void:'Annuler',voidConfirm:"Annuler l'op\u00e9ration?",entries:'entr\u00e9es',
fillAmountCat:'Veuillez remplir le montant et la cat\u00e9gorie.',requiredFields:'Champs obligatoires',
optional:'Optionnel',descExample:'ex: 20 poulets \u00e0 Mme Ablavi',
shipments:'Bordereaux',newShipment:'Nouveau bordereau',editShipment:'Modifier le bordereau',
inbound:'R\u00e9ception',outbound:'Exp\u00e9dition',supplier:'Fournisseur',customer:'Client',reference:'R\u00e9f\u00e9rence',
status:'Statut',draft:'Brouillon',delivered:'Livr\u00e9',cancelled:'Annul\u00e9',stored:'En stock',sold:'Vendu',
positions:'Lignes',addLine:'Ligne',article:'Article',quantity:'Quantit\u00e9',price:'Prix',total:'Total',
units:'unit\u00e9s',notes:'Notes',createShipment:'Cr\u00e9er le bordereau',
fillPartner:'Veuillez entrer le fournisseur ou client.',fillPosition:'Veuillez ajouter au moins une ligne avec article et quantit\u00e9 > 0.',
documents:'Documents',noShipments:'Aucun bordereau',
inStock:'En stock',stockValue:'Valeur du stock',soldItems:'Vendus',items:'articles',unitsLabel:'unit\u00e9s',
waitingForPrice:"articles en attente d'un meilleur prix",warehouseEmpty:'Le stock est vide',
createStoredShipment:'Cr\u00e9er un bordereau avec statut "En stock"',storedSince:'depuis {n} jours',
purchaseValue:"Prix d'achat",sell:'Vendre',sellPrice:'Prix de vente (FCFA):',sellConfirm:'Vendre pour {price}?',
profit:'B\u00e9n\u00e9fice',loss:'Perte',showSold:'afficher les articles vendus',hideSold:'Masquer vendus',
reports:'Rapports',periodAnalysis:'Analyse par p\u00e9riode, cat\u00e9gorie et mode de paiement',
balance:'Solde',bookings:'Op\u00e9rations',totalLabel:'total',byCategory:'Par cat\u00e9gorie',byPayment:'Par mode de paiement',noData:'Aucune donn\u00e9e',
settings:'Param\u00e8tres',interface:'Interface',simpleMode:'Mode simple',
simpleModeDesc:'Affiche des conseils courts et des entr\u00e9es plus claires pour les d\u00e9butants.',
simpleModeActive:'Mode simple actif',enableSimpleMode:'Activer le mode simple',
language:'Langue',synchronization:'Synchronisation',online:'En ligne',offline:'Hors ligne',
lastSync:'Derni\u00e8re sync',pending:'En attente',changes:'Modifications',syncNow:'Synchroniser maintenant',
users:'Utilisateurs',deactivate:'D\u00e9sactiver',activate:'Activer',admin:'Admin',
data:'Donn\u00e9es',exportCSV:'Exporter CSV',deleteAllData:'Supprimer toutes les donn\u00e9es',deleteConfirm:'Supprimer TOUTES les donn\u00e9es locales?',
info:'Info',loggedInAs:'Connect\u00e9',
googleSync:'Sync Google Sheets',sheetId:'ID de la feuille',apiEndpoint:'URL API (Apps Script)',
apiKey:'Cl\u00e9 API',testConnection:'Tester la connexion',saveConfig:'Enregistrer la configuration',
notConfigured:'Non configur\u00e9',configured:'Configur\u00e9',connectionOk:'Connexion OK',
connectionFailed:'\u00c9chec de la connexion',
adminArea:'Zone Admin',adminPinRequired:'PIN Admin requis',enterAdminPin:'Veuillez entrer le PIN Admin:',
wrongPin:'PIN incorrect',adminOnly:'R\u00e9serv\u00e9 aux administrateurs',
guideStart:"Aujourd'hui: <b>1)</b> Cr\u00e9er une op\u00e9ration, <b>2)</b> V\u00e9rifier le stock, <b>3)</b> Synchroniser le soir.",
guideCash:'Caisse: Entrer le montant, choisir la cat\u00e9gorie et appuyer sur <b>Enregistrer</b>.',
guideWarehouse:'Stock: V\u00e9rifier les articles stock\u00e9s et entrer le prix de vente lors de la vente.',
guideShipments:'Bordereau: Entrer le partenaire, ajouter les lignes et enregistrer.',
guideSettings:'Plus: Synchroniser, exporter et param\u00e8tres de base.',
simpleModeHint:'Mode simple actif: seules les \u00e9tapes essentielles sont affich\u00e9es.',
changeHistory:'Historique des modifications',
actionCreate:'cr\u00e9\u00e9',actionUpdate:'modifi\u00e9',actionDelete:'supprim\u00e9',actionVoid:'annul\u00e9',
entityTransaction:'Transaction',entityShipment:'Bordereau',entityItem:'Ligne',entityUser:'Utilisateur',
noTransactions:'Aucune transaction trouv\u00e9e',voided:'Annul\u00e9',createdBy:'Cr\u00e9\u00e9 par',partner:'Partenaire',
addToStock:'Stocker',sum:'Somme',deliveryNote:'Note de livraison',warehouseEmptyHint:'Cr\u00e9er un bordereau avec statut "En stock"',
waitItems:'{n} articles en attente',sinceXDays:'depuis {n} jours',items_units:'{items} articles \u00b7 {units} unit\u00e9s',
// New v2 strings
contacts:'Contacts',contactName:'Nom',contactType:'Type',contactPhone:'T\u00e9l\u00e9phone',contactEmail:'Email',
contactAddress:'Adresse',contactNotes:'Notes',newContact:'Nouveau contact',editContact:'Modifier le contact',
supplierType:'Fournisseur',customerType:'Client',bothType:'Les deux',noContacts:'Aucun contact',
contactTransactions:'Transactions',contactShipments:'Bordereaux',
backup:'Sauvegarde',exportBackup:'Exporter sauvegarde',importBackup:'Importer sauvegarde',
mergeImport:'Fusionner',replaceImport:'Remplacer',importSuccess:'Import r\u00e9ussi',
exportSuccess:'Sauvegarde export\u00e9e',importError:"Erreur d'import",
attachPhoto:'Joindre photo',removePhoto:'Supprimer photo',viewPhoto:'Voir photo',
changePin:'Changer le PIN',oldPin:'Ancien PIN',newPin:'Nouveau PIN',confirmPin:'Confirmer le PIN',
pinChanged:'PIN chang\u00e9',pinMismatch:'Les PINs ne correspondent pas',pinWeak:'PIN trop court',
pinStrength:'Force du PIN',weak:'Faible',medium:'Moyen',strong:'Fort',
templates:'Mod\u00e8les',newTemplate:'Enregistrer comme mod\u00e8le',templateName:'Nom du mod\u00e8le',
noTemplates:'Aucun mod\u00e8le',useTemplate:'Utiliser le mod\u00e8le',deleteTemplate:'Supprimer le mod\u00e8le',
quickTemplates:'Mod\u00e8les rapides',
welcome:'Bienvenue',welcomeDesc:'Tcha Agro vous aide \u00e0 g\u00e9rer votre caisse et votre stock.',
onbStep1Title:'Enregistrer des op\u00e9rations',onbStep1Desc:'Enregistrez rapidement recettes et d\u00e9penses en quelques clics.',
onbStep2Title:'G\u00e9rer le stock',onbStep2Desc:'Gardez un \u0153il sur vos marchandises en stock.',
onbStep3Title:'Cr\u00e9er des rapports',onbStep3Desc:"Analysez vos chiffres d'affaires avec des rapports d\u00e9taill\u00e9s.",
gotIt:'Compris',next:'Suivant',
weekDays:'Lun,Mar,Mer,Jeu,Ven,Sam,Dim',
prevPeriod:'P\u00e9riode pr\u00e9c\u00e9dente',comparison:'Comparaison',
dailyTrend:'Tendance quotidienne',categoryBreakdown:'R\u00e9partition par cat\u00e9gorie',
last7days:'7 derniers jours'
},
en: {
start:'Home',dashboard:'Dashboard',cash:'Cash',warehouse:'Stock',delivery:'Delivery',more:'More',
save:'Save',cancel:'Cancel',delete:'Delete',edit:'Edit',back:'Back',search:'Search\u2026',
new:'New',all:'All',today:'Today',yesterday:'Yesterday',justNow:'just now',minAgo:'{n} min ago',hrAgo:'{n} hr ago',
username:'Username',pin:'PIN',login:'Login',logout:'Logout',wrongCredentials:'Username or PIN incorrect',
enterBoth:'Please fill in both fields',demoAccess:'Demo Access',
hello:'Hello',businessCenter:'Tcha Agro Business Center',todayIn3Steps:'Today in 3 Steps',
step1:'Record income or expense',step2:'Check stock briefly',step3:'Sync at end of day',
booking:'Entry',sync:'Sync',income:'Income',expenses:'Expenses',cashBalance:'Cash Balance',warehouseVal:'Stock',
empty:'Empty',recentBookings:'Recent Entries',noBookingsToday:'No entries today yet',activities:'Activities',
transactions:'Transactions',newBooking:'New Entry',editBooking:'Edit Entry',amount:'Amount (FCFA)',
category:'Category',paymentMethod:'Payment Method',description:'Description',date:'Date',time:'Time',
sale:'Sale',incomeType:'Income',expense:'Expense',cash:'Cash',card:'Card',transfer:'Transfer',
book:'Save',void:'Void',voidConfirm:'Void this entry?',entries:'entries',
fillAmountCat:'Please fill amount and category.',requiredFields:'Required',
optional:'Optional',descExample:'e.g. 20 chickens to Mrs Ablavi',
shipments:'Shipments',newShipment:'New Shipment',editShipment:'Edit Shipment',
inbound:'Inbound',outbound:'Outbound',supplier:'Supplier',customer:'Customer',reference:'Reference',
status:'Status',draft:'Draft',delivered:'Delivered',cancelled:'Cancelled',stored:'In Stock',sold:'Sold',
positions:'Items',addLine:'Line',article:'Article',quantity:'Qty',price:'Price',total:'Total',
units:'units',notes:'Notes',createShipment:'Create Shipment',
fillPartner:'Please enter supplier or customer.',fillPosition:'Please add at least one item with article and quantity > 0.',
documents:'Documents',noShipments:'No shipments',
inStock:'In Stock',stockValue:'Stock Value',soldItems:'Sold',items:'items',unitsLabel:'units',
waitingForPrice:'items waiting for better price',warehouseEmpty:'Stock is empty',
createStoredShipment:'Create shipment with status "In Stock"',storedSince:'since {n} days',
purchaseValue:'Purchase Value',sell:'Sell',sellPrice:'Selling Price (FCFA):',sellConfirm:'Sell for {price}?',
profit:'Profit',loss:'Loss',showSold:'show sold items',hideSold:'Hide sold',
reports:'Reports',periodAnalysis:'Period analysis by category and payment method',
balance:'Balance',bookings:'Entries',totalLabel:'total',byCategory:'By Category',byPayment:'By Payment Method',noData:'No data',
settings:'Settings',interface:'Interface',simpleMode:'Simple Mode',
simpleModeDesc:'Shows short hints and clearer inputs for beginners.',
simpleModeActive:'Simple Mode active',enableSimpleMode:'Enable Simple Mode',
language:'Language',synchronization:'Synchronization',online:'Online',offline:'Offline',
lastSync:'Last Sync',pending:'Pending',changes:'Changes',syncNow:'Sync Now',
users:'Users',deactivate:'Deactivate',activate:'Activate',admin:'Admin',
data:'Data',exportCSV:'Export CSV',deleteAllData:'Delete All Data',deleteConfirm:'Delete ALL local data?',
info:'Info',loggedInAs:'Logged in',
googleSync:'Google Sheets Sync',sheetId:'Sheet ID',apiEndpoint:'API Endpoint (Apps Script URL)',
apiKey:'API Key',testConnection:'Test Connection',saveConfig:'Save Configuration',
notConfigured:'Not configured',configured:'Configured',connectionOk:'Connection OK',
connectionFailed:'Connection failed',
adminArea:'Admin Area',adminPinRequired:'Admin PIN required',enterAdminPin:'Please enter Admin PIN:',
wrongPin:'Wrong PIN',adminOnly:'Administrators only',
guideStart:'Today: <b>1)</b> Create entry, <b>2)</b> Check stock, <b>3)</b> Sync in the evening.',
guideCash:'Cash: Enter amount, select category and tap <b>Save</b>.',
guideWarehouse:'Stock: Check stored items and enter selling price when selling.',
guideShipments:'Shipment: Enter partner, add items and save.',
guideSettings:'More: Sync, export and basic app settings.',
simpleModeHint:'Simple Mode active: only essential steps shown.',
changeHistory:'Change History',
actionCreate:'created',actionUpdate:'updated',actionDelete:'deleted',actionVoid:'voided',
entityTransaction:'Transaction',entityShipment:'Shipment',entityItem:'Item',entityUser:'User',
noTransactions:'No transactions found',voided:'Voided',createdBy:'Created by',partner:'Partner',
addToStock:'Add to Stock',sum:'Sum',deliveryNote:'Delivery note',warehouseEmptyHint:'Create shipment with status "In Stock"',
waitItems:'{n} items waiting for better price',sinceXDays:'since {n} days',items_units:'{items} items \u00b7 {units} units',
// New v2 strings
contacts:'Contacts',contactName:'Name',contactType:'Type',contactPhone:'Phone',contactEmail:'Email',
contactAddress:'Address',contactNotes:'Notes',newContact:'New Contact',editContact:'Edit Contact',
supplierType:'Supplier',customerType:'Customer',bothType:'Both',noContacts:'No contacts',
contactTransactions:'Transactions',contactShipments:'Shipments',
backup:'Backup',exportBackup:'Export Backup',importBackup:'Import Backup',
mergeImport:'Merge',replaceImport:'Replace',importSuccess:'Import successful',
exportSuccess:'Backup exported',importError:'Import error',
attachPhoto:'Attach Photo',removePhoto:'Remove Photo',viewPhoto:'View Photo',
changePin:'Change PIN',oldPin:'Old PIN',newPin:'New PIN',confirmPin:'Confirm PIN',
pinChanged:'PIN changed',pinMismatch:'PINs do not match',pinWeak:'PIN too short',
pinStrength:'PIN Strength',weak:'Weak',medium:'Medium',strong:'Strong',
templates:'Templates',newTemplate:'Save as Template',templateName:'Template Name',
noTemplates:'No templates',useTemplate:'Use Template',deleteTemplate:'Delete Template',
quickTemplates:'Quick Templates',
welcome:'Welcome',welcomeDesc:'Tcha Agro helps you manage your cash register and stock.',
onbStep1Title:'Record Entries',onbStep1Desc:'Quickly record income and expenses with a few taps.',
onbStep2Title:'Manage Stock',onbStep2Desc:'Keep track of your stored goods.',
onbStep3Title:'Create Reports',onbStep3Desc:'Analyze your business numbers with detailed reports.',
gotIt:'Got it',next:'Next',
weekDays:'Mon,Tue,Wed,Thu,Fri,Sat,Sun',
prevPeriod:'Previous period',comparison:'Comparison',
dailyTrend:'Daily Trend',categoryBreakdown:'Category Breakdown',
last7days:'Last 7 days'
}
};
function t(key, params = {}) {
const lang = state.lang || 'de';
let str = LANG[lang]?.[key] || LANG.de[key] || key;
Object.entries(params).forEach(([k, v]) => { str = str.replace(`{${k}}`, v); });
return str;
}
const TXN_TYPE = new Proxy({}, { get: (_, k) => ({ sale: t('sale'), income: t('incomeType'), expense: t('expense') })[k] });
const PAY = new Proxy({}, { get: (_, k) => ({ cash: t('cash'), card: t('card'), transfer: t('transfer') })[k] });
const SHIP_TYPE = new Proxy({}, { get: (_, k) => ({ inbound: t('inbound'), outbound: t('outbound') })[k] });
const STATUS_LABEL = new Proxy({}, { get: (_, k) => ({ draft: t('draft'), final: t('delivered'), cancelled: t('cancelled'), en_stock: t('stored'), vendu: t('sold') })[k] });
const TXN_BADGE = { sale:'badge-green', income:'badge-sky', expense:'badge-red' };
const TXN_COLOR = { sale:'var(--green)', income:'var(--sky)', expense:'var(--red)' };
const SHIP_BADGE = { inbound:'badge-violet', outbound:'badge-amber' };
const STATUS_BADGE = { draft:'badge-gray', final:'badge-green', cancelled:'badge-red', en_stock:'badge-amber', vendu:'badge-sky' };
const ACTION_LABEL = new Proxy({}, { get: (_, k) => ({ create: t('actionCreate'), update: t('actionUpdate'), delete: t('actionDelete'), void: t('actionVoid') })[k] });
const ENTITY_LABEL = new Proxy({}, { get: (_, k) => ({ transaction: t('entityTransaction'), shipment_doc: t('entityShipment'), shipment_item: t('entityItem'), user: t('entityUser') })[k] });
// --- IndexedDB Layer ---
const DB_NAME = 'Tcha AgroDB';
const DB_VER = 2;
let idb = null;
function openDB() {
return new Promise((resolve, reject) => {
if (idb) return resolve(idb);
const req = indexedDB.open(DB_NAME, DB_VER);
req.onupgradeneeded = e => {
const db = e.target.result;
const oldVer = e.oldVersion;
// v1 stores
const v1stores = {
users:'id', transactions:'id', shipment_docs:'id',
shipment_items:'id', audit_log:'id', categories:'id', outbox:'id', meta:'key'
};
Object.entries(v1stores).forEach(([name, key]) => {
if (!db.objectStoreNames.contains(name)) db.createObjectStore(name, { keyPath: key });
});
// v2 stores
if (oldVer < 2) {
if (!db.objectStoreNames.contains('contacts')) db.createObjectStore('contacts', { keyPath: 'id' });
if (!db.objectStoreNames.contains('attachments')) db.createObjectStore('attachments', { keyPath: 'id' });
if (!db.objectStoreNames.contains('templates')) db.createObjectStore('templates', { keyPath: 'id' });
}
};
req.onsuccess = e => { idb = e.target.result; resolve(idb); };
req.onerror = e => reject(e.target.error);
});
}
async function dbPut(store, obj) {
const db = await openDB();
return new Promise((res, rej) => {
const tx = db.transaction(store, 'readwrite');
tx.objectStore(store).put(obj);
tx.oncomplete = () => res(); tx.onerror = e => rej(e.target.error);
});
}
async function dbGet(store, key) {
const db = await openDB();
return new Promise((res, rej) => {
const tx = db.transaction(store, 'readonly');
const req = tx.objectStore(store).get(key);
req.onsuccess = () => res(req.result); req.onerror = e => rej(e.target.error);
});
}
async function dbGetAll(store) {
const db = await openDB();
return new Promise((res, rej) => {
const tx = db.transaction(store, 'readonly');
const req = tx.objectStore(store).getAll();
req.onsuccess = () => res(req.result || []); req.onerror = e => rej(e.target.error);
});
}
async function dbDelete(store, key) {
const db = await openDB();
return new Promise((res, rej) => {
const tx = db.transaction(store, 'readwrite');
tx.objectStore(store).delete(key);
tx.oncomplete = () => res(); tx.onerror = e => rej(e.target.error);
});
}
async function dbCount(store) {
const db = await openDB();
return new Promise((res, rej) => {
const tx = db.transaction(store, 'readonly');
const req = tx.objectStore(store).count();
req.onsuccess = () => res(req.result); req.onerror = e => rej(e.target.error);
});
}
async function dbClear(store) {
const db = await openDB();
return new Promise((res, rej) => {
const tx = db.transaction(store, 'readwrite');
tx.objectStore(store).clear();
tx.oncomplete = () => res(); tx.onerror = e => rej(e.target.error);
});
}
// --- Seed Data ---
const ARTICLE_SUGGESTIONS = [
{name:'Poulets vivants',sku:'POU-VIF',unit:'pi\u00e8ce',defaultPrice:5000},
{name:'Poulets abattus',sku:'POU-ABT',unit:'kg',defaultPrice:3500},
{name:'\u0152ufs (plateau de 30)',sku:'OEU-30',unit:'plateau',defaultPrice:3000},
{name:'\u0152ufs (carton de 180)',sku:'OEU-180',unit:'carton',defaultPrice:17000},
{name:'Aliment poulet 50kg',sku:'ALI-50',unit:'sac',defaultPrice:18500},
{name:'Aliment poulet 25kg',sku:'ALI-25',unit:'sac',defaultPrice:9500},
{name:'Aliment poussin 25kg',sku:'ALP-25',unit:'sac',defaultPrice:11000},
{name:'Ma\u00efs grain',sku:'MAI-GR',unit:'kg',defaultPrice:350},
{name:'Soja torr\u00e9fi\u00e9',sku:'SOJ-TO',unit:'kg',defaultPrice:600},
{name:'Concentr\u00e9 ponte',sku:'CON-PO',unit:'sac',defaultPrice:25000},
{name:'Vaccin Newcastle',sku:'VAC-NEW',unit:'flacon',defaultPrice:3500},
{name:'Antibiotique volaille',sku:'ANT-VOL',unit:'flacon',defaultPrice:5000},
{name:'Vitamines',sku:'VIT-GEN',unit:'sachet',defaultPrice:1500},
{name:'Poussins 1 jour',sku:'PSN-1J',unit:'pi\u00e8ce',defaultPrice:750},
{name:'Copeaux de bois',sku:'COP-BO',unit:'sac',defaultPrice:2500},
];
const PARTNER_SUGGESTIONS = ['March\u00e9 Grand Lom\u00e9','Fournisseur Aliment Lom\u00e9','Restaurant Le B\u00e9nin','H\u00f4tel de la Paix','Superette Bon Prix','Abobo Volaille SA','Ferme Avicole Kara','Grossiste Adja'];
const UNIT_OPTIONS = ['pi\u00e8ce','kg','sac','plateau','carton','litre','tonne','flacon','sachet'];
async function seed() {
const count = await dbCount('users');
if (count > 0) return;
const n = now();
await dbPut('users', {id:'u1',username:'admin',display_name:'Administrateur',pin_hash:'0000',role:'admin',is_active:true,created_at:n,updated_at:n});
const cats = [
{id:'c1',name:'Poulets vivants',type:'sale',is_active:true,sort_order:1},
{id:'c2',name:'Poulets abattus',type:'sale',is_active:true,sort_order:2},
{id:'c3',name:'\u0152ufs',type:'sale',is_active:true,sort_order:3},
{id:'c4',name:'Aliment (vente)',type:'sale',is_active:true,sort_order:4},
{id:'c5',name:'Poussins',type:'sale',is_active:true,sort_order:5},
{id:'c6',name:'Aliment (achat)',type:'expense',is_active:true,sort_order:6},
{id:'c7',name:'M\u00e9dicaments/Vaccins',type:'expense',is_active:true,sort_order:7},
{id:'c8',name:'Personnel',type:'expense',is_active:true,sort_order:8},
{id:'c9',name:'Transport',type:'expense',is_active:true,sort_order:9},
{id:'c10',name:'\u00c9lectricit\u00e9/Eau',type:'expense',is_active:true,sort_order:10},
{id:'c11',name:'Mat\u00e9riel',type:'expense',is_active:true,sort_order:11},
{id:'c12',name:'Autre recette',type:'income',is_active:true,sort_order:12},
{id:'c13',name:'Autre d\u00e9pense',type:'expense',is_active:true,sort_order:13},
];
for (const c of cats) await dbPut('categories', c);
}
async function ensureAdminUser() {
const users = await dbGetAll('users');
if (!users.some(u => u.username === 'admin')) {
const n = now();
await dbPut('users', {id:'u_admin_'+Date.now(),username:'admin',display_name:'Administrateur',pin_hash:'0000',role:'admin',is_active:true,created_at:n,updated_at:n});
}
}
// --- App State ---
const state = {
user:null, token:null,
route:'dashboard', routeParam:null,
users:[], pendingCount:0,
online:navigator.onLine,
lastSync:localStorage.getItem('kf_lastSync'),
simpleMode:localStorage.getItem('kf_simpleMode')!=='0',
lang:localStorage.getItem('kf_lang')||'fr',
adminVerified:false,
gsConfig:JSON.parse(localStorage.getItem('kf_gsConfig')||'null')||{sheetId:'',apiEndpoint:'',apiKey:''}
};
function userMap(){const m={};state.users.forEach(u=>m[u.id]=u);return m}
function setSimpleMode(e){state.simpleMode=!!e;localStorage.setItem('kf_simpleMode',e?'1':'0')}
function setLang(l){state.lang=l;localStorage.setItem('kf_lang',l)}
function saveGsConfig(c){state.gsConfig=c;localStorage.setItem('kf_gsConfig',JSON.stringify(c))}
function isAdmin(){return state.user&&state.user.role==='admin'}
async function requireAdminPin(callback) {
if (!isAdmin()) { showToast(t('adminOnly'),'error'); return false; }
if (state.adminVerified) { await callback(); return true; }
const pin = await showPrompt(t('adminArea'), t('enterAdminPin'));
if (!pin) return false;
if (pin === state.user.pin_hash) {
state.adminVerified = true;
setTimeout(() => { state.adminVerified = false; }, 300000);
await callback();
return true;
} else {
showToast(t('wrongPin'), 'error');
return false;
}
}
async function testGoogleConnection() {
if (!state.gsConfig.apiEndpoint) return {ok:false,error:t('notConfigured')};
try {
const resp = await fetch(state.gsConfig.apiEndpoint+'?action=ping&key='+encodeURIComponent(state.gsConfig.apiKey),{method:'GET'});
return resp.ok ? {ok:true} : {ok:false,error:resp.statusText};
} catch(e) { return {ok:false,error:e.message}; }
}
async function syncToGoogleSheets() {
if (!state.gsConfig.apiEndpoint) return {ok:false,error:t('notConfigured')};
const items = await dbGetAll('outbox');
if (!items.length) return {ok:true,synced:0};
try {
const resp = await fetch(state.gsConfig.apiEndpoint,{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({action:'sync',key:state.gsConfig.apiKey,sheetId:state.gsConfig.sheetId,items})});
if (resp.ok) {
for (const item of items) await dbDelete('outbox',item.id);
state.lastSync=now();localStorage.setItem('kf_lastSync',state.lastSync);state.pendingCount=0;
return {ok:true,synced:items.length};
}
return {ok:false,error:resp.statusText};
} catch(e) { return {ok:false,error:e.message}; }
}
// --- Router ---
function navigate(route, param) {
haptic();
state.route = route;
state.routeParam = param || null;
window.location.hash = param ? `${route}/${param}` : route;
render();
}
function parseHash() {
const hash = window.location.hash.slice(1) || 'dashboard';
const parts = hash.split('/');
state.route = parts[0];
state.routeParam = parts[1] || null;
}
window.addEventListener('hashchange', () => { parseHash(); render(); });
window.addEventListener('online', () => { state.online = true; render(); });
window.addEventListener('offline', () => { state.online = false; render(); });
// --- Auth ---
async function login(username, pin) {
const users = await dbGetAll('users');
const user = users.find(u => u.username === username.toLowerCase().trim() && u.is_active);
if (!user || user.pin_hash !== pin) return false;
state.user = user; state.token = 'tok_'+user.id; state.users = users;
localStorage.setItem('kf_session', JSON.stringify({userId:user.id}));
return true;
}
function logout() {
state.user = null; state.token = null;
localStorage.removeItem('kf_session');
navigate('dashboard');
}
async function restoreSession() {
const s = localStorage.getItem('kf_session');
if (!s) return;
try {
const {userId} = JSON.parse(s);
const user = await dbGet('users', userId);
if (user && user.is_active) { state.user = user; state.token = 'tok_'+user.id; state.users = await dbGetAll('users'); }
} catch(e) {}
}
// --- Sync ---
async function updatePending() { state.pendingCount = await dbCount('outbox'); }
setInterval(updatePending, 3000);
async function triggerSync() {
const items = await dbGetAll('outbox');
for (const item of items) await dbDelete('outbox', item.id);
state.lastSync = now(); localStorage.setItem('kf_lastSync', state.lastSync);
state.pendingCount = 0; render();
}
// --- Audit ---
async function addAudit(entityType, entityId, action, changes) {
await dbPut('audit_log', {id:uuid(),entity_type:entityType,entity_id:entityId,action,changes:JSON.stringify(changes||{}),user_id:state.user.id,timestamp:now()});
}
async function addOutbox(entityType, entityId, payload) {
await dbPut('outbox', {id:uuid(),entity_type:entityType,entity_id:entityId,action:'upsert',payload:JSON.stringify(payload),created_at:now(),retry_count:0});
}
// --- SVG Chart Helpers ---
function buildBarChart7Days(txns) {
const days = [];
const dayLabels = t('weekDays').split(',');
for (let i = 6; i >= 0; i--) {
const d = new Date(Date.now() - i * 86400000);
const ds = d.toISOString().slice(0,10);
const dow = d.getDay(); // 0=Sun