File size: 30,645 Bytes
02ef2f9
 
 
 
 
 
 
abf2872
 
 
02ef2f9
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
abf2872
 
02ef2f9
 
 
 
 
 
 
 
 
 
 
 
 
abf2872
 
02ef2f9
abf2872
 
02ef2f9
abf2872
 
02ef2f9
abf2872
 
02ef2f9
 
 
abf2872
02ef2f9
 
abf2872
02ef2f9
 
 
 
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
abf2872
 
 
 
02ef2f9
abf2872
 
 
 
 
 
 
 
02ef2f9
 
 
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
 
 
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
 
 
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
 
 
abf2872
 
 
02ef2f9
abf2872
02ef2f9
 
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
abf2872
 
 
 
02ef2f9
abf2872
 
 
 
 
 
 
02ef2f9
 
abf2872
02ef2f9
 
 
abf2872
02ef2f9
abf2872
 
02ef2f9
 
abf2872
 
02ef2f9
abf2872
 
02ef2f9
 
 
abf2872
02ef2f9
 
 
abf2872
02ef2f9
 
abf2872
 
02ef2f9
 
abf2872
02ef2f9
 
 
abf2872
02ef2f9
 
 
abf2872
02ef2f9
 
abf2872
 
02ef2f9
abf2872
 
02ef2f9
 
abf2872
 
02ef2f9
 
 
abf2872
02ef2f9
 
abf2872
 
02ef2f9
abf2872
 
02ef2f9
 
 
abf2872
02ef2f9
 
 
 
abf2872
 
 
 
 
02ef2f9
 
abf2872
 
 
02ef2f9
 
 
abf2872
 
 
 
02ef2f9
 
abf2872
 
 
 
02ef2f9
 
 
 
abf2872
 
 
 
02ef2f9
abf2872
 
02ef2f9
abf2872
 
 
 
 
 
02ef2f9
 
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
 
abf2872
 
 
02ef2f9
 
 
 
 
abf2872
02ef2f9
 
abf2872
02ef2f9
abf2872
 
 
 
 
 
 
 
 
02ef2f9
 
abf2872
 
02ef2f9
abf2872
02ef2f9
abf2872
02ef2f9
 
 
abf2872
 
 
02ef2f9
 
abf2872
02ef2f9
 
 
abf2872
 
 
02ef2f9
 
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
abf2872
 
 
 
02ef2f9
 
abf2872
 
 
 
 
02ef2f9
 
abf2872
02ef2f9
abf2872
02ef2f9
abf2872
 
 
 
02ef2f9
abf2872
02ef2f9
 
abf2872
 
02ef2f9
abf2872
 
 
 
02ef2f9
 
abf2872
 
 
 
02ef2f9
 
abf2872
02ef2f9
abf2872
 
 
 
 
 
02ef2f9
abf2872
 
02ef2f9
 
abf2872
 
02ef2f9
 
abf2872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02ef2f9
abf2872
 
02ef2f9
 
abf2872
 
 
 
 
 
 
02ef2f9
abf2872
 
02ef2f9
abf2872
 
 
 
02ef2f9
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>XYZ Cosmetics – FTZ Analysis & Optimization Studio</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.plot.ly/plotly-2.24.1.min.js"></script>
    <script src="https://unpkg.com/tabulator-tables@5.5.2/dist/js/tabulator.min.js"></script>
    <link href="https://unpkg.com/tabulator-tables@5.5.2/dist/css/tabulator.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#1e40af',
                        secondary: '#3b82f6',
                        accent: '#0ea5e9',
                        dark: '#0f172a',
                        light: '#f8fafc'
                    }
                }
            }
        }
    </script>
    <style>
        .sidebar {
            transition: all 0.3s ease;
        }
        .tab-content {
            display: none;
        }
        .tab-content.active {
            display: block;
        }
        .scenario-card {
            transition: all 0.3s ease;
        }
        .scenario-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .kpi-card {
            transition: all 0.3s ease;
        }
        .kpi-card:hover {
            transform: translateY(-2px);
        }
        .chart-container {
            height: 400px;
        }
        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
            }
            .sidebar.active {
                transform: translateX(0);
            }
        }
    </style>
</head>
<body class="bg-gray-50 text-gray-800">
    <!-- Mobile Menu Button -->
    <div class="md:hidden fixed top-4 left-4 z-50">
        <button id="menu-toggle" class="bg-primary text-white p-2 rounded-lg">
            <i class="fas fa-bars"></i>
        </button>
    </div>

    <!-- Sidebar -->
    <div id="sidebar" class="sidebar fixed top-0 left-0 h-full w-64 bg-white shadow-lg z-40 p-4">
        <div class="flex justify-between items-center mb-6">
            <h1 class="text-xl font-bold text-primary">Filters</h1>
            <button id="close-menu" class="md:hidden text-gray-500">
                <i class="fas fa-times"></i>
            </button>
        </div>
        
        <div class="space-y-6">
            <!-- Date Range -->
            <div>
                <h3 class="font-semibold mb-2">Date Range</h3>
                <div class="grid grid-cols-2 gap-2">
                    <div>
                        <label class="text-sm text-gray-600">Start</label>
                        <input type="month" value="2023-01" class="w-full p-2 border rounded">
                    </div>
                    <div>
                        <label class="text-sm text-gray-600">End</label>
                        <input type="month" value="2024-12" class="w-full p-2 border rounded">
                    </div>
                </div>
            </div>
            
            <!-- Product Family -->
            <div>
                <h3 class="font-semibold mb-2">Product Family</h3>
                <div class="space-y-2">
                    <div class="flex items-center">
                        <input type="checkbox" id="skincare" class="mr-2">
                        <label for="skincare">Skincare</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="makeup" class="mr-2" checked>
                        <label for="makeup">Makeup</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="fragrance" class="mr-2" checked>
                        <label for="fragrance">Fragrance</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="haircare" class="mr-2">
                        <label for="haircare">Haircare</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="accessories" class="mr-2" checked>
                        <label for="accessories">Accessories</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="giftsets" class="mr-2">
                        <label for="giftsets">Gift Sets</label>
                    </div>
                </div>
            </div>
            
            <!-- HS Codes -->
            <div>
                <h3 class="font-semibold mb-2">HS Chapters/Codes</h3>
                <div class="grid grid-cols-2 gap-2">
                    <div class="flex items-center">
                        <input type="checkbox" id="hs3304" class="mr-2" checked>
                        <label for="hs3304">3304</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="hs3305" class="mr-2">
                        <label for="hs3305">3305</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="hs3307" class="mr-2" checked>
                        <label for="hs3307">3307</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="hs4202" class="mr-2" checked>
                        <label for="hs4202">4202</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="hs3923" class="mr-2">
                        <label for="hs3923">3923</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="hs7010" class="mr-2" checked>
                        <label for="hs7010">7010</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="hs3401" class="mr-2">
                        <label for="hs3401">3401</label>
                    </div>
                </div>
            </div>
            
            <!-- Supplier Country -->
            <div>
                <h3 class="font-semibold mb-2">Supplier Country</h3>
                <div class="space-y-2 max-h-40 overflow-y-auto">
                    <div class="flex items-center">
                        <input type="checkbox" id="france" class="mr-2">
                        <label for="france">France</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="italy" class="mr-2" checked>
                        <label for="italy">Italy</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="spain" class="mr-2">
                        <label for="spain">Spain</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="korea" class="mr-2" checked>
                        <label for="korea">South Korea</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="japan" class="mr-2">
                        <label for="japan">Japan</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="china" class="mr-2">
                        <label for="china">China</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="vietnam" class="mr-2">
                        <label for="vietnam">Vietnam</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="thailand" class="mr-2">
                        <label for="thailand">Thailand</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="mexico" class="mr-2">
                        <label for="mexico">Mexico</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="canada" class="mr-2" checked>
                        <label for="canada">Canada</label>
                    </div>
                </div>
            </div>
            
            <!-- Port/Entry Point -->
            <div>
                <h3 class="font-semibold mb-2">Port/Entry Point</h3>
                <div class="space-y-2">
                    <div class="flex items-center">
                        <input type="checkbox" id="lax" class="mr-2" checked>
                        <label for="lax">LAX</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="jfk" class="mr-2">
                        <label for="jfk">JFK</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="ewr" class="mr-2">
                        <label for="ewr">EWR</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="mia" class="mr-2" checked>
                        <label for="mia">MIA</label>
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="sav" class="mr-2">
                        <label for="sav">SAV</label>
                    </div>
                </div>
            </div>
        </div>
        
        <button class="w-full mt-6 bg-primary text-white py-2 rounded-lg hover:bg-blue-800 transition">
            Apply Filters
        </button>
    </div>

    <!-- Main Content -->
    <div class="md:ml-64">
        <!-- Top Navbar -->
        <header class="bg-white shadow-md p-4 sticky top-0 z-30">
            <div class="flex flex-col md:flex-row md:items-center md:justify-between">
                <div>
                    <h1 class="text-xl md:text-2xl font-bold text-primary">XYZ Cosmetics – FTZ Analysis & Optimization Studio</h1>
                    <p class="text-sm text-gray-600">Supply Chain Optimization Dashboard</p>
                </div>
                
                <div class="flex flex-wrap items-center mt-4 md:mt-0 space-x-2">
                    <div>
                        <label class="text-sm mr-2">Scenario:</label>
                        <select class="border rounded p-2">
                            <option>Standard Entry</option>
                            <option>FTZ - Baseline</option>
                            <option selected>FTZ - Privileged Foreign</option>
                            <option>FTZ - Inverted Tariff</option>
                            <option>Bonded Warehouse</option>
                            <option>Mixed Network</option>
                        </select>
                    </div>
                    
                    <button class="bg-primary hover:bg-blue-800 text-white px-4 py-2 rounded-lg flex items-center">
                        <i class="fas fa-play mr-2"></i> Run Scenario
                    </button>
                    
                    <button class="border border-gray-300 hover:bg-gray-100 px-4 py-2 rounded-lg">
                        <i class="fas fa-sync-alt mr-2"></i> Reset
                    </button>
                    
                    <button class="border border-gray-300 hover:bg-gray-100 px-4 py-2 rounded-lg">
                        <i class="fas fa-redo mr-2"></i> Regenerate Data
                    </button>
                    
                    <div>
                        <select class="border rounded p-2">
                            <option>USD</option>
                            <option>EUR</option>
                            <option>JPY</option>
                            <option>KRW</option>
                        </select>
                    </div>
                </div>
            </div>
        </header>

        <!-- Tabs Navigation -->
        <div class="bg-white border-b">
            <div class="flex overflow-x-auto px-4">
                <button class="tab-btn px-4 py-3 font-medium text-blue-600 border-b-2 border-blue-600" data-tab="overview">Overview</button>
                <button class="tab-btn px-4 py-3 font-medium text-gray-600 hover:text-blue-600" data-tab="inventory">Inventory & Flows</button>
                <button class="tab-btn px-4 py-3 font-medium text-gray-600 hover:text-blue-600" data-tab="duty">Duty & Fees</button>
                <button class="tab-btn px-4 py-3 font-medium text-gray-600 hover:text-blue-600" data-tab="comparison">FTZ vs. Alternatives</button>
                <button class="tab-btn px-4 py-3 font-medium text-gray-600 hover:text-blue-600" data-tab="optimization">Optimization Lab</button>
                <button class="tab-btn px-4 py-3 font-medium text-gray-600 hover:text-blue-600" data-tab="compliance">Compliance & Risk</button>
                <button class="tab-btn px-4 py-3 font-medium text-gray-600 hover:text-blue-600" data-tab="about">About/Methodology</button>
            </div>
        </div>

        <!-- Tab Content -->
        <div class="p-4 md:p-6">
            <!-- Overview Tab -->
            <div id="overview" class="tab-content active">
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
                    <!-- KPI Cards -->
                    <div class="kpi-card bg-white rounded-xl shadow-md p-4 border-l-4 border-blue-500">
                        <div class="flex justify-between items-start">
                            <div>
                                <h3 class="text-gray-500 text-sm">Total Duty Paid (YTD)</h3>
                                <p class="text-2xl font-bold mt-1">$1,248,950</p>
                            </div>
                            <div class="bg-blue-100 p-2 rounded-full">
                                <i class="fas fa-dollar-sign text-blue-600"></i>
                            </div>
                        </div>
                        <p class="text-green-600 text-sm mt-2">
                            <i class="fas fa-arrow-down mr-1"></i> 12.3% vs Standard Entry
                        </p>
                    </div>
                    
                    <div class="kpi-card bg-white rounded-xl shadow-md p-4 border-l-4 border-green-500">
                        <div class="flex justify-between items-start">
                            <div>
                                <h3 class="text-gray-500 text-sm">MPF/HMF Fees (YTD)</h3>
                                <p class="text-2xl font-bold mt-1">$87,450</p>
                            </div>
                            <div class="bg-green-100 p-2 rounded-full">
                                <i class="fas fa-file-invoice-dollar text-green-600"></i>
                            </div>
                        </div>
                        <p class="text-green-600 text-sm mt-2">
                            <i class="fas fa-arrow-down mr-1"></i> 23.5% vs Standard Entry
                        </p>
                    </div>
                    
                    <div class="kpi-card bg-white rounded-xl shadow-md p-4 border-l-4 border-purple-500">
                        <div class="flex justify-between items-start">
                            <div>
                                <h3 class="text-gray-500 text-sm">Avg Landed Cost/Unit</h3>
                                <p class="text-2xl font-bold mt-1">$18.75</p>
                            </div>
                            <div class="bg-purple-100 p-2 rounded-full">
                                <i class="fas fa-box-open text-purple-600"></i>
                            </div>
                        </div>
                        <p class="text-red-600 text-sm mt-2">
                            <i class="fas fa-arrow-up mr-1"></i> 3.2% vs Standard Entry
                        </p>
                    </div>
                    
                    <div class="kpi-card bg-white rounded-xl shadow-md p-4 border-l-4 border-amber-500">
                        <div class="flex justify-between items-start">
                            <div>
                                <h3 class="text-gray-500 text-sm">Gross Margin %</h3>
                                <p class="text-2xl font-bold mt-1">48.6%</p>
                            </div>
                            <div class="bg-amber-100 p-2 rounded-full">
                                <i class="fas fa-chart-line text-amber-600"></i>
                            </div>
                        </div>
                        <p class="text-green-600 text-sm mt-2">
                            <i class="fas fa-arrow-up mr-1"></i> 2.1% vs Standard Entry
                        </p>
                    </div>
                </div>
                
                <!-- Charts Row -->
                <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
                    <div class="bg-white rounded-xl shadow-md p-4">
                        <h3 class="font-semibold mb-4">Duty and Fees by HS Code and Port</h3>
                        <div id="chart1" class="chart-container"></div>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md p-4">
                        <h3 class="font-semibold mb-4">Monthly Duty/Fees vs Standard Entry</h3>
                        <div id="chart2" class="chart-container"></div>
                    </div>
                </div>
                
                <!-- Cost Composition -->
                <div class="bg-white rounded-xl shadow-md p-4 mb-6">
                    <h3 class="font-semibold mb-4">Cost Composition Breakdown</h3>
                    <div id="costTreemap" class="chart-container"></div>
                </div>
                
                <!-- Savings Table -->
                <div class="bg-white rounded-xl shadow-md p-4">
                    <h3 class="font-semibold mb-4">Top 25 SKUs by Potential FTZ Savings</h3>
                    <div id="savingsTable" class="overflow-x-auto"></div>
                </div>
            </div>
            
            <!-- About Tab -->
            <div id="about" class="tab-content">
                <div class="bg-white rounded-xl shadow-md p-6">
                    <h2 class="text-2xl font-bold text-primary mb-4">FTZ Analysis & Optimization Studio</h2>
                    
                    <div class="prose max-w-none">
                        <h3>About This Tool</h3>
                        <p>This dashboard allows logistics, finance, and compliance teams to simulate the use of U.S. Foreign Trade Zones versus Bonded Warehouses and standard entry to reduce duty/tariff spend, MPF, demurrage, and compliance overhead for imported beauty and cosmetic goods.</p>
                        
                        <h3>Key Concepts</h3>
                        <ul>
                            <li><strong>FTZs</strong> are considered outside the U.S. customs territory for tariff purposes; duties are deferred until merchandise enters U.S. commerce. Weekly entry, direct delivery, inverted tariff opportunities, and scrap/waste relief can create material savings.</li>
                            <li><strong>Bonded Warehouses</strong> defer duty assessment until goods are withdrawn for consumption. Savings depend on anticipated tariff rate changes.</li>
                            <li><strong>Privileged Foreign Status</strong> locks duty rates at admission, protecting against future rate increases.</li>
                            <li><strong>Inverted Tariff</strong> allows using the lower duty rate of the finished product instead of components when applicable.</li>
                        </ul>
                        
                        <h3>How to Use This Dashboard</h3>
                        <ol>
                            <li><strong>Apply Filters</strong> on the left sidebar to focus on specific products, suppliers, or time periods.</li>
                            <li><strong>Select a Scenario</strong> from the dropdown to compare different logistics strategies.</li>
                            <li><strong>Analyze Results</strong> in the Overview tab to understand potential savings.</li>
                            <li><strong>Explore Details</strong> in other tabs for in-depth analysis of inventory flows, duty calculations, and optimization opportunities.</li>
                            <li><strong>Run "What-if" Scenarios</strong> in the Optimization Lab to find the best strategy mix.</li>
                        </ol>
                        
                        <h3>Data and Methodology</h3>
                        <p>All data is synthetic and generated client-side. Calculations follow these principles:</p>
                        <ul>
                            <li>Duty is calculated based on customs value (merchandise + freight + insurance) multiplied by applicable tariff rates</li>
                            <li>MPF (Merchandise Processing Fee) is calculated with minimum/maximum constraints per entry</li>
                            <li>HMF (Harbor Maintenance Fee) applies to ocean shipments</li>
                            <li>Weekly entry aggregations reduce total entries and associated fees</li>
                            <li>Storage fees are calculated based on dwell time in locations</li>
                        </ul>
                        
                        <div class="bg-blue-50 p-4 rounded-lg mt-6">
                            <p class="font-semibold">Demonstration only. FTZ/Bonded mechanics summarized from public resources: strtrade.com, geodis.com, bergenlogistics.com, chiefexecutive.net, zhftaxlaw.com.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Tab switching functionality
        document.querySelectorAll('.tab-btn').forEach(button => {
            button.addEventListener('click', () => {
                // Remove active class from all buttons and content
                document.querySelectorAll('.tab-btn').forEach(btn => {
                    btn.classList.remove('text-blue-600', 'border-b-2', 'border-blue-600');
                    btn.classList.add('text-gray-600');
                });
                
                document.querySelectorAll('.tab-content').forEach(content => {
                    content.classList.remove('active');
                });
                
                // Add active class to clicked button
                button.classList.add('text-blue-600', 'border-b-2', 'border-blue-600');
                button.classList.remove('text-gray-600');
                
                // Show corresponding content
                const tabId = button.getAttribute('data-tab');
                document.getElementById(tabId).classList.add('active');
            });
        });
        
        // Mobile menu toggle
        document.getElementById('menu-toggle').addEventListener('click', () => {
            document.getElementById('sidebar').classList.add('active');
        });
        
        document.getElementById('close-menu').addEventListener('click', () => {
            document.getElementById('sidebar').classList.remove('active');
        });
        
        // Render charts when Overview tab is active
        document.querySelector('[data-tab="overview"]').addEventListener('click', () => {
            renderOverviewCharts();
        });
        
        // Initialize charts on first load if Overview is default
        window.addEventListener('load', () => {
            renderOverviewCharts();
            renderSavingsTable();
        });
        
        // Render Overview Charts
        function renderOverviewCharts() {
            // Chart 1: Duty and Fees by HS Code and Port
            const chart1Data = [{
                type: 'bar',
                x: ['3304', '3305', '3307', '4202', '7010'],
                y: [350000, 220000, 480000, 180000, 210000],
                name: 'Duty',
                marker: {color: '#3b82f6'}
            }, {
                type: 'bar',
                x: ['3304', '3305', '3307', '4202', '7010'],
                y: [85000, 62000, 98000, 42000, 53000],
                name: 'MPF/HMF',
                marker: {color: '#1e40af'}
            }];
            
            const chart1Layout = {
                barmode: 'stack',
                title: 'Duty and Fees by HS Code',
                xaxis: {title: 'HS Code'},
                yaxis: {title: 'Amount ($USD)'}
            };
            
            Plotly.newPlot('chart1', chart1Data, chart1Layout);
            
            // Chart 2: Monthly Duty/Fees vs Standard Entry
            const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
            const standardFees = [120000, 110000, 130000, 140000, 150000, 160000, 170000, 180000, 160000, 150000, 140000, 130000];
            const ftzFees = [100000, 92000, 108000, 115000, 125000, 132000, 140000, 148000, 135000, 128000, 118000, 110000];
            
            const chart2Data = [{
                x: months,
                y: standardFees,
                mode: 'lines+markers',
                name: 'Standard Entry',
                line: {color: '#94a3b8'}
            }, {
                x: months,
                y: ftzFees,
                mode: 'lines+markers',
                name: 'FTZ Strategy',
                line: {color: '#3b82f6'}
            }];
            
            const chart2Layout = {
                title: 'Monthly Duty/Fees vs Standard Entry',
                xaxis: {title: 'Month'},
                yaxis: {title: 'Amount ($USD)'}
            };
            
            Plotly.newPlot('chart2', chart2Data, chart2Layout);
            
            // Cost Composition Treemap
            const costTreemapData = [{
                type: "treemap",
                labels: ["Duty", "MPF", "HMF", "Storage", "Handling", "Compliance"],
                parents: ["", "", "", "", "", ""],
                values:  [45, 12, 8, 15, 10, 10],
                marker: {
                    colors: ['#3b82f6', '#1e40af', '#93c5fd', '#bfdbfe', '#dbeafe', '#dbeafe']
                }
            }];
            
            const costTreemapLayout = {
                title: "Landed Cost Composition Breakdown"
            };
            
            Plotly.newPlot('costTreemap', costTreemapData, costTreemapLayout);
        }
        
        // Render Savings Table
        function renderSavingsTable() {
            const tableData = [
                {hsCode: '3307', dutyBasis: '$8.25/unit', inverted: '$2,450', pf: 'Yes', dwell: 28, storage: '$1,200', savings: '$18,750'},
                {hsCode: '4202', dutyBasis: '$5.50/unit', inverted: '$1,120', pf: 'Yes', dwell: 22, storage: '$890', savings: '$15,400'},
                {hsCode: '3304', dutyBasis: '$3.80/unit', inverted: '$850', pf: 'Yes', dwell: 18, storage: '$650', savings: '$12,300'},
                {hsCode: '7010', dutyBasis: '$4.50/unit', inverted: '$650', pf: 'No', dwell: 35, storage: '$1,500', savings: '$9,800'},
                {hsCode: '3307', dutyBasis: '$7.20/unit', inverted: '$1,800', pf: 'Yes', dwell: 24, storage: '$1,100', savings: '$8,900'},
                {hsCode: '4202', dutyBasis: '$6.10/unit', inverted: '$950', pf: 'Yes', dwell: 20, storage: '$780', savings: '$7,600'},
                {hsCode: '3304', dutyBasis: '$3.20/unit', inverted: '$420', pf: 'No', dwell: 15, storage: '$550', savings: '$6,700'},
                {hsCode: '3307', dutyBasis: '$8.10/unit', inverted: '$2,100', pf: 'Yes', dwell: 30, storage: '$1,300', savings: '$6,400'},
                {hsCode: '7010', dutyBasis: '$5.00/unit', inverted: '$750', pf: 'Yes', dwell: 38, storage: '$1,700', savings: '$5,900'},
                {hsCode: '3304', dutyBasis: '$4.10/unit', inverted: '$680', pf: 'Yes', dwell: 18, storage: '$900', savings: '$5,200'}
            ];
            
            const table = new Tabulator("#savingsTable", {
                data: tableData,
                layout: "fitColumns",
                columns: [
                    {title: "HS Code", field: "hsCode", width: 100},
                    {title: "Duty Basis", field: "dutyBasis", width: 120},
                    {title: "Inverted Savings", field: "inverted", hozAlign: "right"},
                    {title: "PF Locked", field: "pf", width: 100},
                    {title: "Dwell (Days)", field: "dwell", hozAlign: "center"},
                    {title: "Storage Cost", field: "storage", hozAlign: "right"},
                    {title: "Savings", field: "savings", hozAlign: "right", formatter: "money", formatterParams: {symbol: "$"}}
                ],
                pagination: "local",
                paginationSize: 10
            });
        }
        
        // Initialize with Overview tab active
        document.querySelector('[data-tab="overview"]').click();
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=agenticlogistics/ftz-analysis-optimization" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>