: asapien/superpulse

commit 86c752aefebacbfe42d1c3f2aa9c4f599d604d2a
parent fe84180173e0a723d113638fc9f2019d673b1aaa
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Wed, 7 Oct 2026 17:24:34 +0530

Format frontend with oxfmt
8 files changed, 2110 insertions(+), 1424 deletions(-)
M
TVA-CONTROL.md
|
16
+++++++---------
M
index.html
|
240
++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
M
logs.css
|
942
+++++++++++++++++++++++++++++++++++++++----------------------------------------
M
logs.js
|
1077
++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
M
tests/tva-control.test.js
|
45
++++++++++++++++++++++++++++++---------------
M
tva-control-demo.html
|
403
+++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
M
tva-control.css
|
22
++++++++++++++++------
M
tva-control.js
|
789
++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
diff --git a/TVA-CONTROL.md b/TVA-CONTROL.md
@@ -14,14 +14,14 @@ The host page must load Chart.js before `tva-control.js`.
 ## Usage
 
 ```html
-<link rel="stylesheet" href="tva-control.css">
+<link rel="stylesheet" href="tva-control.css" />
 <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
 <script src="tva-control.js"></script>
 
 <div id="tva" class="tva-control-container"><canvas></canvas></div>
 <script>
   const tva = createTvaControl({
-    container: document.getElementById('tva'),
+    container: document.getElementById("tva"),
     data: {
       complaintsOpen: 0,
       invoiceActions: 2,

@@ -31,11 +31,11 @@ The host page must load Chart.js before `tva-control.js`.
       bpclDepositLakhs: 3,
       updatedAt: {
         // Example: force this parameter stale when its refresh window is 30 min.
-        bpclDepositLakhs: Date.now() - (31 * 60 * 1000)
+        bpclDepositLakhs: Date.now() - 31 * 60 * 1000,
       },
-      refillSpreadAreas: { 'KK NAGAR': 12, 'WEST MAMBALAM': 9 },
-      pendencyAreas: { 'KK NAGAR': 3.4, 'WEST MAMBALAM': 2.9 }
-    }
+      refillSpreadAreas: { "KK NAGAR": 12, "WEST MAMBALAM": 9 },
+      pendencyAreas: { "KK NAGAR": 3.4, "WEST MAMBALAM": 2.9 },
+    },
   });
 
   tva.update({ bpclDepositLakhs: 4 });

@@ -73,9 +73,7 @@ Per-level `glowColor`, `glowAlpha`, `glowRadius`, `glowBlur`, or `ambientGlow: f
 A warning level can pulse the control border when it is the highest active level:
 
 ```js
-warningLevels: [
-  { key: 'double-red', label: 'DOUBLE RED', priority: 3, borderBlink: true }
-]
+warningLevels: [{ key: "double-red", label: "DOUBLE RED", priority: 3, borderBlink: true }];
 ```
 
 Aliases `blinkBorder` and `borderAlert` are also accepted.
diff --git a/index.html b/index.html
@@ -1,112 +1,152 @@
-<!DOCTYPE html>
-<head>
-    <meta charset="utf-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+<!doctype html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Event Notifications</title>
-    <link rel="stylesheet" href="style.css">
-    <link rel="stylesheet" href="logs.css">
-    <link rel="stylesheet" href="tva-control.css">
+    <link rel="stylesheet" href="style.css" />
+    <link rel="stylesheet" href="logs.css" />
+    <link rel="stylesheet" href="tva-control.css" />
     <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
-<body>
-	<template id="custom-date">
-    <style>
+  </head>
+  <body>
+    <template id="custom-date">
+      <style>
         .date-p {
-            text-align: center;
-            width: fit-content;
-            line-height: 0.7em;
-            position: relative;
-            left: -6px;
+          text-align: center;
+          width: fit-content;
+          line-height: 0.7em;
+          position: relative;
+          left: -6px;
         }
-    </style>
-    <div class="date-p">
-        <p style="font-weight: 700;color: black;">23</p>
+      </style>
+      <div class="date-p">
+        <p style="font-weight: 700; color: black">23</p>
         <small>Aug</small>
-        <hr style="border: 1px solid black;">
-    </div>
-</template>
-	<script src="tva-control.js"></script>
-	<script src="logs.js"></script>
-	<div class="content">
-		<script src="gt.js"></script>
-        <header class="app-chart-header">
-            <div class="action-chart-container app-header-chart">
-                <button type="button" class="settings-button settings-icon-button" onclick="openLogsSettings()" aria-haspopup="dialog" aria-label="Settings" title="Settings">⚙</button>
-                <canvas id="tvaReactiveChart" aria-label="Action required baseline monitor"></canvas>
-            </div>
-        </header>
-        <dialog id="logs-settings-dialog" class="settings-dialog">
-            <form method="dialog" class="settings-card">
-                <h2>Settings</h2>
-                <label>Theme
-                    <select id="settings-theme" class="filter-select">
-                        <option value="auto">Auto</option>
-                        <option value="light">Light</option>
-                        <option value="dark">Dark</option>
-                    </select>
-                </label>
-                <label class="settings-checkbox">
-                    <input type="checkbox" id="settings-ambient-glow">
-                    TVA ambient warning glow
-                </label>
-                <menu>
-                    <button type="button" onclick="closeLogsSettings()">Cancel</button>
-                    <button type="button" onclick="saveLogsSettings()">Save</button>
-                </menu>
-            </form>
-        </dialog>
-        <div popover="auto" id="device-info-popover">
-            <div class="device-popover-container">
-                <strong id="p-name"></strong>
-                <p>with <span style="border-radius: 4px; font-weight: 600;" id="p-assigned-to"></span></p>
-                <table style="border: 0px;">
-                    <tbody>
-                        <tr><th>Serial</th><td td id="p-serial"></td></tr>
-                        <tr><th>Notes</th><td td id="p-notes"></td></tr>
-                    </tbody>
-                </table>
-                <img class="device-popover-image" id="p-image" src="" >
-            </div>
+        <hr style="border: 1px solid black" />
+      </div>
+    </template>
+    <script src="tva-control.js"></script>
+    <script src="logs.js"></script>
+    <div class="content">
+      <script src="gt.js"></script>
+      <header class="app-chart-header">
+        <div class="action-chart-container app-header-chart">
+          <button
+            type="button"
+            class="settings-button settings-icon-button"
+            onclick="openLogsSettings()"
+            aria-haspopup="dialog"
+            aria-label="Settings"
+            title="Settings"
+          >
+            ⚙
+          </button>
+          <canvas id="tvaReactiveChart" aria-label="Action required baseline monitor"></canvas>
         </div>
-		<!--<p>(Displaying OTP from the last 5 hours only)</p>-->
-        <!-- From/to range controls query kidang with fromTimestamp/toTimestamp. -->
-        <div class="mobile-panel-switch" aria-label="Choose log panel">
-            <button type="button" class="active" data-target-segment="1" onclick="showMobileSegment(1)">Events</button>
-            <button type="button" data-target-segment="2" onclick="showMobileSegment(2)">Action Required</button>
+      </header>
+      <dialog id="logs-settings-dialog" class="settings-dialog">
+        <form method="dialog" class="settings-card">
+          <h2>Settings</h2>
+          <label
+            >Theme
+            <select id="settings-theme" class="filter-select">
+              <option value="auto">Auto</option>
+              <option value="light">Light</option>
+              <option value="dark">Dark</option>
+            </select>
+          </label>
+          <label class="settings-checkbox">
+            <input type="checkbox" id="settings-ambient-glow" />
+            TVA ambient warning glow
+          </label>
+          <menu>
+            <button type="button" onclick="closeLogsSettings()">Cancel</button>
+            <button type="button" onclick="saveLogsSettings()">Save</button>
+          </menu>
+        </form>
+      </dialog>
+      <div popover="auto" id="device-info-popover">
+        <div class="device-popover-container">
+          <strong id="p-name"></strong>
+          <p>with <span style="border-radius: 4px; font-weight: 600" id="p-assigned-to"></span></p>
+          <table style="border: 0px">
+            <tbody>
+              <tr>
+                <th>Serial</th>
+                <td td id="p-serial"></td>
+              </tr>
+              <tr>
+                <th>Notes</th>
+                <td td id="p-notes"></td>
+              </tr>
+            </tbody>
+          </table>
+          <img class="device-popover-image" id="p-image" src="" />
         </div>
-        <div class="segment-container">
-            <div data-segment=1 class="segment active">
-                <div class="log-filter-bar">
-                  <!-- Device Filter (Auto-populated by script) -->
-                  <select id="filter-device" onchange="applyFilters()" class="filter-select">
-                    <option value="">All Devices (mId)</option>
-                  </select>
-
-                  <!-- Category Filter -->
-                  <select id="filter-category" onchange="applyFilters()" class="filter-select">
-                    <option value="">All Categories</option>
-                  </select>
+      </div>
+      <!--<p>(Displaying OTP from the last 5 hours only)</p>-->
+      <!-- From/to range controls query kidang with fromTimestamp/toTimestamp. -->
+      <div class="mobile-panel-switch" aria-label="Choose log panel">
+        <button type="button" class="active" data-target-segment="1" onclick="showMobileSegment(1)">
+          Events
+        </button>
+        <button type="button" data-target-segment="2" onclick="showMobileSegment(2)">
+          Action Required
+        </button>
+      </div>
+      <div class="segment-container">
+        <div data-segment="1" class="segment active">
+          <div class="log-filter-bar">
+            <!-- Device Filter (Auto-populated by script) -->
+            <select id="filter-device" onchange="applyFilters()" class="filter-select">
+              <option value="">All Devices (mId)</option>
+            </select>
 
-                  <!-- Range Query Controls -->
-                  <label class="range-filter-label">From
-                    <input type="datetime-local" id="range-from" onchange="refreshRangeFeeds()" class="filter-select">
-                  </label>
-                  <input type="hidden" id="range-to">
+            <!-- Category Filter -->
+            <select id="filter-category" onchange="applyFilters()" class="filter-select">
+              <option value="">All Categories</option>
+            </select>
 
-                  <!-- Query Text Input Bar -->
-                  <input type="text" id="filter-search" placeholder="Type to search entries..." oninput="applyFilters()" class="filter-select" style="flex-grow: 1; min-width: 200px;">
-                </div>
-                <ul id="data-list"></ul>
-            </div>
-            <div data-segment=2 class="segment">
-                <div class="log-filter-bar">
+            <!-- Range Query Controls -->
+            <label class="range-filter-label"
+              >From
+              <input
+                type="datetime-local"
+                id="range-from"
+                onchange="refreshRangeFeeds()"
+                class="filter-select"
+              />
+            </label>
+            <input type="hidden" id="range-to" />
 
-                  <!-- Query Text Input Bar -->
-                  <input type="text" id="action-filter-search" placeholder="Type to search action required..." oninput="applyActionFilters()" class="filter-select" style="flex-grow: 1; min-width: 200px;">
-                </div>
-                <ul id="action-list" class="sticky-list"></ul>
-            </div>
+            <!-- Query Text Input Bar -->
+            <input
+              type="text"
+              id="filter-search"
+              placeholder="Type to search entries..."
+              oninput="applyFilters()"
+              class="filter-select"
+              style="flex-grow: 1; min-width: 200px"
+            />
+          </div>
+          <ul id="data-list"></ul>
+        </div>
+        <div data-segment="2" class="segment">
+          <div class="log-filter-bar">
+            <!-- Query Text Input Bar -->
+            <input
+              type="text"
+              id="action-filter-search"
+              placeholder="Type to search action required..."
+              oninput="applyActionFilters()"
+              class="filter-select"
+              style="flex-grow: 1; min-width: 200px"
+            />
+          </div>
+          <ul id="action-list" class="sticky-list"></ul>
         </div>
-	</div>
-</body>
+      </div>
+    </div>
+  </body>
 </html>
-
diff --git a/logs.css b/logs.css
@@ -1,335 +1,335 @@
-
 /* card – clean, elevated, with subtle border */
 .dispatch-card {
-    background: #ffffff;
-    border-radius: 28px;
-    padding: 1.8rem 2rem 2rem 2rem;
+  background: #ffffff;
+  border-radius: 28px;
+  padding: 1.8rem 2rem 2rem 2rem;
 }
 
-
 /* header: lorry + badge */
 .card-header {
-    display: flex;
-    align-items: center;
-    justify-content: space-between;
-    flex-wrap: wrap;
-    gap: 0.75rem 0.5rem;
-    border-bottom: 2px solid #f0f4f9;
-    padding-bottom: 1rem;
-    margin-bottom: 1.25rem;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  flex-wrap: wrap;
+  gap: 0.75rem 0.5rem;
+  border-bottom: 2px solid #f0f4f9;
+  padding-bottom: 1rem;
+  margin-bottom: 1.25rem;
 }
 
 .lorry-id {
-    display: flex;
-    align-items: center;
-    gap: 0.65rem;
-    font-size: 1.5rem;
-    font-weight: 700;
-    letter-spacing: -0.02em;
-    color: #0b1a26;
+  display: flex;
+  align-items: center;
+  gap: 0.65rem;
+  font-size: 1.5rem;
+  font-weight: 700;
+  letter-spacing: -0.02em;
+  color: #0b1a26;
 }
 
 .lorry-id i {
-    color: #1e5f8e;
-    font-size: 1.6rem;
-    width: 2rem;
-    text-align: center;
+  color: #1e5f8e;
+  font-size: 1.6rem;
+  width: 2rem;
+  text-align: center;
 }
 
 .lorry-plate {
-    background: #eef3f9;
-    padding: 0.25rem 1rem 0.25rem 0.9rem;
-    border-radius: 40px;
-    font-size: 1.3rem;
-    font-weight: 650;
-    color: #003057;
-    border: 1px solid #d0dce8;
-    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
-    letter-spacing: 0.5px;
+  background: #eef3f9;
+  padding: 0.25rem 1rem 0.25rem 0.9rem;
+  border-radius: 40px;
+  font-size: 1.3rem;
+  font-weight: 650;
+  color: #003057;
+  border: 1px solid #d0dce8;
+  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
+  letter-spacing: 0.5px;
 }
 
 .badge-status {
-    background: #d4e6f7;
-    color: #004b7c;
-    font-weight: 600;
-    font-size: 0.8rem;
-    padding: 0.3rem 1rem 0.3rem 0.9rem;
-    display: inline-flex;
-    align-items: center;
-    gap: 6px;
-    border: 1px solid #b8d1e9;
-    background: #e3effa;
-    letter-spacing: 0.3px;
-    white-space: nowrap;
+  background: #d4e6f7;
+  color: #004b7c;
+  font-weight: 600;
+  font-size: 0.8rem;
+  padding: 0.3rem 1rem 0.3rem 0.9rem;
+  display: inline-flex;
+  align-items: center;
+  gap: 6px;
+  border: 1px solid #b8d1e9;
+  background: #e3effa;
+  letter-spacing: 0.3px;
+  white-space: nowrap;
 }
 
 .badge-status i {
-    font-size: 0.75rem;
-    color: #0077be;
+  font-size: 0.75rem;
+  color: #0077be;
 }
 
 /* main content rows */
 .route-line {
-    display: flex;
-    flex-wrap: wrap;
-    align-items: baseline;
-    gap: 0.3rem 0.75rem;
-    font-size: 1rem;
-    padding: 0.6rem 1rem;
-    margin-bottom: 1rem;
+  display: flex;
+  flex-wrap: wrap;
+  align-items: baseline;
+  gap: 0.3rem 0.75rem;
+  font-size: 1rem;
+  padding: 0.6rem 1rem;
+  margin-bottom: 1rem;
 }
 
-.route-line .from, .route-line .to {
-    font-weight: 500;
-    color: #1f3a4b;
+.route-line .from,
+.route-line .to {
+  font-weight: 500;
+  color: #1f3a4b;
 }
 
-.route-line .from i, .route-line .to i {
-    margin-right: 0.3rem;
-    color: #3c6e8f;
-    width: 1.1rem;
+.route-line .from i,
+.route-line .to i {
+  margin-right: 0.3rem;
+  color: #3c6e8f;
+  width: 1.1rem;
 }
 
 .route-line .time {
-    font-weight: 600;
-    color: #003b66;
-    background: #e6edf5;
-    border-radius: 24px;
-    padding: 0.1rem 0.8rem;
-    font-size: 0.9rem;
-    letter-spacing: 0.2px;
-    white-space: nowrap;
+  font-weight: 600;
+  color: #003b66;
+  background: #e6edf5;
+  border-radius: 24px;
+  padding: 0.1rem 0.8rem;
+  font-size: 0.9rem;
+  letter-spacing: 0.2px;
+  white-space: nowrap;
 }
 
 .route-line .cust-ref {
-    font-weight: 600;
-    color: #005b8c;
-    background: #e5eef7;
-    padding: 0.1rem 0.8rem;
-    border-radius: 30px;
-    font-size: 0.9rem;
-    white-space: nowrap;
+  font-weight: 600;
+  color: #005b8c;
+  background: #e5eef7;
+  padding: 0.1rem 0.8rem;
+  border-radius: 30px;
+  font-size: 0.9rem;
+  white-space: nowrap;
 }
 
 /* cargo grid – two columns */
 .cargo-grid {
-    display: flex;
-    flex-wrap: wrap;
-    gap: 0.75rem 1.2rem;
-    border-radius: 24px;
-    border: 1px solid #e3ecf5;
+  display: flex;
+  flex-wrap: wrap;
+  gap: 0.75rem 1.2rem;
+  border-radius: 24px;
+  border: 1px solid #e3ecf5;
 }
 
 .cargo-item {
-    display: flex;
-    align-items: center;
-    gap: 0.5rem;
-    font-size: 0.95rem;
+  display: flex;
+  align-items: center;
+  gap: 0.5rem;
+  font-size: 0.95rem;
 }
 
 .cargo-item i {
-    color: #2f6f96;
-    width: 1.4rem;
-    font-size: 1rem;
-    text-align: center;
+  color: #2f6f96;
+  width: 1.4rem;
+  font-size: 1rem;
+  text-align: center;
 }
 
 .cargo-item strong {
-    font-weight: 600;
-    color: #0e2b3d;
+  font-weight: 600;
+  color: #0e2b3d;
 }
 
 .cargo-item .qty {
-    font-weight: 600;
-    color: #003057;
-    background: #ff980030;
-    border: 1px solid #ff9800;
-    border-radius: 8px;
-    padding: 1px 5px;
-    font-size: 0.85rem;
-    line-height: 1.6;
+  font-weight: 600;
+  color: #003057;
+  background: #ff980030;
+  border: 1px solid #ff9800;
+  border-radius: 8px;
+  padding: 1px 5px;
+  font-size: 0.85rem;
+  line-height: 1.6;
 }
 
 .cargo-item .unit {
-    font-weight: 500;
-    color: #1f4a66;
+  font-weight: 500;
+  color: #1f4a66;
 }
 
 .cargo-item .kg-badge {
-    background: #d1e2f0;
-    padding: 0.1rem 0.5rem;
-    font-size: 0.75rem;
-    font-weight: 600;
-    color: #004070;
+  background: #d1e2f0;
+  padding: 0.1rem 0.5rem;
+  font-size: 0.75rem;
+  font-weight: 600;
+  color: #004070;
 }
 
 /* invoice & value row */
 .invoice-row {
-    display: flex;
-    flex-wrap: wrap;
-    align-items: center;
-    justify-content: space-between;
-    padding: 0.8rem 1rem 0.8rem 1rem;
-    margin-top: 0.6rem;
-    gap: 0.5rem 1rem;
+  display: flex;
+  flex-wrap: wrap;
+  align-items: center;
+  justify-content: space-between;
+  padding: 0.8rem 1rem 0.8rem 1rem;
+  margin-top: 0.6rem;
+  gap: 0.5rem 1rem;
 }
 
 .invoice-number {
-    display: flex;
-    align-items: center;
-    gap: 0.5rem;
-    font-weight: 500;
-    color: #1d3b4f;
+  display: flex;
+  align-items: center;
+  gap: 0.5rem;
+  font-weight: 500;
+  color: #1d3b4f;
 }
 
 .invoice-number i {
-    color: #3a779b;
-    font-size: 1rem;
-    width: 1.4rem;
+  color: #3a779b;
+  font-size: 1rem;
+  width: 1.4rem;
 }
 
 .invoice-number span {
-    background: #ecf3fa;
-    padding: 0.1rem 0.9rem;
-    border-radius: 40px;
-    font-weight: 600;
-    color: #003d66;
-    letter-spacing: 0.3px;
+  background: #ecf3fa;
+  padding: 0.1rem 0.9rem;
+  border-radius: 40px;
+  font-weight: 600;
+  color: #003d66;
+  letter-spacing: 0.3px;
 }
 
 .value {
-    display: flex;
-    align-items: center;
-    gap: 0.4rem;
-    font-weight: 600;
-    color: #0b3d2b;
-    background: #e5f2ea;
-    padding: 0.25rem 1.2rem 0.25rem 1rem;
-    border-radius: 40px;
-    border: 1px solid #c4decb;
+  display: flex;
+  align-items: center;
+  gap: 0.4rem;
+  font-weight: 600;
+  color: #0b3d2b;
+  background: #e5f2ea;
+  padding: 0.25rem 1.2rem 0.25rem 1rem;
+  border-radius: 40px;
+  border: 1px solid #c4decb;
 }
 
 .value i {
-    color: #2b7a4b;
-    font-size: 0.9rem;
+  color: #2b7a4b;
+  font-size: 0.9rem;
 }
 
 .value .amount {
-    font-size: 1.2rem;
-    font-weight: 700;
-    color: #004d2b;
-    letter-spacing: 0.2px;
+  font-size: 1.2rem;
+  font-weight: 700;
+  color: #004d2b;
+  letter-spacing: 0.2px;
 }
 
 /* small meta / footer */
 .card-footer {
-    margin-top: 1.2rem;
-    font-size: 0.7rem;
-    color: #6b8396;
-    display: flex;
-    justify-content: flex-end;
-    border-top: 1px solid #eef4fa;
-    padding-top: 0.7rem;
-    letter-spacing: 0.2px;
-    gap: 0.5rem;
+  margin-top: 1.2rem;
+  font-size: 0.7rem;
+  color: #6b8396;
+  display: flex;
+  justify-content: flex-end;
+  border-top: 1px solid #eef4fa;
+  padding-top: 0.7rem;
+  letter-spacing: 0.2px;
+  gap: 0.5rem;
 }
 
 .card-footer i {
-    color: #6f8da3;
-    margin-right: 0.2rem;
+  color: #6f8da3;
+  margin-right: 0.2rem;
 }
 
 /* responsive */
 @media (max-width: 550px) {
-    .cargo-grid {
-        grid-template-columns: 1fr;
-        gap: 0.4rem;
-    }
-    .route-line {
-        flex-direction: column;
-        align-items: flex-start;
-        gap: 0.3rem;
-    }
-    .route-line .time {
-        margin-left: 0;
-        align-self: flex-start;
-    }
-    .invoice-row {
-        flex-direction: column;
-        align-items: stretch;
-        gap: 0.5rem;
-        border-radius: 24px;
-        padding: 0.8rem 1rem;
-    }
-    .lorry-id {
-        font-size: 1.2rem;
-        flex-wrap: wrap;
-    }
-    .badge-status {
-        font-size: 0.7rem;
-        padding: 0.2rem 0.8rem;
-    }
+  .cargo-grid {
+    grid-template-columns: 1fr;
+    gap: 0.4rem;
+  }
+  .route-line {
+    flex-direction: column;
+    align-items: flex-start;
+    gap: 0.3rem;
+  }
+  .route-line .time {
+    margin-left: 0;
+    align-self: flex-start;
+  }
+  .invoice-row {
+    flex-direction: column;
+    align-items: stretch;
+    gap: 0.5rem;
+    border-radius: 24px;
+    padding: 0.8rem 1rem;
+  }
+  .lorry-id {
+    font-size: 1.2rem;
+    flex-wrap: wrap;
+  }
+  .badge-status {
+    font-size: 0.7rem;
+    padding: 0.2rem 0.8rem;
+  }
 }
 
 @media (max-width: 400px) {
-    .lorry-plate {
-        font-size: 1rem;
-        padding: 0.1rem 0.8rem;
-    }
-    .cargo-item {
-        font-size: 0.85rem;
-    }
+  .lorry-plate {
+    font-size: 1rem;
+    padding: 0.1rem 0.8rem;
+  }
+  .cargo-item {
+    font-size: 0.85rem;
+  }
 }
 
 /* tweak for print / selection */
 
-
-
 .copyable-code:hover {
   background-color: #e2e2e2 !important;
 }
 
-
 .otp-item-row {
-    vertical-align: middle;
+  vertical-align: middle;
 }
 
 .sim-badge {
-    background:#e1f5fe;
-    /* background: #fff01f8b; */
-    clip-path: polygon(0% 0%, 70% 0%, 100% 25%, 100% 100%, 0% 100%);
-    border-radius: 2px;
-    color: #333;
-    padding: 1px 4px;
-    font-size: 11px;
-    margin: 1px 6px;
+  background: #e1f5fe;
+  /* background: #fff01f8b; */
+  clip-path: polygon(0% 0%, 70% 0%, 100% 25%, 100% 100%, 0% 100%);
+  border-radius: 2px;
+  color: #333;
+  padding: 1px 4px;
+  font-size: 11px;
+  margin: 1px 6px;
 }
 
 /* logs start */
 .content {
-    padding: 24px;
+  padding: 24px;
 }
 
 .logs-message {
-    font-size: 1em;
-    color: #333;
-    line-height: 1.4;
-    word-break: break-word;
+  font-size: 1em;
+  color: #333;
+  line-height: 1.4;
+  word-break: break-word;
 }
 
 .leakage-alert {
-    color: #ff0000;
-    font-weight: bold;
-    margin-bottom: 4px;
+  color: #ff0000;
+  font-weight: bold;
+  margin-bottom: 4px;
 }
 /* logs end */
 
-@supports(position-area: end) {
-    [popover] {
-      margin: 0;
-      position-area: end span-end;
-      position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
-    }
+@supports (position-area: end) {
+  [popover] {
+    margin: 0;
+    position-area: end span-end;
+    position-try-fallbacks:
+      flip-block,
+      flip-inline,
+      flip-block flip-inline;
+  }
 }
 
 :popover-open {

@@ -338,158 +338,158 @@
 }
 
 .device-popover-image {
-    width: auto;
-    max-height: 78px;
-    max-width: 64px;
-    top: -14px;
-    right: 8px;
-    position: absolute;
+  width: auto;
+  max-height: 78px;
+  max-width: 64px;
+  top: -14px;
+  right: 8px;
+  position: absolute;
 }
 
 .device-popover-container {
-    background: white;
-    margin: 16px;
-    padding: 16px;
-    position: relative;
-    min-height: 64px;
+  background: white;
+  margin: 16px;
+  padding: 16px;
+  position: relative;
+  min-height: 64px;
 }
 
 .log-filter-bar {
-    display: flex;
-    gap: 10px;
-    padding: 12px;
-    background: #fafafa;
-    border: 1px solid rgba(0, 0, 0, 0.04);
-    border-radius: 8px;
-    flex-wrap: wrap;
-    position: sticky;
-    top: 0;
-    z-index: 4;
-    box-shadow: none;
+  display: flex;
+  gap: 10px;
+  padding: 12px;
+  background: #fafafa;
+  border: 1px solid rgba(0, 0, 0, 0.04);
+  border-radius: 8px;
+  flex-wrap: wrap;
+  position: sticky;
+  top: 0;
+  z-index: 4;
+  box-shadow: none;
 }
 
 .segment > ul {
-    padding-left: 2px;
-    margin-top: 8px;
+  padding-left: 2px;
+  margin-top: 8px;
 }
 
 .segment > ul > li {
-    list-style-type: none;
-    margin-bottom: 6px;
+  list-style-type: none;
+  margin-bottom: 6px;
 }
 
 /* one standalone list item per date group, inserted before that group's first message. As a top-level
    <li> (not nested inside a message row) it can stick to the top of the list on its own while the
    day's messages scroll underneath it. */
 .date-divider {
-    position: sticky;
-    top: 64px;
-    z-index: 2;
-    background: #fff;
-    padding: 4px 12px;
+  position: sticky;
+  top: 64px;
+  z-index: 2;
+  background: #fff;
+  padding: 4px 12px;
 }
 
 .date-divider .date-p {
-    left: 0;
+  left: 0;
 }
 
 /* day/month badge, styled after the #custom-date template, nudged slightly to the left */
 .date-p {
-    text-align: center;
-    width: fit-content;
-    line-height: 0.7em;
-    position: relative;
-    left: -6px;
+  text-align: center;
+  width: fit-content;
+  line-height: 0.7em;
+  position: relative;
+  left: -6px;
 }
 
 .date-p p {
-    font-weight: 700;
-    color: black;
-    margin: 0;
+  font-weight: 700;
+  color: black;
+  margin: 0;
 }
 
 .date-p hr {
-    border: 1px solid black;
-    margin: 2px 0 0 0;
+  border: 1px solid black;
+  margin: 2px 0 0 0;
 }
 
 .filter-select {
-    padding: 6px 12px;
-    border: 1px solid #ccc;
-    border-radius: 4px;
-    background: #fff;
-    font-size: 13px;
+  padding: 6px 12px;
+  border: 1px solid #ccc;
+  border-radius: 4px;
+  background: #fff;
+  font-size: 13px;
 }
 
 .range-filter-label {
-    display: inline-flex;
-    align-items: center;
-    gap: 6px;
-    color: #555;
-    font-size: 13px;
-    white-space: nowrap;
+  display: inline-flex;
+  align-items: center;
+  gap: 6px;
+  color: #555;
+  font-size: 13px;
+  white-space: nowrap;
 }
 
 .range-filter-label .filter-select {
-    width: auto;
+  width: auto;
 }
 
 .segment-container {
-    display: flex;
-    flex-direction: row;
-    gap: 1em;
+  display: flex;
+  flex-direction: row;
+  gap: 1em;
 }
 
 .segment {
-    min-width: 0;
+  min-width: 0;
 }
 
 .segment[data-segment="1"] {
-    flex: 1.8 1 0;
+  flex: 1.8 1 0;
 }
 
 .segment[data-segment="2"] {
-    flex: 0.9 1 0;
-    max-width: 42rem;
+  flex: 0.9 1 0;
+  max-width: 42rem;
 }
 
 .mobile-panel-switch {
-    display: none;
+  display: none;
 }
 
 .mobile-panel-switch button {
-    flex: 1;
-    border: 1px solid #d8d8d8;
-    background: #fff;
-    padding: 10px 12px;
-    font-weight: 650;
+  flex: 1;
+  border: 1px solid #d8d8d8;
+  background: #fff;
+  padding: 10px 12px;
+  font-weight: 650;
 }
 
 .mobile-panel-switch button.active {
-    background: #111;
-    border-color: #111;
-    color: #fff;
+  background: #111;
+  border-color: #111;
+  color: #fff;
 }
 
 .sticky-list {
 }
 
 .notification-badge {
-    background: #eb2f06;
-    padding: 2px 4px;
-    border-radius: 2em;
-    position: absolute;
-    right: 12px;
-    color: white;
+  background: #eb2f06;
+  padding: 2px 4px;
+  border-radius: 2em;
+  position: absolute;
+  right: 12px;
+  color: white;
 }
 
 .msg-item-header {
-    display: flex;
-    flex-wrap: wrap;
-    align-items: center;
-    justify-content: space-between;
-    gap: 4px;
-    line-height: 0.8rem;
+  display: flex;
+  flex-wrap: wrap;
+  align-items: center;
+  justify-content: space-between;
+  gap: 4px;
+  line-height: 0.8rem;
 }
 
 table {

@@ -512,127 +512,126 @@ td {
 }
 
 @media (max-width: 800px) {
-    .content {
-        padding: 12px;
-    }
-
-    .mobile-panel-switch {
-        display: flex;
-        position: sticky;
-        top: 0;
-        z-index: 6;
-        gap: 0;
-        margin: 8px 0;
-        background: #fff;
-        border-radius: 10px;
-        box-shadow: none;
-    }
-
-    .mobile-panel-switch button:first-child {
-        border-radius: 10px 0 0 10px;
-    }
-
-    .mobile-panel-switch button:last-child {
-        border-radius: 0 10px 10px 0;
-    }
-
-    .segment-container {
-        display: block;
-    }
-
-    .segment {
-        display: none;
-    }
-
-    .segment.active {
-        display: block;
-    }
-
-    .log-filter-bar {
-        top: 46px;
-    }
-
-    .date-divider {
-        top: 118px;
-    }
-
-    .filter-select {
-        width: 100%;
-        min-width: 0 !important;
-    }
-
-    .msg-item-header {
-        gap: 8px;
-        line-height: 1.1rem;
-    }
-}
+  .content {
+    padding: 12px;
+  }
 
+  .mobile-panel-switch {
+    display: flex;
+    position: sticky;
+    top: 0;
+    z-index: 6;
+    gap: 0;
+    margin: 8px 0;
+    background: #fff;
+    border-radius: 10px;
+    box-shadow: none;
+  }
+
+  .mobile-panel-switch button:first-child {
+    border-radius: 10px 0 0 10px;
+  }
+
+  .mobile-panel-switch button:last-child {
+    border-radius: 0 10px 10px 0;
+  }
+
+  .segment-container {
+    display: block;
+  }
+
+  .segment {
+    display: none;
+  }
+
+  .segment.active {
+    display: block;
+  }
+
+  .log-filter-bar {
+    top: 46px;
+  }
+
+  .date-divider {
+    top: 118px;
+  }
+
+  .filter-select {
+    width: 100%;
+    min-width: 0 !important;
+  }
+
+  .msg-item-header {
+    gap: 8px;
+    line-height: 1.1rem;
+  }
+}
 
 .settings-button {
-    margin-left: 10px;
-    padding: 6px 10px;
-    border: 1px solid #d8d8d8;
-    border-radius: 6px;
-    background: #fff;
-    color: #333;
-    cursor: pointer;
-    font-weight: 650;
+  margin-left: 10px;
+  padding: 6px 10px;
+  border: 1px solid #d8d8d8;
+  border-radius: 6px;
+  background: #fff;
+  color: #333;
+  cursor: pointer;
+  font-weight: 650;
 }
 
 .settings-dialog {
-    border: 0;
-    border-radius: 14px;
-    padding: 0;
-    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
+  border: 0;
+  border-radius: 14px;
+  padding: 0;
+  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
 }
 
 .settings-dialog::backdrop {
-    background: rgba(0, 0, 0, 0.42);
+  background: rgba(0, 0, 0, 0.42);
 }
 
 .settings-card {
-    display: grid;
-    gap: 14px;
-    min-width: min(340px, 86vw);
-    padding: 20px;
+  display: grid;
+  gap: 14px;
+  min-width: min(340px, 86vw);
+  padding: 20px;
 }
 
 .settings-card h2 {
-    margin: 0;
+  margin: 0;
 }
 
 .settings-card label {
-    display: grid;
-    gap: 6px;
-    font-weight: 650;
+  display: grid;
+  gap: 6px;
+  font-weight: 650;
 }
 
 .settings-checkbox {
-    align-items: center;
-    display: flex !important;
-    gap: 8px !important;
+  align-items: center;
+  display: flex !important;
+  gap: 8px !important;
 }
 
 .settings-card menu {
-    display: flex;
-    gap: 8px;
-    justify-content: flex-end;
-    margin: 4px 0 0;
-    padding: 0;
+  display: flex;
+  gap: 8px;
+  justify-content: flex-end;
+  margin: 4px 0 0;
+  padding: 0;
 }
 
 .settings-card menu button {
-    padding: 7px 12px;
+  padding: 7px 12px;
 }
 
 body.logs-dark {
-    background: #000 !important;
-    color: #d8e1e7 !important;
+  background: #000 !important;
+  color: #d8e1e7 !important;
 }
 
 body.logs-dark .content {
-    background: #000;
-    color: #d8e1e7;
+  background: #000;
+  color: #d8e1e7;
 }
 
 body.logs-dark h1,

@@ -640,70 +639,69 @@ body.logs-dark .logs-message,
 body.logs-dark .range-filter-label,
 body.logs-dark .date-p p,
 body.logs-dark .date-p small {
-    color: #d8e1e7 !important;
+  color: #d8e1e7 !important;
 }
 
 body.logs-dark .log-filter-bar,
 body.logs-dark .settings-dialog {
-    background: rgba(18, 25, 31, 0.98);
-    border-color: rgba(255, 255, 255, 0.06);
-    color: #d8e1e7;
+  background: rgba(18, 25, 31, 0.98);
+  border-color: rgba(255, 255, 255, 0.06);
+  color: #d8e1e7;
 }
 
 body.logs-dark .filter-select,
 body.logs-dark .settings-button,
 body.logs-dark .settings-card menu button,
 body.logs-dark .mobile-panel-switch button {
-    background: #151d23 !important;
-    border-color: #344653 !important;
-    color: #d8e1e7 !important;
+  background: #151d23 !important;
+  border-color: #344653 !important;
+  color: #d8e1e7 !important;
 }
 
 body.logs-dark .msg-list-item {
-    background: transparent !important;
-    border-bottom-color: #24313a !important;
+  background: transparent !important;
+  border-bottom-color: #24313a !important;
 }
 
 body.logs-dark .date-divider {
-    background: #000;
+  background: #000;
 }
 
 body.logs-dark .copyable-code {
-    background: #1c2932 !important;
-    border-color: #3a4d5b !important;
-    color: #e8f2f7 !important;
+  background: #1c2932 !important;
+  border-color: #3a4d5b !important;
+  color: #e8f2f7 !important;
 }
 
-
 body.logs-dark a,
 body.logs-dark .insignificant {
-    color: #8ec7ff !important;
+  color: #8ec7ff !important;
 }
 
 body.logs-dark .filter-select::placeholder {
-    color: #748693;
+  color: #748693;
 }
 
 body.logs-dark .msg-list-item:hover {
-    background: transparent !important;
+  background: transparent !important;
 }
 
 body.logs-dark .msg-item-header,
 body.logs-dark .msg-item-header small,
 body.logs-dark .device-name-button {
-    color: #93a7b4 !important;
+  color: #93a7b4 !important;
 }
 
 body.logs-dark .msg-item-header span {
-    color: #e4edf2;
+  color: #e4edf2;
 }
 
 body.logs-dark .date-p hr {
-    border-color: #d8e1e7 !important;
+  border-color: #d8e1e7 !important;
 }
 
 body.logs-dark .copyable-code:hover {
-    background: #263847 !important;
+  background: #263847 !important;
 }
 
 body.logs-dark .sim-badge,

@@ -711,24 +709,24 @@ body.logs-dark .route-line .time,
 body.logs-dark .route-line .cust-ref,
 body.logs-dark .invoice-number span,
 body.logs-dark .cargo-item .kg-badge {
-    background: #1c2a34 !important;
-    color: #b8d9ee !important;
-    border-color: #334b5b !important;
+  background: #1c2a34 !important;
+  color: #b8d9ee !important;
+  border-color: #334b5b !important;
 }
 
 body.logs-dark .leakage-alert {
-    color: #ff7b86 !important;
+  color: #ff7b86 !important;
 }
 
 body.logs-dark .msg-list-item[style*="fff5f5"] {
-    background: #2a1418 !important;
-    border-left-color: #ff5c6c !important;
+  background: #2a1418 !important;
+  border-left-color: #ff5c6c !important;
 }
 
 body.logs-dark .dispatch-card,
 body.logs-dark .device-popover-container {
-    background: #121a21 !important;
-    border-color: #26333d !important;
+  background: #121a21 !important;
+  border-color: #26333d !important;
 }
 
 body.logs-dark .card-header,

@@ -736,11 +734,11 @@ body.logs-dark .card-footer,
 body.logs-dark .cargo-grid,
 body.logs-dark table thead th,
 body.logs-dark tr {
-    border-color: #26333d !important;
+  border-color: #26333d !important;
 }
 
 body.logs-dark table thead th {
-    background: #17212a !important;
+  background: #17212a !important;
 }
 
 body.logs-dark .lorry-id,

@@ -752,7 +750,7 @@ body.logs-dark .value,
 body.logs-dark table,
 body.logs-dark th,
 body.logs-dark td {
-    color: #d8e1e7 !important;
+  color: #d8e1e7 !important;
 }
 
 body.logs-dark .lorry-id i,

@@ -760,52 +758,52 @@ body.logs-dark .route-line i,
 body.logs-dark .cargo-item i,
 body.logs-dark .invoice-number i,
 body.logs-dark .card-footer i {
-    color: #8db7d0 !important;
+  color: #8db7d0 !important;
 }
 
 body.logs-dark .lorry-plate,
 body.logs-dark .badge-status,
 body.logs-dark .value {
-    background: #172530 !important;
-    border-color: #335066 !important;
-    color: #c9e3f2 !important;
+  background: #172530 !important;
+  border-color: #335066 !important;
+  color: #c9e3f2 !important;
 }
 
 body.logs-dark .cargo-item .qty {
-    background: rgba(255, 152, 0, 0.14) !important;
-    border-color: rgba(255, 183, 77, 0.58) !important;
-    color: #ffd18a !important;
+  background: rgba(255, 152, 0, 0.14) !important;
+  border-color: rgba(255, 183, 77, 0.58) !important;
+  color: #ffd18a !important;
 }
 
 body.logs-dark .value .amount {
-    color: #7ee0a3 !important;
+  color: #7ee0a3 !important;
 }
 
 body.logs-dark .card-footer,
 body.logs-dark .range-filter-label {
-    color: #8fa2ae !important;
+  color: #8fa2ae !important;
 }
 
 body.logs-dark .mobile-panel-switch {
-    background: #111920 !important;
-    box-shadow: none !important;
+  background: #111920 !important;
+  box-shadow: none !important;
 }
 
 body.logs-dark .mobile-panel-switch button.active {
-    background: #e4edf2 !important;
-    border-color: #e4edf2 !important;
-    color: #111920 !important;
+  background: #e4edf2 !important;
+  border-color: #e4edf2 !important;
+  color: #111920 !important;
 }
 
 body.logs-light {
-    background: #fff !important;
-    color: #333 !important;
+  background: #fff !important;
+  color: #333 !important;
 }
 
 body.logs-light .content,
 body.logs-light .date-divider {
-    background: #fff !important;
-    color: #333 !important;
+  background: #fff !important;
+  color: #333 !important;
 }
 
 body.logs-light h1,

@@ -813,80 +811,80 @@ body.logs-light .logs-message,
 body.logs-light .range-filter-label,
 body.logs-light .date-p p,
 body.logs-light .date-p small {
-    color: #333 !important;
+  color: #333 !important;
 }
 
 body.logs-light .log-filter-bar {
-    background: #fafafa !important;
-    border-color: rgba(0, 0, 0, 0.04) !important;
-    box-shadow: none !important;
+  background: #fafafa !important;
+  border-color: rgba(0, 0, 0, 0.04) !important;
+  box-shadow: none !important;
 }
 
 body.logs-light .filter-select,
 body.logs-light .settings-button,
 body.logs-light .mobile-panel-switch button {
-    background: #fff !important;
-    border-color: #ccc !important;
-    color: #333 !important;
+  background: #fff !important;
+  border-color: #ccc !important;
+  color: #333 !important;
 }
 
 body.logs-light .msg-list-item {
-    background: transparent !important;
-    border-bottom-color: #f2f2f2 !important;
+  background: transparent !important;
+  border-bottom-color: #f2f2f2 !important;
 }
 
 body.logs-light .msg-item-header span {
-    color: inherit !important;
+  color: inherit !important;
 }
 
 body.logs-light .msg-item-header small,
 body.logs-light .device-name-button {
-    color: #727272 !important;
+  color: #727272 !important;
 }
 
 .app-chart-header {
-    margin-bottom: 16px;
+  margin-bottom: 16px;
 }
 
 .settings-icon-button {
-    aspect-ratio: 1;
-    display: inline-grid;
-    font-size: 16px;
-    left: 10px;
-    margin: 0;
-    min-width: 30px;
-    padding: 0;
-    place-items: center;
-    position: absolute;
-    top: 38px;
-    z-index: 6;
+  aspect-ratio: 1;
+  display: inline-grid;
+  font-size: 16px;
+  left: 10px;
+  margin: 0;
+  min-width: 30px;
+  padding: 0;
+  place-items: center;
+  position: absolute;
+  top: 38px;
+  z-index: 6;
 }
 
 .app-header-chart.action-chart-container {
-    height: 240px;
-    margin-bottom: 0;
+  height: 240px;
+  margin-bottom: 0;
 }
 
 .app-header-chart.tva-chart-fullscreen-mode,
 .tva-chart-fullscreen-mode {
-    bottom: 16px !important;
-    height: auto !important;
-    left: 16px !important;
-    max-height: none !important;
-    position: fixed !important;
-    right: 16px !important;
-    top: 16px !important;
-    width: auto !important;
-    z-index: 10001 !important;
+  bottom: 16px !important;
+  height: auto !important;
+  left: 16px !important;
+  max-height: none !important;
+  position: fixed !important;
+  right: 16px !important;
+  top: 16px !important;
+  width: auto !important;
+  z-index: 10001 !important;
 }
 
 .app-header-chart.tva-chart-fullscreen-mode canvas,
 .tva-chart-fullscreen-mode canvas {
-    max-height: none !important;
+  max-height: none !important;
 }
 
 @media (max-width: 800px) {
-    .app-header-chart.action-chart-container {
-        height: 220px;
-    }
+  .app-header-chart.action-chart-container {
+    height: 220px;
+  }
 }
diff --git a/logs.js b/logs.js
@@ -1,77 +1,191 @@
 // Fixed single-quote syntax break error
 const ESC_MAP = {
-  '&': '&amp;',
-  '<': '&lt;',
-  '>': '&gt;',
-  '"': '&quot;',
-  "'": '&#39;' 
+  "&": "&amp;",
+  "<": "&lt;",
+  ">": "&gt;",
+  '"': "&quot;",
+  "'": "&#39;",
 };
 
 let config = {
-    endpoint: "/kidang.fcgi",
-    otpTable: "otp",
-    // Disabled until the backend action-required table/schema exists. Keeping this
-    // enabled causes kidang.fcgi?table=action to return HTTP 500 on maa-1.
-    actionTable: null,
-    defaultRangeHours: 48,// 2 days
-    // Incoming timestamps represent local wall-clock time from the sender/receiver.
-    // Neutralise the browser timezone offset for display so dates don't appear ahead.
-    displayTimestampsAsLocalWallClock: false
+  endpoint: "/kidang.fcgi",
+  otpTable: "otp",
+  // Disabled until the backend action-required table/schema exists. Keeping this
+  // enabled causes kidang.fcgi?table=action to return HTTP 500 on maa-1.
+  actionTable: null,
+  defaultRangeHours: 48, // 2 days
+  // Incoming timestamps represent local wall-clock time from the sender/receiver.
+  // Neutralise the browser timezone offset for display so dates don't appear ahead.
+  displayTimestampsAsLocalWallClock: false,
 };
 
 const trackedDevices = new Set();
 const trackedCategories = new Set(); // Caches categories dynamically to prevent dropdown flickering
 
-const defaultLogsSettings = { theme: 'auto', ambientGlow: true };
+const defaultLogsSettings = { theme: "auto", ambientGlow: true };
 let logsSettings = loadLogsSettings();
 
 function loadLogsSettings() {
   try {
-    return { ...defaultLogsSettings, ...(JSON.parse(localStorage.getItem('logs_settings')) || {}) };
+    return { ...defaultLogsSettings, ...(JSON.parse(localStorage.getItem("logs_settings")) || {}) };
   } catch (e) {
     return { ...defaultLogsSettings };
   }
 }
 
 function persistLogsSettings() {
-  localStorage.setItem('logs_settings', JSON.stringify(logsSettings));
+  localStorage.setItem("logs_settings", JSON.stringify(logsSettings));
 }
 
 const tvaControlConfig = {
-  title: 'TVA REACTIVE CHANNEL',
+  title: "TVA REACTIVE CHANNEL",
   blinkMs: 1100,
   aliases: {
-    bookingAgeDays: 'refillSpreadDays',
-    bookingSpreadDays: 'refillSpreadDays',
-    bpclDeposit: 'bpclDepositLakhs'
+    bookingAgeDays: "refillSpreadDays",
+    bookingSpreadDays: "refillSpreadDays",
+    bpclDeposit: "bpclDepositLakhs",
   },
   ambientGlow: { enabled: logsSettings.ambientGlow !== false, alpha: 0.14, radius: 74, blur: 42 },
   warningLevels: [
-    { key: 'amber', label: 'AMBER ALERT', priority: 1, showAxis: true, dominance: 0.6, axisAlpha: 0.28, axisWidth: 1.45, axisDash: [3, 5], glowAlpha: 0.12 },
-    { key: 'red', label: 'CRITICAL', priority: 2, showAxis: true, dominance: 0.7, axisAlpha: 0.42, axisWidth: 1.45, axisDash: [6, 6], glowAlpha: 0.16 },
-    { key: 'double-red', label: 'DOUBLE RED', priority: 3, showAxis: false, dominance: 0.7, borderBlink: true, glowAlpha: 0.18, glowRadius: 88, glowBlur: 54 }
+    {
+      key: "amber",
+      label: "AMBER ALERT",
+      priority: 1,
+      showAxis: true,
+      dominance: 0.6,
+      axisAlpha: 0.28,
+      axisWidth: 1.45,
+      axisDash: [3, 5],
+      glowAlpha: 0.12,
+    },
+    {
+      key: "red",
+      label: "CRITICAL",
+      priority: 2,
+      showAxis: true,
+      dominance: 0.7,
+      axisAlpha: 0.42,
+      axisWidth: 1.45,
+      axisDash: [6, 6],
+      glowAlpha: 0.16,
+    },
+    {
+      key: "double-red",
+      label: "DOUBLE RED",
+      priority: 3,
+      showAxis: false,
+      dominance: 0.7,
+      borderBlink: true,
+      glowAlpha: 0.18,
+      glowRadius: 88,
+      glowBlur: 54,
+    },
   ],
   colors: {
-    amber: '#ffcc00',
-    red: '#ff0055',
-    critical: '#ff0055',
-    'double-red': '#ff1a1a',
-    doubleRed: '#ff1a1a',
-    disabled: '#777777'
+    amber: "#ffcc00",
+    red: "#ff0055",
+    critical: "#ff0055",
+    "double-red": "#ff1a1a",
+    doubleRed: "#ff1a1a",
+    disabled: "#777777",
   },
   staleAlpha: 0.35,
   parameters: [
-    { key: 'complaintsOpen', label: 'Complaints Open', icon: 'warning', scale: 'count10', refreshMinutes: 15, thresholds: { amberUpper: 52.5, redUpper: 75, amberLower: -52.5, redLower: -75 } },
-    { key: 'invoiceActions', label: 'Invoice Actions', icon: 'invoice', scale: 'count10', refreshMinutes: 15, thresholds: { amberUpper: 59.5, redUpper: 85, amberLower: -59.5, redLower: -85 } },
-    { key: 'deliveryPersonLeave', label: 'Delivery Person Leave', icon: 'person', scale: 'count10', refreshMinutes: 720, thresholds: { amberUpper: 49, redUpper: 70, amberLower: -49, redLower: -70 } },
-    { key: 'refillSpreadDays', label: 'Refill Spread', icon: 'calendar', scale: 'daysCritical', scaleBase: 10, scaleMax: 165, refreshMinutes: 1440, display: { suffix: 'd' }, thresholds: { amberUpper: 50, redUpper: 100, doubleRedUpper: 150, amberLower: -70, redLower: -100 }, detailMode: 'refill-spread', areaKey: 'refillSpreadAreas', detailTitle: 'REFILL SPREAD AREA SCAN', detailLevels: [{ level: 'amber', above: 5 }, { level: 'red', above: 10 }] },
-    { key: 'pendencyDays', label: 'Pendency', icon: 'hourglass', scale: 'pendency', scaleIdeal: 1, scaleBase: 3, scaleMax: 115, refreshMinutes: 720, display: { suffix: 'd', decimals: 1 }, thresholds: { amberUpper: 33.33, redUpper: 100, amberLower: -70, redLower: -100 }, detailMode: 'pendency', areaKey: 'pendencyAreas', detailTitle: 'PENDENCY AREA SCAN', detailLevels: [{ level: 'amber', above: 1 }, { level: 'red', above: 3 }] },
-    { key: 'bpclDepositLakhs', label: 'BPCL Deposit', icon: 'deposit', scale: 'raw', refreshMinutes: 30, display: { prefix: '₹', suffix: 'L', decimals: 1 }, thresholds: { amberUpper: 4, redUpper: 6, amberLower: -1, redLower: -3 } }
+    {
+      key: "complaintsOpen",
+      label: "Complaints Open",
+      icon: "warning",
+      scale: "count10",
+      refreshMinutes: 15,
+      thresholds: { amberUpper: 52.5, redUpper: 75, amberLower: -52.5, redLower: -75 },
+    },
+    {
+      key: "invoiceActions",
+      label: "Invoice Actions",
+      icon: "invoice",
+      scale: "count10",
+      refreshMinutes: 15,
+      thresholds: { amberUpper: 59.5, redUpper: 85, amberLower: -59.5, redLower: -85 },
+    },
+    {
+      key: "deliveryPersonLeave",
+      label: "Delivery Person Leave",
+      icon: "person",
+      scale: "count10",
+      refreshMinutes: 720,
+      thresholds: { amberUpper: 49, redUpper: 70, amberLower: -49, redLower: -70 },
+    },
+    {
+      key: "refillSpreadDays",
+      label: "Refill Spread",
+      icon: "calendar",
+      scale: "daysCritical",
+      scaleBase: 10,
+      scaleMax: 165,
+      refreshMinutes: 1440,
+      display: { suffix: "d" },
+      thresholds: {
+        amberUpper: 50,
+        redUpper: 100,
+        doubleRedUpper: 150,
+        amberLower: -70,
+        redLower: -100,
+      },
+      detailMode: "refill-spread",
+      areaKey: "refillSpreadAreas",
+      detailTitle: "REFILL SPREAD AREA SCAN",
+      detailLevels: [
+        { level: "amber", above: 5 },
+        { level: "red", above: 10 },
+      ],
+    },
+    {
+      key: "pendencyDays",
+      label: "Pendency",
+      icon: "hourglass",
+      scale: "pendency",
+      scaleIdeal: 1,
+      scaleBase: 3,
+      scaleMax: 115,
+      refreshMinutes: 720,
+      display: { suffix: "d", decimals: 1 },
+      thresholds: { amberUpper: 33.33, redUpper: 100, amberLower: -70, redLower: -100 },
+      detailMode: "pendency",
+      areaKey: "pendencyAreas",
+      detailTitle: "PENDENCY AREA SCAN",
+      detailLevels: [
+        { level: "amber", above: 1 },
+        { level: "red", above: 3 },
+      ],
+    },
+    {
+      key: "bpclDepositLakhs",
+      label: "BPCL Deposit",
+      icon: "deposit",
+      scale: "raw",
+      refreshMinutes: 30,
+      display: { prefix: "₹", suffix: "L", decimals: 1 },
+      thresholds: { amberUpper: 4, redUpper: 6, amberLower: -1, redLower: -3 },
+    },
   ],
   extraAxes: [
-    { label: 'BPCL Deposit Good', parameterKey: 'bpclDepositLakhs', value: 6, color: 'rgba(0,255,120,.5)', width: 1.8, dash: [4, 4] },
-    { label: 'BPCL Deposit Soft', parameterKey: 'bpclDepositLakhs', value: 4, color: 'rgba(120,255,160,.34)', width: 1.4, dash: [2, 5] }
-  ]
+    {
+      label: "BPCL Deposit Good",
+      parameterKey: "bpclDepositLakhs",
+      value: 6,
+      color: "rgba(0,255,120,.5)",
+      width: 1.8,
+      dash: [4, 4],
+    },
+    {
+      label: "BPCL Deposit Soft",
+      parameterKey: "bpclDepositLakhs",
+      value: 4,
+      color: "rgba(120,255,160,.34)",
+      width: 1.4,
+      dash: [2, 5],
+    },
+  ],
 };
 
 let tvaControl = null;

@@ -90,45 +204,45 @@ const tvaMetrics = {
   idealPendencyMaxDays: 1,
   criticalPendencyDays: 3,
   refillSpreadAreas: [
-    { name: 'KK NAGAR', days: 12 },
-    { name: 'WEST MAMBALAM', days: 9 },
-    { name: 'ASHOK NAGAR', days: 7 },
-    { name: 'T NAGAR', days: 11 },
-    { name: 'VADAPALANI', days: 6 },
-    { name: 'KODAMBAKKAM', days: 8 },
-    { name: 'SALIGRAMAM', days: 5 },
-    { name: 'VIRUGAMBAKKAM', days: 10 },
-    { name: 'NESAPAKKAM', days: 13 },
-    { name: 'JAFFERKHANPET', days: 6 },
-    { name: 'EKKATTUTHANGAL', days: 4 },
-    { name: 'MGR NAGAR', days: 9 },
-    { name: 'SAIDAPET', days: 7 }
+    { name: "KK NAGAR", days: 12 },
+    { name: "WEST MAMBALAM", days: 9 },
+    { name: "ASHOK NAGAR", days: 7 },
+    { name: "T NAGAR", days: 11 },
+    { name: "VADAPALANI", days: 6 },
+    { name: "KODAMBAKKAM", days: 8 },
+    { name: "SALIGRAMAM", days: 5 },
+    { name: "VIRUGAMBAKKAM", days: 10 },
+    { name: "NESAPAKKAM", days: 13 },
+    { name: "JAFFERKHANPET", days: 6 },
+    { name: "EKKATTUTHANGAL", days: 4 },
+    { name: "MGR NAGAR", days: 9 },
+    { name: "SAIDAPET", days: 7 },
   ],
   pendencyAreas: [
-    { name: 'KK NAGAR', days: 3.4 },
-    { name: 'WEST MAMBALAM', days: 2.9 },
-    { name: 'ASHOK NAGAR', days: 2.6 },
-    { name: 'T NAGAR', days: 3.1 },
-    { name: 'VADAPALANI', days: 2.2 },
-    { name: 'KODAMBAKKAM', days: 2.8 },
-    { name: 'SALIGRAMAM', days: 1.9 },
-    { name: 'VIRUGAMBAKKAM', days: 2.4 },
-    { name: 'NESAPAKKAM', days: 3.0 },
-    { name: 'JAFFERKHANPET', days: 2.1 },
-    { name: 'EKKATTUTHANGAL', days: 1.7 },
-    { name: 'MGR NAGAR', days: 2.5 },
-    { name: 'SAIDAPET', days: 2.0 }
-  ]
+    { name: "KK NAGAR", days: 3.4 },
+    { name: "WEST MAMBALAM", days: 2.9 },
+    { name: "ASHOK NAGAR", days: 2.6 },
+    { name: "T NAGAR", days: 3.1 },
+    { name: "VADAPALANI", days: 2.2 },
+    { name: "KODAMBAKKAM", days: 2.8 },
+    { name: "SALIGRAMAM", days: 1.9 },
+    { name: "VIRUGAMBAKKAM", days: 2.4 },
+    { name: "NESAPAKKAM", days: 3.0 },
+    { name: "JAFFERKHANPET", days: 2.1 },
+    { name: "EKKATTUTHANGAL", days: 1.7 },
+    { name: "MGR NAGAR", days: 2.5 },
+    { name: "SAIDAPET", days: 2.0 },
+  ],
 };
 function getISTDateParts(date = new Date()) {
-  const parts = new Intl.DateTimeFormat('en-CA', {
-    timeZone: 'Asia/Kolkata',
-    year: 'numeric',
-    month: '2-digit',
-    day: '2-digit'
+  const parts = new Intl.DateTimeFormat("en-CA", {
+    timeZone: "Asia/Kolkata",
+    year: "numeric",
+    month: "2-digit",
+    day: "2-digit",
   }).formatToParts(date);
-  const getPart = type => Number(parts.find(part => part.type === type).value);
-  return { year: getPart('year'), month: getPart('month'), day: getPart('day') };
+  const getPart = (type) => Number(parts.find((part) => part.type === type).value);
+  return { year: getPart("year"), month: getPart("month"), day: getPart("day") };
 }
 
 function getISTDateEpochMs(year, month, day) {

@@ -159,50 +273,52 @@ function setTvaMetricFromPayload(payloadKey, metricKey, payload) {
 function normalizeNamedDayAreas(value) {
   const rows = Array.isArray(value)
     ? value
-    : value && typeof value === 'object'
+    : value && typeof value === "object"
       ? Object.entries(value).map(([name, days]) => ({ name, days }))
       : [];
 
-  return rows.map((row, index) => {
-    const name = String(row.name || row.area || row.areaName || `Area ${index + 1}`).trim();
-    const days = finiteNumber(row.days ?? row.pendencyDays ?? row.currentDays);
-    return name && days !== null ? { name, days } : null;
-  }).filter(Boolean);
+  return rows
+    .map((row, index) => {
+      const name = String(row.name || row.area || row.areaName || `Area ${index + 1}`).trim();
+      const days = finiteNumber(row.days ?? row.pendencyDays ?? row.currentDays);
+      return name && days !== null ? { name, days } : null;
+    })
+    .filter(Boolean);
 }
 
 function setTvaPendencyAreasFromPayload(payload) {
-  if (!Object.prototype.hasOwnProperty.call(payload, 'pendencyAreas')) return;
+  if (!Object.prototype.hasOwnProperty.call(payload, "pendencyAreas")) return;
   const areas = normalizeNamedDayAreas(payload.pendencyAreas);
   if (areas.length) tvaMetrics.pendencyAreas = areas;
 }
 
 function setTvaRefillSpreadAreasFromPayload(payload) {
-  if (!Object.prototype.hasOwnProperty.call(payload, 'refillSpreadAreas')) return;
+  if (!Object.prototype.hasOwnProperty.call(payload, "refillSpreadAreas")) return;
   const areas = normalizeNamedDayAreas(payload.refillSpreadAreas);
   if (areas.length) tvaMetrics.refillSpreadAreas = areas;
 }
 
 function applyTvaMetricUpdate(payload) {
-  if (!payload || String(payload.type || '').toLowerCase() !== 'tva-metrics') return false;
+  if (!payload || String(payload.type || "").toLowerCase() !== "tva-metrics") return false;
 
   pendingTvaControlPatch = { ...(pendingTvaControlPatch || {}), ...payload };
   delete pendingTvaControlPatch.type;
 
   // Partial updates are intentional: only keys present in the payload change.
-  setTvaMetricFromPayload('complaintsOpen', 'complaintsOpen', payload);
-  setTvaMetricFromPayload('invoiceActions', 'invoiceActions', payload);
-  setTvaMetricFromPayload('deliveryPersonLeave', 'deliveryPersonLeave', payload);
-  setTvaMetricFromPayload('refillSpreadDays', 'refillSpreadDays', payload);
-  setTvaMetricFromPayload('bookingAgeDays', 'refillSpreadDays', payload);
-  setTvaMetricFromPayload('bookingSpreadDays', 'refillSpreadDays', payload);
-  setTvaMetricFromPayload('amberRefillSpreadDays', 'amberRefillSpreadDays', payload);
-  setTvaMetricFromPayload('criticalRefillSpreadDays', 'criticalRefillSpreadDays', payload);
-  setTvaMetricFromPayload('doubleRedRefillSpreadDays', 'doubleRedRefillSpreadDays', payload);
-  setTvaMetricFromPayload('bpclDepositLakhs', 'bpclDepositLakhs', payload);
-  setTvaMetricFromPayload('bpclDeposit', 'bpclDepositLakhs', payload);
-  setTvaMetricFromPayload('pendencyDays', 'pendencyDays', payload);
-  setTvaMetricFromPayload('idealPendencyMaxDays', 'idealPendencyMaxDays', payload);
-  setTvaMetricFromPayload('criticalPendencyDays', 'criticalPendencyDays', payload);
+  setTvaMetricFromPayload("complaintsOpen", "complaintsOpen", payload);
+  setTvaMetricFromPayload("invoiceActions", "invoiceActions", payload);
+  setTvaMetricFromPayload("deliveryPersonLeave", "deliveryPersonLeave", payload);
+  setTvaMetricFromPayload("refillSpreadDays", "refillSpreadDays", payload);
+  setTvaMetricFromPayload("bookingAgeDays", "refillSpreadDays", payload);
+  setTvaMetricFromPayload("bookingSpreadDays", "refillSpreadDays", payload);
+  setTvaMetricFromPayload("amberRefillSpreadDays", "amberRefillSpreadDays", payload);
+  setTvaMetricFromPayload("criticalRefillSpreadDays", "criticalRefillSpreadDays", payload);
+  setTvaMetricFromPayload("doubleRedRefillSpreadDays", "doubleRedRefillSpreadDays", payload);
+  setTvaMetricFromPayload("bpclDepositLakhs", "bpclDepositLakhs", payload);
+  setTvaMetricFromPayload("bpclDeposit", "bpclDepositLakhs", payload);
+  setTvaMetricFromPayload("pendencyDays", "pendencyDays", payload);
+  setTvaMetricFromPayload("idealPendencyMaxDays", "idealPendencyMaxDays", payload);
+  setTvaMetricFromPayload("criticalPendencyDays", "criticalPendencyDays", payload);
   setTvaPendencyAreasFromPayload(payload);
   setTvaRefillSpreadAreasFromPayload(payload);
   return true;

@@ -211,72 +327,80 @@ function applyTvaMetricUpdate(payload) {
 function applyTvaMetricUpdatesFromRows(items) {
   [...items]
     .sort((a, b) => a.sentstamp - b.sentstamp)
-    .forEach(item => applyTvaMetricUpdate(serverMassage(item.msg, item.extra)));
+    .forEach((item) => applyTvaMetricUpdate(serverMassage(item.msg, item.extra)));
 }
 
 function isTvaMetricsItem(item) {
-  return String(serverMassage(item.msg, item.extra).type || '').toLowerCase() === 'tva-metrics';
+  return String(serverMassage(item.msg, item.extra).type || "").toLowerCase() === "tva-metrics";
 }
 
 function formatTvaMetricValue(index, value) {
-  if (tvaChartCheckpoints[index] === 'Pendency') return `${tvaMetrics.pendencyDays}d · crit >${tvaMetrics.criticalPendencyDays}d`;
-  if (tvaChartCheckpoints[index] === 'Invoice Actions') return `${tvaMetrics.invoiceActions} invoices`;
-  if (tvaChartCheckpoints[index] === 'Complaints Open') return `${tvaMetrics.complaintsOpen} complaints`;
-  if (tvaChartCheckpoints[index] === 'Delivery Person Leave') return `${tvaMetrics.deliveryPersonLeave} leave`;
-  if (tvaChartCheckpoints[index] === 'Refill Spread') return `${tvaMetrics.refillSpreadDays}d · red >${tvaMetrics.criticalRefillSpreadDays}d`;
-  if (tvaChartCheckpoints[index] === 'BPCL Deposit') return `₹${tvaMetrics.bpclDepositLakhs}L`;
+  if (tvaChartCheckpoints[index] === "Pendency")
+    return `${tvaMetrics.pendencyDays}d · crit >${tvaMetrics.criticalPendencyDays}d`;
+  if (tvaChartCheckpoints[index] === "Invoice Actions")
+    return `${tvaMetrics.invoiceActions} invoices`;
+  if (tvaChartCheckpoints[index] === "Complaints Open")
+    return `${tvaMetrics.complaintsOpen} complaints`;
+  if (tvaChartCheckpoints[index] === "Delivery Person Leave")
+    return `${tvaMetrics.deliveryPersonLeave} leave`;
+  if (tvaChartCheckpoints[index] === "Refill Spread")
+    return `${tvaMetrics.refillSpreadDays}d · red >${tvaMetrics.criticalRefillSpreadDays}d`;
+  if (tvaChartCheckpoints[index] === "BPCL Deposit") return `₹${tvaMetrics.bpclDepositLakhs}L`;
   return `${value}%`;
 }
 
-window.setTvaControlData = function(data) {
-  if (typeof data === 'string') data = JSON.parse(data);
-  applyTvaMetricUpdate({ type: 'tva-metrics', ...(data || {}) });
+window.setTvaControlData = function (data) {
+  if (typeof data === "string") data = JSON.parse(data);
+  applyTvaMetricUpdate({ type: "tva-metrics", ...(data || {}) });
   updateActionRequiredChart();
 };
 
-window.getTvaControlData = function() {
+window.getTvaControlData = function () {
   return tvaControl ? tvaControl.getData() : JSON.parse(JSON.stringify(tvaMetrics));
 };
 
 function applyLogsSettingsToDom() {
-  const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
-  const dark = logsSettings.theme === 'dark' || (logsSettings.theme === 'auto' && prefersDark);
-  const light = logsSettings.theme === 'light' || (logsSettings.theme === 'auto' && !prefersDark);
-  document.body.classList.toggle('logs-dark', dark);
-  document.body.classList.toggle('logs-light', light);
-  document.querySelectorAll('.action-chart-container, .tva-control-container').forEach(container => {
-    if (logsSettings.theme === 'auto') container.removeAttribute('data-tva-theme');
-    else container.dataset.tvaTheme = logsSettings.theme;
-  });
+  const prefersDark =
+    window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
+  const dark = logsSettings.theme === "dark" || (logsSettings.theme === "auto" && prefersDark);
+  const light = logsSettings.theme === "light" || (logsSettings.theme === "auto" && !prefersDark);
+  document.body.classList.toggle("logs-dark", dark);
+  document.body.classList.toggle("logs-light", light);
+  document
+    .querySelectorAll(".action-chart-container, .tva-control-container")
+    .forEach((container) => {
+      if (logsSettings.theme === "auto") container.removeAttribute("data-tva-theme");
+      else container.dataset.tvaTheme = logsSettings.theme;
+    });
   tvaControlConfig.ambientGlow.enabled = logsSettings.ambientGlow !== false;
-  if (tvaControl && typeof tvaControl.refreshTheme === 'function') tvaControl.refreshTheme();
+  if (tvaControl && typeof tvaControl.refreshTheme === "function") tvaControl.refreshTheme();
 }
 
 function initLogsSettingsDialog() {
-  const theme = document.getElementById('settings-theme');
-  const glow = document.getElementById('settings-ambient-glow');
+  const theme = document.getElementById("settings-theme");
+  const glow = document.getElementById("settings-ambient-glow");
   if (!theme || !glow) return;
   theme.value = logsSettings.theme;
   glow.checked = logsSettings.ambientGlow !== false;
 }
 
-window.openLogsSettings = function() {
+window.openLogsSettings = function () {
   initLogsSettingsDialog();
-  const dialog = document.getElementById('logs-settings-dialog');
+  const dialog = document.getElementById("logs-settings-dialog");
   if (dialog) dialog.showModal();
 };
 
-window.closeLogsSettings = function() {
-  const dialog = document.getElementById('logs-settings-dialog');
+window.closeLogsSettings = function () {
+  const dialog = document.getElementById("logs-settings-dialog");
   if (dialog) dialog.close();
 };
 
-window.saveLogsSettings = function() {
-  const theme = document.getElementById('settings-theme');
-  const glow = document.getElementById('settings-ambient-glow');
+window.saveLogsSettings = function () {
+  const theme = document.getElementById("settings-theme");
+  const glow = document.getElementById("settings-ambient-glow");
   logsSettings = {
-    theme: theme ? theme.value : 'auto',
-    ambientGlow: glow ? glow.checked : true
+    theme: theme ? theme.value : "auto",
+    ambientGlow: glow ? glow.checked : true,
   };
   persistLogsSettings();
   applyLogsSettingsToDom();

@@ -284,8 +408,14 @@ window.saveLogsSettings = function() {
 };
 
 function initActionRequiredChart() {
-  const canvas = document.getElementById('tvaReactiveChart');
-  if (!canvas || tvaControl || typeof Chart === 'undefined' || typeof createTvaControl !== 'function') return;
+  const canvas = document.getElementById("tvaReactiveChart");
+  if (
+    !canvas ||
+    tvaControl ||
+    typeof Chart === "undefined" ||
+    typeof createTvaControl !== "function"
+  )
+    return;
 
   applyLogsSettingsToDom();
   tvaControl = createTvaControl({ canvas, config: tvaControlConfig, data: tvaMetrics });

@@ -303,7 +433,7 @@ function updateActionRequiredChart() {
 // Reads session memory to track alerts across page refreshes
 function getSeenLeaksLog() {
   try {
-    const data = sessionStorage.getItem('seen_lpg_leaks');
+    const data = sessionStorage.getItem("seen_lpg_leaks");
     return data ? JSON.parse(data) : [];
   } catch (e) {
     return [];

@@ -316,7 +446,7 @@ function markLeakAsSeen(itemDomId) {
     const seenList = getSeenLeaksLog();
     if (!seenList.includes(itemDomId)) {
       seenList.push(itemDomId);
-      sessionStorage.setItem('seen_lpg_leaks', JSON.stringify(seenList));
+      sessionStorage.setItem("seen_lpg_leaks", JSON.stringify(seenList));
     }
   } catch (e) {
     console.error(e);

@@ -329,10 +459,10 @@ function playAlarmSound() {
     const AudioContext = window.AudioContext || window.webkitAudioContext;
     if (!AudioContext) return;
     const ctx = new AudioContext();
-    [0, 0.25].forEach(delay => {
+    [0, 0.25].forEach((delay) => {
       const osc = ctx.createOscillator();
       const gain = ctx.createGain();
-      osc.type = 'sine';
+      osc.type = "sine";
       osc.frequency.setValueAtTime(880, ctx.currentTime + delay);
       gain.gain.setValueAtTime(0.3, ctx.currentTime + delay);
       gain.gain.exponentialRampToValueAtTime(0.01, ctx.currentTime + delay + 0.2);

@@ -342,7 +472,9 @@ function playAlarmSound() {
       osc.stop(ctx.currentTime + delay + 0.2);
     });
   } catch (e) {
-    console.warn("Audio Context blocked. Click anywhere on the webpage once to enable sound alerts.");
+    console.warn(
+      "Audio Context blocked. Click anywhere on the webpage once to enable sound alerts.",
+    );
   }
 }
 

@@ -351,16 +483,16 @@ function triggerDesktopNotification(sender, message, deviceId) {
   if (!("Notification" in window)) return;
   if (Notification.permission === "granted") {
     new Notification("CRITICAL ALERT: LPG Leakage", {
-      body: `From: ${sender} (${deviceId})\n${message}`
+      body: `From: ${sender} (${deviceId})\n${message}`,
     });
   }
 }
 
 function escapeHTML(s, forAttribute) {
   if (s === null || s === undefined) return "";
-  if (typeof(s) !== "string") return s;
+  if (typeof s !== "string") return s;
   if (!s) return "";
-  return s.replace(forAttribute ? /[&<>'"]/g : /[&<>]/g, c => ESC_MAP[c]);
+  return s.replace(forAttribute ? /[&<>'"]/g : /[&<>]/g, (c) => ESC_MAP[c]);
 }
 
 function getDateFromEpoch(ts) {

@@ -380,37 +512,37 @@ function getDateFromEpoch(ts) {
 // Time-only formatting for message headers now that the day/month lives in the per-date-group badge
 function formatTimeOnly(date) {
   if (!(date instanceof Date) || isNaN(date)) return "";
-  const time = new Intl.DateTimeFormat('en-IN', {
-    timeZone: 'Asia/Kolkata',
-    hour: '2-digit',
-    minute: '2-digit',
-    hour12: false
+  const time = new Intl.DateTimeFormat("en-IN", {
+    timeZone: "Asia/Kolkata",
+    hour: "2-digit",
+    minute: "2-digit",
+    hour12: false,
   }).format(date);
   return `<strong>${time}</strong>`;
 }
 
 function getISTDateKey(date) {
   if (!(date instanceof Date) || isNaN(date)) return "";
-  const parts = new Intl.DateTimeFormat('en-CA', {
-    timeZone: 'Asia/Kolkata',
-    year: 'numeric',
-    month: '2-digit',
-    day: '2-digit'
+  const parts = new Intl.DateTimeFormat("en-CA", {
+    timeZone: "Asia/Kolkata",
+    year: "numeric",
+    month: "2-digit",
+    day: "2-digit",
   }).formatToParts(date);
-  const getPart = type => parts.find(part => part.type === type).value;
-  return `${getPart('year')}-${getPart('month')}-${getPart('day')}`;
+  const getPart = (type) => parts.find((part) => part.type === type).value;
+  return `${getPart("year")}-${getPart("month")}-${getPart("day")}`;
 }
 
 // Calendar-style day/month markup, matching the #custom-date template
 function formatDateBadge(date) {
   if (!(date instanceof Date) || isNaN(date)) return "";
-  const parts = new Intl.DateTimeFormat('en-US', {
-    timeZone: 'Asia/Kolkata',
-    day: 'numeric',
-    month: 'short'
+  const parts = new Intl.DateTimeFormat("en-US", {
+    timeZone: "Asia/Kolkata",
+    day: "numeric",
+    month: "short",
   }).formatToParts(date);
-  const day = parts.find(part => part.type === 'day').value;
-  const month = parts.find(part => part.type === 'month').value;
+  const day = parts.find((part) => part.type === "day").value;
+  const month = parts.find((part) => part.type === "month").value;
   return `<div class="date-p"><p>${day}</p><small>${month}</small><hr></div>`;
 }
 

@@ -420,10 +552,10 @@ function formatDateBadge(date) {
 // message <ul> — both the OTP feed and the action-required feed use it.
 function syncDateDividers(list) {
   if (!list) return;
-  list.querySelectorAll("li.date-divider").forEach(el => el.remove());
+  list.querySelectorAll("li.date-divider").forEach((el) => el.remove());
 
   let lastDateKey = null;
-  list.querySelectorAll("li.msg-list-item").forEach(item => {
+  list.querySelectorAll("li.msg-list-item").forEach((item) => {
     const sentDate = getDateFromEpoch(parseInt(item.dataset.timestamp, 10));
     if (!sentDate) return;
     const dateKey = getISTDateKey(sentDate);

@@ -438,18 +570,21 @@ function syncDateDividers(list) {
 }
 
 // Native clipboard click handling operation
-window.copyToClipboard = function(text, element) {
-  navigator.clipboard.writeText(text).then(() => {
-    const originalText = element.innerText;
-    element.innerText = "Copied!";
-    element.style.background = "#d4edda";
-    element.style.borderColor = "#c3e6cb";
-    setTimeout(() => {
-      element.innerText = originalText;
-      element.style.background = "#f0f0f0";
-      element.style.borderColor = "#ddd";
-    }, 1200);
-  }).catch(err => console.error(err));
+window.copyToClipboard = function (text, element) {
+  navigator.clipboard
+    .writeText(text)
+    .then(() => {
+      const originalText = element.innerText;
+      element.innerText = "Copied!";
+      element.style.background = "#d4edda";
+      element.style.borderColor = "#c3e6cb";
+      setTimeout(() => {
+        element.innerText = originalText;
+        element.style.background = "#f0f0f0";
+        element.style.borderColor = "#ddd";
+      }, 1200);
+    })
+    .catch((err) => console.error(err));
 };
 
 function copyableCodeChip(code) {

@@ -486,7 +621,9 @@ function serverMassage(msg, extraRaw) {
     try {
       const parsed = JSON.parse(msg);
       if (parsed && typeof parsed === "object" && parsed.type) return parsed;
-    } catch (e) { /* not valid JSON, fall through to plain-text parsing */ }
+    } catch (e) {
+      /* not valid JSON, fall through to plain-text parsing */
+    }
   }
 
   const iobDebitMatch = msg.match(/^rs\.([0-9.]*) debited to CC-xxx2081 .* \[(.*)\]/i);

@@ -496,14 +633,21 @@ function serverMassage(msg, extraRaw) {
 
   const iobCreditMatch = msg.match(/^rs\.([0-9.]*) credited to CC-xxx2081 .* \[(.*)\]/i);
   if (iobCreditMatch) {
-    return { type: "iob-credit", amount: iobCreditMatch[1], merchant: iobCreditMatch[2] || "", msg };
+    return {
+      type: "iob-credit",
+      amount: iobCreditMatch[1],
+      merchant: iobCreditMatch[2] || "",
+      msg,
+    };
   }
 
   let sim = "";
   try {
     const extraJson = extraRaw ? JSON.parse(extraRaw) : null;
     if (extraJson && extraJson.sim) sim = extraJson.sim;
-  } catch (e) { /* extra wasn't valid JSON, ignore */ }
+  } catch (e) {
+    /* extra wasn't valid JSON, ignore */
+  }
 
   const data = { type: "sms", msg, sim };
 

@@ -518,17 +662,24 @@ function serverMassage(msg, extraRaw) {
 
 // Body markup is fully owned by each message type — nothing outside these templates decides how a body renders.
 const messageBodyTemplates = {
-  "iob-debit": data => `<div>
+  "iob-debit": (data) => `<div>
                             <details style="display: inline-block; width: 100%;"><summary style="margin-left: 6rem; display: block; color: red;">- Rs. ${escapeHTML(data.amount, true)}</summary>${escapeHTML(data.msg)}</details>
                         </div>`,
-  "iob-credit": data => `<div>
+  "iob-credit": (data) => `<div>
                             <details style="display: inline-block; width: 100%;"><summary style="display: block; color: green;">+ Rs. ${escapeHTML(data.amount, true)}</summary>${escapeHTML(data.msg)}</details>
                         </div>`,
-  "sms": data => `${data.leakage ? leakageBanner(data.leakage) : ""}${escapeHTML(data.msg)}${data.otp ? copyableCodeChip(data.otp) : ""}`,
-  "dispatch": data => `<span class="badge-status">${escapeHTML(data.status, true)}</span>
+  sms: (data) =>
+    `${data.leakage ? leakageBanner(data.leakage) : ""}${escapeHTML(data.msg)}${data.otp ? copyableCodeChip(data.otp) : ""}`,
+  dispatch: (data) => `<span class="badge-status">${escapeHTML(data.status, true)}</span>
                         <div class="cargo-grid">
-                        ${(data.cargo || []).map(c => `<div class="cargo-item"><span class="kg-badge">${escapeHTML(c.kg, true)}</span>
-                        <span class="qty">${escapeHTML(String(c.qty), true)}</span></div>`).join("")}
+                        ${(data.cargo || [])
+                          .map(
+                            (
+                              c,
+                            ) => `<div class="cargo-item"><span class="kg-badge">${escapeHTML(c.kg, true)}</span>
+                        <span class="qty">${escapeHTML(String(c.qty), true)}</span></div>`,
+                          )
+                          .join("")}
                         </div>
                         <table>
                         <tbody>

@@ -550,7 +701,7 @@ const messageBodyTemplates = {
                             </tr>
                         </tbody>
                         </table>
-                        <button class="value">Acknowledge Invoice</button>`
+                        <button class="value">Acknowledge Invoice</button>`,
 };
 
 function renderMessageBody(data) {

@@ -591,12 +742,12 @@ function setMessageVisibility(element, visible) {
 }
 
 // Master visual filter calculation logic for the live event feed.
-window.applyFilters = function() {
+window.applyFilters = function () {
   const selectedDevice = document.getElementById("filter-device").value;
   const selectedCategory = document.getElementById("filter-category").value;
   const searchQuery = document.getElementById("filter-search").value.toLowerCase();
-  
-  document.querySelectorAll("#data-list .msg-list-item").forEach(element => {
+
+  document.querySelectorAll("#data-list .msg-list-item").forEach((element) => {
     const matchesDevice = !selectedDevice || element.dataset.device === selectedDevice;
     const matchesCategory = !selectedCategory || element.dataset.category === selectedCategory;
     const matchesSearch = !searchQuery || element.innerText.toLowerCase().includes(searchQuery);

@@ -605,22 +756,22 @@ window.applyFilters = function() {
 };
 
 // Search-only filter for the action-required panel.
-window.applyActionFilters = function() {
+window.applyActionFilters = function () {
   const searchInput = document.getElementById("action-filter-search");
   const searchQuery = searchInput ? searchInput.value.toLowerCase() : "";
 
-  document.querySelectorAll("#action-list .msg-list-item").forEach(element => {
+  document.querySelectorAll("#action-list .msg-list-item").forEach((element) => {
     const matchesSearch = !searchQuery || element.innerText.toLowerCase().includes(searchQuery);
     setMessageVisibility(element, matchesSearch);
   });
 };
 
-window.showMobileSegment = function(segmentNumber) {
-  document.querySelectorAll(".segment").forEach(segment => {
+window.showMobileSegment = function (segmentNumber) {
+  document.querySelectorAll(".segment").forEach((segment) => {
     segment.classList.toggle("active", segment.dataset.segment === String(segmentNumber));
   });
 
-  document.querySelectorAll(".mobile-panel-switch button").forEach(button => {
+  document.querySelectorAll(".mobile-panel-switch button").forEach((button) => {
     const isActive = button.dataset.targetSegment === String(segmentNumber);
     button.classList.toggle("active", isActive);
     button.setAttribute("aria-pressed", isActive ? "true" : "false");

@@ -636,27 +787,26 @@ function epochSecondsFromLocalInput(value) {
   return Math.floor(Date.UTC(year, month - 1, day, hour - 5, minute - 30, 0, 0) / 1000);
 }
 
-
 // 1. Updated helper function that explicitly forces Asia/Kolkata timezone
 function formatDateTimeLocalIST(date) {
   const options = {
-    timeZone: 'Asia/Kolkata',
-    year: 'numeric',
-    month: '2-digit',
-    day: '2-digit',
-    hour: '2-digit',
-    minute: '2-digit',
-    hour12: false // Ensures 24-hour format
+    timeZone: "Asia/Kolkata",
+    year: "numeric",
+    month: "2-digit",
+    day: "2-digit",
+    hour: "2-digit",
+    minute: "2-digit",
+    hour12: false, // Ensures 24-hour format
   };
 
   // This formats the date into an array of parts based on IST rules
-  const formatter = new Intl.DateTimeFormat('en-US', options);
+  const formatter = new Intl.DateTimeFormat("en-US", options);
   const parts = formatter.formatToParts(date);
 
   // Extract the parts to construct the exact YYYY-MM-DDTHH:mm string
-  const getPart = type => parts.find(p => p.type === type).value;
+  const getPart = (type) => parts.find((p) => p.type === type).value;
 
-  return `${getPart('year')}-${getPart('month')}-${getPart('day')}T${getPart('hour')}:${getPart('minute')}`;
+  return `${getPart("year")}-${getPart("month")}-${getPart("day")}T${getPart("hour")}:${getPart("minute")}`;
 }
 
 function initRangeFields(force = false) {

@@ -667,15 +817,13 @@ function initRangeFields(force = false) {
   const now = new Date();
 
   if (force || !rangeFieldsInitialized || !fromInput.value) {
-    const fromDate = new Date(now.getTime() - (config.defaultRangeHours * 60 * 60 * 1000));
+    const fromDate = new Date(now.getTime() - config.defaultRangeHours * 60 * 60 * 1000);
     fromInput.value = formatDateTimeLocalIST(fromDate);
     rangeFieldsInitialized = true;
   }
   toInput.value = formatDateTimeLocalIST(now);
 }
 
-
-
 function getRangeParams() {
   initRangeFields();
   const fromInput = document.getElementById("range-from");

@@ -697,7 +845,7 @@ function getRangeParams() {
   return params;
 }
 
-window.refreshRangeFeeds = function() {
+window.refreshRangeFeeds = function () {
   initRangeFields();
   fetchUpdates();
   fetchActionUpdates();

@@ -723,8 +871,8 @@ function updateCategoryDropdown(category) {
 
   const option = document.createElement("option");
   option.value = category;
-  
-  if (category === 'otp' || category === 'sms') {
+
+  if (category === "otp" || category === "sms") {
     option.textContent = `${category.toUpperCase()} Only`;
   } else {
     option.textContent = category.charAt(0).toUpperCase() + category.slice(1);

@@ -733,48 +881,50 @@ function updateCategoryDropdown(category) {
 }
 
 function fallbackDeviceName(mid) {
-    return mid ? `Device ${mid}` : "unknown";
+  return mid ? `Device ${mid}` : "unknown";
 }
 
 function getDeviceNameFromId(mid) {
-    const cached = deviceMapCache[mid];
-    if (cached && typeof cached === "object" && cached.name) return cached.name;
-    fetchDeviceDetails(mid).then(device => updateDeviceReferences(mid, device));
-    return fallbackDeviceName(mid);
+  const cached = deviceMapCache[mid];
+  if (cached && typeof cached === "object" && cached.name) return cached.name;
+  fetchDeviceDetails(mid).then((device) => updateDeviceReferences(mid, device));
+  return fallbackDeviceName(mid);
 }
 
 function cssEscape(value) {
-    if (window.CSS && CSS.escape) return CSS.escape(value);
-    return value.replace(/[^a-zA-Z0-9_-]/g, "\\$&");
+  if (window.CSS && CSS.escape) return CSS.escape(value);
+  return value.replace(/[^a-zA-Z0-9_-]/g, "\\$&");
 }
 
 function updateDeviceReferences(mid, device) {
-    if (!mid || !device || !device.name) return;
-    document.querySelectorAll(`.device-name-button[data-mid="${cssEscape(String(mid))}"]`).forEach(button => {
-        button.textContent = device.name;
-        const item = button.closest(".msg-list-item");
-        if (item) item.dataset.device = String(mid);
+  if (!mid || !device || !device.name) return;
+  document
+    .querySelectorAll(`.device-name-button[data-mid="${cssEscape(String(mid))}"]`)
+    .forEach((button) => {
+      button.textContent = device.name;
+      const item = button.closest(".msg-list-item");
+      if (item) item.dataset.device = String(mid);
     });
-    const option = document.querySelector(`#filter-device option[value="${cssEscape(String(mid))}"]`);
-    if (option) option.textContent = device.name;
+  const option = document.querySelector(`#filter-device option[value="${cssEscape(String(mid))}"]`);
+  if (option) option.textContent = device.name;
 }
 
 function getCategoryNameFromId(cid) {
-    // TODO Get from kidang and cache
-    let deviceIdMap = {
-        "1": "sms",
-        "2": "econnect",
-        "3": "paytm",
-        "4": "tampermonkey",
-        "5": "printer"
-    };
-    return deviceIdMap[cid + ""];
+  // TODO Get from kidang and cache
+  let deviceIdMap = {
+    1: "sms",
+    2: "econnect",
+    3: "paytm",
+    4: "tampermonkey",
+    5: "printer",
+  };
+  return deviceIdMap[cid + ""];
 }
 
 function getDeterministicColor(str) {
   let hash = 0;
   for (let i = 0; i < str.length; i++) hash = str.charCodeAt(i) + ((hash << 5) - hash);
-  return `hsl(${Math.abs(hash) % 360}, 65%, 42%)`; 
+  return `hsl(${Math.abs(hash) % 360}, 65%, 42%)`;
 }
 
 function insertInOrder(parent, newChild, newTimestamp) {

@@ -790,71 +940,76 @@ function insertInOrder(parent, newChild, newTimestamp) {
 }
 
 function isActionRequiredItem(item) {
-    const sender = String(item.sndr || "").toLowerCase();
-    const msg = String(item.msg || "").toLowerCase();
-    const category = getCategoryNameFromId(item.cid) || "";
-    return sender === "complaints" || category === "econnect" && /\b(urgent|emergency|complain|complaint|leak)/i.test(msg);
+  const sender = String(item.sndr || "").toLowerCase();
+  const msg = String(item.msg || "").toLowerCase();
+  const category = getCategoryNameFromId(item.cid) || "";
+  return (
+    sender === "complaints" ||
+    (category === "econnect" && /\b(urgent|emergency|complain|complaint|leak)/i.test(msg))
+  );
 }
 
 function removeDeadItems(parent, freshData) {
-    const freshIds = freshData.map(item => `msg-${item.sndr}-${item.sentstamp}`.replace(/[^a-zA-Z0-9-]/g, '_'));
-    parent.querySelectorAll('li[id^="msg-"]').forEach(item => {
-        if (!freshIds.includes(item.id)) item.remove();
-    });
+  const freshIds = freshData.map((item) =>
+    `msg-${item.sndr}-${item.sentstamp}`.replace(/[^a-zA-Z0-9-]/g, "_"),
+  );
+  parent.querySelectorAll('li[id^="msg-"]').forEach((item) => {
+    if (!freshIds.includes(item.id)) item.remove();
+  });
 }
 
 // Builds one <li class="msg-list-item"> from a raw item ({ sndr, sentstamp, mid, cid, msg, extra }),
 // using serverMassage() + the header/body templates above. Shared by the live OTP feed and any other
 // message list (e.g. the sample action-required item below) so both render through the same templates.
 function createMessageListItem(item) {
-    const sentDate = getDateFromEpoch(item.sentstamp);
-    if (!sentDate) return null;
-
-    const dName = getDeviceNameFromId(item.mid) || fallbackDeviceName(item.mid);
-    const cId = getCategoryNameFromId(item.cid) || "unknown";
-    const messageData = serverMassage(item.msg, item.extra);
-
-    const listItem = document.createElement("li");
-    listItem.id = `msg-${item.sndr}-${item.sentstamp}`.replace(/[^a-zA-Z0-9-]/g, '_');
-    listItem.className = "msg-list-item";
-    listItem.dataset.device = String(item.mid || "unknown");
-    listItem.dataset.category = cId;
-    listItem.dataset.timestamp = item.sentstamp;
-
-    listItem.style.display = "flex";
-    listItem.style.alignItems = "flex-start";
-    listItem.style.padding = "10px 12px";
-    listItem.style.borderBottom = "1px solid #f2f2f2";
-
-    if (messageData.leakage) {
-        listItem.style.background = "#fff5f5";
-        listItem.style.borderLeft = "4px solid #dc3545";
-    }
+  const sentDate = getDateFromEpoch(item.sentstamp);
+  if (!sentDate) return null;
+
+  const dName = getDeviceNameFromId(item.mid) || fallbackDeviceName(item.mid);
+  const cId = getCategoryNameFromId(item.cid) || "unknown";
+  const messageData = serverMassage(item.msg, item.extra);
+
+  const listItem = document.createElement("li");
+  listItem.id = `msg-${item.sndr}-${item.sentstamp}`.replace(/[^a-zA-Z0-9-]/g, "_");
+  listItem.className = "msg-list-item";
+  listItem.dataset.device = String(item.mid || "unknown");
+  listItem.dataset.category = cId;
+  listItem.dataset.timestamp = item.sentstamp;
+
+  listItem.style.display = "flex";
+  listItem.style.alignItems = "flex-start";
+  listItem.style.padding = "10px 12px";
+  listItem.style.borderBottom = "1px solid #f2f2f2";
+
+  if (messageData.leakage) {
+    listItem.style.background = "#fff5f5";
+    listItem.style.borderLeft = "4px solid #dc3545";
+  }
 
-    const iconColor = getDeterministicColor(item.sndr || 'Unknown');
+  const iconColor = getDeterministicColor(item.sndr || "Unknown");
 
-    let imgType = "";
-    if (cId === "sms") {
-        imgType=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="${iconColor}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
+  let imgType = "";
+  if (cId === "sms") {
+    imgType = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="${iconColor}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
             <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
             </svg>`;
-    } else if (cId === "tampermonkey") {
-        imgType = '<img src="/assets/tampermonkey.svg">';
-    } else if (cId === "printer") {
-        imgType = '<img src="/assets/printer.svg">';
-    } else {
-        imgType = '<img style="height: 16px; width: 16px;" src="/assets/logs/cid-2-16x.png">';
-    }
+  } else if (cId === "tampermonkey") {
+    imgType = '<img src="/assets/tampermonkey.svg">';
+  } else if (cId === "printer") {
+    imgType = '<img src="/assets/printer.svg">';
+  } else {
+    imgType = '<img style="height: 16px; width: 16px;" src="/assets/logs/cid-2-16x.png">';
+  }
 
-    listItem.innerHTML = `
+  listItem.innerHTML = `
                     <div style="flex-grow: 1; min-width: 0; display: flex; flex-direction: column;">
                     ${renderMessageHeader({
-                        imgType,
-                        sender: escapeHTML(item.sndr, true),
-                        headerLabel: escapeHTML(getHeaderLabel(messageData), true),
-                        timeStr: formatTimeOnly(sentDate),
-                        mid: item.mid,
-                        deviceName: escapeHTML(dName, true)
+                      imgType,
+                      sender: escapeHTML(item.sndr, true),
+                      headerLabel: escapeHTML(getHeaderLabel(messageData), true),
+                      timeStr: formatTimeOnly(sentDate),
+                      mid: item.mid,
+                      deviceName: escapeHTML(dName, true),
                     })}
 
                     <!-- Body markup is fully owned by the message type template -->

@@ -863,207 +1018,216 @@ function createMessageListItem(item) {
                     </div>
                     </div>
                     `;
-    return listItem;
+  return listItem;
 }
 
 function parseFeedResponse(textData) {
-    const trimmed = textData.trim();
-    if (!trimmed) return [];
-    if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
-        try {
-            const parsed = JSON.parse(trimmed);
-            if (Array.isArray(parsed)) return parsed;
-            if (Array.isArray(parsed.rows)) return parsed.rows;
-            if (Array.isArray(parsed.data)) return parsed.data;
-            return [parsed];
-        } catch (e) {
-            // kidang's GT format can also start with "{"/"[" but is not JSON.
-            // Fall through to the legacy GT parser instead of breaking the live feed.
-        }
+  const trimmed = textData.trim();
+  if (!trimmed) return [];
+  if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
+    try {
+      const parsed = JSON.parse(trimmed);
+      if (Array.isArray(parsed)) return parsed;
+      if (Array.isArray(parsed.rows)) return parsed.rows;
+      if (Array.isArray(parsed.data)) return parsed.data;
+      return [parsed];
+    } catch (e) {
+      // kidang's GT format can also start with "{"/"[" but is not JSON.
+      // Fall through to the legacy GT parser instead of breaking the live feed.
     }
-    const parsed = parseGT(textData);
-    return Array.isArray(parsed) ? parsed : [parsed];
+  }
+  const parsed = parseGT(textData);
+  return Array.isArray(parsed) ? parsed : [parsed];
 }
 
 async function fetchTable(tableName, queryParams = {}) {
-    const params = new URLSearchParams({ table: tableName });
-    Object.entries(queryParams).forEach(([key, value]) => {
-        if (value !== null && value !== undefined && value !== "") params.set(key, value);
-    });
+  const params = new URLSearchParams({ table: tableName });
+  Object.entries(queryParams).forEach(([key, value]) => {
+    if (value !== null && value !== undefined && value !== "") params.set(key, value);
+  });
 
-    const response = await fetch(`${config.endpoint}?${params.toString()}`);
-    if (!response.ok) throw new Error(`${tableName} fetch failed: ${response.status}`);
-    return parseFeedResponse(await response.text());
+  const response = await fetch(`${config.endpoint}?${params.toString()}`);
+  if (!response.ok) throw new Error(`${tableName} fetch failed: ${response.status}`);
+  return parseFeedResponse(await response.text());
 }
 
 async function fetchUpdates() {
-    try {
-        const rangeParams = getRangeParams();
-        const data = await fetchTable(config.otpTable, rangeParams);
-        const list = document.getElementById("data-list");
-        const toTimestampMs = rangeParams.toTimestamp ? rangeParams.toTimestamp * 1000 : null;
-        const rangedData = toTimestampMs ? data.filter(item => item.sentstamp <= toTimestampMs) : data;
-
-        rangedData.sort((a, b) => b.sentstamp - a.sentstamp);
-        applyTvaMetricUpdatesFromRows(rangedData);
-
-        const historySeenAlerts = getSeenLeaksLog();
-        const eventData = [];
-        const actionData = [];
-
-        rangedData.forEach(item => {
-            if (isTvaMetricsItem(item)) return;
-
-            const cId = getCategoryNameFromId(item.cid) || "unknown";
-
-            updateDeviceDropdown(item.mid);
-            updateCategoryDropdown(cId);
-
-            const isActionRequired = isActionRequiredItem(item);
-            const targetList = isActionRequired ? document.getElementById("action-list") : list;
-            if (isActionRequired) actionData.push(item);
-            else eventData.push(item);
-
-            const itemDomId = `msg-${item.sndr}-${item.sentstamp}`.replace(/[^a-zA-Z0-9-]/g, '_');
-            if (targetList && targetList.querySelector(`#${cssEscape(itemDomId)}`)) return;
-
-            const messageData = serverMassage(item.msg, item.extra);
-
-            // Fires sound and alert banners only if it hasn't popped during this browser session
-            if (messageData.leakage && !historySeenAlerts.includes(itemDomId)) {
-                markLeakAsSeen(itemDomId);
-                historySeenAlerts.push(itemDomId);
-                // FIXME Enable later
-                playAlarmSound();
-                triggerDesktopNotification(item.sndr, item.msg, item.mid);
-            }
-
-            const listItem = createMessageListItem(item);
-            if (targetList && listItem) insertInOrder(targetList, listItem, item.sentstamp);
-        });
-        removeDeadItems(list, eventData);
-        const actionList = document.getElementById("action-list");
-        if (actionList) {
-            removeDeadItems(actionList, actionData);
-            updateActionRequiredChart(actionData);
-            applyActionFilters();
-            syncDateDividers(actionList);
-        }
-        applyFilters();
-        syncDateDividers(list);
-    } catch (error) {
-        console.error("Error fetching updates:", error);
+  try {
+    const rangeParams = getRangeParams();
+    const data = await fetchTable(config.otpTable, rangeParams);
+    const list = document.getElementById("data-list");
+    const toTimestampMs = rangeParams.toTimestamp ? rangeParams.toTimestamp * 1000 : null;
+    const rangedData = toTimestampMs
+      ? data.filter((item) => item.sentstamp <= toTimestampMs)
+      : data;
+
+    rangedData.sort((a, b) => b.sentstamp - a.sentstamp);
+    applyTvaMetricUpdatesFromRows(rangedData);
+
+    const historySeenAlerts = getSeenLeaksLog();
+    const eventData = [];
+    const actionData = [];
+
+    rangedData.forEach((item) => {
+      if (isTvaMetricsItem(item)) return;
+
+      const cId = getCategoryNameFromId(item.cid) || "unknown";
+
+      updateDeviceDropdown(item.mid);
+      updateCategoryDropdown(cId);
+
+      const isActionRequired = isActionRequiredItem(item);
+      const targetList = isActionRequired ? document.getElementById("action-list") : list;
+      if (isActionRequired) actionData.push(item);
+      else eventData.push(item);
+
+      const itemDomId = `msg-${item.sndr}-${item.sentstamp}`.replace(/[^a-zA-Z0-9-]/g, "_");
+      if (targetList && targetList.querySelector(`#${cssEscape(itemDomId)}`)) return;
+
+      const messageData = serverMassage(item.msg, item.extra);
+
+      // Fires sound and alert banners only if it hasn't popped during this browser session
+      if (messageData.leakage && !historySeenAlerts.includes(itemDomId)) {
+        markLeakAsSeen(itemDomId);
+        historySeenAlerts.push(itemDomId);
+        // FIXME Enable later
+        playAlarmSound();
+        triggerDesktopNotification(item.sndr, item.msg, item.mid);
+      }
+
+      const listItem = createMessageListItem(item);
+      if (targetList && listItem) insertInOrder(targetList, listItem, item.sentstamp);
+    });
+    removeDeadItems(list, eventData);
+    const actionList = document.getElementById("action-list");
+    if (actionList) {
+      removeDeadItems(actionList, actionData);
+      updateActionRequiredChart(actionData);
+      applyActionFilters();
+      syncDateDividers(actionList);
     }
+    applyFilters();
+    syncDateDividers(list);
+  } catch (error) {
+    console.error("Error fetching updates:", error);
+  }
 }
 
 async function fetchActionUpdates() {
-    const list = document.getElementById("action-list");
-    if (!list || !config.actionTable) return;
+  const list = document.getElementById("action-list");
+  if (!list || !config.actionTable) return;
 
-    try {
-        const rangeParams = getRangeParams();
-        const data = await fetchTable(config.actionTable, rangeParams);
-        const toTimestampMs = rangeParams.toTimestamp ? rangeParams.toTimestamp * 1000 : null;
-        const rangedData = toTimestampMs ? data.filter(item => item.sentstamp <= toTimestampMs) : data;
-
-        rangedData.sort((a, b) => b.sentstamp - a.sentstamp);
-        applyTvaMetricUpdatesFromRows(rangedData);
-
-        rangedData.forEach(item => {
-            if (isTvaMetricsItem(item)) return;
-            const itemDomId = `msg-${item.sndr}-${item.sentstamp}`.replace(/[^a-zA-Z0-9-]/g, '_');
-            if (document.getElementById(itemDomId)) return;
-
-            const listItem = createMessageListItem(item);
-            if (listItem) insertInOrder(list, listItem, item.sentstamp);
-        });
-
-        removeDeadItems(list, rangedData);
-        updateActionRequiredChart(rangedData);
-        applyActionFilters();
-        syncDateDividers(list);
-    } catch (error) {
-        // Some deployments do not have the action-required table yet. Stop polling
-        // after the first server-side failure so the normal OTP feed stays quiet.
-        if (String(error.message || "").match(/\b(404|500)\b/)) {
-            console.warn("Action-required feed unavailable; stopping action polling.", error);
-            config.actionTable = null;
-            if (actionFetchIntervalId) clearInterval(actionFetchIntervalId);
-            return;
-        }
-        console.error("Error fetching action-required updates:", error);
+  try {
+    const rangeParams = getRangeParams();
+    const data = await fetchTable(config.actionTable, rangeParams);
+    const toTimestampMs = rangeParams.toTimestamp ? rangeParams.toTimestamp * 1000 : null;
+    const rangedData = toTimestampMs
+      ? data.filter((item) => item.sentstamp <= toTimestampMs)
+      : data;
+
+    rangedData.sort((a, b) => b.sentstamp - a.sentstamp);
+    applyTvaMetricUpdatesFromRows(rangedData);
+
+    rangedData.forEach((item) => {
+      if (isTvaMetricsItem(item)) return;
+      const itemDomId = `msg-${item.sndr}-${item.sentstamp}`.replace(/[^a-zA-Z0-9-]/g, "_");
+      if (document.getElementById(itemDomId)) return;
+
+      const listItem = createMessageListItem(item);
+      if (listItem) insertInOrder(list, listItem, item.sentstamp);
+    });
+
+    removeDeadItems(list, rangedData);
+    updateActionRequiredChart(rangedData);
+    applyActionFilters();
+    syncDateDividers(list);
+  } catch (error) {
+    // Some deployments do not have the action-required table yet. Stop polling
+    // after the first server-side failure so the normal OTP feed stays quiet.
+    if (String(error.message || "").match(/\b(404|500)\b/)) {
+      console.warn("Action-required feed unavailable; stopping action polling.", error);
+      config.actionTable = null;
+      if (actionFetchIntervalId) clearInterval(actionFetchIntervalId);
+      return;
     }
+    console.error("Error fetching action-required updates:", error);
+  }
 }
 
-function $(id) { return document.getElementById(id); }
+function $(id) {
+  return document.getElementById(id);
+}
 
 let deviceMapCache = {};
 
 function fetchDeviceDetails(id) {
-    if (!id) return Promise.resolve(null);
-    const key = String(id);
-    const cached = deviceMapCache[key];
-    if (cached && typeof cached.then === "function") return cached;
-    if (cached && typeof cached === "object") return Promise.resolve(cached);
-
-    const promise = fetch('/logs.php?id=' + encodeURIComponent(key))
-        .then(async r => {
-            let device = null;
-            try {
-                device = await r.json();
-            } catch (error) {
-                throw new Error(`Device lookup returned invalid JSON: ${r.status}`);
-            }
-            if (!r.ok) throw new Error(device && device.error ? device.error : `Device lookup failed: ${r.status}`);
-            if (!device || !device.name) throw new Error('Device lookup response missing name');
-            return device;
-        })
-        .then(device => {
-            deviceMapCache[key] = device;
-            updateDeviceReferences(key, device);
-            return device;
-        })
-        .catch(error => {
-            console.warn("Device lookup failed", key, error);
-            delete deviceMapCache[key];
-            return null;
-        });
-    deviceMapCache[key] = promise;
-    return promise;
+  if (!id) return Promise.resolve(null);
+  const key = String(id);
+  const cached = deviceMapCache[key];
+  if (cached && typeof cached.then === "function") return cached;
+  if (cached && typeof cached === "object") return Promise.resolve(cached);
+
+  const promise = fetch("/logs.php?id=" + encodeURIComponent(key))
+    .then(async (r) => {
+      let device = null;
+      try {
+        device = await r.json();
+      } catch (error) {
+        throw new Error(`Device lookup returned invalid JSON: ${r.status}`);
+      }
+      if (!r.ok)
+        throw new Error(
+          device && device.error ? device.error : `Device lookup failed: ${r.status}`,
+        );
+      if (!device || !device.name) throw new Error("Device lookup response missing name");
+      return device;
+    })
+    .then((device) => {
+      deviceMapCache[key] = device;
+      updateDeviceReferences(key, device);
+      return device;
+    })
+    .catch((error) => {
+      console.warn("Device lookup failed", key, error);
+      delete deviceMapCache[key];
+      return null;
+    });
+  deviceMapCache[key] = promise;
+  return promise;
 }
 
 function updateDeviceCard(device) {
-    device = device || {};
-    $('p-name').parentNode.style.borderColor = device.category_color || "gray";
-    $('p-name').parentNode.style.borderWidth = '1px';
-    $('p-name').parentNode.style.borderStyle = 'solid';
-    $('p-name').textContent = device.name || "Loading device…";
-    $('p-assigned-to').textContent = device.assigned_to || "";
-    $('p-image').src = device.image || '';
-    $('p-notes').textContent = device.notes || "";
-    $('p-serial').textContent = device.serial || "";
+  device = device || {};
+  $("p-name").parentNode.style.borderColor = device.category_color || "gray";
+  $("p-name").parentNode.style.borderWidth = "1px";
+  $("p-name").parentNode.style.borderStyle = "solid";
+  $("p-name").textContent = device.name || "Loading device…";
+  $("p-assigned-to").textContent = device.assigned_to || "";
+  $("p-image").src = device.image || "";
+  $("p-notes").textContent = device.notes || "";
+  $("p-serial").textContent = device.serial || "";
 }
 
 function placeDevicePopoverNear(el) {
-    const popover = document.getElementById("device-info-popover");
-    if (!popover || !el) return;
-    const rect = el.getBoundingClientRect();
-    popover.style.position = "fixed";
-    popover.style.left = `${Math.min(rect.left, window.innerWidth - 320)}px`;
-    popover.style.top = `${Math.min(rect.bottom + 6, window.innerHeight - 180)}px`;
-    popover.style.inset = "auto";
+  const popover = document.getElementById("device-info-popover");
+  if (!popover || !el) return;
+  const rect = el.getBoundingClientRect();
+  popover.style.position = "fixed";
+  popover.style.left = `${Math.min(rect.left, window.innerWidth - 320)}px`;
+  popover.style.top = `${Math.min(rect.bottom + 6, window.innerHeight - 180)}px`;
+  popover.style.inset = "auto";
 }
 
 function deviceCardUpdate(ev) {
-    const el = ev.target;
-    const id = el.dataset.mid;
+  const el = ev.target;
+  const id = el.dataset.mid;
+  placeDevicePopoverNear(el);
+  updateDeviceCard({ name: fallbackDeviceName(id) });
+  if (!id) return;
+  fetchDeviceDetails(id).then((device) => {
+    if (device) updateDeviceCard(device);
     placeDevicePopoverNear(el);
-    updateDeviceCard({ name: fallbackDeviceName(id) });
-    if (!id) return;
-    fetchDeviceDetails(id).then(device => {
-        if (device) updateDeviceCard(device);
-        placeDevicePopoverNear(el);
-    });
+  });
 }
 
 // parent.querySelectorAll('li[id^="msg-"]').forEach(item => {if (!freshIds.includes(item.id)) item.remove();});}if ("Notification" in window && Notification.permission !== "granted" && Notification.permission !== "denied") {Notification.requestPermission();}var fetchIntervalId = setInterval(fetchUpdates, 2000);

@@ -1082,12 +1246,15 @@ fetchUpdates();
 // logs.js runs before <ul id="action-list"> exists in the DOM (script tag comes before .content),
 // so action-required polling starts after the parser has created that panel.
 document.addEventListener("DOMContentLoaded", () => {
-    if (window.matchMedia) window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyLogsSettingsToDom);
-    initLogsSettingsDialog();
-    applyLogsSettingsToDom();
-    initRangeFields();
-    initActionRequiredChart();
-    fetchUpdates();
-    fetchActionUpdates();
-    actionFetchIntervalId = setInterval(fetchActionUpdates, 3000);
+  if (window.matchMedia)
+    window
+      .matchMedia("(prefers-color-scheme: dark)")
+      .addEventListener("change", applyLogsSettingsToDom);
+  initLogsSettingsDialog();
+  applyLogsSettingsToDom();
+  initRangeFields();
+  initActionRequiredChart();
+  fetchUpdates();
+  fetchActionUpdates();
+  actionFetchIntervalId = setInterval(fetchActionUpdates, 3000);
 });
diff --git a/tests/tva-control.test.js b/tests/tva-control.test.js
@@ -1,28 +1,43 @@
-const assert = require('assert');
-const fs = require('fs');
-const vm = require('vm');
+const assert = require("assert");
+const fs = require("fs");
+const vm = require("vm");
 
-const code = fs.readFileSync('tva-control.js', 'utf8');
-const context = { window: {}, console, setInterval() { return 1; }, clearInterval() {} };
+const code = fs.readFileSync("tva-control.js", "utf8");
+const context = {
+  window: {},
+  console,
+  setInterval() {
+    return 1;
+  },
+  clearInterval() {},
+};
 vm.createContext(context);
 vm.runInContext(code, context);
 
 const { getTrend, isStale, mergeData } = context.window.TvaControlInternals;
 
-assert.equal(getTrend(10, 10), 'flat');
-assert.equal(getTrend(10, 24), 'flat');
-assert.equal(getTrend(10, 25), 'up');
-assert.equal(getTrend(25, 10), 'down');
-assert.equal(getTrend(undefined, 10), 'flat');
-assert.equal(getTrend(10, 24, 10), 'up');
-assert.equal(getTrend(24, 10, 10), 'down');
+assert.equal(getTrend(10, 10), "flat");
+assert.equal(getTrend(10, 24), "flat");
+assert.equal(getTrend(10, 25), "up");
+assert.equal(getTrend(25, 10), "down");
+assert.equal(getTrend(undefined, 10), "flat");
+assert.equal(getTrend(10, 24, 10), "up");
+assert.equal(getTrend(24, 10, 10), "down");
 
 assert.equal(isStale(Date.now() - 1_000, 5_000, Date.now()), false);
 assert.equal(isStale(Date.now() - 6_000, 5_000, Date.now()), true);
 assert.equal(isStale(null, 5_000, Date.now()), true);
 assert.equal(isStale(null, 0, Date.now()), false);
 
-assert.equal(mergeData({ refillSpreadDays: 0 }, { bookingAgeDays: 7 }, { bookingAgeDays: 'refillSpreadDays' }).refillSpreadDays, 7);
-assert.equal(mergeData({ bpclDepositLakhs: 0 }, { bpclDeposit: 3 }, { bpclDeposit: 'bpclDepositLakhs' }).bpclDepositLakhs, 3);
+assert.equal(
+  mergeData({ refillSpreadDays: 0 }, { bookingAgeDays: 7 }, { bookingAgeDays: "refillSpreadDays" })
+    .refillSpreadDays,
+  7,
+);
+assert.equal(
+  mergeData({ bpclDepositLakhs: 0 }, { bpclDeposit: 3 }, { bpclDeposit: "bpclDepositLakhs" })
+    .bpclDepositLakhs,
+  3,
+);
 
-console.log('tva-control tests passed');
+console.log("tva-control tests passed");
diff --git a/tva-control-demo.html b/tva-control-demo.html
@@ -1,130 +1,291 @@
 <!doctype html>
 <html lang="en">
-<head>
-  <meta charset="utf-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1">
-  <title>TVA Control Demo</title>
-  <link rel="stylesheet" href="tva-control.css">
-  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
-  <script src="tva-control.js"></script>
-  <style>
-    body { background: #0e0e0e; color: #eee; font-family: system-ui, sans-serif; margin: 24px; transition: background 180ms ease, color 180ms ease; }
-    body.demo-light { background: #fff; color: #333; }
-    .demo-toolbar { align-items: center; display: flex; gap: 8px; margin: 0 0 14px; }
-    .demo-toolbar button { background: #222; border: 1px solid #555; color: #eee; cursor: pointer; font: 700 12px/1 system-ui, sans-serif; padding: 8px 10px; }
-    body.demo-light .demo-toolbar button { background: #fff; border-color: #b9c7c4; color: #173f3a; }
-    .demo-toolbar button.is-active { border-color: #00b49f; box-shadow: 0 0 0 2px rgba(0, 180, 159, .18); }
-    .tva-control-container { max-width: 920px; }
-  </style>
-</head>
-<body>
-  <h1>TVA Control Demo</h1>
-  <div class="demo-toolbar" aria-label="Theme switcher">
-    <button type="button" data-theme="dark" class="is-active">Dark</button>
-    <button type="button" data-theme="light">Light</button>
-    <button type="button" data-theme="auto">Auto</button>
-  </div>
-  <div id="demo-chart" class="tva-control-container" data-tva-theme="dark"><canvas></canvas></div>
-  <script>
-    const config = {
-      title: 'TVA REACTIVE CHANNEL',
-      blinkMs: 1100,
-      aliases: {
-        bookingAgeDays: 'refillSpreadDays',
-        bookingSpreadDays: 'refillSpreadDays',
-        bpclDeposit: 'bpclDepositLakhs'
-      },
-      ambientGlow: { enabled: true, alpha: 0.14, radius: 74, blur: 42 },
-      warningLevels: [
-        { key: 'amber', label: 'AMBER ALERT', priority: 1, showAxis: true, dominance: 0.6, axisAlpha: 0.28, axisWidth: 1.45, axisDash: [3, 5], glowAlpha: 0.12 },
-        { key: 'red', label: 'CRITICAL', priority: 2, showAxis: true, dominance: 0.7, axisAlpha: 0.42, axisWidth: 1.45, axisDash: [6, 6], glowAlpha: 0.16 },
-        { key: 'double-red', label: 'DOUBLE RED', priority: 3, showAxis: false, dominance: 0.7, borderBlink: true, glowAlpha: 0.18, glowRadius: 88, glowBlur: 54 }
-      ],
-      colors: {
-        amber: '#ffcc00',
-        red: '#ff0055',
-        'double-red': '#ff1a1a',
-        disabled: '#777777'
-      },
-      staleAlpha: 0.35,
-      parameters: [
-        { key: 'complaintsOpen', label: 'Complaints Open', icon: 'warning', scale: 'count10', refreshMinutes: 15, thresholds: { amberUpper: 52.5, redUpper: 75, amberLower: -52.5, redLower: -75 } },
-        { key: 'invoiceActions', label: 'Invoice Actions', icon: 'invoice', scale: 'count10', refreshMinutes: 15, thresholds: { amberUpper: 59.5, redUpper: 85, amberLower: -59.5, redLower: -85 } },
-        { key: 'deliveryPersonLeave', label: 'Delivery Person Leave', icon: 'person', scale: 'count10', refreshMinutes: 720, thresholds: { amberUpper: 49, redUpper: 70, amberLower: -49, redLower: -70 } },
-        { key: 'refillSpreadDays', label: 'Refill Spread', icon: 'calendar', scale: 'daysCritical', scaleBase: 10, scaleMax: 165, refreshMinutes: 1440, display: { suffix: 'd' }, thresholds: { amberUpper: 50, redUpper: 100, doubleRedUpper: 150, amberLower: -70, redLower: -100 }, detailMode: 'refill-spread', areaKey: 'refillSpreadAreas', detailTitle: 'REFILL SPREAD AREA SCAN', detailLevels: [{ level: 'amber', above: 5 }, { level: 'red', above: 10 }] },
-        { key: 'pendencyDays', label: 'Pendency', icon: 'hourglass', scale: 'pendency', scaleIdeal: 1, scaleBase: 3, scaleMax: 115, refreshMinutes: 720, display: { suffix: 'd', decimals: 1 }, thresholds: { amberUpper: 33.33, redUpper: 100, amberLower: -70, redLower: -100 }, detailMode: 'pendency', areaKey: 'pendencyAreas', detailTitle: 'PENDENCY AREA SCAN', detailLevels: [{ level: 'amber', above: 1 }, { level: 'red', above: 3 }] },
-        { key: 'bpclDepositLakhs', label: 'BPCL Deposit', icon: 'deposit', scale: 'raw', refreshMinutes: 30, display: { prefix: '₹', suffix: 'L', decimals: 1 }, thresholds: { amberUpper: 4, redUpper: 6, amberLower: -1, redLower: -3 } }
-      ],
-      extraAxes: [
-        { label: 'BPCL Deposit Good', parameterKey: 'bpclDepositLakhs', value: 6, color: 'rgba(0,255,120,.5)', width: 1.8, dash: [4, 4] },
-        { label: 'BPCL Deposit Soft', parameterKey: 'bpclDepositLakhs', value: 4, color: 'rgba(120,255,160,.34)', width: 1.4, dash: [2, 5] }
-      ]
-    };
-
-    const data = {
-      complaintsOpen: 0,
-      invoiceActions: 2,
-      deliveryPersonLeave: 0,
-      refillSpreadDays: 12,
-      pendencyDays: 2.7,
-      bpclDepositLakhs: 3,
-      updatedAt: {
-        bpclDepositLakhs: Date.now() - (31 * 60 * 1000)
-      },
-      refillSpreadAreas: {
-        'KK NAGAR': 12,
-        'WEST MAMBALAM': 9,
-        'ASHOK NAGAR': 7,
-        'T NAGAR': 11,
-        'VADAPALANI': 6,
-        'KODAMBAKKAM': 8,
-        'SALIGRAMAM': 5,
-        'VIRUGAMBAKKAM': 10,
-        'NESAPAKKAM': 13,
-        'JAFFERKHANPET': 6,
-        'EKKATTUTHANGAL': 4,
-        'MGR NAGAR': 9,
-        'SAIDAPET': 7
-      },
-      pendencyAreas: {
-        'KK NAGAR': 3.4,
-        'WEST MAMBALAM': 2.9,
-        'ASHOK NAGAR': 2.6,
-        'T NAGAR': 3.1,
-        'VADAPALANI': 2.2,
-        'KODAMBAKKAM': 2.8,
-        'SALIGRAMAM': 1.9,
-        'VIRUGAMBAKKAM': 2.4,
-        'NESAPAKKAM': 3.0,
-        'JAFFERKHANPET': 2.1,
-        'EKKATTUTHANGAL': 1.7,
-        'MGR NAGAR': 2.5,
-        'SAIDAPET': 2.0
+  <head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
+    <title>TVA Control Demo</title>
+    <link rel="stylesheet" href="tva-control.css" />
+    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
+    <script src="tva-control.js"></script>
+    <style>
+      body {
+        background: #0e0e0e;
+        color: #eee;
+        font-family: system-ui, sans-serif;
+        margin: 24px;
+        transition:
+          background 180ms ease,
+          color 180ms ease;
+      }
+      body.demo-light {
+        background: #fff;
+        color: #333;
+      }
+      .demo-toolbar {
+        align-items: center;
+        display: flex;
+        gap: 8px;
+        margin: 0 0 14px;
+      }
+      .demo-toolbar button {
+        background: #222;
+        border: 1px solid #555;
+        color: #eee;
+        cursor: pointer;
+        font:
+          700 12px/1 system-ui,
+          sans-serif;
+        padding: 8px 10px;
+      }
+      body.demo-light .demo-toolbar button {
+        background: #fff;
+        border-color: #b9c7c4;
+        color: #173f3a;
+      }
+      .demo-toolbar button.is-active {
+        border-color: #00b49f;
+        box-shadow: 0 0 0 2px rgba(0, 180, 159, 0.18);
       }
-    };
+      .tva-control-container {
+        max-width: 920px;
+      }
+    </style>
+  </head>
+  <body>
+    <h1>TVA Control Demo</h1>
+    <div class="demo-toolbar" aria-label="Theme switcher">
+      <button type="button" data-theme="dark" class="is-active">Dark</button>
+      <button type="button" data-theme="light">Light</button>
+      <button type="button" data-theme="auto">Auto</button>
+    </div>
+    <div id="demo-chart" class="tva-control-container" data-tva-theme="dark"><canvas></canvas></div>
+    <script>
+      const config = {
+        title: "TVA REACTIVE CHANNEL",
+        blinkMs: 1100,
+        aliases: {
+          bookingAgeDays: "refillSpreadDays",
+          bookingSpreadDays: "refillSpreadDays",
+          bpclDeposit: "bpclDepositLakhs",
+        },
+        ambientGlow: { enabled: true, alpha: 0.14, radius: 74, blur: 42 },
+        warningLevels: [
+          {
+            key: "amber",
+            label: "AMBER ALERT",
+            priority: 1,
+            showAxis: true,
+            dominance: 0.6,
+            axisAlpha: 0.28,
+            axisWidth: 1.45,
+            axisDash: [3, 5],
+            glowAlpha: 0.12,
+          },
+          {
+            key: "red",
+            label: "CRITICAL",
+            priority: 2,
+            showAxis: true,
+            dominance: 0.7,
+            axisAlpha: 0.42,
+            axisWidth: 1.45,
+            axisDash: [6, 6],
+            glowAlpha: 0.16,
+          },
+          {
+            key: "double-red",
+            label: "DOUBLE RED",
+            priority: 3,
+            showAxis: false,
+            dominance: 0.7,
+            borderBlink: true,
+            glowAlpha: 0.18,
+            glowRadius: 88,
+            glowBlur: 54,
+          },
+        ],
+        colors: {
+          amber: "#ffcc00",
+          red: "#ff0055",
+          "double-red": "#ff1a1a",
+          disabled: "#777777",
+        },
+        staleAlpha: 0.35,
+        parameters: [
+          {
+            key: "complaintsOpen",
+            label: "Complaints Open",
+            icon: "warning",
+            scale: "count10",
+            refreshMinutes: 15,
+            thresholds: { amberUpper: 52.5, redUpper: 75, amberLower: -52.5, redLower: -75 },
+          },
+          {
+            key: "invoiceActions",
+            label: "Invoice Actions",
+            icon: "invoice",
+            scale: "count10",
+            refreshMinutes: 15,
+            thresholds: { amberUpper: 59.5, redUpper: 85, amberLower: -59.5, redLower: -85 },
+          },
+          {
+            key: "deliveryPersonLeave",
+            label: "Delivery Person Leave",
+            icon: "person",
+            scale: "count10",
+            refreshMinutes: 720,
+            thresholds: { amberUpper: 49, redUpper: 70, amberLower: -49, redLower: -70 },
+          },
+          {
+            key: "refillSpreadDays",
+            label: "Refill Spread",
+            icon: "calendar",
+            scale: "daysCritical",
+            scaleBase: 10,
+            scaleMax: 165,
+            refreshMinutes: 1440,
+            display: { suffix: "d" },
+            thresholds: {
+              amberUpper: 50,
+              redUpper: 100,
+              doubleRedUpper: 150,
+              amberLower: -70,
+              redLower: -100,
+            },
+            detailMode: "refill-spread",
+            areaKey: "refillSpreadAreas",
+            detailTitle: "REFILL SPREAD AREA SCAN",
+            detailLevels: [
+              { level: "amber", above: 5 },
+              { level: "red", above: 10 },
+            ],
+          },
+          {
+            key: "pendencyDays",
+            label: "Pendency",
+            icon: "hourglass",
+            scale: "pendency",
+            scaleIdeal: 1,
+            scaleBase: 3,
+            scaleMax: 115,
+            refreshMinutes: 720,
+            display: { suffix: "d", decimals: 1 },
+            thresholds: { amberUpper: 33.33, redUpper: 100, amberLower: -70, redLower: -100 },
+            detailMode: "pendency",
+            areaKey: "pendencyAreas",
+            detailTitle: "PENDENCY AREA SCAN",
+            detailLevels: [
+              { level: "amber", above: 1 },
+              { level: "red", above: 3 },
+            ],
+          },
+          {
+            key: "bpclDepositLakhs",
+            label: "BPCL Deposit",
+            icon: "deposit",
+            scale: "raw",
+            refreshMinutes: 30,
+            display: { prefix: "₹", suffix: "L", decimals: 1 },
+            thresholds: { amberUpper: 4, redUpper: 6, amberLower: -1, redLower: -3 },
+          },
+        ],
+        extraAxes: [
+          {
+            label: "BPCL Deposit Good",
+            parameterKey: "bpclDepositLakhs",
+            value: 6,
+            color: "rgba(0,255,120,.5)",
+            width: 1.8,
+            dash: [4, 4],
+          },
+          {
+            label: "BPCL Deposit Soft",
+            parameterKey: "bpclDepositLakhs",
+            value: 4,
+            color: "rgba(120,255,160,.34)",
+            width: 1.4,
+            dash: [2, 5],
+          },
+        ],
+      };
 
-    const chartContainer = document.getElementById('demo-chart');
-    let tva = createTvaControl({ container: chartContainer, config, data });
+      const data = {
+        complaintsOpen: 0,
+        invoiceActions: 2,
+        deliveryPersonLeave: 0,
+        refillSpreadDays: 12,
+        pendencyDays: 2.7,
+        bpclDepositLakhs: 3,
+        updatedAt: {
+          bpclDepositLakhs: Date.now() - 31 * 60 * 1000,
+        },
+        refillSpreadAreas: {
+          "KK NAGAR": 12,
+          "WEST MAMBALAM": 9,
+          "ASHOK NAGAR": 7,
+          "T NAGAR": 11,
+          VADAPALANI: 6,
+          KODAMBAKKAM: 8,
+          SALIGRAMAM: 5,
+          VIRUGAMBAKKAM: 10,
+          NESAPAKKAM: 13,
+          JAFFERKHANPET: 6,
+          EKKATTUTHANGAL: 4,
+          "MGR NAGAR": 9,
+          SAIDAPET: 7,
+        },
+        pendencyAreas: {
+          "KK NAGAR": 3.4,
+          "WEST MAMBALAM": 2.9,
+          "ASHOK NAGAR": 2.6,
+          "T NAGAR": 3.1,
+          VADAPALANI: 2.2,
+          KODAMBAKKAM: 2.8,
+          SALIGRAMAM: 1.9,
+          VIRUGAMBAKKAM: 2.4,
+          NESAPAKKAM: 3.0,
+          JAFFERKHANPET: 2.1,
+          EKKATTUTHANGAL: 1.7,
+          "MGR NAGAR": 2.5,
+          SAIDAPET: 2.0,
+        },
+      };
 
-    function applyDemoTheme(theme) {
-      chartContainer.dataset.tvaTheme = theme === 'auto' ? '' : theme;
-      if (theme === 'auto') chartContainer.removeAttribute('data-tva-theme');
-      document.body.classList.toggle('demo-light', theme === 'light' || (theme === 'auto' && matchMedia('(prefers-color-scheme: light)').matches));
-      document.querySelectorAll('.demo-toolbar button').forEach(button => button.classList.toggle('is-active', button.dataset.theme === theme));
-      tva.refreshTheme();
-      window.tva = tva;
-    }
+      const chartContainer = document.getElementById("demo-chart");
+      let tva = createTvaControl({ container: chartContainer, config, data });
 
-    document.querySelector('.demo-toolbar').addEventListener('click', event => {
-      const button = event.target.closest('button[data-theme]');
-      if (button) applyDemoTheme(button.dataset.theme);
-    });
+      function applyDemoTheme(theme) {
+        chartContainer.dataset.tvaTheme = theme === "auto" ? "" : theme;
+        if (theme === "auto") chartContainer.removeAttribute("data-tva-theme");
+        document.body.classList.toggle(
+          "demo-light",
+          theme === "light" ||
+            (theme === "auto" && matchMedia("(prefers-color-scheme: light)").matches),
+        );
+        document
+          .querySelectorAll(".demo-toolbar button")
+          .forEach((button) =>
+            button.classList.toggle("is-active", button.dataset.theme === theme),
+          );
+        tva.refreshTheme();
+        window.tva = tva;
+      }
 
-    matchMedia('(prefers-color-scheme: light)').addEventListener('change', () => {
-      if (document.querySelector('.demo-toolbar button[data-theme="auto"]').classList.contains('is-active')) applyDemoTheme('auto');
-    });
+      document.querySelector(".demo-toolbar").addEventListener("click", (event) => {
+        const button = event.target.closest("button[data-theme]");
+        if (button) applyDemoTheme(button.dataset.theme);
+      });
 
-    window.tva = tva;
-  </script>
-</body>
+      matchMedia("(prefers-color-scheme: light)").addEventListener("change", () => {
+        if (
+          document
+            .querySelector('.demo-toolbar button[data-theme="auto"]')
+            .classList.contains("is-active")
+        )
+          applyDemoTheme("auto");
+      });
+
+      window.tva = tva;
+    </script>
+  </body>
 </html>
diff --git a/tva-control.css b/tva-control.css
@@ -141,14 +141,17 @@
 
 .tva-control-container,
 .action-chart-container {
-  background: radial-gradient(circle at 50% 20%, var(--tva-plot-glow), transparent 32%), var(--tva-bg);
+  background:
+    radial-gradient(circle at 50% 20%, var(--tva-plot-glow), transparent 32%), var(--tva-bg);
   border: 1px solid var(--tva-border);
   border-radius: 12px;
   height: 280px;
   margin-bottom: 12px;
   padding: 10px 0;
   position: relative;
-  transition: border-color 180ms ease, box-shadow 180ms ease;
+  transition:
+    border-color 180ms ease,
+    box-shadow 180ms ease;
 }
 
 .tva-control-container.tva-border-alert,

@@ -158,13 +161,18 @@
 }
 
 @keyframes tvaBorderAlertPulse {
-  0%, 100% {
+  0%,
+  100% {
     border-color: var(--tva-border-alert-color);
-    box-shadow: 0 0 0 rgba(255, 0, 0, 0), inset 0 0 0 rgba(255, 0, 0, 0);
+    box-shadow:
+      0 0 0 rgba(255, 0, 0, 0),
+      inset 0 0 0 rgba(255, 0, 0, 0);
   }
   50% {
     border-color: var(--tva-border-alert-color);
-    box-shadow: 0 0 22px color-mix(in srgb, var(--tva-border-alert-color) 42%, transparent), inset 0 0 18px color-mix(in srgb, var(--tva-border-alert-color) 16%, transparent);
+    box-shadow:
+      0 0 22px color-mix(in srgb, var(--tva-border-alert-color) 42%, transparent),
+      inset 0 0 18px color-mix(in srgb, var(--tva-border-alert-color) 16%, transparent);
   }
 }
 

@@ -377,7 +385,9 @@
   border-color: var(--tva-fullscreen-border);
   border-radius: 0;
   bottom: 8px;
-  box-shadow: 0 0 48px var(--tva-fullscreen-shadow), inset 0 0 30px var(--tva-fullscreen-inset);
+  box-shadow:
+    0 0 48px var(--tva-fullscreen-shadow),
+    inset 0 0 30px var(--tva-fullscreen-inset);
   height: auto;
   left: 8px;
   margin: 0;
diff --git a/tva-control.js b/tva-control.js
@@ -3,30 +3,49 @@
     const parsed = Number(value);
     return Number.isFinite(parsed) ? parsed : fallback;
   }
-  function clamp(value, min, max) { return Math.max(min, Math.min(max, value)); }
-  function clone(value) { return JSON.parse(JSON.stringify(value)); }
-  function camel(key) { return String(key).replace(/-([a-z])/g, (_, c) => c.toUpperCase()); }
-  function escapeAttr(value) { return String(value).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c])); }
+  function clamp(value, min, max) {
+    return Math.max(min, Math.min(max, value));
+  }
+  function clone(value) {
+    return JSON.parse(JSON.stringify(value));
+  }
+  function camel(key) {
+    return String(key).replace(/-([a-z])/g, (_, c) => c.toUpperCase());
+  }
+  function escapeAttr(value) {
+    return String(value).replace(
+      /[&<>"]/g,
+      (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c],
+    );
+  }
   function colorWithAlpha(color, alpha) {
-    if (String(color).startsWith('#') && color.length === 7) {
-      const r = parseInt(color.slice(1, 3), 16), g = parseInt(color.slice(3, 5), 16), b = parseInt(color.slice(5, 7), 16);
+    if (String(color).startsWith("#") && color.length === 7) {
+      const r = parseInt(color.slice(1, 3), 16),
+        g = parseInt(color.slice(3, 5), 16),
+        b = parseInt(color.slice(5, 7), 16);
       return `rgba(${r},${g},${b},${alpha})`;
     }
     return color;
   }
   function normalizeAreas(value) {
-    const rows = Array.isArray(value) ? value : value && typeof value === 'object' ? Object.entries(value).map(([name, days]) => ({ name, days })) : [];
-    return rows.map((row, index) => ({
-      name: String(row.name || row.area || row.areaName || `Area ${index + 1}`).trim(),
-      days: number(row.days ?? row.pendencyDays ?? row.refillSpreadDays ?? row.currentDays)
-    })).filter(row => row.name);
+    const rows = Array.isArray(value)
+      ? value
+      : value && typeof value === "object"
+        ? Object.entries(value).map(([name, days]) => ({ name, days }))
+        : [];
+    return rows
+      .map((row, index) => ({
+        name: String(row.name || row.area || row.areaName || `Area ${index + 1}`).trim(),
+        days: number(row.days ?? row.pendencyDays ?? row.refillSpreadDays ?? row.currentDays),
+      }))
+      .filter((row) => row.name);
   }
   function getTrend(previousValue, currentValue, threshold = 15) {
-    if (!Number.isFinite(previousValue) || !Number.isFinite(currentValue)) return 'flat';
+    if (!Number.isFinite(previousValue) || !Number.isFinite(currentValue)) return "flat";
     const delta = currentValue - previousValue;
-    if (delta >= threshold) return 'up';
-    if (delta <= -threshold) return 'down';
-    return 'flat';
+    if (delta >= threshold) return "up";
+    if (delta <= -threshold) return "down";
+    return "flat";
   }
   function isStale(updatedAt, refreshMs, now = Date.now()) {
     if (!refreshMs) return false;

@@ -37,25 +56,27 @@
     if (!patch) return base;
     const next = { ...base };
     Object.entries(patch).forEach(([rawKey, value]) => {
-      if (value === undefined || value === null || rawKey === 'type') return;
+      if (value === undefined || value === null || rawKey === "type") return;
       const key = aliases[rawKey] || rawKey;
-      if (key === 'colors' && value && typeof value === 'object') next.colors = { ...(next.colors || {}), ...value };
-      else if (key === 'metricFreshnessMinutes' && value && typeof value === 'object') next.metricFreshnessMinutes = { ...(next.metricFreshnessMinutes || {}), ...value };
-      else if (key.endsWith('Areas')) next[key] = normalizeAreas(value);
-      else if (typeof next[key] === 'number') next[key] = number(value, next[key]);
+      if (key === "colors" && value && typeof value === "object")
+        next.colors = { ...(next.colors || {}), ...value };
+      else if (key === "metricFreshnessMinutes" && value && typeof value === "object")
+        next.metricFreshnessMinutes = { ...(next.metricFreshnessMinutes || {}), ...value };
+      else if (key.endsWith("Areas")) next[key] = normalizeAreas(value);
+      else if (typeof next[key] === "number") next[key] = number(value, next[key]);
       else next[key] = value;
     });
     return next;
   }
   const DEFAULT_COLORS = {
-    normal: '#4f646e',
-    stale: '#4f646e',
-    disabled: '#777777'
+    normal: "#4f646e",
+    stale: "#4f646e",
+    disabled: "#777777",
   };
 
   const DEFAULT_UI_COLORS = {
     staleText: null,
-    neutralGradientMid: '#879aa3',
+    neutralGradientMid: "#879aa3",
     staleLabelFill: null,
     normalLabelFill: null,
     normalLabelStroke: null,

@@ -63,14 +84,14 @@
     detailGrid: null,
     tick: null,
     detailTick: null,
-    transparent: 'rgba(0,0,0,0)',
-    white: '#fff',
-    plotIcon: null
+    transparent: "rgba(0,0,0,0)",
+    white: "#fff",
+    plotIcon: null,
   };
 
   function strokePath(ctx, points, close = false) {
     ctx.beginPath();
-    points.forEach(([x, y], i) => i ? ctx.lineTo(x, y) : ctx.moveTo(x, y));
+    points.forEach(([x, y], i) => (i ? ctx.lineTo(x, y) : ctx.moveTo(x, y)));
     if (close) ctx.closePath();
     ctx.stroke();
   }

@@ -80,135 +101,270 @@
     ctx.strokeStyle = color;
     ctx.fillStyle = color;
     ctx.lineWidth = 1.25;
-    ctx.lineCap = 'round';
-    ctx.lineJoin = 'round';
+    ctx.lineCap = "round";
+    ctx.lineJoin = "round";
 
-    if (type === 'invoice') {
+    if (type === "invoice") {
       ctx.strokeRect(x - 5, y + 1, 10, 11.5);
-      [4, 7, 10].forEach(o => strokePath(ctx, [[x - 3, y + o], [x + 3, y + o]]));
-    } else if (type === 'person') {
-      ctx.beginPath(); ctx.arc(x, y + 3.8, 2.8, 0, Math.PI * 2); ctx.stroke();
-      ctx.beginPath(); ctx.moveTo(x - 5, y + 12); ctx.quadraticCurveTo(x, y + 7.6, x + 5, y + 12); ctx.stroke();
-    } else if (type === 'calendar') {
+      [4, 7, 10].forEach((o) =>
+        strokePath(ctx, [
+          [x - 3, y + o],
+          [x + 3, y + o],
+        ]),
+      );
+    } else if (type === "person") {
+      ctx.beginPath();
+      ctx.arc(x, y + 3.8, 2.8, 0, Math.PI * 2);
+      ctx.stroke();
+      ctx.beginPath();
+      ctx.moveTo(x - 5, y + 12);
+      ctx.quadraticCurveTo(x, y + 7.6, x + 5, y + 12);
+      ctx.stroke();
+    } else if (type === "calendar") {
       ctx.strokeRect(x - 5, y + 3, 10, 10);
-      strokePath(ctx, [[x - 5, y + 6], [x + 5, y + 6]]);
-      strokePath(ctx, [[x - 2.8, y + 1], [x - 2.8, y + 4]]);
-      strokePath(ctx, [[x + 2.8, y + 1], [x + 2.8, y + 4]]);
-      ctx.fillRect(x - 2.8, y + 8, 1.3, 1.3); ctx.fillRect(x + 1.5, y + 8, 1.3, 1.3);
-    } else if (type === 'deposit') {
+      strokePath(ctx, [
+        [x - 5, y + 6],
+        [x + 5, y + 6],
+      ]);
+      strokePath(ctx, [
+        [x - 2.8, y + 1],
+        [x - 2.8, y + 4],
+      ]);
+      strokePath(ctx, [
+        [x + 2.8, y + 1],
+        [x + 2.8, y + 4],
+      ]);
+      ctx.fillRect(x - 2.8, y + 8, 1.3, 1.3);
+      ctx.fillRect(x + 1.5, y + 8, 1.3, 1.3);
+    } else if (type === "deposit") {
       ctx.strokeRect(x - 5, y + 4, 10, 8);
-      strokePath(ctx, [[x - 6, y + 4], [x, y + .5], [x + 6, y + 4]]);
-      strokePath(ctx, [[x - 3, y + 7], [x + 3, y + 7]]);
-      strokePath(ctx, [[x - 3, y + 10], [x + 3, y + 10]]);
-    } else if (type === 'hourglass') {
-      strokePath(ctx, [[x - 5, y + 1], [x + 5, y + 1], [x - 5, y + 12.5], [x + 5, y + 12.5]], true);
+      strokePath(ctx, [
+        [x - 6, y + 4],
+        [x, y + 0.5],
+        [x + 6, y + 4],
+      ]);
+      strokePath(ctx, [
+        [x - 3, y + 7],
+        [x + 3, y + 7],
+      ]);
+      strokePath(ctx, [
+        [x - 3, y + 10],
+        [x + 3, y + 10],
+      ]);
+    } else if (type === "hourglass") {
+      strokePath(
+        ctx,
+        [
+          [x - 5, y + 1],
+          [x + 5, y + 1],
+          [x - 5, y + 12.5],
+          [x + 5, y + 12.5],
+        ],
+        true,
+      );
     } else {
-      strokePath(ctx, [[x, y], [x - 5.5, y + 10.5], [x + 5.5, y + 10.5]], true);
-      strokePath(ctx, [[x, y + 3.5], [x, y + 7.2]]);
-      ctx.beginPath(); ctx.arc(x, y + 9.2, .6, 0, Math.PI * 2); ctx.fill();
+      strokePath(
+        ctx,
+        [
+          [x, y],
+          [x - 5.5, y + 10.5],
+          [x + 5.5, y + 10.5],
+        ],
+        true,
+      );
+      strokePath(ctx, [
+        [x, y + 3.5],
+        [x, y + 7.2],
+      ]);
+      ctx.beginPath();
+      ctx.arc(x, y + 9.2, 0.6, 0, Math.PI * 2);
+      ctx.fill();
     }
     ctx.restore();
   }
   window.TvaControlInternals = { getTrend, isStale, mergeData, normalizeAreas };
 
-  window.createTvaControl = function createTvaControl({ canvas, container, config = {}, data = {} }) {
-    if (!canvas && container) canvas = container.querySelector('canvas') || container.appendChild(document.createElement('canvas'));
-    container = container || canvas.closest('.tva-control-container, .action-chart-container') || canvas.parentElement;
-    container.classList.add('tva-control-container');
+  window.createTvaControl = function createTvaControl({
+    canvas,
+    container,
+    config = {},
+    data = {},
+  }) {
+    if (!canvas && container)
+      canvas =
+        container.querySelector("canvas") ||
+        container.appendChild(document.createElement("canvas"));
+    container =
+      container ||
+      canvas.closest(".tva-control-container, .action-chart-container") ||
+      canvas.parentElement;
+    container.classList.add("tva-control-container");
     const init = config && Object.keys(config).length ? config : data.init || {};
     const parameters = init.parameters || [];
     const levels = init.warningLevels || [];
-    if (!parameters.length) throw new Error('createTvaControl requires init.parameters');
-    if (!levels.length) throw new Error('createTvaControl requires init.warningLevels');
+    if (!parameters.length) throw new Error("createTvaControl requires init.parameters");
+    if (!levels.length) throw new Error("createTvaControl requires init.warningLevels");
 
     const aliases = init.aliases || {};
-    const labels = parameters.map(p => p.label);
-    const metricKeys = parameters.map(p => p.key);
-    const metricDatasetIndex = levels.filter(l => l.showAxis !== false).length * 2 + (init.extraAxes || []).length;
-    const baseState = () => ({ colors: { ...DEFAULT_COLORS, ...(init.colors || {}) }, uiColors: { ...DEFAULT_UI_COLORS, ...(init.uiColors || {}) }, staleAlpha: 0.35, trendThreshold: 15 });
+    const labels = parameters.map((p) => p.label);
+    const metricKeys = parameters.map((p) => p.key);
+    const metricDatasetIndex =
+      levels.filter((l) => l.showAxis !== false).length * 2 + (init.extraAxes || []).length;
+    const baseState = () => ({
+      colors: { ...DEFAULT_COLORS, ...(init.colors || {}) },
+      uiColors: { ...DEFAULT_UI_COLORS, ...(init.uiColors || {}) },
+      staleAlpha: 0.35,
+      trendThreshold: 15,
+    });
     let state = mergeData(baseState(), data, aliases);
-    const cssVar = name => getComputedStyle(container).getPropertyValue(name).trim();
+    const cssVar = (name) => getComputedStyle(container).getPropertyValue(name).trim();
     function resolveUiColors() {
       const configured = init.uiColors || {};
       const pick = (key, cssName, fallback) => configured[key] || cssVar(cssName) || fallback;
-      state.colors.normal = init.colors && init.colors.normal ? init.colors.normal : cssVar('--tva-normal-line') || DEFAULT_COLORS.normal;
-      state.colors.stale = init.colors && init.colors.stale ? init.colors.stale : cssVar('--tva-stale-line') || state.colors.normal;
+      state.colors.normal =
+        init.colors && init.colors.normal
+          ? init.colors.normal
+          : cssVar("--tva-normal-line") || DEFAULT_COLORS.normal;
+      state.colors.stale =
+        init.colors && init.colors.stale
+          ? init.colors.stale
+          : cssVar("--tva-stale-line") || state.colors.normal;
       state.uiColors = {
         ...DEFAULT_UI_COLORS,
         ...configured,
-        grid: pick('grid', '--tva-chart-grid', '#222'),
-        detailGrid: pick('detailGrid', '--tva-chart-detail-grid', '#242424'),
-        tick: pick('tick', '--tva-axis-text', '#fff'),
-        detailTick: pick('detailTick', '--tva-detail-axis-text', '#aaa'),
-        plotIcon: pick('plotIcon', '--tva-plot-icon', configured.white || DEFAULT_UI_COLORS.white),
-        staleText: pick('staleText', '--tva-stale-text', '#9aa6ac'),
-        staleLabelFill: pick('staleLabelFill', '--tva-stale-label-fill', 'rgba(2,6,8,.84)'),
-        normalLabelFill: pick('normalLabelFill', '--tva-normal-label-fill', 'rgba(5,34,30,.62)'),
-        normalLabelStroke: pick('normalLabelStroke', '--tva-normal-label-stroke', 'rgba(116,137,148,.44)')
+        grid: pick("grid", "--tva-chart-grid", "#222"),
+        detailGrid: pick("detailGrid", "--tva-chart-detail-grid", "#242424"),
+        tick: pick("tick", "--tva-axis-text", "#fff"),
+        detailTick: pick("detailTick", "--tva-detail-axis-text", "#aaa"),
+        plotIcon: pick("plotIcon", "--tva-plot-icon", configured.white || DEFAULT_UI_COLORS.white),
+        staleText: pick("staleText", "--tva-stale-text", "#9aa6ac"),
+        staleLabelFill: pick("staleLabelFill", "--tva-stale-label-fill", "rgba(2,6,8,.84)"),
+        normalLabelFill: pick("normalLabelFill", "--tva-normal-label-fill", "rgba(5,34,30,.62)"),
+        normalLabelStroke: pick(
+          "normalLabelStroke",
+          "--tva-normal-label-stroke",
+          "rgba(116,137,148,.44)",
+        ),
       };
     }
     resolveUiColors();
-    let chart = null, mode = 'timeline', criticalBlink = true, stalePhase = 0, staleDirection = 1, previousMetricValues = null;
-    let updatedAtByKey = Object.fromEntries(metricKeys.map(k => [k, Date.now()]));
-    if (data.updatedAt) Object.entries(data.updatedAt).forEach(([k, v]) => { const ts = typeof v === 'string' ? Date.parse(v) : number(v, NaN); if (Number.isFinite(ts)) updatedAtByKey[k] = ts; });
+    let chart = null,
+      mode = "timeline",
+      criticalBlink = true,
+      stalePhase = 0,
+      staleDirection = 1,
+      previousMetricValues = null;
+    let updatedAtByKey = Object.fromEntries(metricKeys.map((k) => [k, Date.now()]));
+    if (data.updatedAt)
+      Object.entries(data.updatedAt).forEach(([k, v]) => {
+        const ts = typeof v === "string" ? Date.parse(v) : number(v, NaN);
+        if (Number.isFinite(ts)) updatedAtByKey[k] = ts;
+      });
 
-    const controls = document.createElement('div');
-    controls.className = 'tva-chart-controls';
+    const controls = document.createElement("div");
+    controls.className = "tva-chart-controls";
     const modeOptions = [
-      { key: 'timeline', label: init.title || 'Timeline' },
-      ...parameters.filter(p => p.detailMode).map(p => ({ key: p.detailMode, label: p.detailTitle || `${p.label} Area Scan` }))
+      { key: "timeline", label: init.title || "Timeline" },
+      ...parameters
+        .filter((p) => p.detailMode)
+        .map((p) => ({ key: p.detailMode, label: p.detailTitle || `${p.label} Area Scan` })),
     ];
-    const modeOptionHtml = modeOptions.map(o => `<option value="${escapeAttr(o.key)}">${escapeAttr(o.label)}</option>`).join('');
+    const modeOptionHtml = modeOptions
+      .map((o) => `<option value="${escapeAttr(o.key)}">${escapeAttr(o.label)}</option>`)
+      .join("");
     controls.innerHTML = `
       <button type="button" class="tva-chart-back" hidden>←</button>
       <label class="tva-chart-heading"><span class="sr-only">Chart type</span><select class="tva-chart-mode-select">${modeOptionHtml}</select></label>
       <button type="button" class="tva-chart-fullscreen" title="Fullscreen chart" aria-label="Fullscreen chart"><span class="tva-fullscreen-icon" aria-hidden="true"></span></button>
     `;
-    const alertBadge = document.createElement('div');
-    alertBadge.className = 'tva-alert-badge';
+    const alertBadge = document.createElement("div");
+    alertBadge.className = "tva-alert-badge";
     alertBadge.hidden = true;
-    if (!container.querySelector('.tva-chart-controls')) container.prepend(controls);
-    if (!container.querySelector('.tva-alert-badge')) container.prepend(alertBadge);
-    controls.querySelector('.tva-chart-back').onclick = () => switchMode('timeline');
-    controls.querySelector('.tva-chart-mode-select').onchange = e => switchMode(e.target.value);
-    controls.querySelector('.tva-chart-fullscreen').onclick = () => {
-      container.classList.toggle('tva-chart-fullscreen-mode');
+    if (!container.querySelector(".tva-chart-controls")) container.prepend(controls);
+    if (!container.querySelector(".tva-alert-badge")) container.prepend(alertBadge);
+    controls.querySelector(".tva-chart-back").onclick = () => switchMode("timeline");
+    controls.querySelector(".tva-chart-mode-select").onchange = (e) => switchMode(e.target.value);
+    controls.querySelector(".tva-chart-fullscreen").onclick = () => {
+      container.classList.toggle("tva-chart-fullscreen-mode");
       syncControls();
       chart && chart.resize();
-      chart && chart.update('none');
+      chart && chart.update("none");
     };
 
-    function getValue(p) { return number(state[p.key], number(p.defaultValue)); }
-    function limit(p, level, side, fallback) { return number(p.thresholds && p.thresholds[`${camel(level.key)}${side}`], fallback); }
+    function getValue(p) {
+      return number(state[p.key], number(p.defaultValue));
+    }
+    function limit(p, level, side, fallback) {
+      return number(p.thresholds && p.thresholds[`${camel(level.key)}${side}`], fallback);
+    }
     function metricValue(p) {
       const v = getValue(p);
-      if (p.scale === 'count10') return clamp(v * 10, -100, 100);
-      if (p.scale === 'daysCritical') return clamp(v / number(p.scaleBase, 10) * 100, 0, number(p.scaleMax, 165));
-      if (p.scale === 'pendency') return v <= number(p.scaleIdeal, 1) ? 0 : clamp(v / number(p.scaleBase, 3) * 100, 0, number(p.scaleMax, 115));
+      if (p.scale === "count10") return clamp(v * 10, -100, 100);
+      if (p.scale === "daysCritical")
+        return clamp((v / number(p.scaleBase, 10)) * 100, 0, number(p.scaleMax, 165));
+      if (p.scale === "pendency")
+        return v <= number(p.scaleIdeal, 1)
+          ? 0
+          : clamp((v / number(p.scaleBase, 3)) * 100, 0, number(p.scaleMax, 115));
       return v;
     }
-    function values() { return parameters.map(metricValue); }
-    function isMetricStale(i) { return isStale(updatedAtByKey[parameters[i].key], number(parameters[i].refreshMinutes, 0) * 60000); }
-    function levelColor(level) { return state.colors[level.key] || state.colors[camel(level.key)] || state.colors.normal; }
-    function breachedLevel(i, v) { let hit = null; levels.forEach(l => { if (v > limit(parameters[i], l, 'Upper', Infinity) || v < limit(parameters[i], l, 'Lower', -Infinity)) hit = l; }); return hit; }
-    function staleColor(full = false) { return full ? state.colors.stale : colorWithAlpha(state.colors.stale, number(state.staleAlpha, 0.35)); }
-    function metricColor(i, v) { if (isMetricStale(i)) return staleColor(false); const l = breachedLevel(i, v); return l ? levelColor(l) : state.colors.normal; }
+    function values() {
+      return parameters.map(metricValue);
+    }
+    function isMetricStale(i) {
+      return isStale(
+        updatedAtByKey[parameters[i].key],
+        number(parameters[i].refreshMinutes, 0) * 60000,
+      );
+    }
+    function levelColor(level) {
+      return state.colors[level.key] || state.colors[camel(level.key)] || state.colors.normal;
+    }
+    function breachedLevel(i, v) {
+      let hit = null;
+      levels.forEach((l) => {
+        if (
+          v > limit(parameters[i], l, "Upper", Infinity) ||
+          v < limit(parameters[i], l, "Lower", -Infinity)
+        )
+          hit = l;
+      });
+      return hit;
+    }
+    function staleColor(full = false) {
+      return full
+        ? state.colors.stale
+        : colorWithAlpha(state.colors.stale, number(state.staleAlpha, 0.35));
+    }
+    function metricColor(i, v) {
+      if (isMetricStale(i)) return staleColor(false);
+      const l = breachedLevel(i, v);
+      return l ? levelColor(l) : state.colors.normal;
+    }
     function formatPoint(p) {
       const v = getValue(p);
       const d = p.display || {};
       const decimals = Number.isInteger(d.decimals) ? d.decimals : 0;
-      const text = Number.isInteger(v) || decimals === 0 ? String(Math.round(v)) : v.toFixed(decimals);
-      return `${d.prefix || ''}${text}${d.suffix || ''}`;
+      const text =
+        Number.isInteger(v) || decimals === 0 ? String(Math.round(v)) : v.toFixed(decimals);
+      return `${d.prefix || ""}${text}${d.suffix || ""}`;
     }
     function trend(i) {
       const v = values();
-      return getTrend(previousMetricValues && previousMetricValues[i], v[i], number(state.trendThreshold, 15));
+      return getTrend(
+        previousMetricValues && previousMetricValues[i],
+        v[i],
+        number(state.trendThreshold, 15),
+      );
     }
     function zoomBounds(vs) {
       let min = Math.min(0, ...vs);
       let max = Math.max(0, ...vs);
-      if (min === max) { min -= 10; max += 10; }
-      const pad = Math.max(8, (max - min) * .24);
+      if (min === max) {
+        min -= 10;
+        max += 10;
+      }
+      const pad = Math.max(8, (max - min) * 0.24);
       return { min: Math.floor(min - pad), max: Math.ceil(max + pad) };
     }
     function gradient(ctx) {

@@ -224,7 +380,13 @@
         const base = staleColor(false);
         const full = staleColor(true);
         const width = 0.12;
-        [[0, base], [Math.max(0, stalePhase - width), base], [stalePhase, full], [Math.min(1, stalePhase + width), base], [1, base]]
+        [
+          [0, base],
+          [Math.max(0, stalePhase - width), base],
+          [stalePhase, full],
+          [Math.min(1, stalePhase + width), base],
+          [1, base],
+        ]
           .sort((a, b) => a[0] - b[0])
           .forEach(([stop, color]) => g.addColorStop(stop, color));
         return g;

@@ -237,16 +399,20 @@
       const dom1 = l1 && number(l1.dominance, 0);
       if (dom0) g.addColorStop(dom0, c0);
       else if (dom1) g.addColorStop(1 - dom1, c1);
-      else g.addColorStop(.5, state.uiColors.neutralGradientMid);
+      else g.addColorStop(0.5, state.uiColors.neutralGradientMid);
       g.addColorStop(1, c1);
       return g;
     }
 
     const ambientGlow = init.ambientGlow || {};
-    function ambientGlowEnabled() { return ambientGlow.enabled !== false && ambientGlow.enabled !== 0; }
-    function levelGlowEnabled(level) { return level && level.ambientGlow !== false && level.glow !== false; }
+    function ambientGlowEnabled() {
+      return ambientGlow.enabled !== false && ambientGlow.enabled !== 0;
+    }
+    function levelGlowEnabled(level) {
+      return level && level.ambientGlow !== false && level.glow !== false;
+    }
     function drawAmbientGlow(chart) {
-      if (mode !== 'timeline' || !ambientGlowEnabled()) return;
+      if (mode !== "timeline" || !ambientGlowEnabled()) return;
       const meta = chart.getDatasetMeta(metricDatasetIndex);
       if (!meta || !chart.chartArea) return;
 

@@ -262,17 +428,17 @@
         const lvl = breachedLevel(i, vs[i]);
         if (!levelGlowEnabled(lvl)) return;
 
-        const { x, y } = pt.getProps(['x', 'y'], true);
+        const { x, y } = pt.getProps(["x", "y"], true);
         const color = lvl.glowColor || levelColor(lvl);
         const radius = number(lvl.glowRadius, number(ambientGlow.radius, 72));
         const blur = number(lvl.glowBlur, number(ambientGlow.blur, 36));
-        const alpha = number(lvl.glowAlpha, number(ambientGlow.alpha, .16));
+        const alpha = number(lvl.glowAlpha, number(ambientGlow.alpha, 0.16));
         const spread = radius + blur;
         const g = ctx.createRadialGradient(x, y, 0, x, y, spread);
 
         g.addColorStop(0, colorWithAlpha(color, alpha));
-        g.addColorStop(.34, colorWithAlpha(color, alpha * .42));
-        g.addColorStop(.72, colorWithAlpha(color, alpha * .12));
+        g.addColorStop(0.34, colorWithAlpha(color, alpha * 0.42));
+        g.addColorStop(0.72, colorWithAlpha(color, alpha * 0.12));
         g.addColorStop(1, colorWithAlpha(color, 0));
         ctx.fillStyle = g;
         ctx.fillRect(x - spread, y - spread, spread * 2, spread * 2);

@@ -280,101 +446,138 @@
 
       ctx.restore();
     }
-    const ambientGlowPlugin = { id: 'tvaAmbientGlow', beforeDraw: drawAmbientGlow };
-    const zeroAxisPlugin = { id: 'tvaZeroAxis', beforeDatasetsDraw(c) {
-      if (mode !== 'timeline') return;
-      const y = c.scales.y;
-      if (!y) return;
-      const py = y.getPixelForValue(0);
-      const ctx = c.ctx;
-      ctx.save();
-      ctx.strokeStyle = colorWithAlpha(state.colors.normal, .48);
-      ctx.lineWidth = 1.5;
-      ctx.beginPath();
-      ctx.moveTo(0, py);
-      ctx.lineTo(c.width, py);
-      ctx.stroke();
-      ctx.restore();
-    } };
+    const ambientGlowPlugin = { id: "tvaAmbientGlow", beforeDraw: drawAmbientGlow };
+    const zeroAxisPlugin = {
+      id: "tvaZeroAxis",
+      beforeDatasetsDraw(c) {
+        if (mode !== "timeline") return;
+        const y = c.scales.y;
+        if (!y) return;
+        const py = y.getPixelForValue(0);
+        const ctx = c.ctx;
+        ctx.save();
+        ctx.strokeStyle = colorWithAlpha(state.colors.normal, 0.48);
+        ctx.lineWidth = 1.5;
+        ctx.beginPath();
+        ctx.moveTo(0, py);
+        ctx.lineTo(c.width, py);
+        ctx.stroke();
+        ctx.restore();
+      },
+    };
     function drawLabel(c, pt, i, vs) {
       const p = parameters[i];
       const stale = isMetricStale(i);
       const lvl = !stale && breachedLevel(i, vs[i]);
       const critical = lvl && lvl.blink !== false && lvl.key !== levels[0].key;
-      const { x, y } = pt.getProps(['x', 'y'], true);
-      const text = stale ? 'STALE' : formatPoint(p);
+      const { x, y } = pt.getProps(["x", "y"], true);
+      const text = stale ? "STALE" : formatPoint(p);
       const ctx = c.ctx;
       const gy = y - c.chartArea.top < 52 ? y + 18 : y - 43;
 
       ctx.save();
-      ctx.globalAlpha = stale ? .72 : critical ? (criticalBlink ? 1 : .38) : 1;
-      ctx.font = 'bold 9px monospace';
+      ctx.globalAlpha = stale ? 0.72 : critical ? (criticalBlink ? 1 : 0.38) : 1;
+      ctx.font = "bold 9px monospace";
       const w = Math.max(28, ctx.measureText(text).width + 10);
       const gx = Math.min(Math.max(x - w / 2, c.chartArea.left + 2), c.chartArea.right - w - 2);
-      ctx.fillStyle = stale ? state.uiColors.staleLabelFill : lvl ? colorWithAlpha(levelColor(lvl), .18) : state.uiColors.normalLabelFill;
-      ctx.strokeStyle = stale ? staleColor(false) : lvl ? levelColor(lvl) : state.uiColors.normalLabelStroke;
+      ctx.fillStyle = stale
+        ? state.uiColors.staleLabelFill
+        : lvl
+          ? colorWithAlpha(levelColor(lvl), 0.18)
+          : state.uiColors.normalLabelFill;
+      ctx.strokeStyle = stale
+        ? staleColor(false)
+        : lvl
+          ? levelColor(lvl)
+          : state.uiColors.normalLabelStroke;
       ctx.beginPath();
       ctx.rect(gx, gy, w, 31);
       ctx.fill();
       ctx.stroke();
-      drawIcon(ctx, p.icon || 'warning', gx + w / 2, gy + 3, stale ? state.uiColors.staleText : state.uiColors.plotIcon);
+      drawIcon(
+        ctx,
+        p.icon || "warning",
+        gx + w / 2,
+        gy + 3,
+        stale ? state.uiColors.staleText : state.uiColors.plotIcon,
+      );
       ctx.fillStyle = stale ? state.uiColors.staleText : state.uiColors.plotIcon;
-      ctx.textAlign = 'center';
-      ctx.textBaseline = 'middle';
+      ctx.textAlign = "center";
+      ctx.textBaseline = "middle";
       ctx.fillText(text, gx + w / 2, gy + 24);
       ctx.restore();
     }
-    const labelPlugin = { id: 'tvaLabels', afterDatasetsDraw(c) {
-      if (mode !== 'timeline') return;
-      const meta = c.getDatasetMeta(metricDatasetIndex);
-      if (!meta) return;
-      const vs = values();
-      meta.data.forEach((pt, i) => drawLabel(c, pt, i, vs));
-    } };
+    const labelPlugin = {
+      id: "tvaLabels",
+      afterDatasetsDraw(c) {
+        if (mode !== "timeline") return;
+        const meta = c.getDatasetMeta(metricDatasetIndex);
+        if (!meta) return;
+        const vs = values();
+        meta.data.forEach((pt, i) => drawLabel(c, pt, i, vs));
+      },
+    };
 
-    function thresholdDataset(level, side) { return parameters.map(p => limit(p, level, side, side === 'Upper' ? Infinity : -Infinity)); }
+    function thresholdDataset(level, side) {
+      return parameters.map((p) => limit(p, level, side, side === "Upper" ? Infinity : -Infinity));
+    }
     function thresholdDatasets() {
-      return levels.filter(l => l.showAxis !== false).flatMap(l => ['Upper', 'Lower'].map(side => ({
-        label: `${l.label || l.key} ${side}`,
-        data: thresholdDataset(l, side),
-        borderColor: colorWithAlpha(levelColor(l), number(l.axisAlpha, .35)),
-        borderWidth: number(l.axisWidth, 1.6),
-        borderDash: l.axisDash || [4, 5],
-        pointRadius: 0,
-        tension: .4
-      })));
+      return levels
+        .filter((l) => l.showAxis !== false)
+        .flatMap((l) =>
+          ["Upper", "Lower"].map((side) => ({
+            label: `${l.label || l.key} ${side}`,
+            data: thresholdDataset(l, side),
+            borderColor: colorWithAlpha(levelColor(l), number(l.axisAlpha, 0.35)),
+            borderWidth: number(l.axisWidth, 1.6),
+            borderDash: l.axisDash || [4, 5],
+            pointRadius: 0,
+            tension: 0.4,
+          })),
+        );
     }
     function extraAxisDatasets() {
-      return (init.extraAxes || []).map(axis => ({
+      return (init.extraAxes || []).map((axis) => ({
         label: axis.label,
-        data: parameters.map(p => p.key === axis.parameterKey ? number(axis.value) : null),
+        data: parameters.map((p) => (p.key === axis.parameterKey ? number(axis.value) : null)),
         borderColor: axis.color || state.colors.normal,
         borderWidth: number(axis.width, 1.4),
         borderDash: axis.dash || [3, 5],
         pointRadius: 0,
-        spanGaps: false
+        spanGaps: false,
       }));
     }
     function metricDataset(vs) {
       return {
-        label: 'Timeline Metric',
+        label: "Timeline Metric",
         data: vs,
         borderWidth: 3.5,
-        tension: .4,
+        tension: 0.4,
         fill: false,
         borderColor: state.colors.normal,
-        segment: { borderColor: gradient, borderDash: c => isMetricStale(c.p0DataIndex) || isMetricStale(c.p1DataIndex) ? [3, 5] : [] },
-        pointBorderColor: c => metricColor(c.dataIndex, vs[c.dataIndex]),
-        pointBackgroundColor: c => metricColor(c.dataIndex, vs[c.dataIndex]),
-        pointStyle: c => isMetricStale(c.dataIndex) ? 'circle' : trend(c.dataIndex) === 'flat' ? 'circle' : 'triangle',
-        rotation: c => trend(c.dataIndex) === 'down' ? 180 : 0,
-        pointRadius: c => isMetricStale(c.dataIndex) ? 3 : trend(c.dataIndex) === 'flat' ? 4 : 5.5,
-        pointHoverRadius: 8
+        segment: {
+          borderColor: gradient,
+          borderDash: (c) =>
+            isMetricStale(c.p0DataIndex) || isMetricStale(c.p1DataIndex) ? [3, 5] : [],
+        },
+        pointBorderColor: (c) => metricColor(c.dataIndex, vs[c.dataIndex]),
+        pointBackgroundColor: (c) => metricColor(c.dataIndex, vs[c.dataIndex]),
+        pointStyle: (c) =>
+          isMetricStale(c.dataIndex)
+            ? "circle"
+            : trend(c.dataIndex) === "flat"
+              ? "circle"
+              : "triangle",
+        rotation: (c) => (trend(c.dataIndex) === "down" ? 180 : 0),
+        pointRadius: (c) =>
+          isMetricStale(c.dataIndex) ? 3 : trend(c.dataIndex) === "flat" ? 4 : 5.5,
+        pointHoverRadius: 8,
       };
     }
     function openDetailFromClick(_e, els) {
       const hit = els[0];
-      if (hit && hit.datasetIndex === metricDatasetIndex && parameters[hit.index].detailMode) switchMode(parameters[hit.index].detailMode);
+      if (hit && hit.datasetIndex === metricDatasetIndex && parameters[hit.index].detailMode)
+        switchMode(parameters[hit.index].detailMode);
     }
     function timelineScales(vs) {
       return {

@@ -382,127 +585,207 @@
           offset: false,
           border: { display: false },
           grid: { color: state.uiColors.grid },
-          ticks: { color: state.uiColors.tick, font: { weight: 'bold', size: 10 }, callback: (_v, i) => container.classList.contains('tva-chart-fullscreen-mode') ? labels[i] : '' }
+          ticks: {
+            color: state.uiColors.tick,
+            font: { weight: "bold", size: 10 },
+            callback: (_v, i) =>
+              container.classList.contains("tva-chart-fullscreen-mode") ? labels[i] : "",
+          },
         },
         y: {
           ...zoomBounds(vs),
           border: { display: false },
-          grid: { color: c => c.tick.value === 0 ? state.uiColors.transparent : state.uiColors.grid },
-          ticks: { display: false }
-        }
+          grid: {
+            color: (c) => (c.tick.value === 0 ? state.uiColors.transparent : state.uiColors.grid),
+          },
+          ticks: { display: false },
+        },
       };
     }
     function timelineConfig() {
       const vs = values();
       return {
-        type: 'line',
-        data: { labels, datasets: [...thresholdDatasets(), ...extraAxisDatasets(), metricDataset(vs)] },
+        type: "line",
+        data: {
+          labels,
+          datasets: [...thresholdDatasets(), ...extraAxisDatasets(), metricDataset(vs)],
+        },
         options: {
           responsive: true,
           maintainAspectRatio: false,
           layout: { padding: { left: 2, right: 6, top: number(init.topPadding, 34), bottom: 4 } },
           onClick: openDetailFromClick,
-          plugins: { title: { display: false }, legend: { display: false }, tooltip: { callbacks: { title: items => items.length ? labels[items[0].dataIndex] : '', label: c => c.datasetIndex === metricDatasetIndex ? formatPoint(parameters[c.dataIndex]) : null } } },
-          scales: timelineScales(vs)
+          plugins: {
+            title: { display: false },
+            legend: { display: false },
+            tooltip: {
+              callbacks: {
+                title: (items) => (items.length ? labels[items[0].dataIndex] : ""),
+                label: (c) =>
+                  c.datasetIndex === metricDatasetIndex
+                    ? formatPoint(parameters[c.dataIndex])
+                    : null,
+              },
+            },
+          },
+          scales: timelineScales(vs),
         },
-        plugins: [ambientGlowPlugin, zeroAxisPlugin, labelPlugin]
+        plugins: [ambientGlowPlugin, zeroAxisPlugin, labelPlugin],
       };
     }
-    function detailParam() { return parameters.find(p => p.detailMode === mode); }
-    function colorForDetail(l) { return state.colors[l.level] || state.colors[camel(l.level)] || state.colors.normal; }
-    function detailLevelFor(value, levels) { return levels.findLast(l => (value || 0) > number(l.above, Infinity)); }
+    function detailParam() {
+      return parameters.find((p) => p.detailMode === mode);
+    }
+    function colorForDetail(l) {
+      return state.colors[l.level] || state.colors[camel(l.level)] || state.colors.normal;
+    }
+    function detailLevelFor(value, levels) {
+      return levels.findLast((l) => (value || 0) > number(l.above, Infinity));
+    }
     function barConfig() {
       const p = detailParam();
       const rows = normalizeAreas(state[p.areaKey]);
-      const days = rows.map(r => r.days);
+      const days = rows.map((r) => r.days);
       const detailLevels = p.detailLevels || [];
 
       return {
-        type: 'bar',
+        type: "bar",
         data: {
-          labels: rows.map(r => r.name),
-          datasets: [{
-            data: days,
-            borderWidth: 1.2,
-            borderRadius: 8,
-            backgroundColor: c => {
-              const lvl = detailLevelFor(c.raw, detailLevels);
-              return colorWithAlpha(lvl ? colorForDetail(lvl) : state.colors.normal, lvl ? .38 : .3);
+          labels: rows.map((r) => r.name),
+          datasets: [
+            {
+              data: days,
+              borderWidth: 1.2,
+              borderRadius: 8,
+              backgroundColor: (c) => {
+                const lvl = detailLevelFor(c.raw, detailLevels);
+                return colorWithAlpha(
+                  lvl ? colorForDetail(lvl) : state.colors.normal,
+                  lvl ? 0.38 : 0.3,
+                );
+              },
+              borderColor: (c) => {
+                const lvl = detailLevelFor(c.raw, detailLevels);
+                return lvl ? colorForDetail(lvl) : state.colors.normal;
+              },
             },
-            borderColor: c => {
-              const lvl = detailLevelFor(c.raw, detailLevels);
-              return lvl ? colorForDetail(lvl) : state.colors.normal;
-            }
-          }]
+          ],
         },
         options: {
           responsive: true,
           maintainAspectRatio: false,
           plugins: {
             title: { display: false },
-            subtitle: { display: true, text: p.detailSubtitle || '', color: state.colors[detailLevels[0] && detailLevels[0].level] || state.colors.normal, font: { size: 10, weight: 'bold' } },
-            legend: { display: false }
+            subtitle: {
+              display: true,
+              text: p.detailSubtitle || "",
+              color: state.colors[detailLevels[0] && detailLevels[0].level] || state.colors.normal,
+              font: { size: 10, weight: "bold" },
+            },
+            legend: { display: false },
           },
           scales: {
-            x: { grid: { color: state.uiColors.detailGrid }, ticks: { color: state.uiColors.tick, font: { weight: 'bold', size: 10 } } },
-            y: { min: 0, max: Math.max(...days, ...detailLevels.map(l => number(l.above, 0))) + 1.5, ticks: { color: state.uiColors.detailTick, callback: v => `${v}d` } }
-          }
-        }
+            x: {
+              grid: { color: state.uiColors.detailGrid },
+              ticks: { color: state.uiColors.tick, font: { weight: "bold", size: 10 } },
+            },
+            y: {
+              min: 0,
+              max: Math.max(...days, ...detailLevels.map((l) => number(l.above, 0))) + 1.5,
+              ticks: { color: state.uiColors.detailTick, callback: (v) => `${v}d` },
+            },
+          },
+        },
       };
     }
     function activeLevel() {
       return values()
-        .map((v, i) => isMetricStale(i) ? null : breachedLevel(i, v))
+        .map((v, i) => (isMetricStale(i) ? null : breachedLevel(i, v)))
         .filter(Boolean)
         .sort((a, b) => number(b.priority, 0) - number(a.priority, 0))[0];
     }
     function syncControls() {
-      const select = controls.querySelector('.tva-chart-mode-select');
-      const back = controls.querySelector('.tva-chart-back');
-      const fs = controls.querySelector('.tva-chart-fullscreen');
+      const select = controls.querySelector(".tva-chart-mode-select");
+      const back = controls.querySelector(".tva-chart-back");
+      const fs = controls.querySelector(".tva-chart-fullscreen");
       const active = activeLevel();
-      const borderAlert = active && (active.borderBlink || active.blinkBorder || active.borderAlert);
+      const borderAlert =
+        active && (active.borderBlink || active.blinkBorder || active.borderAlert);
 
       if (select) select.value = mode;
-      back.hidden = mode === 'timeline';
-      fs.classList.toggle('is-restore', container.classList.contains('tva-chart-fullscreen-mode'));
-      alertBadge.hidden = mode !== 'timeline' || !active;
-      alertBadge.innerHTML = active ? `<span class="tva-alert-icon" aria-hidden="true"></span>${active.label || active.key.toUpperCase()}` : '';
-      alertBadge.style.color = active ? levelColor(active) : '';
-      container.classList.toggle('tva-border-alert', !!borderAlert);
-      if (borderAlert) container.style.setProperty('--tva-border-alert-color', levelColor(active));
-      else container.style.removeProperty('--tva-border-alert-color');
-    }
-    function render() { if (chart) chart.destroy(); chart = new Chart(canvas.getContext('2d'), mode === 'timeline' ? timelineConfig() : barConfig()); syncControls(); }
+      back.hidden = mode === "timeline";
+      fs.classList.toggle("is-restore", container.classList.contains("tva-chart-fullscreen-mode"));
+      alertBadge.hidden = mode !== "timeline" || !active;
+      alertBadge.innerHTML = active
+        ? `<span class="tva-alert-icon" aria-hidden="true"></span>${active.label || active.key.toUpperCase()}`
+        : "";
+      alertBadge.style.color = active ? levelColor(active) : "";
+      container.classList.toggle("tva-border-alert", !!borderAlert);
+      if (borderAlert) container.style.setProperty("--tva-border-alert-color", levelColor(active));
+      else container.style.removeProperty("--tva-border-alert-color");
+    }
+    function render() {
+      if (chart) chart.destroy();
+      chart = new Chart(
+        canvas.getContext("2d"),
+        mode === "timeline" ? timelineConfig() : barConfig(),
+      );
+      syncControls();
+    }
     let blinkId = null;
     let staleSweepId = null;
-    function hasCriticalBlink() { if (mode !== 'timeline') return false; return values().some((v, i) => { if (isMetricStale(i)) return false; const level = breachedLevel(i, v); return !!(level && level.blink !== false); }); }
-    function hasStaleSweep() { return mode === 'timeline' && values().some((_v, i) => isMetricStale(i)); }
+    function hasCriticalBlink() {
+      if (mode !== "timeline") return false;
+      return values().some((v, i) => {
+        if (isMetricStale(i)) return false;
+        const level = breachedLevel(i, v);
+        return !!(level && level.blink !== false);
+      });
+    }
+    function hasStaleSweep() {
+      return mode === "timeline" && values().some((_v, i) => isMetricStale(i));
+    }
     function syncBlinkTimer() {
       const shouldBlink = hasCriticalBlink();
       if (shouldBlink && !blinkId) {
-        blinkId = setInterval(() => {
-          criticalBlink = !criticalBlink;
-          if (chart && mode === 'timeline') chart.update('none');
-        }, number(init.blinkMs, 1100));
+        blinkId = setInterval(
+          () => {
+            criticalBlink = !criticalBlink;
+            if (chart && mode === "timeline") chart.update("none");
+          },
+          number(init.blinkMs, 1100),
+        );
       } else if (!shouldBlink && blinkId) {
-        clearInterval(blinkId); blinkId = null; criticalBlink = true;
+        clearInterval(blinkId);
+        blinkId = null;
+        criticalBlink = true;
       }
 
       const shouldSweep = hasStaleSweep();
       if (shouldSweep && !staleSweepId) {
-        staleSweepId = setInterval(() => {
-          stalePhase += staleDirection * 0.08;
-          if (stalePhase >= 1) { stalePhase = 1; staleDirection = -1; }
-          else if (stalePhase <= 0) { stalePhase = 0; staleDirection = 1; }
-          if (chart && mode === 'timeline') chart.update('none');
-        }, number(init.staleSweepMs, 140));
+        staleSweepId = setInterval(
+          () => {
+            stalePhase += staleDirection * 0.08;
+            if (stalePhase >= 1) {
+              stalePhase = 1;
+              staleDirection = -1;
+            } else if (stalePhase <= 0) {
+              stalePhase = 0;
+              staleDirection = 1;
+            }
+            if (chart && mode === "timeline") chart.update("none");
+          },
+          number(init.staleSweepMs, 140),
+        );
       } else if (!shouldSweep && staleSweepId) {
-        clearInterval(staleSweepId); staleSweepId = null; stalePhase = 0; staleDirection = 1;
+        clearInterval(staleSweepId);
+        staleSweepId = null;
+        stalePhase = 0;
+        staleDirection = 1;
       }
     }
     function refresh() {
-      if (!chart || mode !== 'timeline') {
+      if (!chart || mode !== "timeline") {
         render();
         syncBlinkTimer();
         return;

@@ -518,10 +801,15 @@
       Object.assign(chart.options.scales.y, zoomBounds(values()));
       syncControls();
       syncBlinkTimer();
-      chart.update('none');
+      chart.update("none");
+    }
+    function switchMode(next) {
+      mode = next;
+      render();
+      syncBlinkTimer();
     }
-    function switchMode(next) { mode = next; render(); syncBlinkTimer(); }
-    render(); syncBlinkTimer();
+    render();
+    syncBlinkTimer();
     function publicData() {
       const out = { ...clone(state), updatedAt: clone(updatedAtByKey) };
       delete out.uiColors;

@@ -535,13 +823,16 @@
       const now = Date.now();
       Object.entries(patch || {}).forEach(([raw, val]) => {
         const key = aliases[raw] || raw;
-        if (metricKeys.includes(key) && val !== undefined && val !== null) updatedAtByKey[key] = now;
-      });
-      if (patch && patch.updatedAt && typeof patch.updatedAt === 'object') Object.entries(patch.updatedAt).forEach(([raw, value]) => {
-        const key = aliases[raw] || raw;
-        const timestamp = typeof value === 'string' ? Date.parse(value) : number(value, NaN);
-        if (metricKeys.includes(key) && Number.isFinite(timestamp)) updatedAtByKey[key] = timestamp;
+        if (metricKeys.includes(key) && val !== undefined && val !== null)
+          updatedAtByKey[key] = now;
       });
+      if (patch && patch.updatedAt && typeof patch.updatedAt === "object")
+        Object.entries(patch.updatedAt).forEach(([raw, value]) => {
+          const key = aliases[raw] || raw;
+          const timestamp = typeof value === "string" ? Date.parse(value) : number(value, NaN);
+          if (metricKeys.includes(key) && Number.isFinite(timestamp))
+            updatedAtByKey[key] = timestamp;
+        });
     }
     return {
       update(patch) {

@@ -556,20 +847,26 @@
         previousMetricValues = values();
         state = mergeData(baseState(), next, aliases);
         resolveUiColors();
-        updatedAtByKey = Object.fromEntries(metricKeys.map(k => [k, Date.now()]));
+        updatedAtByKey = Object.fromEntries(metricKeys.map((k) => [k, Date.now()]));
         refresh();
       },
-      refreshTheme() { resolveUiColors(); render(); syncBlinkTimer(); },
-      getData() { return publicData(); },
+      refreshTheme() {
+        resolveUiColors();
+        render();
+        syncBlinkTimer();
+      },
+      getData() {
+        return publicData();
+      },
       destroy() {
         if (blinkId) clearInterval(blinkId);
         if (staleSweepId) clearInterval(staleSweepId);
-        container.classList.remove('tva-border-alert');
-        container.style.removeProperty('--tva-border-alert-color');
+        container.classList.remove("tva-border-alert");
+        container.style.removeProperty("--tva-border-alert-color");
         if (chart) chart.destroy();
         controls.remove();
         alertBadge.remove();
-      }
+      },
     };
   };
 })();