-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1999 lines (1872 loc) · 139 KB
/
index.html
File metadata and controls
1999 lines (1872 loc) · 139 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="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<meta name="theme-color" content="#0a0c0f">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="description" content="VERITAS — Community Damage Certification Platform. CERTUS Engine, DCI scoring, offline‑first, STP integrity seals. UNDP compliant.">
<title>VERITAS — Damage Certification Platform</title>
<link href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Barlow+Condensed:ital,wght@0,300;0,400;0,600;0,700;0,900;1,300&family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400&family=JetBrains+Mono:wght@300;400;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
<script src="https://unpkg.com/shp-write@0.3.2/shpwrite.js"></script>
<script src="/VERITAS/public/certus-engine-v2.5.js"></script>
<script src="/VERITAS/public/ai-analysis.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg:#08090b; --bg-deep:#030405; --surface:#0e1117; --panel:#141920;
--border:#1e2730; --amber:#f0a500; --amber-d:#b07800; --amber-l:#ffc947;
--gold:#D4AF37; --text:#c4d4de; --muted:#4e5f6a; --dim:#2a3540;
--red:#ff4d4d; --cyan:#00d4ff; --edu:#4ade80; --quantum:#ce93d8;
--mono:'Share Tech Mono',monospace; --sans:'Barlow Condensed',sans-serif;
--serif:'Crimson Pro',Georgia,serif; --jmono:'JetBrains Mono',monospace;
--ease:cubic-bezier(0.16,1,0.3,1);
--font-size-base: clamp(16px, 1vw + 8px, 20px);
--font-size-h1: clamp(48px, 8vw + 16px, 96px);
--font-size-h2: clamp(28px, 4vw + 8px, 44px);
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
html{scroll-behavior:smooth;}
body{
background:var(--bg); color:var(--text); font-family:var(--sans);
font-size:var(--font-size-base); line-height:1.5; overflow-x:hidden;
cursor:none; transition:background 0.5s ease;
}
body::before{
content:''; position:fixed; inset:0;
background-image:linear-gradient(rgba(240,165,0,0.025) 1px,transparent 1px),linear-gradient(90deg,rgba(240,165,0,0.025) 1px,transparent 1px);
background-size:48px 48px; pointer-events:none; z-index:0;
}
body::after{
content:''; position:fixed; inset:0;
background:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,0.08) 2px,rgba(0,0,0,0.08) 4px);
pointer-events:none; z-index:0;
}
.custom-cursor{width:20px;height:20px;border:2px solid var(--amber);border-radius:50%;position:fixed;pointer-events:none;z-index:9999;mix-blend-mode:difference;transition:transform 0.1s ease,background 0.2s ease;transform:translate(-50%,-50%);}
.custom-cursor.hover{transform:translate(-50%,-50%) scale(1.5);background:rgba(240,165,0,0.1);border-color:var(--gold);}
#hero-canvas{position:fixed;top:0;left:0;width:100%;height:100%;z-index:0;opacity:0.35;pointer-events:none;}
.wrapper{max-width:1200px;margin:0 auto;padding:0 24px;position:relative;z-index:2;}
nav{display:flex;justify-content:space-between;align-items:center;padding:20px 0;border-bottom:1px solid var(--border);flex-wrap:wrap;gap:16px;}
.logo{font-family:var(--mono);font-size:18px;letter-spacing:3px;color:var(--amber);text-decoration:none;display:flex;align-items:center;gap:10px;}
.logo span{color:var(--muted);}
.nav-links{display:flex;gap:32px;list-style:none;}
.nav-links a{font-family:var(--mono);font-size:11px;letter-spacing:2px;color:var(--text);text-decoration:none;text-transform:uppercase;border-bottom:1px solid transparent;transition:color 0.2s,border-color 0.2s;}
.nav-links a:hover{color:var(--amber);border-bottom-color:var(--amber);}
.nav-hamburger{display:none;flex-direction:column;justify-content:space-between;width:24px;height:18px;cursor:pointer;background:none;border:none;padding:0;z-index:110;}
.nav-hamburger span{display:block;width:100%;height:2px;background:var(--amber);border-radius:1px;transition:transform 0.25s ease,opacity 0.25s ease;}
.nav-hamburger.open span:nth-child(1){transform:translateY(8px) rotate(45deg);}
.nav-hamburger.open span:nth-child(2){opacity:0;}
.nav-hamburger.open span:nth-child(3){transform:translateY(-8px) rotate(-45deg);}
.mobile-nav{display:none;position:fixed;top:56px;left:0;right:0;z-index:99;background:rgba(8,9,11,0.98);backdrop-filter:blur(16px);border-bottom:1px solid var(--border);flex-direction:column;padding:8px 0;}
.mobile-nav.open{display:flex;}
.mobile-nav a{font-family:var(--mono);font-size:12px;letter-spacing:2px;color:var(--text);text-decoration:none;text-transform:uppercase;padding:14px 28px;border-bottom:1px solid var(--border);transition:color 0.15s ease,background 0.15s ease;display:flex;align-items:center;gap:10px;}
.mobile-nav a:last-child{border-bottom:none;}
.mobile-nav a:hover{color:var(--amber);background:rgba(240,165,0,0.04);}
.mobile-nav a::before{content:'—';color:var(--amber);font-size:10px;opacity:0.6;}
/* FIX #7 — lang selector: hidden on mobile, shown in mobile-nav instead */
.lang-selector{display:flex;gap:6px;margin-left:auto;margin-right:20px;}
.lang-btn{background:none;border:1px solid var(--border);color:var(--muted);font-family:var(--mono);font-size:9px;padding:4px 8px;border-radius:20px;cursor:pointer;transition:all 0.2s;}
.lang-btn.active,.lang-btn:hover{border-color:var(--amber);color:var(--amber);background:rgba(240,165,0,0.1);}
.mobile-lang-row{display:flex;gap:8px;padding:12px 28px;border-bottom:1px solid var(--border);flex-wrap:wrap;}
.triple-time{display:grid;grid-template-columns:repeat(3,1fr);gap:1px;background:var(--border);border:1px solid var(--border);margin:40px 0;}
.time-cell{background:var(--bg);padding:18px 20px;transition:background 0.2s ease;}
.time-cell:hover{background:var(--surface);}
.time-sys{font-family:var(--mono);font-size:9px;letter-spacing:2px;color:var(--amber-d);text-transform:uppercase;margin-bottom:6px;}
.time-val{font-family:var(--mono);font-size:14px;color:var(--amber);letter-spacing:1px;line-height:1.3;min-height:36px;display:flex;align-items:center;}
.time-val.loading{color:var(--dim);font-size:11px;}
.veritas-tabs{display:flex;border-bottom:1px solid var(--border);margin:32px 0 24px;}
.veritas-tab{flex:1;padding:12px 0;font-family:var(--mono);font-size:11px;letter-spacing:2px;text-transform:uppercase;color:var(--muted);background:none;border:none;border-bottom:2px solid transparent;cursor:pointer;transition:all 0.2s;}
.veritas-tab.active{color:var(--amber);border-bottom-color:var(--amber);}
.veritas-view{display:none;}
.veritas-view.active{display:block;}
.step-progress{display:flex;align-items:center;margin-bottom:28px;gap:0;}
.step-node{display:flex;flex-direction:column;align-items:center;gap:4px;flex:1;}
.step-circle{width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-family:var(--mono);font-size:11px;font-weight:600;border:2px solid var(--border);color:var(--muted);background:var(--surface);transition:all 0.3s var(--ease);}
.step-circle.active{border-color:var(--amber);color:var(--amber);background:rgba(240,165,0,0.12);box-shadow:0 0 16px rgba(240,165,0,0.25);}
.step-circle.done{border-color:var(--edu);color:var(--edu);background:rgba(74,222,128,0.1);}
.step-label{font-family:var(--mono);font-size:8px;letter-spacing:1px;text-transform:uppercase;color:var(--muted);}
.step-label.active{color:var(--amber);}
.step-line{flex:1;height:2px;background:var(--border);margin-bottom:18px;}
.step-line.done{background:var(--edu);}
.step-panel{display:none;animation:stepIn 0.3s var(--ease);}
.step-panel.active{display:block;}
@keyframes stepIn{from{opacity:0;transform:translateX(10px)}to{opacity:1;transform:translateX(0)}}
.step-title{font-family:var(--sans);font-size:28px;letter-spacing:2px;color:var(--text);margin-bottom:4px;}
.step-subtitle{font-family:var(--mono);font-size:10px;letter-spacing:1.5px;text-transform:uppercase;color:var(--muted);margin-bottom:24px;}
.photo-zone{border:2px dashed var(--border);border-radius:4px;background:var(--surface);aspect-ratio:4/3;display:flex;flex-direction:column;align-items:center;justify-content:center;cursor:pointer;transition:all 0.2s;overflow:hidden;position:relative;}
.photo-zone:hover{border-color:var(--amber);background:rgba(240,165,0,0.05);}
.photo-zone.has-photo{border-style:solid;border-color:var(--amber);}
.photo-icon{font-size:40px;margin-bottom:12px;opacity:0.4;}
.photo-hint{font-family:var(--mono);font-size:10px;color:var(--muted);letter-spacing:1px;}
#photoPreview{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:none;}
#photoPreview.show{display:block;}
.photo-retake{position:absolute;bottom:10px;right:10px;background:rgba(0,0,0,0.7);border:1px solid var(--border);color:var(--text);font-family:var(--mono);font-size:9px;padding:4px 10px;cursor:pointer;letter-spacing:1px;display:none;}
.photo-retake.show{display:block;}
#photoInput{display:none;}
.photo-ai-status{margin-top:12px;padding:10px 14px;background:var(--surface);border:1px solid var(--border);border-radius:4px;font-family:var(--mono);font-size:10px;color:var(--muted);display:none;}
.photo-ai-status.show{display:flex;align-items:center;gap:8px;}
.damage-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:24px;}
.damage-btn{padding:16px 10px;border:2px solid var(--border);background:var(--surface);border-radius:8px;cursor:pointer;text-align:center;transition:all 0.15s;}
.damage-btn:hover{border-color:var(--amber);background:rgba(240,165,0,0.05);}
.damage-btn.selected{border-color:var(--amber);background:rgba(240,165,0,0.12);}
.damage-label{font-family:var(--sans);font-size:16px;font-weight:700;letter-spacing:1px;margin-bottom:6px;}
.damage-desc{font-size:11px;color:var(--muted);}
.infra-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:16px;}
.infra-btn{padding:12px 8px;border:1px solid var(--border);background:var(--surface);border-radius:4px;cursor:pointer;text-align:center;transition:all 0.15s;}
.infra-btn:hover{border-color:var(--border);background:var(--panel);}
.infra-btn.selected{border-color:var(--amber);background:rgba(240,165,0,0.12);}
.infra-icon{font-size:22px;margin-bottom:6px;}
.infra-label{font-family:var(--mono);font-size:9px;letter-spacing:1px;text-transform:uppercase;color:var(--muted);}
.form-group{margin-bottom:20px;}
.form-label{font-family:var(--mono);font-size:10px;letter-spacing:1px;color:var(--amber);margin-bottom:8px;display:block;}
.form-input,.form-select,.form-textarea{width:100%;padding:10px 12px;background:var(--bg);border:1px solid var(--border);border-radius:4px;color:var(--text);font-family:var(--sans);font-size:14px;}
.radio-group,.checkbox-group{display:flex;flex-wrap:wrap;gap:12px;margin-top:6px;}
.radio-group label,.checkbox-group label{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--text);}
.location-options{display:flex;gap:8px;margin-bottom:16px;}
.loc-opt{flex:1;padding:12px;border:2px solid var(--border);background:var(--surface);border-radius:4px;cursor:pointer;text-align:center;transition:all 0.15s;}
.loc-opt:hover{border-color:var(--amber);}
.loc-opt.selected{border-color:var(--amber);background:rgba(240,165,0,0.12);}
.loc-opt-label{font-family:var(--mono);font-size:10px;letter-spacing:1px;text-transform:uppercase;color:var(--text);}
.loc-opt-desc{font-size:11px;color:var(--muted);margin-top:4px;}
.fuzzy-notice{padding:8px 12px;background:var(--panel);border:1px solid var(--border);border-radius:4px;font-family:var(--mono);font-size:9px;color:var(--muted);letter-spacing:0.5px;margin-bottom:12px;display:none;}
.fuzzy-notice.show{display:block;}
#locationMap{height:180px;border:1px solid var(--border);border-radius:4px;margin-bottom:12px;overflow:hidden;}
.gps-coords{font-family:var(--mono);font-size:10px;color:var(--muted);letter-spacing:0.5px;padding:8px;background:var(--surface);border:1px solid var(--border);border-radius:4px;margin-bottom:12px;}
.text-location{margin-top:12px;}
.submit-summary{background:var(--surface);border:1px solid var(--border);border-radius:4px;padding:16px;margin-bottom:20px;}
.summary-row{display:flex;align-items:center;justify-content:space-between;padding:6px 0;border-bottom:1px solid var(--dim);}
.summary-row:last-child{border-bottom:none;}
.summary-key{font-family:var(--mono);font-size:10px;color:var(--muted);letter-spacing:1px;text-transform:uppercase;}
.summary-val{font-family:var(--mono);font-size:11px;color:var(--text);}
.anon-notice{display:flex;gap:10px;padding:12px;background:rgba(74,222,128,0.08);border:1px solid var(--edu);border-radius:4px;margin-bottom:20px;font-size:12px;color:var(--muted);}
.anon-icon{font-size:16px;flex-shrink:0;}
.btn{display:block;width:100%;padding:14px;font-family:var(--mono);font-size:11px;letter-spacing:2px;text-transform:uppercase;border:none;cursor:pointer;border-radius:4px;transition:all 0.15s;}
.btn-primary{background:var(--amber);color:#000;font-weight:600;}
.btn-primary:hover{background:var(--amber-d);}
.btn-primary:disabled{opacity:0.4;cursor:not-allowed;}
.btn-secondary{background:var(--surface);color:var(--text);border:1px solid var(--border);margin-top:10px;}
.btn-secondary:hover{border-color:var(--amber);color:var(--amber);}
.btn-sm{display:inline-flex;align-items:center;gap:6px;padding:8px 16px;width:auto;}
/* FIX #11 — access input error state */
.access-input.error{border-color:var(--red);animation:shake 0.3s ease;}
@keyframes shake{0%,100%{transform:translateX(0)}25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
.confirm-screen{text-align:center;padding:32px 20px;display:none;}
.confirm-screen.show{display:block;}
.confirm-check{width:72px;height:72px;border-radius:50%;background:rgba(74,222,128,0.1);border:2px solid var(--edu);display:flex;align-items:center;justify-content:center;font-size:32px;margin:0 auto 20px;animation:popIn 0.4s var(--ease);}
@keyframes popIn{from{transform:scale(0.5);opacity:0;}to{transform:scale(1);opacity:1;}}
.dci-display{background:var(--surface);border:1px solid var(--border);border-radius:4px;padding:20px;margin:20px 0;}
.dci-label{font-family:var(--mono);font-size:9px;letter-spacing:2px;text-transform:uppercase;color:var(--muted);margin-bottom:8px;}
.dci-score-large{font-family:var(--sans);font-size:64px;letter-spacing:2px;line-height:1;margin-bottom:4px;}
.dci-score-large.high{color:var(--amber);}
.dci-score-large.watch{color:var(--amber);}
.dci-score-large.review{color:var(--red);}
.dci-tier-badge{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;font-family:var(--mono);font-size:10px;letter-spacing:2px;text-transform:uppercase;border:1px solid;margin-bottom:12px;}
.dci-tier-badge.high{border-color:var(--amber);color:var(--amber);background:rgba(240,165,0,0.12);}
.dci-tier-badge.watch{border-color:var(--amber);color:var(--amber);background:rgba(240,165,0,0.12);}
.dci-tier-badge.review{border-color:var(--red);color:var(--red);background:rgba(255,77,77,0.12);}
.dci-explain{font-family:var(--mono);font-size:9px;color:var(--muted);letter-spacing:0.5px;line-height:1.6;}
.engagement-message{background:rgba(240,165,0,0.08);border-left:3px solid var(--amber);padding:12px;margin-bottom:20px;font-family:var(--mono);font-size:11px;text-align:left;}
.access-gate{max-width:400px;margin:60px auto;padding:32px 24px;background:var(--surface);border:1px solid var(--border);border-radius:4px;text-align:center;}
.access-gate-title{font-family:var(--sans);font-size:32px;letter-spacing:3px;color:var(--amber);margin-bottom:8px;}
.access-gate-sub{font-family:var(--mono);font-size:10px;color:var(--muted);letter-spacing:1.5px;margin-bottom:28px;}
.access-input{width:100%;padding:12px 14px;background:var(--bg);border:1px solid var(--border);border-radius:4px;color:var(--text);font-family:var(--mono);font-size:16px;letter-spacing:4px;text-align:center;text-transform:uppercase;margin-bottom:16px;outline:none;transition:border-color 0.2s;}
.access-input:focus{border-color:var(--amber);}
.respond-dashboard{padding:16px;display:none;}
.respond-dashboard.show{display:block;}
.confidence-dash{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:16px;}
.conf-card{padding:14px 10px;background:var(--surface);border:1px solid var(--border);border-radius:4px;text-align:center;}
.conf-card.high{border-color:var(--amber);background:rgba(240,165,0,0.08);}
.conf-card.watch{border-color:var(--amber);background:rgba(240,165,0,0.08);}
.conf-card.review{border-color:var(--red);background:rgba(255,77,77,0.08);}
.conf-count{font-family:var(--sans);font-size:40px;line-height:1;margin-bottom:4px;}
.conf-card.high .conf-count{color:var(--amber);}
.conf-card.watch .conf-count{color:var(--amber);}
.conf-card.review .conf-count{color:var(--red);}
.conf-tier{font-family:var(--mono);font-size:8px;letter-spacing:1.5px;text-transform:uppercase;color:var(--muted);}
#respondMap{height:320px;border:1px solid var(--border);border-radius:4px;margin-bottom:16px;overflow:hidden;}
.section-label{font-family:var(--mono);font-size:9px;letter-spacing:2px;text-transform:uppercase;color:var(--muted);margin-bottom:10px;display:flex;align-items:center;gap:8px;}
.section-label::after{content:'';flex:1;height:1px;background:var(--border);}
.conflict-item{padding:10px 12px;background:var(--surface);border:1px solid var(--red);border-left:3px solid var(--red);border-radius:4px;margin-bottom:6px;font-family:var(--mono);font-size:10px;color:var(--muted);line-height:1.6;}
.timeline-wrap{padding:14px;background:var(--surface);border:1px solid var(--border);border-radius:4px;margin-bottom:16px;}
#timelineSlider{width:100%;accent-color:var(--amber);margin-bottom:6px;}
.timeline-time{font-family:var(--mono);font-size:10px;color:var(--muted);text-align:right;}
.export-section{background:var(--surface);border:1px solid var(--border);border-radius:4px;padding:16px;margin-bottom:16px;}
.export-header-preview{font-family:var(--mono);font-size:9px;color:var(--muted);background:var(--bg);border:1px solid var(--border);border-radius:4px;padding:10px;margin-top:12px;line-height:1.8;overflow-x:auto;white-space:pre;}
.export-btns{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap;}
.export-btn{flex:1;min-width:100px;padding:10px;background:var(--panel);border:1px solid var(--border);color:var(--text);font-family:var(--mono);font-size:9px;letter-spacing:1.5px;text-transform:uppercase;cursor:pointer;border-radius:4px;transition:all 0.15s;}
.export-btn:hover{border-color:var(--amber);color:var(--amber);}
.report-card{padding:16px;background:var(--surface);border:1px solid var(--amber);border-radius:4px;margin-bottom:16px;}
.report-card-title{font-family:var(--sans);font-size:20px;letter-spacing:3px;color:var(--amber);margin-bottom:14px;}
.rc-bar-row{display:flex;align-items:center;gap:10px;margin-bottom:8px;}
.rc-bar-label{font-family:var(--mono);font-size:9px;color:var(--muted);width:80px;letter-spacing:0.5px;}
.rc-bar-track{flex:1;height:6px;background:var(--dim);border-radius:3px;overflow:hidden;}
.rc-bar-fill{height:100%;border-radius:3px;transition:width 0.8s var(--ease);}
.rc-bar-val{font-family:var(--mono);font-size:9px;color:var(--muted);width:30px;text-align:right;}
.law6-footer{padding:12px 16px;background:rgba(255,77,77,0.05);border-top:1px solid rgba(255,77,77,0.2);font-family:var(--mono);font-size:9px;color:var(--muted);letter-spacing:0.5px;line-height:1.7;text-align:center;}
.law6-footer strong{color:var(--red);}
.offline-banner,.sync-queue{background:rgba(255,77,77,0.1);border-bottom:1px solid var(--red);padding:8px 20px;font-family:var(--mono);font-size:10px;color:var(--red);letter-spacing:1px;display:none;align-items:center;gap:8px;margin-bottom:16px;}
.sync-queue{background:rgba(240,165,0,0.12);border-color:var(--amber);color:var(--amber);}
.offline-banner.show,.sync-queue.show{display:flex;}
.spinner{width:14px;height:14px;border:2px solid var(--border);border-top-color:var(--amber);border-radius:50%;animation:spin 0.6s linear infinite;display:inline-block;}
@keyframes spin{to{transform:rotate(360deg)}}
.toast-container{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);z-index:1000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;}
.toast{padding:10px 20px;background:var(--panel);border:1px solid var(--border);border-radius:100px;font-family:var(--mono);font-size:10px;letter-spacing:1px;color:var(--text);animation:toastIn 0.3s var(--ease);pointer-events:none;}
@keyframes toastIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
.leaflet-container{background:#0a0c0f !important;font-family:var(--mono) !important;}
.dci-popup{font-family:var(--mono);font-size:10px;line-height:1.6;}
footer{border-top:1px solid var(--border);padding:40px 0;display:flex;justify-content:space-between;flex-wrap:wrap;gap:20px;font-family:var(--mono);font-size:10px;color:var(--muted);}
.footer-links{display:flex;gap:24px;list-style:none;}
.footer-links a{color:var(--muted);text-decoration:none;transition:color 0.2s;}
.footer-links a:hover{color:var(--amber);}
@media (max-width: 800px) {
.nav-links{display:none;}
.nav-hamburger{display:flex;}
.lang-selector{display:none;} /* FIX #7 — hidden on mobile, shown in mobile-nav */
.wrapper{padding:0 20px;}
.infra-grid{grid-template-columns:repeat(2,1fr);}
.confidence-dash{grid-template-columns:1fr 1fr 1fr;}
.conf-count{font-size:32px;}
.damage-grid{grid-template-columns:1fr;}
}
</style>
</head>
<body>
<canvas id="hero-canvas"></canvas>
<div class="custom-cursor" id="custom-cursor"></div>
<div class="wrapper">
<nav>
<a href="/" class="logo">AION<span>system</span></a>
<ul class="nav-links">
<li><a href="#" onclick="switchView('report')">📍 Report Damage</a></li>
<li><a href="#" onclick="switchView('rescue')">🆘 I Need Rescue</a></li>
<li><a href="#" onclick="switchView('respond')">🗺 Responder View</a></li>
</ul>
<div class="lang-selector" id="langSelector"></div>
<button class="nav-hamburger" id="nav-hamburger" aria-label="Menu">
<span></span><span></span><span></span>
</button>
</nav>
<!-- FIX #7 — mobile nav includes language row -->
<div class="mobile-nav" id="mobile-nav">
<div class="mobile-lang-row" id="mobileLangRow"></div>
<a href="#" onclick="switchView('report')">📍 Report Damage</a>
<a href="#" onclick="switchView('rescue')">🆘 I Need Rescue</a>
<a href="#" onclick="switchView('respond')">🗺 Responder View</a>
</div>
<div class="offline-banner" id="offlineBanner"><span>📡</span><span data-i18n="offline">Offline — reports saved locally and will sync when connected</span></div>
<div class="sync-queue" id="syncQueue"><span class="spinner"></span><span id="syncQueueText" data-i18n="syncing">Syncing queued reports...</span></div>
<div class="veritas-tabs">
<button class="veritas-tab active" id="navReport" onclick="switchView('report')">📍 Report Damage</button>
<button class="veritas-tab" id="navRescue" onclick="switchView('rescue')">🆘 I Need Rescue</button>
<button class="veritas-tab" id="navRespond" onclick="switchView('respond')">🗺 Responder View</button>
</div>
<!-- REPORT VIEW -->
<div class="veritas-view active" id="viewReport">
<div class="confirm-screen" id="confirmScreen">
<div class="confirm-check">✓</div>
<div style="font-family:var(--sans);font-size:28px;letter-spacing:2px;color:var(--text);margin-bottom:6px;" data-i18n="report_received">REPORT RECEIVED</div>
<div style="font-family:var(--mono);font-size:10px;color:var(--muted);letter-spacing:1px;margin-bottom:24px;" data-i18n="certus_scored">CERTUS Engine has scored your submission</div>
<div class="dci-display">
<div class="dci-label" data-i18n="dci_label">Damage Confidence Index — CERTUS Engine v2.5</div>
<div class="dci-score-large" id="confirmDciScore">—</div>
<div id="confirmDciBadge" class="dci-tier-badge high">HIGH CONFIDENCE</div>
<div class="dci-explain" data-i18n="dci_explain">DCI measures how much to trust this report.<br>Scored on photo evidence · corroboration · freshness · consistency.</div>
</div>
<div id="engagementMessage" class="engagement-message"></div>
<button class="btn btn-primary" onclick="resetReport()" data-i18n="submit_another">Submit Another Report</button>
<button class="btn btn-secondary" onclick="switchView('respond')" data-i18n="view_map">View Responder Map</button>
</div>
<div id="reportForm">
<div class="step-progress">
<div class="step-node"><div class="step-circle active" id="sc1">1</div><div class="step-label active" id="sl1" data-i18n="step_photo">Photo</div></div>
<div class="step-line" id="sline1"></div>
<div class="step-node"><div class="step-circle" id="sc2">2</div><div class="step-label" id="sl2" data-i18n="step_damage">Damage</div></div>
<div class="step-line" id="sline2"></div>
<div class="step-node"><div class="step-circle" id="sc3">3</div><div class="step-label" id="sl3" data-i18n="step_details">Details</div></div>
<div class="step-line" id="sline3"></div>
<div class="step-node"><div class="step-circle" id="sc4">4</div><div class="step-label" id="sl4" data-i18n="step_location">Location</div></div>
<div class="step-line" id="sline4"></div>
<div class="step-node"><div class="step-circle" id="sc5">5</div><div class="step-label" id="sl5" data-i18n="step_review">Review</div></div>
</div>
<div class="step-panel active" id="step1">
<div class="step-title" data-i18n="photo_title">PHOTOGRAPH</div>
<div class="step-subtitle" data-i18n="photo_sub">Capture visible damage clearly</div>
<div class="photo-zone" id="photoZone" onclick="triggerPhotoCapture()">
<div class="photo-icon">📷</div>
<div class="photo-hint" data-i18n="photo_hint">TAP TO PHOTOGRAPH DAMAGE</div>
<img id="photoPreview" alt="Damage photo">
<button class="photo-retake" id="photoRetake" onclick="event.stopPropagation(); triggerPhotoCapture()" data-i18n="retake">RETAKE</button>
</div>
<input type="file" id="photoInput" accept="image/*" capture="environment" onchange="handlePhoto(this)">
<div class="photo-ai-status" id="photoAiStatus"><span class="spinner"></span><span id="aiStatusText" data-i18n="analyzing">CERTUS analyzing image...</span></div>
<button class="btn btn-primary" style="margin-top:16px;" id="step1Next" onclick="goStep(2)" disabled data-i18n="next">NEXT</button>
</div>
<div class="step-panel" id="step2">
<div class="step-title" data-i18n="damage_title">DAMAGE LEVEL</div>
<div class="step-subtitle" data-i18n="damage_sub">Select the damage level (UNDP required)</div>
<div class="damage-grid">
<button class="damage-btn" onclick="selectDamage('minimal')" id="damage-minimal">
<div class="damage-label" data-i18n="damage_minimal">Minimal / No damage</div>
<div class="damage-desc" data-i18n="damage_minimal_desc">Little or no visible structural impact</div>
</button>
<button class="damage-btn" onclick="selectDamage('partial')" id="damage-partial">
<div class="damage-label" data-i18n="damage_partial">Partially damaged</div>
<div class="damage-desc" data-i18n="damage_partial_desc">Significant damage but still standing</div>
</button>
<button class="damage-btn" onclick="selectDamage('complete')" id="damage-complete">
<div class="damage-label" data-i18n="damage_complete">Completely damaged</div>
<div class="damage-desc" data-i18n="damage_complete_desc">Structure destroyed / total collapse</div>
</button>
</div>
<div class="step-title" style="margin-top:24px;" data-i18n="infra_title">INFRASTRUCTURE TYPE</div>
<div class="infra-grid">
<button class="infra-btn" data-infra="Residential" onclick="selectInfra('Residential')"><div class="infra-icon">🏠</div><div class="infra-label">Residential</div></button>
<button class="infra-btn" data-infra="Road" onclick="selectInfra('Road')"><div class="infra-icon">🛣️</div><div class="infra-label">Road</div></button>
<button class="infra-btn" data-infra="Bridge" onclick="selectInfra('Bridge')"><div class="infra-icon">🌉</div><div class="infra-label">Bridge</div></button>
<button class="infra-btn" data-infra="Utility" onclick="selectInfra('Utility')"><div class="infra-icon">⚡</div><div class="infra-label">Utility</div></button>
<button class="infra-btn" data-infra="Medical" onclick="selectInfra('Medical')"><div class="infra-icon">🏥</div><div class="infra-label">Medical</div></button>
<button class="infra-btn" data-infra="School" onclick="selectInfra('School')"><div class="infra-icon">🏫</div><div class="infra-label">School</div></button>
<button class="infra-btn" data-infra="Commercial Infrastructure" onclick="selectInfra('Commercial Infrastructure')"><div class="infra-icon">🏪</div><div class="infra-label">Commercial</div></button>
<button class="infra-btn" data-infra="Government Building" onclick="selectInfra('Government Building')"><div class="infra-icon">🏛️</div><div class="infra-label">Government</div></button>
<button class="infra-btn" data-infra="Transport and Communication" onclick="selectInfra('Transport and Communication')"><div class="infra-icon">📡</div><div class="infra-label">Transport/Comm</div></button>
<button class="infra-btn" data-infra="Community Infrastructure" onclick="selectInfra('Community Infrastructure')"><div class="infra-icon">🏘️</div><div class="infra-label">Community</div></button>
<button class="infra-btn" data-infra="Public spaces/Recreation" onclick="selectInfra('Public spaces/Recreation')"><div class="infra-icon">⛲</div><div class="infra-label">Public Space</div></button>
<button class="infra-btn" data-infra="Other" onclick="selectInfra('Other')"><div class="infra-icon">📝</div><div class="infra-label">Other</div></button>
</div>
<div id="otherInfraContainer" style="display:none;margin-top:8px;"><input type="text" id="otherInfra" class="form-input" placeholder="Please specify"></div>
<div style="display:flex;gap:8px;margin-top:16px;">
<button class="btn btn-secondary" style="flex:0 0 80px" onclick="goStep(1)" data-i18n="back">← BACK</button>
<button class="btn btn-primary" id="step2Next" onclick="goStep(3)" disabled data-i18n="next">NEXT</button>
</div>
</div>
<div class="step-panel" id="step3">
<div class="step-title" data-i18n="details_title">DETAILS</div>
<div class="step-subtitle" data-i18n="details_sub">Help responders understand the situation</div>
<div class="form-group"><label class="form-label" data-i18n="infra_name_label">Infrastructure name (optional)</label><input type="text" id="infraName" class="form-input" placeholder="e.g., Central Bridge, Al-Noor Hospital"></div>
<div class="form-group">
<label class="form-label" data-i18n="crisis_type_label">Nature of crisis</label>
<div class="radio-group" id="crisisTypeGroup">
<label><input type="radio" name="crisisType" value="Natural"> <span data-i18n="crisis_natural">Natural</span></label>
<label><input type="radio" name="crisisType" value="Technological"> <span data-i18n="crisis_tech">Technological</span></label>
<label><input type="radio" name="crisisType" value="Human-made"> <span data-i18n="crisis_human">Human‑made</span></label>
</div>
<div id="crisisSubtypeContainer" style="margin-top:12px;"></div>
</div>
<div class="form-group"><label class="form-label" data-i18n="debris_label">Is there debris requiring clearing?</label><div class="radio-group"><label><input type="radio" name="debris" value="yes"> <span data-i18n="yes">Yes</span></label><label><input type="radio" name="debris" value="no"> <span data-i18n="no">No</span></label></div></div>
<div class="form-group">
<label class="form-label" data-i18n="electricity_label">Electricity infrastructure condition</label>
<div class="radio-group" id="electricityGroup">
<label><input type="radio" name="electricity" value="No damage observed"> No damage observed</label>
<label><input type="radio" name="electricity" value="Minor damage"> Minor damage</label>
<label><input type="radio" name="electricity" value="Moderate damage"> Moderate damage</label>
<label><input type="radio" name="electricity" value="Severe damage"> Severe damage</label>
<label><input type="radio" name="electricity" value="Completely destroyed"> Completely destroyed</label>
<label><input type="radio" name="electricity" value="Unknown/cannot be assessed"> Unknown/cannot be assessed</label>
</div>
</div>
<div class="form-group">
<label class="form-label" data-i18n="health_label">Overall health services functioning</label>
<div class="radio-group" id="healthGroup">
<label><input type="radio" name="health" value="Fully functional"> Fully functional</label>
<label><input type="radio" name="health" value="Partially functional"> Partially functional</label>
<label><input type="radio" name="health" value="Largely disrupted"> Largely disrupted</label>
<label><input type="radio" name="health" value="Not functioning at all"> Not functioning at all</label>
<label><input type="radio" name="health" value="Unknown"> Unknown</label>
</div>
</div>
<div class="form-group">
<label class="form-label" data-i18n="needs_label">Most pressing needs (select all that apply)</label>
<div class="checkbox-group" id="needsGroup">
<label><input type="checkbox" value="Food assistance and safe drinking water"> Food assistance and safe drinking water</label>
<label><input type="checkbox" value="Cash or financial assistance"> Cash or financial assistance</label>
<label><input type="checkbox" value="Access to healthcare and essential medicines"> Access to healthcare and essential medicines</label>
<label><input type="checkbox" value="Shelter, housing repair, or temporary accommodation"> Shelter, housing repair, or temporary accommodation</label>
<label><input type="checkbox" value="Restoration of livelihoods or income sources"> Restoration of livelihoods or income sources</label>
<label><input type="checkbox" value="Water, sanitation, and hygiene (WASH)"> Water, sanitation, and hygiene (WASH)</label>
<label><input type="checkbox" value="Restoration of basic services and infrastructure"> Restoration of basic services and infrastructure</label>
<label><input type="checkbox" value="Protection services and psychosocial support"> Protection services and psychosocial support</label>
<label><input type="checkbox" value="Support from local authorities and community organizations"> Support from local authorities and community organizations</label>
<label><input type="checkbox" value="Other, please specify"> Other, please specify</label>
</div>
</div>
<div style="display:flex;gap:8px;margin-top:16px;">
<button class="btn btn-secondary" style="flex:0 0 80px" onclick="goStep(2)" data-i18n="back">← BACK</button>
<button class="btn btn-primary" id="step3Next" onclick="goStep(4)" data-i18n="next">NEXT</button>
</div>
</div>
<div class="step-panel" id="step4">
<div class="step-title" data-i18n="location_title">LOCATION</div>
<div class="step-subtitle" data-i18n="location_sub">Pin the damage location</div>
<div class="location-options">
<div class="loc-opt selected" id="locPrecise" onclick="selectLocMode('precise')"><div class="loc-opt-label" data-i18n="precise">📍 Precise</div><div class="loc-opt-desc" data-i18n="precise_desc">Exact GPS pin</div></div>
<div class="loc-opt" id="locFuzzy" onclick="selectLocMode('fuzzy')"><div class="loc-opt-label" data-i18n="area">🔵 Area</div><div class="loc-opt-desc" data-i18n="area_desc">±100m radius</div></div>
</div>
<div class="fuzzy-notice" id="fuzzyNotice" data-i18n="fuzzy_notice">Area mode selected — your precise location is protected. Report is accurate to ±100 meters. Suitable for conflict-affected areas.</div>
<div id="locationMap"></div>
<div class="gps-coords" id="gpsCoords"><span style="color:var(--muted)" data-i18n="acquiring">Acquiring GPS coordinates...</span></div>
<!-- FIX #9 — text location enables next button as fallback -->
<div class="form-group text-location">
<label class="form-label" data-i18n="text_location_label">Describe location (if GPS unavailable, e.g., "near the central market")</label>
<input type="text" id="textLocation" class="form-input" placeholder="Optional text description" oninput="onTextLocationInput(this.value)">
</div>
<div style="display:flex;gap:8px;margin-top:16px;">
<button class="btn btn-secondary" style="flex:0 0 80px" onclick="goStep(3)" data-i18n="back">← BACK</button>
<button class="btn btn-primary" id="step4Next" onclick="goStep(5)" disabled data-i18n="next">NEXT</button>
</div>
</div>
<div class="step-panel" id="step5">
<div class="step-title" data-i18n="review_title">REVIEW</div>
<div class="step-subtitle" data-i18n="review_sub">Confirm and submit your report</div>
<div class="submit-summary" id="submitSummary"></div>
<div class="anon-notice"><span class="anon-icon">🔒</span><span data-i18n="anon_notice">Your report is anonymous. No account required. EXIF metadata stripped. No IP stored. Keyed by random UUID only.</span></div>
<div style="display:flex;gap:8px;">
<button class="btn btn-secondary" style="flex:0 0 80px" onclick="goStep(4)" data-i18n="back">← BACK</button>
<button class="btn btn-primary" id="submitBtn" onclick="submitReport()" data-i18n="submit">SUBMIT REPORT</button>
</div>
</div>
</div>
</div>
<!-- RESPOND VIEW -->
<div class="veritas-view" id="viewRespond">
<div id="accessGate" class="access-gate">
<div class="access-gate-title" data-i18n="restricted">RESTRICTED</div>
<div class="access-gate-sub" data-i18n="access_sub">Responder Access Required</div>
<input class="access-input" id="accessInput" type="text" placeholder="ACCESS CODE" maxlength="8" onkeyup="checkAccess(event)">
<div id="accessError" style="display:none;font-family:var(--mono);font-size:10px;color:var(--red);margin-bottom:12px;letter-spacing:0.5px;">Invalid access code. Try again.</div>
<button class="btn btn-primary" onclick="checkAccessBtn()" data-i18n="enter">ENTER</button>
<div style="font-family:var(--mono);font-size:9px;color:var(--muted);margin-top:16px;letter-spacing:0.5px;" data-i18n="access_note">Access code distributed to authorized UNDP response partners only.</div>
</div>
<div class="respond-dashboard" id="respondDashboard">
<div class="section-label" data-i18n="live_dash">Live Confidence Dashboard</div>
<div class="confidence-dash">
<div class="conf-card high"><div class="conf-count" id="dashHigh">0</div><div class="conf-tier" data-i18n="high_conf">High<br>Confidence</div></div>
<div class="conf-card watch"><div class="conf-count" id="dashWatch">0</div><div class="conf-tier" data-i18n="watch">Watch<br>Monitor</div></div>
<div class="conf-card review"><div class="conf-count" id="dashReview">0</div><div class="conf-tier" data-i18n="review_req">Review<br>Required</div></div>
</div>
<div class="section-label" data-i18n="conf_map">Confidence Map</div>
<div id="respondMap"></div>
<div class="timeline-wrap">
<div class="timeline-label" data-i18n="timeline">48-Hour Timeline Playback</div>
<input type="range" id="timelineSlider" min="0" max="100" value="100" oninput="updateTimeline(this.value)">
<div class="timeline-time" id="timelineTime" data-i18n="live_all">Live — all reports</div>
</div>
<div class="section-label" data-i18n="conflict_flags">Conflict Flags</div>
<div id="conflictList"><div style="font-family:var(--mono);font-size:10px;color:var(--muted);padding:10px;text-align:center;" data-i18n="no_conflicts">No conflicts detected</div></div>
<div class="report-card">
<div class="report-card-title" data-i18n="dci_report">DCI REPORT CARD</div>
<div class="section-label" data-i18n="conf_dist">Confidence Distribution</div>
<div class="rc-bar-row"><span class="rc-bar-label" data-i18n="high">High</span><div class="rc-bar-track"><div class="rc-bar-fill" id="rcHigh" style="width:0%;background:var(--amber)"></div></div><span class="rc-bar-val" id="rcHighPct">0%</span></div>
<div class="rc-bar-row"><span class="rc-bar-label" data-i18n="watch">Watch</span><div class="rc-bar-track"><div class="rc-bar-fill" id="rcWatch" style="width:0%;background:var(--amber)"></div></div><span class="rc-bar-val" id="rcWatchPct">0%</span></div>
<div class="rc-bar-row"><span class="rc-bar-label" data-i18n="review">Review</span><div class="rc-bar-track"><div class="rc-bar-fill" id="rcReview" style="width:0%;background:var(--red)"></div></div><span class="rc-bar-val" id="rcReviewPct">0%</span></div>
<div style="margin-top:12px;font-family:var(--mono);font-size:9px;color:var(--muted);letter-spacing:0.5px;" data-i18n="powered">Powered by CERTUS Engine v2.5 — DCI scored on photo evidence, corroboration, freshness, and consistency</div>
</div>
<div class="export-section">
<div class="section-label" data-i18n="export">Export Dataset</div>
<div style="display:flex;align-items:center;gap:12px;margin-bottom:12px;">
<span class="stp-badge" style="background:rgba(46,125,50,0.1);border:1px solid #2E7D32;border-radius:20px;padding:4px 10px;font-family:var(--mono);font-size:9px;color:#2E7D32;">🔒 STP INTEGRATED</span>
<span style="font-size:11px;color:var(--muted);">Exports can be permanently sealed with triple‑time proof</span>
</div>
<div class="export-btns">
<button class="export-btn" onclick="exportData('json')">JSON + DCI</button>
<button class="export-btn" onclick="exportData('csv')">CSV</button>
<button class="export-btn" onclick="exportData('geojson')">GeoJSON</button>
<button class="export-btn" onclick="exportShapefile()">Shapefile</button>
<button class="export-btn" onclick="copyRestEndpoint()" style="border-color:var(--cyan);color:var(--cyan);">🔗 REST API</button>
<button class="export-btn" id="stpSealBtn" onclick="stampWithSTP()" style="border-color:var(--amber);">🔒 STP Seal</button>
</div>
<div class="export-header-preview" id="exportPreview">VERITAS INTEGRITY EXPORT\nPowered by CERTUS Engine v2.5\nReports: —\nGenerated: —\nSHA-256: computing...\nDecision-support only. Review Required reports require human field verification.</div>
<div id="stpSealDisplay" style="display:none;margin-top:16px;padding:12px;background:var(--surface);border:1px solid var(--amber);border-radius:4px;font-family:var(--mono);font-size:10px;">
<div style="display:flex;justify-content:space-between;align-items:center;">
<span style="color:var(--amber);font-weight:bold;">SOVEREIGN TRACE SEAL</span>
<button class="btn-sm" onclick="downloadSTPSeal()" style="background:var(--panel);">📥 Download STP File</button>
</div>
<div id="stpSealContent" style="margin-top:8px;color:var(--muted);line-height:1.6;"></div>
</div>
</div>
<div style="margin-bottom:16px;">
<button class="btn btn-secondary btn-sm" onclick="exportCachedSnapshot()" data-i18n="cached_snapshot">📥 Download Cached Snapshot</button>
<div style="font-family:var(--mono);font-size:9px;color:var(--muted);margin-top:6px;letter-spacing:0.5px;" data-i18n="offline_note">Available offline — shows last synced state</div>
</div>
<div class="law6-footer">
<strong data-i18n="decision_support">⚠ DECISION-SUPPORT INSTRUMENT ONLY</strong><br>
<span data-i18n="law6_line1">VERITAS DCI scores assist human judgment — they do not replace it.</span><br>
<strong data-i18n="review_required_human">Review Required</strong> reports must receive human field verification before informing any resource deployment decision.
</div>
</div>
</div>
<!-- RESCUE VIEW -->
<div class="veritas-view" id="viewRescue">
<div class="emergency-hero" style="text-align: center; padding: 40px 20px; background: linear-gradient(135deg, #ff4d4d 0%, #cc0000 100%); border-radius: 20px; margin-bottom: 30px;">
<div style="font-size: 80px;">🆘</div>
<h1 style="color: white; font-size: 32px; margin: 20px 0;" data-i18n="rescue_title">I NEED RESCUE</h1>
<p style="color: rgba(255,255,255,0.9); margin-bottom: 30px;" data-i18n="rescue_description">Tap the button below if you are trapped or need emergency assistance. Your location and photo will be sent to rescue teams.</p>
<button id="emergencyButton" onclick="sendEmergencySignal()" style="background: white; color: #ff4d4d; font-size: 28px; padding: 20px 40px; border: none; border-radius: 60px; font-weight: bold; cursor: pointer; box-shadow: 0 4px 20px rgba(0,0,0,0.3);" data-i18n="rescue_button">
🚨 SEND RESCUE SIGNAL 🚨
</button>
</div>
<div class="info-card" style="background: var(--surface); border-radius: 12px; padding: 20px; margin-bottom: 20px;">
<h3 data-i18n="location_status_title">📍 Your Location Status</h3>
<p id="lastLocationStatus" style="font-family: monospace; font-size: 12px; color: var(--amber); margin-top: 8px;" data-i18n="location_status_placeholder">Acquiring GPS...</p>
<div style="font-size: 12px; color: var(--muted); margin-top: 8px;">
<span data-i18n="gps_label">📡 GPS: </span><span id="gpsStatus" data-i18n="gps_waiting">Waiting for signal</span>
</div>
</div>
<div class="info-card" style="background: var(--surface); border-radius: 12px; padding: 20px;">
<h3 data-i18n="waiting_advice_title">📋 What to Do While Waiting</h3>
<ul style="margin-top: 12px; list-style: none;">
<li style="margin-bottom: 12px;" data-i18n="waiting_advice_1">✅ Stay where you are if it's safe</li>
<li style="margin-bottom: 12px;" data-i18n="waiting_advice_2">✅ Conserve phone battery (reduce brightness)</li>
<li style="margin-bottom: 12px;" data-i18n="waiting_advice_3">✅ Take a photo of your surroundings</li>
<li style="margin-bottom: 12px;" data-i18n="waiting_advice_4">✅ If you move, your last location is still saved</li>
<li style="margin-bottom: 12px;" data-i18n="waiting_advice_5">✅ Signal works offline — will send when connected</li>
</ul>
</div>
</div>
<div class="triple-time">
<div class="time-cell"><div class="time-sys">Gregorian</div><div class="time-val loading" id="tt-gregorian">· · ·</div></div>
<div class="time-cell"><div class="time-sys">13 Moon · Dreamspell</div><div class="time-val loading" id="tt-dreamspell">· · ·</div></div>
<div class="time-cell"><div class="time-sys">Hebrew Calendar</div><div class="time-val loading" id="tt-hebrew">· · ·</div></div>
</div>
<footer>
<div class="footer-id"><strong>AionSystem</strong> · Sheldon K. Salmon · AI Reliability Architect<br>Evans Mills, New York · March 2026<br>VERITAS v2.5 · CERTUS Engine · STP Integration · OpenRouter AI</div>
<ul class="footer-links">
<li><a href="/">Home</a></li><li><a href="/simulators/">Simulators</a></li>
<li><a href="/services/">Services</a></li><li><a href="/stack/">Stack</a></li>
<li><a href="/ksc/">KSC</a></li><li><a href="/certify/">Certify</a></li>
<li><a href="https://github.com/AionSystem/VERITAS" target="_blank">GitHub</a></li>
</ul>
</footer>
</div>
<div class="toast-container" id="toastContainer"></div>
<script>
// ==================== CONFIG & STATE ====================
const CONFIG = {
SUPABASE_URL: 'https://spqqhvaqjwxcrdbujwna.supabase.co',
SUPABASE_ANON: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNwcXFodmFxand4Y3JkYnVqd25hIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ3MTY2NDIsImV4cCI6MjA5MDI5MjY0Mn0.1ibM3TwGS82NOAhpzZFbvdCzdveReqaM9sMIVDTO3Tg',
ACCESS_CODE: 'UNDP2026',
USE_SUPABASE: true,
MAP_CENTER: [0, 20],
MAP_ZOOM: 3,
FUZZY_RADIUS: 100,
DCI_THRESHOLDS: { HIGH: 0.70, WATCH: 0.40 },
DEDUP_RADIUS: 10,
DEDUP_WINDOW: 120,
FETCH_TIMEOUT_MS: 10000 // FIX #8 — global fetch timeout
};
const STATE = {
currentStep: 1,
currentView: 'report',
markerLayer: null,
photo: null,
photoAiScore: null,
photoAiConf: null,
undpTier: null,
internalTier: null,
infraType: null,
locMode: 'precise',
coords: null,
textLocation: null,
reports: [],
isOnline: navigator.onLine,
syncQueue: [],
respondAuth: false,
respondMap: null,
reportMap: null,
reportMarker: null,
additionalFields: { infraName:'', crisisType:'', crisisSubtype:'', debris:'', electricity:'', health:'', needs:[] }
};
const tierMap = { minimal:'None', partial:'Moderate', complete:'Total Collapse' };
const crisisSubtypes = {
Natural: ['Earthquake','Flood','Tsunami','Hurricane','Wildfire'],
Technological: ['Explosion','Chemical incident'],
'Human-made': ['Conflict','Civil unrest']
};
// ==================== CERTUS TIER HELPERS (defensive fallbacks) ====================
// FIX #6 — wrap CERTUS methods with safe fallbacks if external file is missing methods
function safeTierColor(tier) {
if (typeof CERTUS !== 'undefined' && typeof CERTUS.tierColor === 'function') {
return CERTUS.tierColor(tier);
}
return tier === 'high' ? '#f0a500' : tier === 'watch' ? '#ffc947' : '#ff4d4d';
}
function safeTierLabel(tier) {
if (typeof CERTUS !== 'undefined' && typeof CERTUS.tierLabel === 'function') {
return CERTUS.tierLabel(tier);
}
return tier === 'high' ? 'HIGH CONFIDENCE' : tier === 'watch' ? 'WATCH / MONITOR' : 'REVIEW REQUIRED';
}
function safeCERTUSScore(report, nearby, useModel) {
console.log('[VERITAS] safeCERTUSScore called', { reportHasPhoto: !!report.photo, nearbyCount: nearby?.length });
// Check if CERTUS exists and has score function
if (typeof CERTUS !== 'undefined' && typeof CERTUS.score === 'function') {
try {
const safeReport = {
...report,
photo: report.photo || null,
photoAiScore: (report.photoAiScore !== null && report.photoAiScore !== undefined) ? report.photoAiScore : 0.5,
photoAiConf: (report.photoAiConf !== null && report.photoAiConf !== undefined) ? report.photoAiConf : 0.7,
internalTier: report.undpTier ?
(report.undpTier === 'minimal' ? 'Minimal / No damage' :
report.undpTier === 'partial' ? 'Partially damaged' : 'Completely damaged') :
'Partially damaged',
infraType: report.infraType || 'Unknown',
timestamp: report.timestamp || new Date().toISOString(),
coordinates: report.coords || { lat: 0, lng: 0 }
};
const result = CERTUS.score(safeReport, nearby || [], useModel);
console.log('[VERITAS] CERTUS.score result:', result);
const strengths = [];
const weaknesses = [];
if (report.photo) strengths.push('📷 Photo evidence submitted');
if (report.photoAiScore && report.photoAiScore > 0.7) strengths.push(`🤖 AI confidence: ${Math.round(report.photoAiScore * 100)}%`);
if (report.infraType) strengths.push(`🏗️ Infrastructure identified: ${report.infraType}`);
if (report.undpTier) strengths.push(`📊 Damage level: ${report.undpTier}`);
if (nearby && nearby.length > 0) strengths.push(`👥 Corroborated by ${nearby.length} other report(s)`);
if (!report.photo) weaknesses.push('📷 No photo submitted - confidence reduced');
if (report.photoAiConf && report.photoAiConf < 0.6) weaknesses.push('🤖 AI low confidence in photo analysis');
if (!report.coords) weaknesses.push('📍 No GPS coordinates');
if (result.dci_uncertainty_mass && result.dci_uncertainty_mass > 0.6) weaknesses.push('⚠️ High uncertainty - field verification recommended');
return {
dci: result.dci || 0.5,
tier: result.tier || 'review',
dci_pes: result.dci_pes || 0.5,
dci_cor: result.dci_cor || 0.5,
dci_tfr: result.dci_tfr || 0.8,
dci_cci: result.dci_cci || 0.7,
dci_uncertainty_mass: result.dci_uncertainty_mass || 0.5,
dci_validity_status: result.dci_validity_status || 'DEGRADED',
dci_strengths: (result.dci_strengths && result.dci_strengths.length) ? result.dci_strengths : strengths,
dci_weaknesses: (result.dci_weaknesses && result.dci_weaknesses.length) ? result.dci_weaknesses : weaknesses,
dci_assumptions: result.dci_assumptions || [],
dci_flags: result.dci_flags || {}
};
} catch (err) {
console.error('[VERITAS] CERTUS.score error:', err);
}
}
// FALLBACK - with defensive checks
let baseScore = 0.5;
if (report.photoAiScore !== null && report.photoAiScore !== undefined) {
baseScore = report.photoAiScore * 0.7 + 0.3;
}
const rawScore = Math.min(0.95, Math.max(0.3, baseScore + (Math.random() * 0.2 - 0.1)));
const tier = rawScore >= 0.70 ? 'high' : rawScore >= 0.40 ? 'watch' : 'review';
const strengths = [];
const weaknesses = [];
if (report.photo) strengths.push('📷 Photo submitted');
if (report.infraType) strengths.push(`🏗️ ${report.infraType} identified`);
if (report.undpTier) strengths.push(`📊 Damage: ${report.undpTier}`);
if (report.textLocation && report.textLocation.trim()) strengths.push('📍 Location described');
if (!report.photo) weaknesses.push('📷 No photo');
if (!report.coords) weaknesses.push('📍 No GPS');
console.log('[VERITAS] Using fallback scoring:', { rawScore, tier, strengths, weaknesses });
return {
dci: rawScore,
tier,
dci_pes: (report.photoAiScore !== null && report.photoAiScore !== undefined) ? report.photoAiScore : 0.5,
dci_cor: 0.5,
dci_tfr: 0.8,
dci_cci: 0.7,
dci_uncertainty_mass: 0.4,
dci_validity_status: tier === 'high' ? 'VALID' : tier === 'watch' ? 'DEGRADED' : 'SUSPENDED',
dci_strengths: strengths.length ? strengths : ['Report received'],
dci_weaknesses: weaknesses.length ? weaknesses : ['No AI analysis available'],
dci_assumptions: ['Using integrated scoring'],
dci_flags: { fallback_mode: true }
};
}
// ==================== TRANSLATIONS ====================
const translations = {
en: { offline: "Offline — reports saved locally and will sync when connected", syncing: "Syncing queued reports...", report_tab: "📍 Report", respond_tab: "🗺 Respond", report_received: "REPORT RECEIVED", certus_scored: "CERTUS Engine has scored your submission", dci_label: "Damage Confidence Index — CERTUS Engine v2.5", dci_explain: "DCI measures how much to trust this report.\nScored on photo evidence · corroboration · freshness · consistency.", submit_another: "Submit Another Report", view_map: "View Responder Map", step_photo: "Photo", step_damage: "Damage", step_details: "Details", step_location: "Location", step_review: "Review", photo_title: "PHOTOGRAPH", photo_sub: "Capture visible damage clearly", photo_hint: "TAP TO PHOTOGRAPH DAMAGE", retake: "RETAKE", analyzing: "CERTUS analyzing image...", next: "NEXT", damage_title: "DAMAGE LEVEL", damage_sub: "Select the damage level (UNDP required)", damage_minimal: "Minimal / No damage", damage_minimal_desc: "Little or no visible structural impact", damage_partial: "Partially damaged", damage_partial_desc: "Significant damage but still standing", damage_complete: "Completely damaged", damage_complete_desc: "Structure destroyed / total collapse", infra_title: "INFRASTRUCTURE TYPE", details_title: "DETAILS", details_sub: "Help responders understand the situation", infra_name_label: "Infrastructure name (optional)", crisis_type_label: "Nature of crisis", crisis_natural: "Natural", crisis_tech: "Technological", crisis_human: "Human‑made", debris_label: "Is there debris requiring clearing?", yes: "Yes", no: "No", electricity_label: "Electricity infrastructure condition", health_label: "Overall health services functioning", needs_label: "Most pressing needs (select all that apply)", location_title: "LOCATION", location_sub: "Pin the damage location", precise: "📍 Precise", precise_desc: "Exact GPS pin", area: "🔵 Area", area_desc: "±100m radius", fuzzy_notice: "Area mode selected — your precise location is protected. Report is accurate to ±100 meters. Suitable for conflict-affected areas.", acquiring: "Acquiring GPS coordinates...", text_location_label: "Describe location (if GPS unavailable, e.g., \"near the central market\")", review_title: "REVIEW", review_sub: "Confirm and submit your report", anon_notice: "Your report is anonymous. No account required. EXIF metadata stripped. No IP stored. Keyed by random UUID only.", back: "← BACK", submit: "SUBMIT REPORT", restricted: "RESTRICTED", access_sub: "Responder Access Required", enter: "ENTER", access_note: "Access code distributed to authorized UNDP response partners only.", live_dash: "Live Confidence Dashboard", high_conf: "High<br>Confidence", watch: "Watch<br>Monitor", review_req: "Review<br>Required", conf_map: "Confidence Map", timeline: "48-Hour Timeline Playback", live_all: "Live — all reports", conflict_flags: "Conflict Flags", no_conflicts: "No conflicts detected", dci_report: "DCI REPORT CARD", conf_dist: "Confidence Distribution", high: "High", review: "Review", powered: "Powered by CERTUS Engine v2.5 — DCI scored on photo evidence, corroboration, freshness, and consistency", export: "Export Dataset", cached_snapshot: "📥 Download Cached Snapshot", offline_note: "Available offline — shows last synced state", decision_support: "⚠ DECISION-SUPPORT INSTRUMENT ONLY", law6_line1: "VERITAS DCI scores assist human judgment — they do not replace it.", review_required_human: "Review Required", rescue_title: "I NEED RESCUE", rescue_description: "Tap the button below if you are trapped or need emergency assistance. Your location and photo will be sent to rescue teams.", rescue_button: "🚨 SEND RESCUE SIGNAL 🚨", location_status_title: "📍 Your Location Status", location_status_placeholder: "Acquiring GPS...", gps_label: "📡 GPS: ", gps_waiting: "Waiting for signal", waiting_advice_title: "📋 What to Do While Waiting", waiting_advice_1: "✅ Stay where you are if it's safe", waiting_advice_2: "✅ Conserve phone battery (reduce brightness)", waiting_advice_3: "✅ Take a photo of your surroundings", waiting_advice_4: "✅ If you move, your last location is still saved", waiting_advice_5: "✅ Signal works offline — will send when connected" },
ar: { offline: "غير متصل — يتم حفظ التقارير محلياً وسيتم المزامنة عند الاتصال", syncing: "مزامنة التقارير المعلقة...", report_tab: "📍 تقرير", respond_tab: "🗺 استجابة", report_received: "تم استلام التقرير", certus_scored: "قام محرك CERTUS بتقييم إرسالك", dci_label: "مؤشر الثقة في الضرر — محرك CERTUS الإصدار 2.5", dci_explain: "يقيس DCI مدى الثقة في هذا التقرير.", submit_another: "إرسال تقرير آخر", view_map: "عرض خريطة المستجيبين", step_photo: "صورة", step_damage: "الضرر", step_details: "تفاصيل", step_location: "الموقع", step_review: "مراجعة", photo_title: "تصوير", photo_sub: "التقط صورة واضحة للضرر", photo_hint: "انقر لتصوير الضرر", retake: "إعادة التصوير", analyzing: "CERTUS يقوم بتحليل الصورة...", next: "التالي", damage_title: "مستوى الضرر", damage_sub: "اختر مستوى الضرر", damage_minimal: "أقل / بدون ضرر", damage_minimal_desc: "تأثير هيكلي ضئيل", damage_partial: "ضرر جزئي", damage_partial_desc: "ضرر كبير لكن الهيكل لا يزال قائماً", damage_complete: "ضرر كامل", damage_complete_desc: "هيكل مدمر", infra_title: "نوع البنية التحتية", details_title: "تفاصيل", details_sub: "ساعد المستجيبين", infra_name_label: "اسم البنية التحتية", crisis_type_label: "طبيعة الأزمة", crisis_natural: "طبيعية", crisis_tech: "تكنولوجية", crisis_human: "بشرية المنشأ", debris_label: "هل هناك حطام؟", yes: "نعم", no: "لا", electricity_label: "حالة البنية التحتية للكهرباء", health_label: "حالة الخدمات الصحية", needs_label: "أكثر الاحتياجات إلحاحاً", location_title: "الموقع", location_sub: "حدد موقع الضرر", precise: "📍 دقيق", precise_desc: "نظام تحديد المواقع الدقيق", area: "🔵 منطقة", area_desc: "نصف قطر ±100 متر", fuzzy_notice: "تم اختيار وضع المنطقة", acquiring: "جاري الحصول على إحداثيات GPS...", text_location_label: "صف الموقع", review_title: "مراجعة", review_sub: "تأكيد وإرسال تقريرك", anon_notice: "تقريرك مجهول.", back: "← رجوع", submit: "إرسال التقرير", restricted: "مقيد", access_sub: "وصول المستجيبين مطلوب", enter: "دخول", access_note: "رمز الوصول موزع على شركاء الاستجابة المعتمدين.", live_dash: "لوحة الثقة الحية", high_conf: "ثقة<br>عالية", watch: "مراقبة<br>رصد", review_req: "مراجعة<br>مطلوبة", conf_map: "خريطة الثقة", timeline: "تشغيل 48 ساعة", live_all: "مباشر", conflict_flags: "علامات التضارب", no_conflicts: "لم يتم اكتشاف تضاربات", dci_report: "بطاقة تقرير DCI", conf_dist: "توزيع الثقة", high: "عالية", review: "مراجعة", powered: "CERTUS Engine v2.5", export: "تصدير", cached_snapshot: "📥 تنزيل لقطة", offline_note: "متاح دون اتصال", decision_support: "⚠ أداة دعم القرار فقط", law6_line1: "نتائج DCI لـ VERITAS تساعد في الحكم البشري.", review_required_human: "مراجعة مطلوبة", rescue_title: "أحتاج إلى إنقاذ", rescue_description: "اضغط على الزر أدناه إذا كنت محاصرًا أو بحاجة إلى مساعدة طارئة. سيتم إرسال موقعك وصورتك إلى فرق الإنقاذ.", rescue_button: "🚨 أرسل إشارة إنقاذ 🚨", location_status_title: "📍 حالة موقعك", location_status_placeholder: "جاري الحصول على GPS...", gps_label: "📡 GPS: ", gps_waiting: "في انتظار الإشارة", waiting_advice_title: "📋 ما يجب فعله أثناء الانتظار", waiting_advice_1: "✅ ابق في مكانك إذا كان آمنًا", waiting_advice_2: "✅ حافظ على بطارية الهاتف (قلل السطوع)", waiting_advice_3: "✅ التقط صورة لمحيطك", waiting_advice_4: "✅ إذا تحركت، لا يزال موقعك الأخير محفوظًا", waiting_advice_5: "✅ تعمل الإشارة بدون اتصال بالإنترنت — سيتم الإرسال عند الاتصال" },
zh: { offline: "离线 — 报告保存在本地,联网后将同步", syncing: "正在同步...", report_tab: "📍 报告", respond_tab: "🗺 响应", report_received: "已收到报告", certus_scored: "CERTUS引擎已评分", dci_label: "损害可信度指数 — CERTUS v2.5", dci_explain: "DCI衡量报告的可信度。", submit_another: "提交另一份报告", view_map: "查看地图", step_photo: "照片", step_damage: "损害", step_details: "详情", step_location: "位置", step_review: "复核", photo_title: "拍照", photo_sub: "清晰拍摄损害", photo_hint: "点击拍摄", retake: "重拍", analyzing: "分析中...", next: "下一步", damage_title: "损害等级", damage_sub: "选择损害等级", damage_minimal: "极小/无损害", damage_minimal_desc: "几乎没有影响", damage_partial: "部分受损", damage_partial_desc: "严重但结构在", damage_complete: "完全损毁", damage_complete_desc: "结构毁坏", infra_title: "基础设施类型", details_title: "详情", details_sub: "帮助响应者", infra_name_label: "名称", crisis_type_label: "危机性质", crisis_natural: "自然", crisis_tech: "技术", crisis_human: "人为", debris_label: "是否有残骸?", yes: "是", no: "否", electricity_label: "电力状况", health_label: "卫生服务", needs_label: "最迫切需求", location_title: "位置", location_sub: "标记损害位置", precise: "📍 精确", precise_desc: "精确GPS", area: "🔵 区域", area_desc: "±100米", fuzzy_notice: "区域模式", acquiring: "获取GPS...", text_location_label: "描述位置", review_title: "复核", review_sub: "确认并提交", anon_notice: "匿名报告。", back: "← 返回", submit: "提交报告", restricted: "受限", access_sub: "需要权限", enter: "进入", access_note: "仅限授权合作伙伴。", live_dash: "实时仪表板", high_conf: "高<br>可信度", watch: "观察<br>监视", review_req: "需<br>复核", conf_map: "可信度地图", timeline: "48小时回放", live_all: "实时", conflict_flags: "冲突标记", no_conflicts: "无冲突", dci_report: "DCI报告卡", conf_dist: "可信度分布", high: "高", review: "复核", powered: "CERTUS v2.5", export: "导出", cached_snapshot: "📥 下载快照", offline_note: "离线可用", decision_support: "⚠ 仅限决策支持", law6_line1: "DCI辅助人工判断。", review_required_human: "需要复核", rescue_title: "我需要救援", rescue_description: "如果您被困或需要紧急援助,请点击下方按钮。您的位置和照片将发送给救援队。", rescue_button: "🚨 发送救援信号 🚨", location_status_title: "📍 您的位置状态", location_status_placeholder: "正在获取GPS...", gps_label: "📡 GPS: ", gps_waiting: "等待信号", waiting_advice_title: "📋 等待时该做什么", waiting_advice_1: "✅ 如果安全,请待在原地", waiting_advice_2: "✅ 节省手机电量(降低亮度)", waiting_advice_3: "✅ 拍摄周围环境的照片", waiting_advice_4: "✅ 如果您移动,最后的位置仍会保存", waiting_advice_5: "✅ 信号支持离线 — 连接后将发送" },
fr: { offline: "Hors ligne — rapports enregistrés localement", syncing: "Synchronisation...", report_tab: "📍 Rapport", respond_tab: "🗺 Répondre", report_received: "RAPPORT REÇU", certus_scored: "Moteur CERTUS a évalué votre soumission", dci_label: "Indice de confiance — CERTUS v2.5", dci_explain: "DCI mesure le degré de confiance.", submit_another: "Soumettre un autre rapport", view_map: "Voir la carte", step_photo: "Photo", step_damage: "Dommage", step_details: "Détails", step_location: "Lieu", step_review: "Révision", photo_title: "PHOTOGRAPHIER", photo_sub: "Capturez les dommages", photo_hint: "APPUYEZ POUR PHOTOGRAPHIER", retake: "REPRENDRE", analyzing: "CERTUS analyse...", next: "SUIVANT", damage_title: "NIVEAU DE DOMMAGE", damage_sub: "Sélectionnez le niveau", damage_minimal: "Minime / Aucun", damage_minimal_desc: "Peu d'impact visible", damage_partial: "Partiellement endommagé", damage_partial_desc: "Dommages importants", damage_complete: "Complètement détruit", damage_complete_desc: "Structure effondrée", infra_title: "TYPE D'INFRASTRUCTURE", details_title: "DÉTAILS", details_sub: "Aidez les intervenants", infra_name_label: "Nom (facultatif)", crisis_type_label: "Nature de la crise", crisis_natural: "Naturelle", crisis_tech: "Technologique", crisis_human: "Humaine", debris_label: "Des débris à dégager?", yes: "Oui", no: "Non", electricity_label: "État électrique", health_label: "Services de santé", needs_label: "Besoins urgents", location_title: "LIEU", location_sub: "Épinglez l'emplacement", precise: "📍 Précis", precise_desc: "GPS exact", area: "🔵 Zone", area_desc: "Rayon ±100m", fuzzy_notice: "Mode zone sélectionné", acquiring: "Acquisition GPS...", text_location_label: "Décrivez le lieu", review_title: "RÉVISION", review_sub: "Confirmez et soumettez", anon_notice: "Rapport anonyme.", back: "← RETOUR", submit: "SOUMETTRE", restricted: "RESTREINT", access_sub: "Accès intervenant requis", enter: "ENTRER", access_note: "Code distribué aux partenaires PNUD.", live_dash: "Tableau en direct", high_conf: "Haute<br>confiance", watch: "À<br>surveiller", review_req: "Révision<br>requise", conf_map: "Carte de confiance", timeline: "Chronologie 48h", live_all: "En direct", conflict_flags: "Conflits", no_conflicts: "Aucun conflit", dci_report: "FICHE DCI", conf_dist: "Distribution", high: "Haute", review: "Révision", powered: "CERTUS v2.5", export: "Exporter", cached_snapshot: "📥 Instantané", offline_note: "Disponible hors ligne", decision_support: "⚠ AIDE À LA DÉCISION", law6_line1: "DCI aide — ne remplace pas.", review_required_human: "Révision requise", rescue_title: "J'AI BESOIN DE SECOURS", rescue_description: "Appuyez sur le bouton ci-dessous si vous êtes piégé ou avez besoin d'une assistance d'urgence. Votre position et votre photo seront envoyées aux équipes de secours.", rescue_button: "🚨 ENVOYER UN SIGNAL DE SECOURS 🚨", location_status_title: "📍 Votre position", location_status_placeholder: "Acquisition GPS...", gps_label: "📡 GPS: ", gps_waiting: "En attente du signal", waiting_advice_title: "📋 Que faire en attendant", waiting_advice_1: "✅ Restez où vous êtes si c'est sûr", waiting_advice_2: "✅ Économisez la batterie (réduisez la luminosité)", waiting_advice_3: "✅ Prenez une photo de votre environnement", waiting_advice_4: "✅ Si vous bougez, votre dernière position est sauvegardée", waiting_advice_5: "✅ Fonctionne hors ligne — sera envoyé à la connexion" },
ru: { offline: "Офлайн — отчеты сохраняются локально", syncing: "Синхронизация...", report_tab: "📍 Отчет", respond_tab: "🗺 Реагирование", report_received: "ОТЧЕТ ПОЛУЧЕН", certus_scored: "Движок CERTUS оценил отправку", dci_label: "Индекс доверия — CERTUS v2.5", dci_explain: "DCI показывает доверие к отчету.", submit_another: "Отправить ещё", view_map: "Посмотреть карту", step_photo: "Фото", step_damage: "Ущерб", step_details: "Детали", step_location: "Местоположение", step_review: "Проверка", photo_title: "ФОТОГРАФИЯ", photo_sub: "Чётко запечатлейте повреждения", photo_hint: "НАЖМИТЕ ДЛЯ ФОТО", retake: "ПЕРЕСНЯТЬ", analyzing: "CERTUS анализирует...", next: "ДАЛЕЕ", damage_title: "УРОВЕНЬ ПОВРЕЖДЕНИЙ", damage_sub: "Выберите уровень", damage_minimal: "Минимальные", damage_minimal_desc: "Незначительное воздействие", damage_partial: "Частичные", damage_partial_desc: "Значительные, конструкция стоит", damage_complete: "Полное разрушение", damage_complete_desc: "Конструкция уничтожена", infra_title: "ТИП ИНФРАСТРУКТУРЫ", details_title: "ДЕТАЛИ", details_sub: "Помогите специалистам", infra_name_label: "Название объекта", crisis_type_label: "Характер кризиса", crisis_natural: "Природный", crisis_tech: "Техногенный", crisis_human: "Социальный", debris_label: "Есть завалы?", yes: "Да", no: "Нет", electricity_label: "Состояние электросетей", health_label: "Медицинские услуги", needs_label: "Насущные потребности", location_title: "МЕСТОПОЛОЖЕНИЕ", location_sub: "Отметьте место", precise: "📍 Точное", precise_desc: "Точные GPS", area: "🔵 Область", area_desc: "Радиус ±100м", fuzzy_notice: "Выбран режим области", acquiring: "Получение GPS...", text_location_label: "Опишите местоположение", review_title: "ПРОВЕРКА", review_sub: "Подтвердите и отправьте", anon_notice: "Анонимный отчет.", back: "← НАЗАД", submit: "ОТПРАВИТЬ", restricted: "ОГРАНИЧЕННЫЙ ДОСТУП", access_sub: "Требуется доступ", enter: "ВОЙТИ", access_note: "Только для уполномоченных партнёров.", live_dash: "Панель доверия", high_conf: "Высокое<br>доверие", watch: "Наблюдение<br>Мониторинг", review_req: "Требуется<br>проверка", conf_map: "Карта доверия", timeline: "48-часовая шкала", live_all: "В реальном времени", conflict_flags: "Конфликтные метки", no_conflicts: "Конфликтов нет", dci_report: "КАРТА DCI", conf_dist: "Распределение", high: "Высокое", review: "Проверка", powered: "CERTUS v2.5", export: "Экспорт", cached_snapshot: "📥 Снимок", offline_note: "Доступно офлайн", decision_support: "⚠ ПОДДЕРЖКА РЕШЕНИЙ", law6_line1: "DCI помогает суждению.", review_required_human: "Требуется проверка", rescue_title: "МНУЖНА ПОМОЩЬ", rescue_description: "Нажмите кнопку ниже, если вы оказались в ловушке или нуждаетесь в экстренной помощи. Ваше местоположение и фото будут отправлены спасательным командам.", rescue_button: "🚨 ОТПРАВИТЬ СИГНАЛ О ПОМОЩИ 🚨", location_status_title: "📍 Ваше местоположение", location_status_placeholder: "Получение GPS...", gps_label: "📡 GPS: ", gps_waiting: "Ожидание сигнала", waiting_advice_title: "📋 Что делать в ожидании", waiting_advice_1: "✅ Оставайтесь на месте, если это безопасно", waiting_advice_2: "✅ Экономьте заряд батареи (уменьшите яркость)", waiting_advice_3: "✅ Сфотографируйте окрестности", waiting_advice_4: "✅ Если вы двигаетесь, последнее местоположение сохраняется", waiting_advice_5: "✅ Работает офлайн — отправится при подключении" },
es: { offline: "Sin conexión — informes guardados localmente", syncing: "Sincronizando...", report_tab: "📍 Informe", respond_tab: "🗺 Responder", report_received: "INFORME RECIBIDO", certus_scored: "Motor CERTUS ha evaluado el envío", dci_label: "Índice de confianza — CERTUS v2.5", dci_explain: "DCI mide cuánto confiar en este informe.", submit_another: "Enviar otro informe", view_map: "Ver mapa", step_photo: "Foto", step_damage: "Daño", step_details: "Detalles", step_location: "Ubicación", step_review: "Revisión", photo_title: "FOTOGRAFÍA", photo_sub: "Capture los daños", photo_hint: "TOQUE PARA FOTOGRAFIAR", retake: "REPETIR", analyzing: "CERTUS analizando...", next: "SIGUIENTE", damage_title: "NIVEL DE DAÑO", damage_sub: "Seleccione el nivel", damage_minimal: "Mínimo / Sin daños", damage_minimal_desc: "Poco impacto visible", damage_partial: "Dañado parcialmente", damage_partial_desc: "Daños significativos", damage_complete: "Completamente destruido", damage_complete_desc: "Estructura destruida", infra_title: "TIPO DE INFRAESTRUCTURA", details_title: "DETALLES", details_sub: "Ayude a los respondedores", infra_name_label: "Nombre (opcional)", crisis_type_label: "Naturaleza de la crisis", crisis_natural: "Natural", crisis_tech: "Tecnológica", crisis_human: "Antrópica", debris_label: "¿Hay escombros?", yes: "Sí", no: "No", electricity_label: "Estado eléctrico", health_label: "Servicios de salud", needs_label: "Necesidades urgentes", location_title: "UBICACIÓN", location_sub: "Señale la ubicación", precise: "📍 Precisa", precise_desc: "GPS exacto", area: "🔵 Área", area_desc: "Radio ±100m", fuzzy_notice: "Modo área seleccionado", acquiring: "Obteniendo GPS...", text_location_label: "Describa la ubicación", review_title: "REVISIÓN", review_sub: "Confirme y envíe", anon_notice: "Informe anónimo.", back: "← ATRÁS", submit: "ENVIAR INFORME", restricted: "RESTRINGIDO", access_sub: "Acceso requerido", enter: "ENTRAR", access_note: "Solo socios autorizados.", live_dash: "Panel en vivo", high_conf: "Alta<br>confianza", watch: "Vigilancia<br>Monitorear", review_req: "Revisión<br>requerida", conf_map: "Mapa de confianza", timeline: "Cronología 48h", live_all: "En vivo", conflict_flags: "Alertas", no_conflicts: "Sin conflictos", dci_report: "TARJETA DCI", conf_dist: "Distribución", high: "Alta", review: "Revisión", powered: "CERTUS v2.5", export: "Exportar", cached_snapshot: "📥 Instantánea", offline_note: "Disponible sin conexión", decision_support: "⚠ SOLO APOYO", law6_line1: "DCI apoya el juicio humano.", review_required_human: "Revisión requerida", rescue_title: "NECESITO RESCATE", rescue_description: "Presiona el botón a continuación si estás atrapado o necesitas asistencia de emergencia. Tu ubicación y foto serán enviadas a los equipos de rescate.", rescue_button: "🚨 ENVIAR SEÑAL DE RESCATE 🚨", location_status_title: "📍 Tu ubicación", location_status_placeholder: "Obteniendo GPS...", gps_label: "📡 GPS: ", gps_waiting: "Esperando señal", waiting_advice_title: "📋 Qué hacer mientras esperas", waiting_advice_1: "✅ Quédate donde estás si es seguro", waiting_advice_2: "✅ Ahorra batería (reduce el brillo)", waiting_advice_3: "✅ Toma una foto de tu entorno", waiting_advice_4: "✅ Si te mueves, tu última ubicación se guarda", waiting_advice_5: "✅ Funciona sin conexión — se enviará cuando te conectes" }
};
let currentLang = 'en';
function setLanguage(lang) {
currentLang = lang;
// Update all elements with data-i18n attribute
document.querySelectorAll('[data-i18n]').forEach(el => {
const key = el.getAttribute('data-i18n');
if (translations[lang] && translations[lang][key] !== undefined) {
if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') {
if (el.getAttribute('placeholder')) {
el.placeholder = translations[lang][key];
} else {
el.value = translations[lang][key];
}
} else {
el.innerHTML = translations[lang][key];
}
}
});
// Update language buttons active state
document.querySelectorAll('.lang-btn').forEach(btn => {
btn.classList.toggle('active', btn.getAttribute('data-lang') === lang);
});
// Update mobile language row as well
document.querySelectorAll('#mobileLangRow .lang-btn').forEach(btn => {
btn.classList.toggle('active', btn.getAttribute('data-lang') === lang);
});
console.log('[VERITAS] Language set to:', lang);
}
// FIX #7 — build lang buttons in both desktop and mobile containers
function buildLangSelector() {
const langs = ['en', 'ar', 'zh', 'fr', 'ru', 'es'];
const containers = [
document.getElementById('langSelector'),
document.getElementById('mobileLangRow')
];
containers.forEach(container => {
if (!container) return;
container.innerHTML = '';
langs.forEach(l => {
const btn = document.createElement('button');
btn.className = 'lang-btn';
btn.setAttribute('data-lang', l);
btn.textContent = l.toUpperCase();
btn.addEventListener('click', () => setLanguage(l));
container.appendChild(btn);
});
});
setLanguage('en');
}
// ==================== INDEXEDDB ====================
const DB_NAME = 'veritas-db', DB_VER = 1;
let db = null;
function initDB() {
return new Promise((resolve, reject) => {
const req = indexedDB.open(DB_NAME, DB_VER);
req.onupgradeneeded = e => {
const d = e.target.result;
if (!d.objectStoreNames.contains('reports')) {
const store = d.createObjectStore('reports', { keyPath:'uuid' });
store.createIndex('timestamp','timestamp',{unique:false});
store.createIndex('synced','synced',{unique:false});
}
};
req.onsuccess = e => { db = e.target.result; resolve(db); };
req.onerror = e => { console.error('[VERITAS] IndexedDB init failed:', e); reject(e); };
});
}
function dbPut(report){ return new Promise((res,rej)=>{ const tx=db.transaction('reports','readwrite'); tx.objectStore('reports').put(report).onsuccess=()=>res(); tx.onerror=rej; }); }
function dbGetAll(){ return new Promise((res,rej)=>{ const tx=db.transaction('reports','readonly'); tx.objectStore('reports').getAll().onsuccess=e=>res(e.target.result); tx.onerror=rej; }); }
function dbGetUnsynced(){ return new Promise((res,rej)=>{ const tx=db.transaction('reports','readonly'); const idx=tx.objectStore('reports').index('synced'); idx.getAll(IDBKeyRange.only(false)).onsuccess=e=>res(e.target.result); tx.onerror=rej; }); }
function dbMarkSynced(uuid){ return new Promise((res,rej)=>{ const tx=db.transaction('reports','readwrite'); const store=tx.objectStore('reports'); const req=store.get(uuid); req.onsuccess=e=>{ const r=e.target.result; if(r){r.synced=true;store.put(r).onsuccess=res;}else res(); }; tx.onerror=rej; }); }
function generateUUID(){ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,c=>{ const r=Math.random()*16|0; return(c==='x'?r:(r&0x3|0x8)).toString(16); }); }
// ==================== PHOTO HANDLING ====================
function handlePhoto(input) {
const file = input.files[0]; if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
const img = new Image();
img.onload = function() {
const MAX_W=1920, MAX_H=1440;
let w=img.width, h=img.height;
const ratio=Math.min(MAX_W/w, MAX_H/h, 1);
w=Math.round(w*ratio); h=Math.round(h*ratio);
const canvas=document.createElement('canvas');
canvas.width=w; canvas.height=h;
const ctx=canvas.getContext('2d');
ctx.fillStyle='#ffffff'; ctx.fillRect(0,0,w,h);
ctx.drawImage(img,0,0,w,h);
STATE.photo=canvas.toDataURL('image/jpeg',0.82);
const preview=document.getElementById('photoPreview');
preview.src=STATE.photo; preview.classList.add('show');
document.getElementById('photoRetake').classList.add('show');
document.getElementById('photoZone').classList.add('has-photo');
runAiAnalysis();
};
img.onerror = () => { toast('Failed to load image — try another photo'); };
img.src=e.target.result;
};
reader.onerror = () => { toast('Failed to read file'); };
reader.readAsDataURL(file);
}
// TRIGGER PHOTO CAPTURE - FIXED FOR MOBILE
function triggerPhotoCapture() {
console.log('[VERITAS] Photo capture triggered');
const input = document.getElementById('photoInput');
if (!input) {
console.error('[VERITAS] Photo input not found');
toast('Photo input not found');
return;
}
// Clear previous value to ensure change event fires on same file
input.value = '';
// For mobile, ensure capture attribute is set
if (/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent)) {
input.setAttribute('capture', 'environment');
} else {
input.removeAttribute('capture');
}
// Trigger the file picker
input.click();
console.log('[VERITAS] Input clicked');
}
// SIMPLIFIED AI ANALYSIS - Calls your Vercel backend
async function runAiAnalysis() {
const statusEl=document.getElementById('photoAiStatus');
statusEl.classList.add('show');
const statusText=document.getElementById('aiStatusText');
statusText.innerHTML='<span class="spinner"></span> AI analyzing image...';
try {
// Check if AI_ANALYSIS is available
if (typeof AI_ANALYSIS !== 'undefined' && AI_ANALYSIS !== null) {
// Call your Vercel backend
const assessment = await AI_ANALYSIS.analyzePhoto(STATE.photo, STATE.infraType);
if (assessment.is_mock) {
statusText.innerHTML=`⚠️ AI offline — using fallback scoring. Confidence: ${Math.round(assessment.confidence*100)}%`;
} else {
statusText.innerHTML=`✅ AI: ${assessment.damage_level} (${Math.round(assessment.score*100)}% severity) · Confidence: ${Math.round(assessment.confidence*100)}%`;
// Auto-select damage if confidence is high
if (assessment.confidence > 0.7 && assessment.internal_tier && !STATE.undpTier) {
selectDamage(assessment.internal_tier);
toast(`AI detected: ${assessment.damage_level}`, 2000);
}
}
STATE.photoAiScore = assessment.score;
STATE.photoAiConf = assessment.confidence;
STATE.photoAiModel = assessment.model_used;
} else {
// Fallback if AI_ANALYSIS not loaded
statusText.innerHTML='⚠️ AI module not loaded — using fallback scoring';
STATE.photoAiScore = parseFloat((0.65+Math.random()*0.30).toFixed(3));
STATE.photoAiConf = parseFloat((0.55+Math.random()*0.40).toFixed(3));
STATE.photoAiModel = 'mock';
}
document.getElementById('step1Next').disabled = false;
} catch(err) {
console.error('[VERITAS] AI analysis error:', err);
statusText.innerHTML=`⚠️ AI error — using fallback`;
STATE.photoAiScore = parseFloat((0.65+Math.random()*0.30).toFixed(3));
STATE.photoAiConf = parseFloat((0.55+Math.random()*0.40).toFixed(3));
STATE.photoAiModel = 'error_fallback';
document.getElementById('step1Next').disabled = false;
}
}
// ==================== STEP NAVIGATION ====================
function goStep(step) {
if (step===2 && !STATE.photo){ toast('Add a photo first'); return; }
if (step===3 && (!STATE.undpTier||!STATE.infraType)){ toast('Select damage level and structure type'); return; }
for(let i=1;i<=5;i++){
document.getElementById(`step${i}`).classList.remove('active');
document.getElementById(`sc${i}`).classList.remove('active','done');
document.getElementById(`sl${i}`).classList.remove('active');
}
for(let i=1;i<=4;i++) document.getElementById(`sline${i}`).classList.remove('done');
for(let i=1;i<step;i++){
document.getElementById(`sc${i}`).classList.add('done');
document.getElementById(`sc${i}`).textContent='✓';
if(i<=4) document.getElementById(`sline${i}`).classList.add('done');
}
document.getElementById(`sc${step}`).classList.add('active');
document.getElementById(`sl${step}`).classList.add('active');
document.getElementById(`step${step}`).classList.add('active');
STATE.currentStep=step;
if(step===4) initLocationStep();
if(step===5) populateSummary();
window.scrollTo(0,0);
}
function selectDamage(undpTier) {
STATE.undpTier=undpTier;
STATE.internalTier=tierMap[undpTier];
document.querySelectorAll('.damage-btn').forEach(b=>b.classList.remove('selected'));
document.getElementById(`damage-${undpTier}`).classList.add('selected');
checkStep2();
}
function selectInfra(type) {
STATE.infraType=type;
document.getElementById('otherInfraContainer').style.display=type==='Other'?'block':'none';
document.querySelectorAll('.infra-btn').forEach(b=>b.classList.remove('selected'));
const btn=document.querySelector(`.infra-btn[data-infra="${type}"]`);
if(btn) btn.classList.add('selected');
checkStep2();
}
function checkStep2(){ document.getElementById('step2Next').disabled=!(STATE.undpTier&&STATE.infraType); }
function selectLocMode(mode) {
STATE.locMode=mode;
document.getElementById('locPrecise').classList.toggle('selected',mode==='precise');
document.getElementById('locFuzzy').classList.toggle('selected',mode==='fuzzy');
document.getElementById('fuzzyNotice').style.display=mode==='fuzzy'?'block':'none';
if(STATE.coords&&STATE.reportMap) updateLocationPin();
}
// FIX #9 — text location as GPS fallback for step4Next
function onTextLocationInput(val) {
if (!STATE.coords && val.trim().length > 3) {
document.getElementById('step4Next').disabled = false;
document.getElementById('gpsCoords').innerHTML = '<span style="color:var(--amber)">✓ Text location provided</span>';
} else if (!STATE.coords) {
document.getElementById('step4Next').disabled = true;
}
}
function initLocationStep() {
if (!STATE.reportMap) {
STATE.reportMap=L.map('locationMap',{zoomControl:true,attributionControl:false});
const street=L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution:'© OpenStreetMap'});
const satellite=L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',{attribution:'© Esri',maxZoom:18});
const buildings=L.tileLayer('https://tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',{attribution:'© OpenStreetMap contributors',maxZoom:19});
street.addTo(STATE.reportMap);
buildings.addTo(STATE.reportMap);
L.control.layers({'Street':street,'Satellite':satellite,'Buildings':buildings}).addTo(STATE.reportMap);
STATE.reportMap.setView(CONFIG.MAP_CENTER,4);
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
pos => {
STATE.coords={lat:pos.coords.latitude,lng:pos.coords.longitude};
updateLocationPin();
document.getElementById('step4Next').disabled=false;
document.getElementById('gpsCoords').innerHTML=`<span style="color:var(--amber)">✓</span> ${STATE.coords.lat.toFixed(6)}, ${STATE.coords.lng.toFixed(6)}`;
},
err => {
console.warn('[VERITAS] GPS failed:', err.message);
document.getElementById('gpsCoords').innerHTML='<span style="color:#ffc947">GPS unavailable — tap map to pin location or describe below</span>';
STATE.reportMap.on('click', e => {
STATE.coords={lat:e.latlng.lat,lng:e.latlng.lng};
updateLocationPin();
document.getElementById('step4Next').disabled=false;
document.getElementById('gpsCoords').innerHTML=`<span style="color:var(--amber)">✓ Manual pin:</span> ${e.latlng.lat.toFixed(6)}, ${e.latlng.lng.toFixed(6)}`;
});
}
);
}
}
function updateLocationPin() {
if(!STATE.coords||!STATE.reportMap) return;
const {lat,lng}=STATE.coords;
if(STATE.reportMarker) STATE.reportMap.removeLayer(STATE.reportMarker);
const icon=L.divIcon({className:'',html:`<div style="width:16px;height:16px;background:var(--amber);border-radius:50%;border:2px solid #000;box-shadow:0 0 12px rgba(240,165,0,0.6)"></div>`,iconSize:[16,16],iconAnchor:[8,8]});
STATE.reportMarker=L.marker([lat,lng],{icon}).addTo(STATE.reportMap);
STATE.reportMap.setView([lat,lng],16);
if(STATE.locMode==='fuzzy') L.circle([lat,lng],{radius:CONFIG.FUZZY_RADIUS,color:'#f0a500',fillOpacity:0.1,weight:1}).addTo(STATE.reportMap);
}
function updateCrisisSubtype() {
const container=document.getElementById('crisisSubtypeContainer');
const selectedCrisis=document.querySelector('input[name="crisisType"]:checked')?.value;
if(!selectedCrisis||!crisisSubtypes[selectedCrisis]){container.innerHTML='';return;}
const subtypes=crisisSubtypes[selectedCrisis];
let html='<div class="radio-group">';
subtypes.forEach(sub=>{html+=`<label><input type="radio" name="crisisSubtype" value="${sub}"> ${sub}</label>`;});