e().includes("connect")) setConnUI('connected');
    });

    socket.on("gauge_snapshot", (payload) => {
      const g = payload?.gauges || payload;
      if (g) {
        applyG(g);
      }
    });

  })();
</script>
{% endif %}

<!-- Optional origin guard -->
<script>
  document.addEventListener("DOMContentLoaded", function() {
    if (window.location.hostname !== 'localhost' && window.Swal) {
      Swal.fire({
        title: "Access Alert",
        text: "You are not accessing the application from the st