Subversion Repositories SmartDukaan

Rev

Rev 37460 | Rev 37469 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
37444 ranu 1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
  <meta charset="utf-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
  <title>RBM DRR Dashboard</title>
7
  <style>
8
    :root {
9
      --bg: #f4f6fb;
10
      --card: #ffffff;
11
      --ink: #141a2b;
12
      --muted: #5d6a83;
13
      --soft: #97a1b5;
14
      --line: #e6e9f1;
15
      --line2: #eef1f6;
16
      --brand: #3b5bdb;
17
      --brand2: #5c7cfa;
18
      --teal: #0ca678;
19
      --cyan: #1098ad;
20
      --amber: #f59f00;
21
      --orange: #e8590c;
22
      --red: #e03131;
23
      --violet: #7048e8;
24
      --pink: #d6336c;
25
      --good: #2f9e44;
26
      --warn: #e8590c;
27
      --bad: #e03131;
28
      --hid: #7048e8;
29
      --fast: #3b5bdb;
30
      --run: #0ca678;
31
      --slow: #e8590c;
32
      --other: #868e96;
33
      --hid-bg: #f2edff;
34
      --fast-bg: #eaf0ff;
35
      --run-bg: #e5f7ee;
36
      --slow-bg: #ffefe0;
37
      --other-bg: #eef0f4;
38
    }
39
 
40
    * {
41
      box-sizing: border-box
42
    }
43
 
44
    html, body {
45
      margin: 0;
46
      background: var(--bg);
47
      color: var(--ink);
48
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
49
      -webkit-font-smoothing: antialiased;
50
      font-size: 14px
51
    }
52
 
53
    .wrap {
54
      max-width: 1440px;
55
      margin: 0 auto;
56
      padding: 22px 26px 100px
57
    }
58
 
59
    a {
60
      color: var(--brand);
61
      text-decoration: none
62
    }
63
 
64
    a:hover {
65
      text-decoration: underline
66
    }
67
 
68
    /* header */
69
    header.top {
70
      display: flex;
71
      align-items: flex-end;
72
      justify-content: space-between;
73
      gap: 18px;
74
      flex-wrap: wrap;
75
      margin-bottom: 20px
76
    }
77
 
78
    .brand .crumb {
79
      font-size: 12px;
80
      color: var(--soft);
81
      font-weight: 600
82
    }
83
 
84
    .brand h1 {
85
      margin: 4px 0 0;
86
      font-size: 26px;
87
      font-weight: 770;
88
      letter-spacing: -.015em;
89
      display: flex;
90
      align-items: center;
91
      gap: 12px
92
    }
93
 
94
    .brand h1 .live {
95
      font-size: 11px;
96
      font-weight: 700;
97
      color: var(--teal);
98
      background: #e6fcf5;
99
      border: 1px solid #c3fae8;
100
      border-radius: 999px;
101
      padding: 3px 10px
102
    }
103
 
104
    .brand h1 .live i {
105
      display: inline-block;
106
      width: 7px;
107
      height: 7px;
108
      border-radius: 50%;
109
      background: var(--teal);
110
      margin-right: 5px;
111
      animation: pulse 1.6s infinite;
112
      vertical-align: middle
113
    }
114
 
115
    @keyframes pulse {
116
      0%, 100% {
117
        opacity: 1
118
      }
119
      50% {
120
        opacity: .25
121
      }
122
    }
123
 
124
    .hd-right {
125
      display: flex;
126
      align-items: center;
127
      gap: 10px;
128
      flex-wrap: wrap
129
    }
130
 
131
    .ctl {
132
      background: var(--card);
133
      border: 1px solid var(--line);
134
      border-radius: 10px;
135
      padding: 9px 13px;
136
      font-size: 13px;
137
      color: var(--ink);
138
      font-weight: 600;
139
      box-shadow: 0 1px 2px rgba(20, 30, 60, .04)
140
    }
141
 
142
    input.ctl {
143
      appearance: none;
144
      cursor: pointer;
145
      height: 38px;
146
      min-width: 240px
147
    }
148
 
149
    .btn-r {
150
      background: var(--brand);
151
      border: 0;
152
      color: #fff;
153
      font-weight: 670;
154
      padding: 9px 18px;
155
      border-radius: 10px;
156
      cursor: pointer;
157
      font-size: 13px;
158
      height: 38px;
159
      box-shadow: 0 1px 2px rgba(59, 91, 219, .35);
160
      transition: transform .1s, box-shadow .1s
161
    }
162
 
163
    .btn-r:hover {
164
      background: var(--brand2);
165
      box-shadow: 0 3px 10px rgba(59, 91, 219, .35)
166
    }
167
 
168
    .btn-r:active {
169
      transform: translateY(1px)
170
    }
171
 
172
    /* KPI cards */
173
    .kpis {
174
      display: grid;
175
      grid-template-columns:repeat(4, 1fr);
176
      gap: 14px;
177
      margin-bottom: 22px
178
    }
179
 
180
    .kpi {
181
      position: relative;
182
      background: var(--card);
183
      border: 1px solid var(--line);
184
      border-radius: 14px;
185
      padding: 16px 18px;
186
      box-shadow: 0 1px 2px rgba(20, 30, 60, .05);
187
      display: flex;
188
      flex-direction: column;
189
      min-height: 118px;
190
      overflow: hidden
191
    }
192
 
193
    .kpi::before {
194
      content: "";
195
      position: absolute;
196
      top: 0;
197
      left: 0;
198
      height: 3px;
199
      width: 100%;
200
      border-top-left-radius: 14px;
201
      border-top-right-radius: 14px
202
    }
203
 
204
    .kpi.a::before {
205
      background: linear-gradient(90deg, var(--brand), var(--brand2))
206
    }
207
 
208
    .kpi.b::before {
209
      background: linear-gradient(90deg, var(--teal), #20c997)
210
    }
211
 
212
    .kpi.c::before {
213
      background: linear-gradient(90deg, var(--amber), #ffc078)
214
    }
215
 
216
    .kpi.d::before {
217
      background: linear-gradient(90deg, var(--violet), #9775fa)
218
    }
219
 
220
    .kpi .top {
221
      display: flex;
222
      align-items: center;
223
      gap: 10px
224
    }
225
 
226
    .kpi .ic {
227
      width: 34px;
228
      height: 34px;
229
      border-radius: 10px;
230
      display: flex;
231
      align-items: center;
232
      justify-content: center;
233
      flex: none;
234
      color: #fff;
235
      box-shadow: 0 2px 6px rgba(0, 0, 0, .08)
236
    }
237
 
238
    .kpi.a .ic {
239
      background: linear-gradient(135deg, var(--brand), var(--brand2))
240
    }
241
 
242
    .kpi.b .ic {
243
      background: linear-gradient(135deg, var(--teal), #20c997)
244
    }
245
 
246
    .kpi.c .ic {
247
      background: linear-gradient(135deg, var(--amber), #ffc078);
248
      color: #3a2500
249
    }
250
 
251
    .kpi.d .ic {
252
      background: linear-gradient(135deg, var(--violet), #9775fa)
253
    }
254
 
255
    .kpi .ic svg {
256
      width: 18px;
257
      height: 18px
258
    }
259
 
260
    .kpi .label {
261
      font-size: 12px;
262
      color: var(--muted);
263
      font-weight: 650;
264
      line-height: 1.2;
265
      letter-spacing: .005em
266
    }
267
 
268
    .kpi .val {
269
      font-size: 28px;
270
      font-weight: 780;
271
      margin-top: auto;
272
      padding-top: 10px;
273
      letter-spacing: -.02em;
274
      line-height: 1;
275
      font-variant-numeric: tabular-nums
276
    }
277
 
278
    .kpi .val .u {
279
      font-size: 13px;
280
      color: var(--soft);
281
      font-weight: 600;
282
      margin-left: 3px
283
    }
284
 
285
    .kpi .foot {
286
      font-size: 11.5px;
287
      color: var(--soft);
288
      margin-top: 8px;
289
      font-weight: 500
290
    }
291
 
292
    .kpi .val .pct {
293
      margin-left: 0;
294
      font-size: 20px;
295
      padding: 4px 12px
296
    }
297
 
298
    .kpi.clickable {
299
      cursor: pointer;
300
      transition: transform .1s, box-shadow .12s, border-color .12s
301
    }
302
 
303
    .kpi.clickable:hover {
304
      transform: translateY(-2px);
305
      box-shadow: 0 6px 18px rgba(20, 30, 60, .08);
306
      border-color: #c8d2f4
307
    }
308
 
309
    .kpi.clickable .hint {
310
      position: absolute;
311
      bottom: 8px;
312
      right: 12px;
313
      color: var(--soft);
314
      font-size: 11px;
315
      font-weight: 600;
316
      opacity: .7
317
    }
318
 
319
    .kpi.clickable:hover .hint {
320
      opacity: 1;
321
      color: var(--brand)
322
    }
323
 
324
    /* Cards & section labels */
325
    .card {
326
      background: var(--card);
327
      border: 1px solid var(--line);
328
      border-radius: 15px;
329
      padding: 18px 20px;
330
      margin-bottom: 16px;
331
      box-shadow: 0 1px 2px rgba(20, 30, 60, .04)
332
    }
333
 
334
    .card .card-hd {
335
      display: flex;
336
      align-items: baseline;
337
      justify-content: space-between;
338
      gap: 14px;
339
      margin-bottom: 14px
340
    }
341
 
342
    .card h2 {
343
      margin: 0;
344
      font-size: 16px;
345
      font-weight: 730;
346
      letter-spacing: -.01em
347
    }
348
 
349
    .card .desc {
350
      color: var(--muted);
351
      font-size: 12.5px;
352
      margin: 2px 0 0
353
    }
354
 
355
    .card .badge-period {
356
      background: #eef2ff;
357
      border: 1px solid #d7defb;
358
      color: var(--brand);
359
      border-radius: 999px;
360
      padding: 3px 12px;
361
      font-size: 12px;
362
      font-weight: 650;
363
      letter-spacing: .01em
364
    }
365
 
366
    .sectionlabel {
367
      font-size: 11px;
368
      letter-spacing: .14em;
369
      text-transform: uppercase;
370
      color: var(--soft);
371
      font-weight: 700;
372
      margin: 20px 2px 10px
373
    }
374
 
375
    /* Legend under section label */
376
    .legend {
377
      display: flex;
378
      gap: 14px;
379
      flex-wrap: wrap;
380
      margin: 0 2px 10px;
381
      align-items: center;
382
      color: var(--soft);
383
      font-size: 11.5px;
384
      font-weight: 600
385
    }
386
 
387
    .legend .lg {
388
      display: inline-flex;
389
      align-items: center;
390
      gap: 5px
391
    }
392
 
393
    .legend .lg i {
394
      width: 8px;
395
      height: 8px;
396
      border-radius: 50%;
397
      display: inline-block
398
    }
399
 
400
    .legend .lg.hid i {
401
      background: var(--hid)
402
    }
403
 
404
    .legend .lg.fast i {
405
      background: var(--fast)
406
    }
407
 
408
    .legend .lg.run i {
409
      background: var(--run)
410
    }
411
 
412
    .legend .lg.slow i {
413
      background: var(--slow)
414
    }
415
 
416
    .legend .lg.other i {
417
      background: var(--other)
418
    }
419
 
420
    .legend .lg .lgt {
421
      color: var(--muted)
422
    }
423
 
424
    /* Table */
425
    table {
426
      width: 100%;
427
      border-collapse: separate;
428
      border-spacing: 0;
429
      font-size: 13px
430
    }
431
 
432
    th, td {
433
      text-align: left;
434
      padding: 11px 10px;
435
      border-bottom: 1px solid var(--line2)
436
    }
437
 
438
    thead th {
439
      font-size: 10.5px;
440
      text-transform: uppercase;
441
      letter-spacing: .06em;
442
      color: var(--soft);
443
      font-weight: 700;
444
      white-space: nowrap;
445
      user-select: none;
446
      position: sticky;
447
      top: 0;
448
      background: #fff;
449
      z-index: 1;
450
      border-bottom: 1px solid var(--line)
451
    }
452
 
453
    th.num, td.num {
454
      text-align: right
455
    }
456
 
457
    th.g-hid {
458
      color: var(--hid);
459
      border-top: 3px solid var(--hid)
460
    }
461
 
462
    th.g-fast {
463
      color: var(--fast);
464
      border-top: 3px solid var(--fast)
465
    }
466
 
467
    th.g-run {
468
      color: var(--run);
469
      border-top: 3px solid var(--run)
470
    }
471
 
472
    th.g-slow {
473
      color: var(--slow);
474
      border-top: 3px solid var(--slow)
475
    }
476
 
477
    th.g-other {
478
      color: var(--other);
479
      border-top: 3px solid var(--other)
480
    }
481
 
482
    th.g-total {
483
      color: var(--brand);
484
      border-top: 3px solid var(--brand)
485
    }
486
 
487
    tbody tr:hover {
488
      background: #f6f8fd
489
    }
490
 
491
    tbody tr.clickable {
492
      cursor: pointer;
493
      transition: background .1s
494
    }
495
 
496
    tbody tr.clickable:hover {
497
      background: #eef2ff
498
    }
499
 
500
    tr.totalrow {
501
      background: #fafbfe;
502
      border-top: 2px solid var(--line)
503
    }
504
 
505
    tr.totalrow td {
506
      font-weight: 770;
507
      color: var(--ink)
508
    }
509
 
510
    tr.totalrow .cell-val {
511
      font-size: 14px
512
    }
513
 
514
    .rbm-cell {
515
      display: flex;
516
      flex-direction: column;
517
      gap: 2px
518
    }
519
 
520
    .rbm-cell .rn {
521
      font-weight: 700;
522
      color: var(--ink);
523
      font-size: 13.5px
524
    }
525
 
526
    .rbm-cell .wh {
527
      font-size: 11.5px;
528
      color: var(--muted);
529
      font-weight: 600
530
    }
531
 
532
    .cell-val {
533
      font-variant-numeric: tabular-nums;
534
      font-weight: 650;
535
      color: var(--ink);
536
      white-space: nowrap
537
    }
538
 
539
    .cell-val small {
540
      color: var(--soft);
541
      font-weight: 500;
542
      margin-left: 3px
543
    }
544
 
545
    .pct {
546
      display: inline-flex;
547
      align-items: center;
548
      justify-content: center;
549
      min-width: 56px;
550
      padding: 3px 9px;
551
      border-radius: 7px;
552
      font-size: 11.5px;
553
      font-weight: 700;
554
      text-align: center;
555
      font-variant-numeric: tabular-nums;
556
      line-height: 1.35
557
    }
558
 
559
    .pct.good {
560
      background: #e5f7ee;
561
      color: #177a3a
562
    }
563
 
564
    .pct.warn {
565
      background: #fff0e0;
566
      color: #a04600
567
    }
568
 
569
    .pct.bad {
570
      background: #ffeaea;
571
      color: #b8272b
572
    }
573
 
574
    .pct.na {
575
      background: transparent;
576
      color: var(--soft);
577
      font-weight: 600;
578
      min-width: auto;
579
      padding: 0
580
    }
581
 
582
    .bar {
583
      height: 5px;
584
      border-radius: 3px;
585
      background: #eef1f6;
586
      overflow: hidden;
587
      margin-top: 6px
588
    }
589
 
590
    .bar > i {
591
      display: block;
592
      height: 100%;
593
      border-radius: 3px;
594
      transition: width .3s ease
595
    }
596
 
597
    .bar > i.good {
598
      background: linear-gradient(90deg, #51cf66, #2f9e44)
599
    }
600
 
601
    .bar > i.warn {
602
      background: linear-gradient(90deg, #ffa94d, #e8590c)
603
    }
604
 
605
    .bar > i.bad {
606
      background: linear-gradient(90deg, #ff8787, #e03131)
607
    }
608
 
609
    .chev {
610
      color: #c5cce0;
611
      font-size: 16px;
612
      padding-left: 6px;
613
      transition: transform .12s, color .12s
614
    }
615
 
616
    tr.clickable:hover .chev {
617
      color: var(--brand);
618
      transform: translateX(2px)
619
    }
620
 
621
    .loading {
622
      padding: 70px;
623
      text-align: center;
624
      color: var(--muted)
625
    }
626
 
627
    .spinner {
628
      width: 32px;
629
      height: 32px;
630
      border: 3px solid #e3e8f5;
631
      border-top-color: var(--brand);
632
      border-radius: 50%;
633
      animation: spin 1s linear infinite;
634
      margin: 0 auto 12px
635
    }
636
 
637
    @keyframes spin {
638
      to {
639
        transform: rotate(360deg)
640
      }
641
    }
642
 
643
    .empty {
644
      padding: 56px 20px;
645
      text-align: center;
646
      color: var(--soft);
647
      font-size: 13.5px
648
    }
649
 
650
    .empty .ei {
651
      font-size: 36px;
652
      margin-bottom: 8px;
653
      opacity: .5
654
    }
655
 
656
    .foot-note {
657
      color: var(--soft);
658
      font-size: 11.5px;
659
      margin-top: 14px;
660
      padding: 10px 12px;
661
      background: #fafbfe;
662
      border: 1px dashed var(--line);
663
      border-radius: 10px;
664
      line-height: 1.5
665
    }
666
 
667
    .foot-note code {
668
      background: #eef1f6;
669
      color: var(--muted);
670
      padding: 1px 5px;
671
      border-radius: 4px;
672
      font-size: 11px
673
    }
674
 
675
    /* drill-down panel */
676
    .rdrr-back {
677
      position: fixed;
678
      inset: 0;
679
      background: rgba(15, 22, 40, .5);
680
      backdrop-filter: blur(2px);
681
      z-index: 1200;
682
      display: none
683
    }
684
 
685
    .rdrr-back.show {
686
      display: block
687
    }
688
 
689
    .rdrr-panel {
690
      position: absolute;
691
      top: 0;
692
      right: 0;
693
      height: 100%;
694
      width: min(760px, 96vw);
695
      background: #fff;
696
      box-shadow: -12px 0 40px rgba(20, 30, 60, .22);
697
      display: flex;
698
      flex-direction: column;
699
      padding: 24px 26px 20px;
700
      transform: translateX(100%);
701
      transition: transform .22s ease;
702
      overflow-y: auto
703
    }
704
 
705
    .rdrr-back.show .rdrr-panel {
706
      transform: translateX(0)
707
    }
708
 
709
    .rdrr-panel .x {
710
      position: absolute;
711
      top: 16px;
712
      right: 18px;
713
      cursor: pointer;
714
      color: var(--soft);
715
      font-size: 24px;
716
      line-height: 1;
717
      border: 0;
718
      background: none;
719
      width: 32px;
720
      height: 32px;
721
      border-radius: 8px;
722
      transition: background .1s, color .1s
723
    }
724
 
725
    .rdrr-panel .x:hover {
726
      background: #f1f3f9;
727
      color: var(--ink)
728
    }
729
 
730
    .rdrr-panel h3 {
731
      margin: 0 0 3px;
732
      font-size: 19px;
733
      font-weight: 750;
734
      letter-spacing: -.01em;
735
      padding-right: 40px
736
    }
737
 
738
    .rdrr-panel > .desc {
739
      margin: 0 0 18px;
740
      font-size: 12.5px;
741
      color: var(--muted);
742
      font-weight: 600
743
    }
744
 
745
    .rdrr-total {
746
      display: flex;
747
      gap: 14px;
748
      padding: 14px 16px;
749
      background: linear-gradient(135deg, #f8f9fc, #eef2ff);
750
      border: 1px solid #dbe2f6;
751
      border-radius: 12px;
752
      margin-bottom: 18px
753
    }
754
 
755
    .rdrr-total > div {
756
      flex: 1;
757
      text-align: center;
758
      border-right: 1px solid #dbe2f6;
759
      padding: 0 4px
760
    }
761
 
762
    .rdrr-total > div:last-child {
763
      border-right: 0
764
    }
765
 
766
    .rdrr-total .k {
767
      font-size: 10.5px;
768
      color: var(--muted);
769
      text-transform: uppercase;
770
      letter-spacing: .06em;
771
      font-weight: 700
772
    }
773
 
774
    .rdrr-total .v {
775
      font-size: 20px;
776
      font-weight: 770;
777
      color: var(--ink);
778
      font-variant-numeric: tabular-nums;
779
      margin-top: 5px;
780
      letter-spacing: -.01em
781
    }
782
 
783
    .rdrr-total .v .pct {
784
      font-size: 16px;
785
      padding: 3px 10px;
786
      margin-top: 0
787
    }
788
 
789
    .bbars {
790
      display: flex;
791
      flex-direction: column;
792
      gap: 10px;
793
      margin-bottom: 20px
794
    }
795
 
796
    .bbar {
797
      display: grid;
798
      grid-template-columns:82px 1fr 145px 60px;
799
      gap: 14px;
800
      align-items: center;
801
      padding: 12px 14px;
802
      background: #fff;
803
      border: 1px solid var(--line);
804
      border-radius: 11px;
805
      transition: box-shadow .12s
806
    }
807
 
808
    .bbar:hover {
809
      box-shadow: 0 3px 10px rgba(20, 30, 60, .06)
810
    }
811
 
812
    .bbar .bname {
813
      font-size: 11.5px;
814
      font-weight: 750;
815
      color: var(--ink);
816
      letter-spacing: .04em;
817
      text-transform: uppercase;
818
      display: flex;
819
      align-items: center;
820
      gap: 6px
821
    }
822
 
823
    .bbar .bname i {
824
      display: inline-block;
825
      width: 8px;
826
      height: 8px;
827
      border-radius: 50%
828
    }
829
 
830
    .bbar.hid .bname {
831
      color: var(--hid)
832
    }
833
 
834
    .bbar.fast .bname {
835
      color: var(--fast)
836
    }
837
 
838
    .bbar.run .bname {
839
      color: var(--run)
840
    }
841
 
842
    .bbar.slow .bname {
843
      color: var(--slow)
844
    }
845
 
846
    .bbar.other .bname {
847
      color: var(--other)
848
    }
849
 
850
    .bbar.hid .bname i {
851
      background: var(--hid)
852
    }
853
 
854
    .bbar.fast .bname i {
855
      background: var(--fast)
856
    }
857
 
858
    .bbar.run .bname i {
859
      background: var(--run)
860
    }
861
 
862
    .bbar.slow .bname i {
863
      background: var(--slow)
864
    }
865
 
866
    .bbar.other .bname i {
867
      background: var(--other)
868
    }
869
 
870
    .bbar .btrack {
871
      height: 14px;
872
      border-radius: 8px;
873
      overflow: hidden;
874
      position: relative
875
    }
876
 
877
    .bbar.hid .btrack {
878
      background: var(--hid-bg)
879
    }
880
 
881
    .bbar.fast .btrack {
882
      background: var(--fast-bg)
883
    }
884
 
885
    .bbar.run .btrack {
886
      background: var(--run-bg)
887
    }
888
 
889
    .bbar.slow .btrack {
890
      background: var(--slow-bg)
891
    }
892
 
893
    .bbar.other .btrack {
894
      background: var(--other-bg)
895
    }
896
 
897
    .bbar .btrack > i {
898
      display: block;
899
      height: 100%;
900
      border-radius: 8px;
901
      transition: width .3s ease;
902
      position: relative
903
    }
904
 
905
    .bbar.hid .btrack > i {
906
      background: linear-gradient(90deg, #9775fa, var(--hid))
907
    }
908
 
909
    .bbar.fast .btrack > i {
910
      background: linear-gradient(90deg, var(--brand2), var(--fast))
911
    }
912
 
913
    .bbar.run .btrack > i {
914
      background: linear-gradient(90deg, #20c997, var(--run))
915
    }
916
 
917
    .bbar.slow .btrack > i {
918
      background: linear-gradient(90deg, #ffa94d, var(--slow))
919
    }
920
 
921
    .bbar.other .btrack > i {
922
      background: linear-gradient(90deg, #adb5bd, var(--other))
923
    }
924
 
925
    .bbar .btgt {
926
      font-size: 12px;
927
      color: var(--muted);
928
      font-variant-numeric: tabular-nums;
929
      font-weight: 600;
930
      text-align: right
931
    }
932
 
933
    .bbar .btgt b {
934
      color: var(--ink);
935
      font-weight: 700
936
    }
937
 
938
    .bbar .bpct {
939
      font-size: 13px;
940
      font-weight: 750;
941
      text-align: right;
942
      font-variant-numeric: tabular-nums
943
    }
944
 
945
    .bbar .bpct.good {
946
      color: var(--good)
947
    }
948
 
949
    .bbar .bpct.warn {
950
      color: var(--warn)
951
    }
952
 
953
    .bbar .bpct.bad {
954
      color: var(--bad)
955
    }
956
 
957
    .bbar .bpct.na {
958
      color: var(--soft);
959
      font-weight: 600
960
    }
961
 
962
    /* brand mix bars in drill-down */
963
    .brands {
964
      display: flex;
965
      flex-direction: column;
966
      gap: 8px;
967
      margin-bottom: 20px
968
    }
969
 
970
    .brand-card {
971
      background: #fff;
972
      border: 1px solid var(--line);
973
      border-radius: 11px;
974
      overflow: hidden;
975
      transition: box-shadow .12s
976
    }
977
 
978
    .brand-card:hover {
979
      box-shadow: 0 3px 10px rgba(20, 30, 60, .06)
980
    }
981
 
982
    .brand-card.open {
983
      box-shadow: 0 4px 14px rgba(59, 91, 219, .14);
984
      border-color: #c8d2f4
985
    }
986
 
987
    .brand-head {
988
      display: grid;
37460 ranu 989
      grid-template-columns:24px 130px 1fr 96px 100px 60px;
37444 ranu 990
      gap: 12px;
991
      align-items: center;
992
      padding: 10px 14px;
993
      cursor: pointer;
994
      user-select: none
995
    }
996
 
37460 ranu 997
    .brand-head .bpc {
998
      display: inline-flex;
999
      align-items: center;
1000
      justify-content: center;
1001
      gap: 4px;
1002
      font-size: 11.5px;
1003
      font-weight: 700;
1004
      color: var(--brand);
1005
      background: #eef2ff;
1006
      border: 1px solid #d7defb;
1007
      border-radius: 999px;
1008
      padding: 3px 9px;
1009
      font-variant-numeric: tabular-nums;
1010
      white-space: nowrap;
1011
      justify-self: center
1012
    }
1013
 
1014
    .brand-head .bpc.zero {
1015
      color: var(--soft);
1016
      background: #f1f3f9;
1017
      border-color: var(--line)
1018
    }
1019
 
1020
    .brand-head .bpc svg {
1021
      width: 11px;
1022
      height: 11px
1023
    }
1024
 
37444 ranu 1025
    .brand-head .cx {
1026
      color: #c5cce0;
1027
      font-size: 14px;
1028
      transition: transform .18s ease, color .12s
1029
    }
1030
 
1031
    .brand-card.open .brand-head .cx {
1032
      transform: rotate(90deg);
1033
      color: var(--brand)
1034
    }
1035
 
1036
    .brand-head .bn {
1037
      font-size: 13px;
1038
      font-weight: 700;
1039
      color: var(--ink);
1040
      white-space: nowrap;
1041
      overflow: hidden;
1042
      text-overflow: ellipsis
1043
    }
1044
 
1045
    .brand-head .btrack {
1046
      height: 10px;
1047
      background: #eef1f6;
1048
      border-radius: 6px;
1049
      overflow: hidden
1050
    }
1051
 
1052
    .brand-head .btrack > i {
1053
      display: block;
1054
      height: 100%;
1055
      border-radius: 6px;
1056
      background: linear-gradient(90deg, var(--brand2), var(--brand));
1057
      transition: width .3s ease
1058
    }
1059
 
1060
    .brand-head .bval {
1061
      font-size: 13px;
1062
      font-weight: 700;
1063
      color: var(--ink);
1064
      font-variant-numeric: tabular-nums;
1065
      text-align: right
1066
    }
1067
 
1068
    .brand-head .bshare {
1069
      font-size: 12px;
1070
      font-weight: 700;
1071
      color: var(--muted);
1072
      font-variant-numeric: tabular-nums;
1073
      text-align: right
1074
    }
1075
 
1076
    .brand-card.top .brand-head .btrack > i {
1077
      background: linear-gradient(90deg, #38b2ac, var(--teal))
1078
    }
1079
 
1080
    .brand-card.top .brand-head .bshare {
1081
      color: var(--teal)
1082
    }
1083
 
1084
    .brand-body {
1085
      display: none;
1086
      padding: 6px 14px 14px;
1087
      border-top: 1px dashed var(--line);
1088
      background: #fafbfe
1089
    }
1090
 
1091
    .brand-card.open .brand-body {
1092
      display: block
1093
    }
1094
 
1095
    .brand-body .bhdr {
1096
      font-size: 10.5px;
1097
      letter-spacing: .06em;
1098
      text-transform: uppercase;
1099
      color: var(--soft);
1100
      font-weight: 700;
1101
      margin: 8px 0 8px
1102
    }
1103
 
1104
    .mbars {
1105
      display: flex;
1106
      flex-direction: column;
1107
      gap: 6px
1108
    }
1109
 
1110
    .mbar {
1111
      display: grid;
1112
      grid-template-columns:90px 1fr 100px 60px;
1113
      gap: 10px;
1114
      align-items: center;
1115
      padding: 6px 10px;
1116
      background: #fff;
1117
      border: 1px solid var(--line2);
1118
      border-radius: 8px
1119
    }
1120
 
1121
    .mbar .mname {
1122
      font-size: 11px;
1123
      font-weight: 700;
1124
      letter-spacing: .04em;
1125
      text-transform: uppercase;
1126
      display: flex;
1127
      align-items: center;
1128
      gap: 5px
1129
    }
1130
 
1131
    .mbar .mname i {
1132
      display: inline-block;
1133
      width: 7px;
1134
      height: 7px;
1135
      border-radius: 50%
1136
    }
1137
 
1138
    .mbar.hid .mname {
1139
      color: var(--hid)
1140
    }
1141
 
1142
    .mbar.hid .mname i {
1143
      background: var(--hid)
1144
    }
1145
 
1146
    .mbar.fastmoving .mname {
1147
      color: var(--fast)
1148
    }
1149
 
1150
    .mbar.fastmoving .mname i {
1151
      background: var(--fast)
1152
    }
1153
 
1154
    .mbar.running .mname {
1155
      color: var(--run)
1156
    }
1157
 
1158
    .mbar.running .mname i {
1159
      background: var(--run)
1160
    }
1161
 
1162
    .mbar.slowmoving .mname {
1163
      color: var(--slow)
1164
    }
1165
 
1166
    .mbar.slowmoving .mname i {
1167
      background: var(--slow)
1168
    }
1169
 
1170
    .mbar.other .mname {
1171
      color: var(--other)
1172
    }
1173
 
1174
    .mbar.other .mname i {
1175
      background: var(--other)
1176
    }
1177
 
1178
    .mbar .mtrack {
1179
      height: 10px;
1180
      border-radius: 5px;
1181
      overflow: hidden
1182
    }
1183
 
1184
    .mbar.hid .mtrack {
1185
      background: var(--hid-bg)
1186
    }
1187
 
1188
    .mbar.fastmoving .mtrack {
1189
      background: var(--fast-bg)
1190
    }
1191
 
1192
    .mbar.running .mtrack {
1193
      background: var(--run-bg)
1194
    }
1195
 
1196
    .mbar.slowmoving .mtrack {
1197
      background: var(--slow-bg)
1198
    }
1199
 
1200
    .mbar.other .mtrack {
1201
      background: var(--other-bg)
1202
    }
1203
 
1204
    .mbar .mtrack > i {
1205
      display: block;
1206
      height: 100%;
1207
      border-radius: 5px;
1208
      transition: width .3s ease
1209
    }
1210
 
1211
    .mbar.hid .mtrack > i {
1212
      background: linear-gradient(90deg, #9775fa, var(--hid))
1213
    }
1214
 
1215
    .mbar.fastmoving .mtrack > i {
1216
      background: linear-gradient(90deg, var(--brand2), var(--fast))
1217
    }
1218
 
1219
    .mbar.running .mtrack > i {
1220
      background: linear-gradient(90deg, #20c997, var(--run))
1221
    }
1222
 
1223
    .mbar.slowmoving .mtrack > i {
1224
      background: linear-gradient(90deg, #ffa94d, var(--slow))
1225
    }
1226
 
1227
    .mbar.other .mtrack > i {
1228
      background: linear-gradient(90deg, #adb5bd, var(--other))
1229
    }
1230
 
1231
    .mbar .mval {
1232
      font-size: 12px;
1233
      font-weight: 650;
1234
      color: var(--ink);
1235
      font-variant-numeric: tabular-nums;
1236
      text-align: right
1237
    }
1238
 
1239
    .mbar .mshare {
1240
      font-size: 12px;
1241
      font-weight: 700;
1242
      font-variant-numeric: tabular-nums;
1243
      text-align: right;
1244
      color: var(--muted)
1245
    }
1246
 
1247
    /* status list modal (achieved vs pending) */
1248
    .status-back {
1249
      position: fixed;
1250
      inset: 0;
1251
      background: rgba(15, 22, 40, .5);
1252
      backdrop-filter: blur(2px);
1253
      z-index: 1300;
1254
      display: none;
1255
      align-items: flex-start;
1256
      justify-content: center;
1257
      padding: 60px 20px;
1258
      overflow-y: auto
1259
    }
1260
 
1261
    .status-back.show {
1262
      display: flex
1263
    }
1264
 
1265
    .status-modal {
1266
      background: #fff;
1267
      border-radius: 16px;
1268
      max-width: 1000px;
1269
      width: 100%;
1270
      box-shadow: 0 20px 60px rgba(20, 30, 60, .28);
1271
      padding: 22px 24px 20px;
1272
      position: relative
1273
    }
1274
 
1275
    .status-modal .x {
1276
      position: absolute;
1277
      top: 14px;
1278
      right: 16px;
1279
      cursor: pointer;
1280
      color: var(--soft);
1281
      font-size: 24px;
1282
      line-height: 1;
1283
      border: 0;
1284
      background: none;
1285
      width: 32px;
1286
      height: 32px;
1287
      border-radius: 8px;
1288
      transition: background .1s
1289
    }
1290
 
1291
    .status-modal .x:hover {
1292
      background: #f1f3f9;
1293
      color: var(--ink)
1294
    }
1295
 
1296
    .status-modal h3 {
1297
      margin: 0 0 3px;
1298
      font-size: 19px;
1299
      font-weight: 760;
1300
      letter-spacing: -.01em;
1301
      padding-right: 40px
1302
    }
1303
 
1304
    .status-modal > .desc {
1305
      margin: 0 0 18px;
1306
      font-size: 12.5px;
1307
      color: var(--muted);
1308
      font-weight: 600
1309
    }
1310
 
1311
    .status-grid {
1312
      display: grid;
1313
      grid-template-columns:1fr 1fr;
1314
      gap: 18px
1315
    }
1316
 
1317
    .status-col {
1318
      border: 1px solid var(--line);
1319
      border-radius: 12px;
1320
      padding: 14px 16px;
1321
      background: #fbfcfe
1322
    }
1323
 
1324
    .status-col.good {
1325
      border-color: #c3e8d0;
1326
      background: #f4fbf6
1327
    }
1328
 
1329
    .status-col.bad {
1330
      border-color: #f2c4c4;
1331
      background: #fdf5f5
1332
    }
1333
 
1334
    .status-col h4 {
1335
      margin: 0 0 10px;
1336
      font-size: 13px;
1337
      font-weight: 730;
1338
      display: flex;
1339
      align-items: center;
1340
      gap: 8px;
1341
      letter-spacing: -.005em
1342
    }
1343
 
1344
    .status-col h4 .cnt {
1345
      background: #fff;
1346
      border: 1px solid var(--line);
1347
      color: var(--ink);
1348
      font-size: 11px;
1349
      font-weight: 700;
1350
      padding: 2px 9px;
1351
      border-radius: 999px
1352
    }
1353
 
1354
    .status-col.good h4 {
1355
      color: #177a3a
1356
    }
1357
 
1358
    .status-col.good h4 .cnt {
1359
      background: #e5f7ee;
1360
      border-color: #c3e8d0;
1361
      color: #177a3a
1362
    }
1363
 
1364
    .status-col.bad h4 {
1365
      color: #b8272b
1366
    }
1367
 
1368
    .status-col.bad h4 .cnt {
1369
      background: #ffeaea;
1370
      border-color: #f2c4c4;
1371
      color: #b8272b
1372
    }
1373
 
1374
    .status-list {
1375
      display: flex;
1376
      flex-direction: column;
1377
      gap: 6px;
1378
      max-height: 60vh;
1379
      overflow-y: auto;
1380
      padding-right: 4px
1381
    }
1382
 
1383
    .status-item {
1384
      display: grid;
1385
      grid-template-columns:1fr 100px 68px;
1386
      gap: 10px;
1387
      align-items: center;
1388
      padding: 9px 12px;
1389
      background: #fff;
1390
      border: 1px solid var(--line2);
1391
      border-radius: 9px;
1392
      transition: box-shadow .12s
1393
    }
1394
 
1395
    .status-item:hover {
1396
      box-shadow: 0 2px 8px rgba(20, 30, 60, .06)
1397
    }
1398
 
1399
    .status-item .rn {
1400
      font-weight: 700;
1401
      color: var(--ink);
1402
      font-size: 12.5px;
1403
      line-height: 1.3
1404
    }
1405
 
1406
    .status-item .wh {
1407
      font-size: 11px;
1408
      color: var(--muted);
1409
      font-weight: 600;
1410
      display: block;
1411
      margin-top: 2px
1412
    }
1413
 
1414
    .status-item .vv {
1415
      font-size: 12px;
1416
      color: var(--muted);
1417
      font-variant-numeric: tabular-nums;
1418
      font-weight: 600;
1419
      text-align: right;
1420
      white-space: nowrap
1421
    }
1422
 
1423
    .status-item .vv b {
1424
      color: var(--ink);
1425
      font-weight: 700
1426
    }
1427
 
1428
    .status-item .pp {
1429
      font-size: 12px;
1430
      font-weight: 700;
1431
      font-variant-numeric: tabular-nums;
1432
      text-align: right
1433
    }
1434
 
1435
    .status-item .pp.good {
1436
      color: var(--good)
1437
    }
1438
 
1439
    .status-item .pp.warn {
1440
      color: var(--warn)
1441
    }
1442
 
1443
    .status-item .pp.bad {
1444
      color: var(--bad)
1445
    }
1446
 
1447
    .status-empty {
1448
      padding: 24px;
1449
      text-align: center;
1450
      color: var(--soft);
1451
      font-size: 12.5px
1452
    }
1453
 
37460 ranu 1454
    /* extras: aging + partner-billing tables */
1455
    .xtable {
1456
      width: 100%;
1457
      border-collapse: separate;
1458
      border-spacing: 0;
1459
      font-size: 13px
1460
    }
1461
 
1462
    .xtable th {
1463
      font-size: 10.5px;
1464
      text-transform: uppercase;
1465
      letter-spacing: .06em;
1466
      color: var(--soft);
1467
      font-weight: 700;
1468
      white-space: nowrap;
1469
      padding: 10px 10px;
1470
      border-bottom: 1px solid var(--line);
1471
      text-align: left;
1472
      background: #fff
1473
    }
1474
 
1475
    .xtable th.num {
1476
      text-align: right
1477
    }
1478
 
1479
    .xtable td {
1480
      padding: 10px;
1481
      border-bottom: 1px solid var(--line2);
1482
      color: var(--ink);
1483
      font-weight: 500
1484
    }
1485
 
1486
    .xtable td.num {
1487
      text-align: right;
1488
      font-variant-numeric: tabular-nums;
1489
      font-weight: 650
1490
    }
1491
 
1492
    .xtable tbody tr:hover {
1493
      background: #f6f8fd
1494
    }
1495
 
1496
    .xtable .rbm-nm {
1497
      font-weight: 700;
1498
      color: var(--ink)
1499
    }
1500
 
1501
    .xtable tr.tot td {
1502
      font-weight: 770;
1503
      background: #fafbfe;
1504
      border-top: 2px solid var(--line);
1505
      color: var(--ink)
1506
    }
1507
 
1508
    .xtable tr.bal td {
1509
      font-weight: 700;
1510
      background: #fffbf2;
1511
      border-top: 1px dashed #f0d68a;
1512
      color: #7a5a00
1513
    }
1514
 
1515
    .xtable tr.bal td.hdr {
1516
      font-weight: 770
1517
    }
1518
 
1519
    .xtable td.g-hid {
1520
      border-left: 2px solid transparent
1521
    }
1522
 
1523
    /* placeholder for future column tint */
1524
    .xtable th.g-hid, .xtable td.g-hid {
1525
      color: var(--hid)
1526
    }
1527
 
1528
    .xtable th.g-fast, .xtable td.g-fast {
1529
      color: var(--fast)
1530
    }
1531
 
1532
    .xtable th.g-run, .xtable td.g-run {
1533
      color: var(--run)
1534
    }
1535
 
1536
    .xtable th.g-slow, .xtable td.g-slow {
1537
      color: var(--slow)
1538
    }
1539
 
1540
    .xtable th.g-other, .xtable td.g-other {
1541
      color: var(--other)
1542
    }
1543
 
1544
    .xtable th.g-total, .xtable td.g-total {
1545
      color: var(--brand);
1546
      font-weight: 700
1547
    }
1548
 
1549
    .xtable td.g-hid, .xtable td.g-fast, .xtable td.g-run, .xtable td.g-slow, .xtable td.g-other {
1550
      opacity: .95
1551
    }
1552
 
1553
    .xtable td.zero {
1554
      color: var(--soft);
1555
      font-weight: 500
1556
    }
1557
 
1558
    .xtable .cnt-pill {
1559
      display: inline-block;
1560
      min-width: 32px;
1561
      padding: 2px 8px;
1562
      border-radius: 6px;
1563
      font-size: 11.5px;
1564
      font-weight: 700;
1565
      font-variant-numeric: tabular-nums;
1566
      background: #eef2ff;
1567
      color: var(--brand)
1568
    }
1569
 
1570
    .xtable .cnt-pill.zero {
1571
      background: #f1f3f9;
1572
      color: var(--soft)
1573
    }
1574
 
1575
    .xtable .cnt-pill.warn {
1576
      background: #fff0e0;
1577
      color: #a04600
1578
    }
1579
 
1580
    .xtable .cnt-pill.good {
1581
      background: #e5f7ee;
1582
      color: #177a3a
1583
    }
1584
 
37468 ranu 1585
    /* rbm performance dashboard (extracted from today_po_rbm) */
1586
    #rdrrPerfWrap {
1587
      overflow-x: auto
1588
    }
1589
 
1590
    #rdrrPerfWrap table {
1591
      width: 100%;
1592
      border-collapse: separate;
1593
      border-spacing: 0;
1594
      font-size: 12.5px;
1595
      background: #fff
1596
    }
1597
 
1598
    #rdrrPerfWrap table th, #rdrrPerfWrap table td {
1599
      padding: 9px 10px;
1600
      text-align: center;
1601
      vertical-align: middle;
1602
      border-bottom: 1px solid var(--line2);
1603
      color: var(--ink);
1604
      font-weight: 500
1605
    }
1606
 
1607
    #rdrrPerfWrap table thead th {
1608
      font-size: 10.5px;
1609
      text-transform: uppercase;
1610
      letter-spacing: .05em;
1611
      font-weight: 700;
1612
      background: #1d2433;
1613
      color: #fff;
1614
      border-bottom: 0;
1615
      padding: 10px 8px;
1616
      line-height: 1.2
1617
    }
1618
 
1619
    #rdrrPerfWrap table thead th small {
1620
      font-size: 9.5px;
1621
      color: rgba(255, 255, 255, .7);
1622
      font-weight: 600;
1623
      display: block;
1624
      margin-top: 2px
1625
    }
1626
 
1627
    /* per-column accent badges (keep original palette from today_po_rbm) */
1628
    #rdrrPerfWrap table thead th:nth-child(4) {
1629
      background: linear-gradient(180deg, #40c057, #2f9e44)
1630
    }
1631
 
1632
    #rdrrPerfWrap table thead th:nth-child(5) {
1633
      background: linear-gradient(180deg, #22b8cf, #0e959f)
1634
    }
1635
 
1636
    #rdrrPerfWrap table thead th:nth-child(6) {
1637
      background: linear-gradient(180deg, #ffa94d, #e8590c)
1638
    }
1639
 
1640
    #rdrrPerfWrap table thead th:nth-child(7) {
1641
      background: linear-gradient(180deg, #9775fa, #7048e8)
1642
    }
1643
 
1644
    #rdrrPerfWrap table thead th:nth-child(8) {
1645
      background: linear-gradient(180deg, #ffd43b, #e8ac00);
1646
      color: #3a2500
1647
    }
1648
 
1649
    #rdrrPerfWrap table thead th:nth-child(8) small {
1650
      color: rgba(58, 37, 0, .75)
1651
    }
1652
 
1653
    #rdrrPerfWrap table thead th:nth-child(9) {
1654
      background: linear-gradient(180deg, #ff922b, #e8590c)
1655
    }
1656
 
1657
    #rdrrPerfWrap table thead th:last-child {
1658
      background: linear-gradient(180deg, #ff6b6b, #e03131)
1659
    }
1660
 
1661
    #rdrrPerfWrap table tbody tr:hover {
1662
      background: #f6f8fd
1663
    }
1664
 
1665
    /* rank rows keep their original background tint from today_po_rbm inline style */
1666
    #rdrrPerfWrap table tbody tr td:nth-child(2) {
1667
      text-align: left;
1668
      font-weight: 700;
1669
      color: var(--ink)
1670
    }
1671
 
1672
    #rdrrPerfWrap table tbody tr td:first-child img {
1673
      width: 24px;
1674
      height: 24px
1675
    }
1676
 
1677
    #rdrrPerfWrap table tbody tr:first-child td {
1678
      font-weight: 700
1679
    }
1680
 
1681
    #rdrrPerfWrap table tbody tr td:last-child {
1682
      font-weight: 770;
1683
      font-size: 13.5px;
1684
      font-variant-numeric: tabular-nums
1685
    }
1686
 
1687
    /* purchase-milestones (brand × RBM) container — restyles the injected Bootstrap fragment */
1688
    #rdrrPmWrap {
1689
      overflow-x: auto
1690
    }
1691
 
1692
    #rdrrPmWrap table {
1693
      width: 100%;
1694
      border-collapse: separate;
1695
      border-spacing: 0;
1696
      font-size: 12.5px;
1697
      margin-bottom: 12px;
1698
      background: #fff
1699
    }
1700
 
1701
    #rdrrPmWrap table th, #rdrrPmWrap table td {
1702
      padding: 8px 8px;
1703
      border-bottom: 1px solid var(--line2);
1704
      border-right: 1px solid var(--line2);
1705
      text-align: right;
1706
      font-variant-numeric: tabular-nums;
1707
      color: var(--ink);
1708
      vertical-align: middle
1709
    }
1710
 
1711
    #rdrrPmWrap table th:first-child, #rdrrPmWrap table td:first-child {
1712
      text-align: left;
1713
      border-left: 1px solid var(--line2);
1714
      font-weight: 650;
1715
      position: sticky;
1716
      left: 0;
1717
      background: #fff;
1718
      z-index: 1;
1719
      min-width: 130px
1720
    }
1721
 
1722
    #rdrrPmWrap table thead th {
1723
      text-transform: uppercase;
1724
      letter-spacing: .04em;
1725
      font-size: 10.5px;
1726
      color: var(--soft);
1727
      font-weight: 700;
1728
      background: #fafbfe;
1729
      border-top: 1px solid var(--line);
1730
      border-bottom: 1px solid var(--line);
1731
      text-align: center
1732
    }
1733
 
1734
    #rdrrPmWrap table thead th[colspan] {
1735
      font-size: 12px;
1736
      padding: 8px 6px;
1737
      color: #fff
1738
    }
1739
 
1740
    #rdrrPmWrap table thead th p {
1741
      margin: 0;
1742
      font-size: 13px;
1743
      font-weight: 770;
1744
      letter-spacing: .01em;
1745
      line-height: 1.1
1746
    }
1747
 
1748
    #rdrrPmWrap table thead tr:first-child th:first-child {
1749
      background: #fafbfe;
1750
      color: var(--soft)
1751
    }
1752
 
1753
    #rdrrPmWrap table tbody tr:hover {
1754
      background: #f6f8fd
1755
    }
1756
 
1757
    #rdrrPmWrap table tbody tr:hover td:first-child {
1758
      background: #f6f8fd
1759
    }
1760
 
1761
    #rdrrPmWrap table tr.green td {
1762
      background: #eaf7ef !important;
1763
      font-weight: 770;
1764
      color: #177a3a
1765
    }
1766
 
1767
    #rdrrPmWrap table tr.green td:first-child {
1768
      background: #eaf7ef !important;
1769
      color: #177a3a
1770
    }
1771
 
1772
    /* known brand accents (extend as more brands appear) */
1773
    #rdrrPmWrap table thead th.vivo {
1774
      background: linear-gradient(180deg, #00baf2, #0a8fb5)
1775
    }
1776
 
1777
    #rdrrPmWrap table thead th.oppo {
1778
      background: linear-gradient(180deg, #20a558, #177a3a)
1779
    }
1780
 
1781
    #rdrrPmWrap table thead th.samsung {
1782
      background: linear-gradient(180deg, #0b3d91, #071e51)
1783
    }
1784
 
1785
    #rdrrPmWrap table thead th.alcatel {
1786
      background: linear-gradient(180deg, #5c7cfa, #3b5bdb)
1787
    }
1788
 
1789
    #rdrrPmWrap table thead th.motorola {
1790
      background: linear-gradient(180deg, #495057, #212529)
1791
    }
1792
 
1793
    #rdrrPmWrap table thead th.hmd {
1794
      background: linear-gradient(180deg, #7048e8, #5b34c9)
1795
    }
1796
 
1797
    #rdrrPmWrap table thead th.xiaomi {
1798
      background: linear-gradient(180deg, #ffa726, #e8590c)
1799
    }
1800
 
1801
    #rdrrPmWrap table thead th.lava {
1802
      background: linear-gradient(180deg, #e03131, #a11515)
1803
    }
1804
 
1805
    #rdrrPmWrap table thead th.poco {
1806
      background: linear-gradient(180deg, #ffd43b, #e8ac00);
1807
      color: #3a2500
1808
    }
1809
 
1810
    #rdrrPmWrap table thead th.realme {
1811
      background: linear-gradient(180deg, #f59f00, #e8590c)
1812
    }
1813
 
1814
    #rdrrPmWrap table thead th.apple {
1815
      background: linear-gradient(180deg, #495057, #141a2b)
1816
    }
1817
 
1818
    #rdrrPmWrap table thead th.oneplus {
1819
      background: linear-gradient(180deg, #e03131, #a11515)
1820
    }
1821
 
1822
    #rdrrPmWrap table thead th.tecno {
1823
      background: linear-gradient(180deg, #0ca678, #087a56)
1824
    }
1825
 
1826
    #rdrrPmWrap table thead th.ai + {
1827
      background: linear-gradient(180deg, #7048e8, #5b34c9)
1828
    }
1829
 
1830
    #rdrrPmWrap table thead th.total {
1831
      background: linear-gradient(180deg, #3b5bdb, #28449e)
1832
    }
1833
 
1834
    /* default gradient for any unmapped brand */
1835
    #rdrrPmWrap table thead th[colspan]:not(.vivo):not(.oppo):not(.samsung):not(.alcatel):not(.motorola):not(.hmd):not(.xiaomi):not(.lava):not(.poco):not(.realme):not(.apple):not(.oneplus):not(.tecno):not(.total) {
1836
      background: linear-gradient(180deg, var(--brand2), var(--brand))
1837
    }
1838
 
1839
    #rdrrPmWrap table td.currency {
1840
      font-weight: 600
1841
    }
1842
 
37444 ranu 1843
    @media (max-width: 960px) {
1844
      .kpis {
1845
        grid-template-columns:repeat(2, 1fr)
1846
      }
1847
 
1848
      .brand h1 {
1849
        font-size: 22px
1850
      }
1851
 
1852
      .status-grid {
1853
        grid-template-columns:1fr
1854
      }
1855
    }
1856
  </style>
1857
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css"/>
1858
</head>
1859
<body>
1860
<div class="wrap">
1861
  <header class="top">
1862
    <div class="brand">
1863
      <div class="crumb"><a href="/indent/today_po_rbm">&larr; Today PO / RBM</a> &middot; Sales &middot; Indent</div>
1864
      <h1>RBM DRR Dashboard <span class="live"><i></i>Live</span></h1>
1865
    </div>
1866
    <div class="hd-right">
1867
      <input class="ctl" id="rdrrPeriod" type="text" placeholder="Select date range"/>
1868
      <button class="btn-r" id="rdrrApply">Apply</button>
1869
    </div>
1870
  </header>
1871
 
1872
  <div class="kpis">
1873
    <div class="kpi a">
1874
      <div class="top">
1875
        <div class="ic">
1876
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"
1877
               stroke-linejoin="round">
1878
            <path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>
1879
          </svg>
1880
        </div>
1881
        <div class="label">Total Achieved</div>
1882
      </div>
1883
      <div class="val" id="rdrrKpiAch">&mdash;</div>
1884
      <div class="foot" id="rdrrKpiAchSub">Actual billed across all RBMs</div>
1885
    </div>
1886
    <div class="kpi b">
1887
      <div class="top">
1888
        <div class="ic">
1889
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"
1890
               stroke-linejoin="round">
1891
            <circle cx="12" cy="12" r="9"/>
1892
            <circle cx="12" cy="12" r="5"/>
1893
            <circle cx="12" cy="12" r="1.5" fill="currentColor"/>
1894
          </svg>
1895
        </div>
1896
        <div class="label">Total Target</div>
1897
      </div>
1898
      <div class="val" id="rdrrKpiTgt">&mdash;</div>
1899
      <div class="foot" id="rdrrKpiTgtSub">Sum of daily target snapshots</div>
1900
    </div>
1901
    <div class="kpi c">
1902
      <div class="top">
1903
        <div class="ic">
1904
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"
1905
               stroke-linejoin="round">
1906
            <path d="M3 17l6-6 4 4 8-8"/>
1907
            <path d="M17 7h4v4"/>
1908
          </svg>
1909
        </div>
1910
        <div class="label">Achievement %</div>
1911
      </div>
1912
      <div class="val" id="rdrrKpiPct">&mdash;</div>
1913
      <div class="foot" id="rdrrKpiPctSub">Total ACH / Total TGT</div>
1914
    </div>
1915
    <div class="kpi d clickable" id="rdrrKpiTopCard" title="Click to see achieved vs pending RBMs">
1916
      <div class="top">
1917
        <div class="ic">
1918
          <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"
1919
               stroke-linejoin="round">
1920
            <path d="M12 2l3 6.5 7 1-5 5 1.5 7L12 18l-6.5 3.5L7 14.5 2 9.5l7-1L12 2z"/>
1921
          </svg>
1922
        </div>
1923
        <div class="label">RBMs ≥ 100% Target</div>
1924
      </div>
1925
      <div class="val" id="rdrrKpiTop">&mdash;</div>
1926
      <div class="foot" id="rdrrKpiTopSub">Rows meeting or beating target</div>
1927
      <span class="hint">Click for list &rsaquo;</span>
1928
    </div>
1929
  </div>
1930
 
1931
  <div class="sectionlabel">RBM &times; Warehouse &times; Movement Bucket</div>
1932
  <div class="legend">
1933
    <span class="lg hid"><i></i><span class="lgt">HID</span></span>
1934
    <span class="lg fast"><i></i><span class="lgt">FAST</span></span>
1935
    <span class="lg run"><i></i><span class="lgt">RUN</span></span>
1936
    <span class="lg slow"><i></i><span class="lgt">SLOW</span></span>
1937
    <span class="lg other"><i></i><span class="lgt">OTHER</span></span>
1938
  </div>
1939
  <div class="card">
1940
    <div class="card-hd">
1941
      <div>
1942
        <h2>Achievement vs Target</h2>
1943
        <p class="desc">Click any row for a per-bucket breakdown and the catalogs sold.</p>
1944
      </div>
1945
      <span class="badge-period" id="rdrrPeriodLabel">&mdash;</span>
1946
    </div>
1947
    <div id="rdrrTableWrap">
1948
      <div class="loading">
1949
        <div class="spinner"></div>
1950
        Loading&hellip;
1951
      </div>
1952
    </div>
1953
    <div class="foot-note">
1954
      <b>TGT</b> is summed from persisted per-day snapshots (<code>inventory.rbm_targets</code>) — days with no
1955
      scheduler-written snapshot contribute 0.
1956
      <b>ACH</b> is computed from source orders (<code>transaction.order</code>) for the range.
1957
    </div>
1958
  </div>
37460 ranu 1959
 
1960
  <!-- >15 Days Aging Sold -->
1961
  <div class="sectionlabel">&gt; 15 Days Aging Sold</div>
1962
  <div class="card">
1963
    <div class="card-hd">
1964
      <div>
1965
        <h2>Aging Inventory Cleared</h2>
1966
        <p class="desc">Billed value of items that were &gt; 15 days old at sale, per RBM, for the picked range.</p>
1967
      </div>
1968
      <span class="badge-period" id="rdrrAgingPeriod">&mdash;</span>
1969
    </div>
1970
    <div id="rdrrAgingWrap">
1971
      <div class="loading">
1972
        <div class="spinner"></div>
1973
        Loading&hellip;
1974
      </div>
1975
    </div>
1976
  </div>
1977
 
1978
  <!-- Partner Billing Count -->
1979
  <div class="sectionlabel">Partner Billing Count <span
1980
          style="color:var(--soft);font-weight:600;text-transform:none;letter-spacing:0;margin-left:6px">(Target: &gt;1L, Non-Target: &gt;20K)</span>
1981
  </div>
1982
  <div class="card">
1983
    <div class="card-hd">
1984
      <div>
1985
        <h2>Partners Who Billed This Month</h2>
1986
        <p class="desc">Counts partners meeting the billing threshold in each week bucket. Always month-to-date (weekly
1987
          buckets are inherently monthly).</p>
1988
      </div>
1989
      <span class="badge-period" id="rdrrBillingPeriod">&mdash;</span>
1990
    </div>
1991
    <div id="rdrrBillingWrap">
1992
      <div class="loading">
1993
        <div class="spinner"></div>
1994
        Loading&hellip;
1995
      </div>
1996
    </div>
1997
  </div>
37468 ranu 1998
 
1999
  <!-- RBM Performance Dashboard (MTD) — extracted from /indent/today_po_rbm without any backend change -->
2000
  <div class="sectionlabel">RBM Performance Dashboard (MTD)</div>
2001
  <div class="card">
2002
    <div class="card-hd">
2003
      <div>
2004
        <h2>Composite MTD Ranking</h2>
2005
        <p class="desc">Rank of RBMs by weighted score across Talk Time (10%) + MTD Achievement (55%) + Aging (2%) +
2006
          &gt;1L Partners (29%) + Rating (2%) + Partners Rated (2%).</p>
2007
      </div>
2008
      <span class="badge-period" id="rdrrPerfMonth">MTD</span>
2009
    </div>
2010
    <div id="rdrrPerfWrap">
2011
      <div class="loading">
2012
        <div class="spinner"></div>
2013
        Loading&hellip;
2014
      </div>
2015
    </div>
2016
  </div>
2017
 
2018
  <!-- RBM Call Target Summary — full interactive page embedded via iframe (no backend change) -->
2019
  <div class="sectionlabel">RBM Call Target Summary</div>
2020
  <div class="card">
2021
    <div class="card-hd">
2022
      <div>
2023
        <h2>Today's Call Coverage per RBM</h2>
2024
        <p class="desc">Full interactive view — all popups, drill-downs and downloads work exactly like the standalone
2025
          page.</p>
2026
      </div>
2027
      <a class="badge-period" href="/indent/rbm_call_target" target="_blank" style="text-decoration:none">Open in new
2028
        tab &rsaquo;</a>
2029
    </div>
2030
    <iframe id="rdrrCallFrame" src="/indent/rbm_call_target" title="RBM Call Target Summary"
2031
            style="width:100%;min-height:800px;border:0;border-radius:10px;background:#fff;display:block"></iframe>
2032
  </div>
2033
 
2034
  <!-- Today PO & Billed — Brand × RBM matrix (reuses /indent/today_po_table_fragment) -->
2035
  <div class="sectionlabel">Today PO &amp; Billed — Brand &times; RBM</div>
2036
  <div class="card">
2037
    <div class="card-hd">
2038
      <div>
2039
        <h2>Purchase Milestones by Brand</h2>
2040
        <p class="desc">Today's PO value / partner count / total billed, per RBM &times; brand. Always today
2041
          (independent of the range picker above).</p>
2042
      </div>
2043
      <select id="rdrrPmCategory" class="ctl" style="min-width:170px;height:34px;padding:6px 12px">
2044
        <option value="RBM">All RBMs</option>
2045
        <option value="NSM">All NSMs</option>
2046
        <option value="RSM">All RSMs</option>
2047
        <option value="BM">All BMs</option>
2048
        <option value="DM">All DMs</option>
2049
        <option value="CM">All CMs</option>
2050
        <option value="ASM">All ASMs</option>
2051
      </select>
2052
    </div>
2053
    <div id="rdrrPmWrap">
2054
      <div class="loading">
2055
        <div class="spinner"></div>
2056
        Loading&hellip;
2057
      </div>
2058
    </div>
2059
  </div>
37444 ranu 2060
</div>
2061
 
2062
<!-- achieved-vs-pending modal (opens from the RBMs ≥ 100% Target KPI card) -->
2063
<div class="status-back" id="rdrrStatusBack">
2064
  <div class="status-modal">
2065
    <button class="x" id="rdrrStatusClose" aria-label="Close">&times;</button>
2066
    <h3>Target Status by RBM</h3>
2067
    <p class="desc" id="rdrrStatusDesc">&mdash;</p>
2068
    <div class="status-grid">
2069
      <div class="status-col good">
2070
        <h4>✅ Achieved <span class="cnt" id="rdrrStatusAchCnt">0</span></h4>
2071
        <div class="status-list" id="rdrrStatusAchList"></div>
2072
      </div>
2073
      <div class="status-col bad">
2074
        <h4>⚠ Pending <span class="cnt" id="rdrrStatusPndCnt">0</span></h4>
2075
        <div class="status-list" id="rdrrStatusPndList"></div>
2076
      </div>
2077
    </div>
2078
  </div>
2079
</div>
2080
 
2081
<!-- drill-down panel -->
2082
<div class="rdrr-back" id="rdrrBack">
2083
  <div class="rdrr-panel">
2084
    <button class="x" id="rdrrClose" aria-label="Close">&times;</button>
2085
    <h3 id="rdrrDdTitle">&mdash;</h3>
2086
    <p class="desc" id="rdrrDdDesc">&mdash;</p>
2087
 
2088
    <div class="rdrr-total">
2089
      <div>
2090
        <div class="k">Achieved</div>
2091
        <div class="v" id="rdrrDdAch">&mdash;</div>
2092
      </div>
2093
      <div>
2094
        <div class="k">Target</div>
2095
        <div class="v" id="rdrrDdTgt">&mdash;</div>
2096
      </div>
2097
      <div>
2098
        <div class="k">Achievement</div>
2099
        <div class="v" id="rdrrDdPct">&mdash;</div>
2100
      </div>
2101
    </div>
2102
 
2103
    <div class="sectionlabel" style="margin-top:2px">Movement Split — Achievement vs Target</div>
2104
    <div class="bbars" id="rdrrDdBars"></div>
2105
 
2106
    <div class="sectionlabel">Brand Mix — Share of Achievement <span
2107
            style="color:var(--soft);font-weight:600;text-transform:none;letter-spacing:0;margin-left:6px">(click a brand for movement split)</span>
2108
    </div>
2109
    <div id="rdrrDdBrands">
2110
      <div class="loading">
2111
        <div class="spinner"></div>
2112
        Loading brand mix&hellip;
2113
      </div>
2114
    </div>
2115
  </div>
2116
</div>
2117
 
2118
<script src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
2119
<script src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
2120
<script src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
2121
<script>
2122
  (function () {
2123
    var DEFAULT_START = "$defaultStartDate";
2124
    var DEFAULT_END = "$defaultEndDate";
2125
 
2126
    // Prefer query-string range if the caller provided one (e.g. from today_po_rbm's date picker).
2127
    var url = new URL(window.location.href);
2128
    var qsStart = url.searchParams.get("startDate");
2129
    var qsEnd = url.searchParams.get("endDate");
2130
    var startDate = qsStart || DEFAULT_START;
2131
    var endDate = qsEnd || DEFAULT_END;
2132
 
2133
    function fmtDate(s) {
2134
      return moment(s).format("DD MMM");
2135
    }
2136
 
2137
    function fmtLakh(v) {
2138
      v = Number(v) || 0;
2139
      return (v / 100000).toFixed(1) + "L";
2140
    }
2141
 
2142
    function pctClass(p) {
2143
      if (p >= 95) return "good";
2144
      if (p >= 41) return "warn";
2145
      return "bad";
2146
    }
2147
 
2148
    function pctLabel(ach, tgt) {
2149
      if (!tgt || tgt <= 0) return {text: "-", cls: "na", num: null};
2150
      var p = (ach / tgt) * 100;
2151
      return {text: p.toFixed(1) + "%", cls: pctClass(p), num: p};
2152
    }
2153
 
2154
    function pctBarWidth(ach, tgt) {
2155
      if (!tgt || tgt <= 0) return 0;
2156
      return Math.min(100, (ach / tgt) * 100);
2157
    }
2158
 
2159
    // Initialise the range picker.
2160
    $("#rdrrPeriod").daterangepicker({
2161
      startDate: moment(startDate),
2162
      endDate: moment(endDate),
2163
      locale: {format: "YYYY-MM-DD", cancelLabel: "Clear"}
2164
    });
2165
    $("#rdrrPeriod").on("apply.daterangepicker", function (ev, picker) {
2166
      startDate = picker.startDate.format("YYYY-MM-DD");
2167
      endDate = picker.endDate.format("YYYY-MM-DD");
2168
    });
2169
 
2170
    // Defensive: read the picker's current state at click time in case
2171
    // the apply.daterangepicker event was swallowed for any reason.
2172
    $("#rdrrApply").on("click", function () {
2173
      var p = $("#rdrrPeriod").data("daterangepicker");
2174
      if (p) {
2175
        startDate = p.startDate.format("YYYY-MM-DD");
2176
        endDate = p.endDate.format("YYYY-MM-DD");
2177
      }
2178
      load();
2179
    });
2180
 
2181
    function load() {
2182
      $("#rdrrTableWrap").html('<div class="loading"><div class="spinner"></div>Loading&hellip;</div>');
37460 ranu 2183
      $("#rdrrAgingWrap").html('<div class="loading"><div class="spinner"></div>Loading&hellip;</div>');
2184
      $("#rdrrBillingWrap").html('<div class="loading"><div class="spinner"></div>Loading&hellip;</div>');
37444 ranu 2185
      $("#rdrrPeriodLabel").text(fmtDate(startDate) + " – " + fmtDate(endDate));
37460 ranu 2186
      $("#rdrrAgingPeriod").text(fmtDate(startDate) + " – " + fmtDate(endDate));
37444 ranu 2187
      fetch("/rbm-drr/data?startDate=" + startDate + "&endDate=" + endDate, {credentials: "same-origin"})
2188
              .then(function (r) {
2189
                return r.json().then(function (b) {
2190
                  return {ok: r.ok, body: b};
2191
                });
2192
              })
2193
              .then(function (res) {
2194
                if (!res.ok) {
2195
                  $("#rdrrTableWrap").html('<div class="empty">' + escapeHtml(res.body && res.body.error ? res.body.error : "Failed to load.") + '</div>');
2196
                  return;
2197
                }
2198
                render(res.body);
2199
              })
2200
              .catch(function (e) {
2201
                $("#rdrrTableWrap").html('<div class="empty">Failed to load: ' + (e && e.message ? e.message : "network error") + '</div>');
2202
              });
37460 ranu 2203
 
2204
      fetch("/rbm-drr/extras?startDate=" + startDate + "&endDate=" + endDate, {credentials: "same-origin"})
2205
              .then(function (r) {
2206
                return r.json().then(function (b) {
2207
                  return {ok: r.ok, body: b};
2208
                });
2209
              })
2210
              .then(function (res) {
2211
                if (!res.ok) {
2212
                  var msg = '<div class="empty">' + escapeHtml(res.body && res.body.error ? res.body.error : "Failed to load.") + '</div>';
2213
                  $("#rdrrAgingWrap").html(msg);
2214
                  $("#rdrrBillingWrap").html(msg);
2215
                  return;
2216
                }
2217
                renderAging(res.body);
2218
                renderPartnerBilling(res.body);
2219
              })
2220
              .catch(function (e) {
2221
                var msg = '<div class="empty">Failed to load: ' + (e && e.message ? e.message : "network error") + '</div>';
2222
                $("#rdrrAgingWrap").html(msg);
2223
                $("#rdrrBillingWrap").html(msg);
2224
              });
37444 ranu 2225
    }
2226
 
37460 ranu 2227
    function renderAging(data) {
2228
      var rows = data.aging || [];
2229
      var totals = data.agingTotals || {};
2230
      var balance = data.balance || {};
2231
      if (rows.length === 0) {
2232
        $("#rdrrAgingWrap").html('<div class="empty"><div class="ei">📦</div>No aging inventory sold in this range.</div>');
2233
        return;
2234
      }
2235
      var html = ['<table class="xtable"><thead><tr>',
2236
        '<th>RBM</th>',
2237
        '<th class="num g-hid">HID</th>',
2238
        '<th class="num g-fast">FAST</th>',
2239
        '<th class="num g-run">RUN</th>',
2240
        '<th class="num g-slow">SLOW</th>',
2241
        '<th class="num g-other">OTHER</th>',
2242
        '<th class="num g-total">TOTAL</th>',
2243
        '</tr></thead><tbody>'];
2244
      rows.forEach(function (r) {
2245
        html.push('<tr>' +
2246
                '<td class="rbm-nm">' + escapeHtml(r.rbmName || '-') + '</td>' +
2247
                cell(r.hid, 'g-hid') + cell(r.fast, 'g-fast') + cell(r.run, 'g-run') +
2248
                cell(r.slow, 'g-slow') + cell(r.other, 'g-other') + cell(r.total, 'g-total') +
2249
                '</tr>');
2250
      });
2251
      html.push('<tr class="tot">' +
2252
              '<td>Total</td>' +
2253
              cell(totals.hid, 'g-hid') + cell(totals.fast, 'g-fast') + cell(totals.run, 'g-run') +
2254
              cell(totals.slow, 'g-slow') + cell(totals.other, 'g-other') + cell(totals.total, 'g-total') +
2255
              '</tr>');
2256
      html.push('<tr class="bal">' +
2257
              '<td class="hdr">15-Day Balance Value</td>' +
2258
              cell(balance.hid) + cell(balance.fast) + cell(balance.run) +
2259
              cell(balance.slow) + cell(balance.other) + cell(balance.total) +
2260
              '</tr>');
2261
      html.push('</tbody></table>');
2262
      $("#rdrrAgingWrap").html(html.join(""));
2263
    }
2264
 
2265
    function cell(v, cls) {
2266
      v = Number(v) || 0;
2267
      var zero = v === 0 ? ' zero' : '';
2268
      var extra = cls ? ' ' + cls : '';
2269
      return '<td class="num' + extra + zero + '">' + formatIndian(v) + '</td>';
2270
    }
2271
 
2272
    function formatIndian(n) {
2273
      n = Math.round(Number(n) || 0);
2274
      if (n === 0) return '0';
2275
      var s = n.toString();
2276
      var lastThree = s.substring(s.length - 3);
2277
      var otherNums = s.substring(0, s.length - 3);
2278
      if (otherNums !== '') lastThree = ',' + lastThree;
2279
      return otherNums.replace(/\B(?=(\d{2})+(?!\d))/g, ',') + lastThree;
2280
    }
2281
 
2282
    function renderPartnerBilling(data) {
2283
      var rows = data.partnerBilling || [];
2284
      var totals = data.partnerBillingTotals || {};
2285
      $("#rdrrBillingPeriod").text(data.partnerBillingMonth || '');
2286
      if (rows.length === 0) {
2287
        $("#rdrrBillingWrap").html('<div class="empty"><div class="ei">👥</div>No targeted partners this month.</div>');
2288
        return;
2289
      }
2290
      var html = ['<table class="xtable"><thead><tr>',
2291
        '<th>RBM</th>',
2292
        '<th class="num">Targeted</th>',
2293
        '<th class="num">Week 1<br><small style="color:var(--soft);font-weight:600">(1–7)</small></th>',
2294
        '<th class="num">Week 2<br><small style="color:var(--soft);font-weight:600">(8–15)</small></th>',
2295
        '<th class="num">Week 3<br><small style="color:var(--soft);font-weight:600">(16–22)</small></th>',
2296
        '<th class="num">Week 4<br><small style="color:var(--soft);font-weight:600">(23–end)</small></th>',
2297
        '<th class="num g-total">MTD</th>',
2298
        '<th class="num">Zero Billed<br><small style="color:var(--soft);font-weight:600">(&lt;1L / &lt;20K)</small></th>',
2299
        '</tr></thead><tbody>'];
2300
      rows.forEach(function (r) {
2301
        html.push('<tr>' +
2302
                '<td class="rbm-nm">' + escapeHtml(r.rbmName || '-') + '</td>' +
2303
                '<td class="num">' + pill(r.targeted, '') + '</td>' +
2304
                '<td class="num">' + pill(r.w1, ratio(r.w1, r.targeted)) + '</td>' +
2305
                '<td class="num">' + pill(r.w2, ratio(r.w2, r.targeted)) + '</td>' +
2306
                '<td class="num">' + pill(r.w3, ratio(r.w3, r.targeted)) + '</td>' +
2307
                '<td class="num">' + pill(r.w4, ratio(r.w4, r.targeted)) + '</td>' +
2308
                '<td class="num g-total">' + pill(r.mtd, ratio(r.mtd, r.targeted)) + '</td>' +
2309
                '<td class="num">' + pill(r.zero, r.zero > 0 ? 'warn' : 'zero') + '</td>' +
2310
                '</tr>');
2311
      });
2312
      html.push('<tr class="tot">' +
2313
              '<td>Total</td>' +
2314
              '<td class="num">' + formatIndian(totals.targeted) + '</td>' +
2315
              '<td class="num">' + formatIndian(totals.w1) + '</td>' +
2316
              '<td class="num">' + formatIndian(totals.w2) + '</td>' +
2317
              '<td class="num">' + formatIndian(totals.w3) + '</td>' +
2318
              '<td class="num">' + formatIndian(totals.w4) + '</td>' +
2319
              '<td class="num g-total">' + formatIndian(totals.mtd) + '</td>' +
2320
              '<td class="num">' + formatIndian(totals.zero) + '</td>' +
2321
              '</tr>');
2322
      html.push('</tbody></table>');
2323
      $("#rdrrBillingWrap").html(html.join(""));
2324
    }
2325
 
2326
    function pill(v, cls) {
2327
      v = Number(v) || 0;
2328
      var c = cls || (v === 0 ? 'zero' : '');
2329
      return '<span class="cnt-pill ' + c + '">' + formatIndian(v) + '</span>';
2330
    }
2331
 
2332
    function ratio(part, total) {
2333
      part = Number(part) || 0;
2334
      total = Number(total) || 0;
2335
      if (total === 0) return 'zero';
2336
      var p = (part / total) * 100;
2337
      if (p >= 60) return 'good';
2338
      if (p >= 30) return '';
2339
      if (p > 0) return 'warn';
2340
      return 'zero';
2341
    }
2342
 
37444 ranu 2343
    // Cached latest payload so the "Target Status by RBM" modal can render
2344
    // without a re-fetch when the KPI card is clicked.
2345
    var LAST_PAYLOAD = null;
2346
 
2347
    function render(data) {
2348
      LAST_PAYLOAD = data;
2349
      var rows = data.rows || [];
2350
      var t = data.totals || {};
2351
 
2352
      $("#rdrrKpiAch").html('&#8377;&nbsp;' + fmtLakh(t.totalAch));
2353
      $("#rdrrKpiTgt").html('&#8377;&nbsp;' + fmtLakh(t.totalTgt));
2354
      var pk = pctLabel(t.totalAch, t.totalTgt);
2355
      $("#rdrrKpiPct").html(pk.cls === "na" ? '<span class="u">n/a</span>' :
2356
              '<span class="pct ' + pk.cls + '">' + pk.text + '</span>');
2357
      $("#rdrrKpiTop").html((t.rbmsAtOrAbove100 || 0) + ' <span class="u">/ ' + (t.rbmRowCount || 0) + '</span>');
2358
 
2359
      if (rows.length === 0) {
2360
        $("#rdrrTableWrap").html('<div class="empty"><div class="ei">📭</div>No RBM rows in this range.</div>');
2361
        return;
2362
      }
2363
 
2364
      var buckets = [
2365
        {key: "hid", label: "HID"},
2366
        {key: "fast", label: "FAST"},
2367
        {key: "run", label: "RUN"},
2368
        {key: "slow", label: "SLOW"},
2369
        {key: "other", label: "OTHER"}
2370
      ];
2371
 
2372
      var html = ['<table id="rdrrGrid"><thead><tr>',
2373
        '<th>RBM &middot; Warehouse</th>',
2374
        '<th class="num g-total">Total<br><small style="color:var(--soft);font-weight:600">ACH / TGT</small></th>',
2375
        '<th class="num g-total">%</th>'];
2376
      buckets.forEach(function (b) {
2377
        html.push('<th class="num g-' + b.key + '">' + b.label + '<br><small style="color:var(--soft);font-weight:600">ACH / TGT</small></th>');
2378
        html.push('<th class="num g-' + b.key + '">%</th>');
2379
      });
2380
      html.push('<th></th></tr></thead><tbody>');
2381
 
2382
      rows.forEach(function (r) {
2383
        var tr = ['<tr class="clickable" data-authid="' + r.authId + '" data-warehouseid="' + r.warehouseId + '" data-rbmname="' + escapeHtml(r.rbmName) + '" data-warehousename="' + escapeHtml(r.warehouseName) + '">'];
2384
        tr.push('<td><div class="rbm-cell"><span class="rn">' + escapeHtml(r.rbmName) + '</span><span class="wh">' + escapeHtml(r.warehouseName) + '</span></div></td>');
2385
        tr.push(cellPair(r.totalAch, r.totalTgt));
2386
        buckets.forEach(function (b) {
2387
          tr.push(cellPair(r[b.key + "Ach"], r[b.key + "Tgt"]));
2388
        });
2389
        tr.push('<td class="chev">&rsaquo;</td>');
2390
        tr.push('</tr>');
2391
        html.push(tr.join(""));
2392
      });
2393
 
2394
      // totals row
2395
      var totTr = ['<tr class="totalrow"><td><strong>Total</strong></td>'];
2396
      totTr.push(cellPair(t.totalAch, t.totalTgt, true));
2397
      buckets.forEach(function (b) {
2398
        totTr.push(cellPair(t[b.key + "Ach"], t[b.key + "Tgt"], true));
2399
      });
2400
      totTr.push('<td></td></tr>');
2401
      html.push(totTr.join(""));
2402
 
2403
      html.push('</tbody></table>');
2404
      $("#rdrrTableWrap").html(html.join(""));
2405
 
2406
      // Cache the parsed row on each <tr> so drill-down can render bars immediately.
2407
      rows.forEach(function (r) {
2408
        $("#rdrrGrid tbody tr").filter(function () {
2409
          return +this.dataset.authid === r.authId && +this.dataset.warehouseid === r.warehouseId;
2410
        }).each(function () {
2411
          $(this).data("cached", r);
2412
        });
2413
      });
2414
 
2415
      $("#rdrrGrid tbody tr.clickable").on("click", function () {
2416
        var d = this.dataset;
2417
        var cached = $(this).data("cached");
2418
        openDrilldown(+d.authid, +d.warehouseid, d.rbmname, d.warehousename, cached);
2419
      });
2420
    }
2421
 
2422
    function cellPair(ach, tgt, isTotal) {
2423
      var p = pctLabel(ach, tgt);
2424
      var vhtml = '<td class="num"><div class="cell-val">' + fmtLakh(ach) + ' <small>/ ' + fmtLakh(tgt) + '</small></div></td>';
2425
      var barCls = p.cls === "na" ? "" : p.cls;
2426
      var barW = pctBarWidth(ach, tgt);
2427
      var pctHtml = '<td class="num"><span class="pct ' + p.cls + '">' + p.text + '</span>' +
2428
              (barCls ? '<div class="bar"><i class="' + barCls + '" style="width:' + barW.toFixed(1) + '%"></i></div>' : '') +
2429
              '</td>';
2430
      return vhtml + pctHtml;
2431
    }
2432
 
2433
    // --------------------------- drill-down ---------------------------
2434
 
2435
    function openDrilldown(authId, warehouseId, rbmName, warehouseName, cachedRow) {
2436
      var back = $("#rdrrBack");
2437
      $("#rdrrDdTitle").text(rbmName + " — " + warehouseName);
2438
      $("#rdrrDdDesc").text(fmtDate(startDate) + " – " + fmtDate(endDate));
2439
      $("#rdrrDdBars").empty();
2440
      back.addClass("show");
2441
 
2442
      if (cachedRow) {
2443
        renderBars(cachedRow);
2444
      } else {
2445
        $("#rdrrDdAch").text("—");
2446
        $("#rdrrDdTgt").text("—");
2447
        $("#rdrrDdPct").text("—");
2448
      }
2449
      $("#rdrrDdBrands").html('<div class="loading"><div class="spinner"></div>Loading brand mix&hellip;</div>');
2450
 
2451
      fetch("/rbm-drr/rbm-detail?authId=" + authId + "&warehouseId=" + warehouseId +
2452
              "&startDate=" + startDate + "&endDate=" + endDate, {credentials: "same-origin"})
2453
              .then(function (r) {
2454
                return r.json();
2455
              })
2456
              .then(function (data) {
2457
                renderBrands(data);
2458
              })
2459
              .catch(function (e) {
2460
                $("#rdrrDdBrands").html('<div class="empty">Failed to load: ' + (e && e.message ? e.message : "network error") + '</div>');
2461
              });
2462
    }
2463
 
2464
    function renderBrands(data) {
2465
      var brands = (data && data.brands) || [];
2466
      if (brands.length === 0) {
2467
        $("#rdrrDdBrands").html('<div class="empty"><div class="ei">🏷️</div>No brand sales in this range.</div>');
2468
        return;
2469
      }
2470
      var maxShare = brands[0].sharePct || 0.001;
2471
      var html = '<div class="brands">';
2472
      brands.forEach(function (b, idx) {
2473
        var barW = maxShare > 0 ? Math.min(100, (b.sharePct / maxShare) * 100) : 0;
2474
        var topCls = idx === 0 ? ' top' : '';
37460 ranu 2475
        var pc = Number(b.partnerCount) || 0;
2476
        var pcCls = pc === 0 ? ' zero' : '';
2477
        var pcLabel = pc + (pc === 1 ? ' partner' : ' partners');
37444 ranu 2478
        html += '<div class="brand-card' + topCls + '" data-idx="' + idx + '">' +
2479
                '<div class="brand-head">' +
2480
                '<div class="cx">&rsaquo;</div>' +
2481
                '<div class="bn" title="' + escapeHtml(b.brand) + '">' + escapeHtml(b.brand) + '</div>' +
2482
                '<div class="btrack"><i style="width:' + barW.toFixed(1) + '%"></i></div>' +
37460 ranu 2483
                '<div class="bpc' + pcCls + '" title="Distinct partners of this RBM who billed ' + escapeHtml(b.brand) + ' in the range">' +
2484
                '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>' +
2485
                pcLabel +
2486
                '</div>' +
37444 ranu 2487
                '<div class="bval">' + fmtLakh(b.valueSold) + '</div>' +
2488
                '<div class="bshare">' + (b.sharePct || 0).toFixed(1) + '%</div>' +
2489
                '</div>' +
2490
                '<div class="brand-body">' +
2491
                '<div class="bhdr">Movement Split within ' + escapeHtml(b.brand) + '</div>' +
2492
                renderBrandBuckets(b.buckets || []) +
2493
                '</div>' +
2494
                '</div>';
2495
      });
2496
      html += '</div>';
2497
      $("#rdrrDdBrands").html(html);
2498
 
2499
      $("#rdrrDdBrands .brand-head").on("click", function () {
2500
        $(this).closest(".brand-card").toggleClass("open");
2501
      });
2502
    }
2503
 
2504
    function renderBrandBuckets(buckets) {
2505
      if (!buckets || buckets.length === 0) {
2506
        return '<div style="color:var(--soft);font-size:12px;padding:8px 4px">No movement split available.</div>';
2507
      }
2508
      var labels = {HID: "HID", FASTMOVING: "FAST", RUNNING: "RUN", SLOWMOVING: "SLOW", OTHER: "OTHER"};
2509
      var html = '<div class="mbars">';
2510
      buckets.forEach(function (bk) {
2511
        var cls = (bk.status || "OTHER").toLowerCase();
2512
        var label = labels[bk.status] || bk.status || "OTHER";
2513
        var sp = bk.sharePctOfBrand || 0;
2514
        var barW = Math.min(100, sp);
2515
        html += '<div class="mbar ' + cls + '">' +
2516
                '<div class="mname"><i></i>' + label + '</div>' +
2517
                '<div class="mtrack"><i style="width:' + barW.toFixed(1) + '%"></i></div>' +
2518
                '<div class="mval">' + fmtLakh(bk.valueSold) + '</div>' +
2519
                '<div class="mshare">' + sp.toFixed(1) + '%</div>' +
2520
                '</div>';
2521
      });
2522
      html += '</div>';
2523
      return html;
2524
    }
2525
 
2526
    function renderBars(row) {
2527
      var totalAch = row.totalAch, totalTgt = row.totalTgt;
2528
      $("#rdrrDdAch").html('&#8377;&nbsp;' + fmtLakh(totalAch));
2529
      $("#rdrrDdTgt").html('&#8377;&nbsp;' + fmtLakh(totalTgt));
2530
      var pt = pctLabel(totalAch, totalTgt);
2531
      $("#rdrrDdPct").html(pt.cls === "na" ? '<span style="color:var(--soft);font-size:14px">n/a</span>' :
2532
              '<span class="pct ' + pt.cls + '">' + pt.text + '</span>');
2533
 
2534
      var buckets = [
2535
        {key: "hid", label: "HID"},
2536
        {key: "fast", label: "FAST"},
2537
        {key: "run", label: "RUN"},
2538
        {key: "slow", label: "SLOW"},
2539
        {key: "other", label: "OTHER"}
2540
      ];
2541
      var html = "";
2542
      buckets.forEach(function (b) {
2543
        var ach = row[b.key + "Ach"], tgt = row[b.key + "Tgt"];
2544
        var p = pctLabel(ach, tgt);
2545
        var w = pctBarWidth(ach, tgt);
2546
        html += '<div class="bbar ' + b.key + '">' +
2547
                '<div class="bname"><i></i>' + b.label + '</div>' +
2548
                '<div class="btrack"><i style="width:' + w.toFixed(1) + '%"></i></div>' +
2549
                '<div class="btgt"><b>' + fmtLakh(ach) + '</b> / ' + fmtLakh(tgt) + '</div>' +
2550
                '<div class="bpct ' + p.cls + '">' + p.text + '</div>' +
2551
                '</div>';
2552
      });
2553
      $("#rdrrDdBars").html(html);
2554
    }
2555
 
2556
    function escapeHtml(s) {
2557
      if (s == null) return "";
2558
      return String(s).replace(/[&<>"']/g, function (c) {
2559
        return {"&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;"}[c];
2560
      });
2561
    }
2562
 
2563
    $("#rdrrClose").on("click", function () {
2564
      $("#rdrrBack").removeClass("show");
2565
    });
2566
    $("#rdrrBack").on("click", function (e) {
2567
      if (e.target === this) $(this).removeClass("show");
2568
    });
2569
 
2570
    // Target-status modal (achieved vs pending) — opens from the KPI card.
2571
    $("#rdrrKpiTopCard").on("click", function () {
2572
      openStatusModal();
2573
    });
2574
    $("#rdrrStatusClose").on("click", function () {
2575
      $("#rdrrStatusBack").removeClass("show");
2576
    });
2577
    $("#rdrrStatusBack").on("click", function (e) {
2578
      if (e.target === this) $(this).removeClass("show");
2579
    });
2580
 
2581
    function openStatusModal() {
2582
      if (!LAST_PAYLOAD) return;
2583
      var rows = (LAST_PAYLOAD.rows || []).slice();
2584
      var achieved = [], pending = [];
2585
      rows.forEach(function (r) {
2586
        if (!r.totalTgt || r.totalTgt <= 0) return;
2587
        var pct = (r.totalAch / r.totalTgt) * 100;
2588
        var enriched = {row: r, pct: pct};
2589
        if (r.totalAch >= r.totalTgt) achieved.push(enriched);
2590
        else pending.push(enriched);
2591
      });
2592
      achieved.sort(function (a, b) {
2593
        return b.pct - a.pct;
2594
      });
2595
      pending.sort(function (a, b) {
2596
        return a.pct - b.pct;
2597
      });
2598
 
2599
      $("#rdrrStatusDesc").text(fmtDate(startDate) + " – " + fmtDate(endDate));
2600
      $("#rdrrStatusAchCnt").text(achieved.length);
2601
      $("#rdrrStatusPndCnt").text(pending.length);
2602
      $("#rdrrStatusAchList").html(renderStatusList(achieved, "achieved"));
2603
      $("#rdrrStatusPndList").html(renderStatusList(pending, "pending"));
2604
      $("#rdrrStatusBack").addClass("show");
2605
 
2606
      // Bind click on each item to open the same drill-down slide-in.
2607
      $("#rdrrStatusBack .status-item").on("click", function () {
2608
        var d = this.dataset;
2609
        var cachedRow = null;
2610
        (LAST_PAYLOAD.rows || []).some(function (r) {
2611
          if (r.authId == d.authid && r.warehouseId == d.warehouseid) {
2612
            cachedRow = r;
2613
            return true;
2614
          }
2615
          return false;
2616
        });
2617
        $("#rdrrStatusBack").removeClass("show");
2618
        openDrilldown(+d.authid, +d.warehouseid, d.rbmname, d.warehousename, cachedRow);
2619
      });
2620
    }
2621
 
2622
    function renderStatusList(items, kind) {
2623
      if (items.length === 0) {
2624
        return '<div class="status-empty">' +
2625
                (kind === "achieved" ? "No RBM has met target in this range." : "All RBMs met target — nice!") +
2626
                '</div>';
2627
      }
2628
      var html = "";
2629
      items.forEach(function (it) {
2630
        var r = it.row;
2631
        var p = pctClass(it.pct);
2632
        html += '<div class="status-item" title="Click to view drill-down"' +
2633
                ' data-authid="' + r.authId + '" data-warehouseid="' + r.warehouseId + '"' +
2634
                ' data-rbmname="' + escapeHtml(r.rbmName) + '" data-warehousename="' + escapeHtml(r.warehouseName) + '"' +
2635
                ' style="cursor:pointer">' +
2636
                '<div><span class="rn">' + escapeHtml(r.rbmName) + '</span>' +
2637
                '<span class="wh">' + escapeHtml(r.warehouseName) + '</span></div>' +
2638
                '<div class="vv"><b>' + fmtLakh(r.totalAch) + '</b> / ' + fmtLakh(r.totalTgt) + '</div>' +
2639
                '<div class="pp ' + p + '">' + it.pct.toFixed(1) + '%</div>' +
2640
                '</div>';
2641
      });
2642
      return html;
2643
    }
2644
 
37468 ranu 2645
    // ------------------------- Today PO & Billed matrix -------------------------
2646
    // Reuses the existing /indent/today_po_table_fragment endpoint (unchanged).
2647
    // Injects the returned HTML and restyles it via #rdrrPmWrap CSS.
2648
    function loadPurchaseMilestones() {
2649
      var cat = $("#rdrrPmCategory").val() || "RBM";
2650
      $("#rdrrPmWrap").html('<div class="loading"><div class="spinner"></div>Loading&hellip;</div>');
2651
      $.ajax({
2652
        url: "/indent/today_po_table_fragment",
2653
        type: "GET",
2654
        data: {categoryType: cat},
2655
        success: function (html) {
2656
          $("#rdrrPmWrap").html(html);
2657
          $("#rdrrPmWrap .currency").each(function () {
2658
            var elem = $(this);
2659
            var n = parseInt(elem.text().replace(/[^\d.-]/g, ""), 10);
2660
            if (!isNaN(n)) elem.text(numberToIndianCurrency(n));
2661
          });
2662
        },
2663
        error: function () {
2664
          $("#rdrrPmWrap").html('<div class="empty">Failed to load purchase-milestones data.</div>');
2665
        }
2666
      });
2667
    }
2668
 
2669
    function numberToIndianCurrency(n) {
2670
      if (n === 0) return "0";
2671
      var s = n.toString();
2672
      var lastThree = s.substring(s.length - 3);
2673
      var other = s.substring(0, s.length - 3);
2674
      if (other !== "") lastThree = "," + lastThree;
2675
      return other.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree;
2676
    }
2677
 
2678
    $("#rdrrPmCategory").on("change", loadPurchaseMilestones);
2679
 
2680
    // ------------------------- RBM Performance Dashboard (MTD) -------------------------
2681
    // No dedicated backend endpoint exists — the perf-dashboard table is only rendered
2682
    // inline in /indent/today_po_rbm. We fetch that page and extract just the table.
2683
    // Trade-off: heavier request (server re-runs full page prep). Consider adding a
2684
    // /rbm-drr/performance fragment endpoint later if this becomes a hot path.
2685
    function loadPerformanceDashboard() {
2686
      $("#rdrrPerfWrap").html('<div class="loading"><div class="spinner"></div>Loading&hellip;</div>');
2687
      $.ajax({
2688
        url: "/indent/today_po_rbm",
2689
        type: "GET",
2690
        dataType: "html",
2691
        success: function (fullHtml) {
2692
          var doc = new DOMParser().parseFromString(fullHtml, "text/html");
2693
          var tbl = doc.querySelector("#performance-dashboard-table");
2694
          if (!tbl) {
2695
            $("#rdrrPerfWrap").html('<div class="empty"><div class="ei">📊</div>No performance dashboard data available yet.</div>');
2696
            return;
2697
          }
2698
          // Fix any relative image paths (e.g. king.png / trophy-cup.png) to be root-relative.
2699
          tbl.querySelectorAll("img").forEach(function (im) {
2700
            var src = im.getAttribute("src") || "";
2701
            if (src.indexOf("resources/") !== -1 && src.charAt(0) !== "/") {
2702
              im.setAttribute("src", "/" + src.replace(/^\.\.\/+/, ""));
2703
            }
2704
          });
2705
          $("#rdrrPerfWrap").empty().append(tbl);
2706
        },
2707
        error: function () {
2708
          $("#rdrrPerfWrap").html('<div class="empty">Failed to load performance dashboard.</div>');
2709
        }
2710
      });
2711
    }
2712
 
37444 ranu 2713
    // initial load
2714
    load();
37468 ranu 2715
    loadPurchaseMilestones();
2716
    loadPerformanceDashboard();
37444 ranu 2717
  })();
2718
</script>
2719
</body>
2720
</html>