@font-face {
  font-family: 'Satoshi';
  src: url('../fonts/Satoshi-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-family: 'Satoshi', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}



#controls {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 100;
  background: #D9D9D9;
  padding: 20px;
  border-radius: 10px;
  width: 500px;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
  align-items: flex-end;
  display: grid;
  grid-template-columns: 1fr 3fr;
}

#controls h3 {
  margin: 0 0 10px 0;
  color: #4fc3f7;
  font-size: 18px;
}

.control-group {
  margin-bottom: 12px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #e0e0e0;
}

input[type="range"] {
  width: 160px;
}

button {
  background: linear-gradient(45deg, #4fc3f7, #29b6f6);
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  margin: 4px;
}

#info {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.8);
  padding: 15px;
  border-radius: 10px;
  color: white;
  font-size: 12px;
  max-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#binDetails {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
  border-radius: 6px;
  max-height: 420px;
  overflow: auto;
}

#hoverLabel {
  position: absolute;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
  display: none;
  z-index: 300;
}

.layout-edit-toolbar {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 180;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  padding: 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

.layout-edit-toolbar button {
  min-height: 36px;
  border-radius: 6px;
  border: 0;
  padding: 6px 12px;
  font-weight: 800;
}

.layout-edit-toolbar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.layout-edit-toolbar span {
  min-width: 92px;
  font-size: 12px;
  font-weight: 800;
  color: #cbd5e1;
}

body.layout-edit-mode .layout-edit-toolbar {
  border-color: rgba(20, 184, 166, 0.72);
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.18), 0 12px 34px rgba(0, 0, 0, 0.28);
}

#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 20px;
  z-index: 200;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #4fc3f7;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  animation: spin 1s linear infinite;
  margin: 0 auto 8px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* modals */
#productModal,
#confirmModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
}

.panel {
  background: #0f1720;
  color: white;
  border-radius: 10px;
  padding: 16px;
  /* border: 1px solid #24303a; */
  max-width: 94%;
  width: 420px;
  box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.5);
}

#confirmModal .panel {
  width: 360px;
  background: #07111a;
  border: 1px solid #23414a;
  text-align: center;
}

.img-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #34414a;
}




.summary-box {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  border: 1px solid #2f3a42;
}

.summary-label {
  font-size: 13px;
  color: #000000;
}

.summary-value {
  font-size: 20px;
  font-weight: bold;
  margin-top: 4px;
}

.summary-box.assigned {
  border-color: #2563eb;
}

.summary-box.unassigned {
  border-color: #f59e0b;
}





.log {
  max-width: 100px;


}

.controls-tab {
  grid-template-columns: 1fr 1fr 1fr;
  display: grid;
  align-items: end;
}


img.logo {
  width: 120px;
  margin: 0 auto;
  display: flex;
  margin-bottom: 15px;
}

.bg-dark {
  background: #000000;
  color: rgb(255, 255, 255);
  display: flex;
  align-items: center;
  height: 40px;
  justify-content: center;
}

button#btnResetCam {
  background: white;
  color: black;
}

.container.btns {
  /* display: flex; */
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex-wrap: wrap;
  justify-content: space-around;
}

#title-box {
  position: absolute;
  top: 20px;
  right: 23px;
  z-index: 100;
  background: #D9D9D9;
  padding: 14px;
  border-radius: 10px;
  color: rgb(5, 4, 4);
  font-weight: bold;
  font-size: 18px !important;
  width: 260px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 375px;
  box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.5);
}

#information {
  position: absolute;
  top: 165px;
  right: 0px;
  z-index: 100;
  background: transparent;
  padding: 1px;
  border-radius: 10px;
  color: rgb(8, 6, 6);
  font-size: 18px !important;
  width: 400px;
  height: auto;
}

.panel {
  background: #D9D9D9;
  color: rgb(7, 7, 7);
  margin-top: 9px;
  padding: 10px;
  border-radius: 10px;
  /* overflow-y: scroll; */
  height: 210px;

}

.right-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 500px;
  background: rgba(15, 25, 30, 0.95);
  color: #fff;
  border-radius: 12px;
  padding: 16px;
  z-index: 100;
  font-size: 13px;
}

.panel-header h4 {
  margin: 0;
  font-size: 18px;
  /* font-size: 16px; */
}


h4 {

  font-size: 18px;

}

.panel-header small {
  color: #9fb6c3;
}

.panel-section {
  margin-top: -4px;
  background: #fcfafa;
  padding: 12px;
  border-radius: 8px;
  color: #000;

}

.panel-section h5 {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: #7dd3fc;
}

.kv {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  font-size: 16px;
  color: #000;
}

.kv span {
  color: #aab8c2;
}

.progress {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #22c55e;
  border-radius: 6px;
}

.product-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  gap: 10px;
}

.product-card img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}

.product-meta {
  flex: 1;
}

.product-meta strong {
  display: block;
}

.muted {
  color: #9aa7b2;
}

#abcLegend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: #D9D9D9;
  color: #080808;
  border-radius: 12px;
  padding: 16px;
  z-index: 100;
  font-size: 16px;
  width: fit-content;

}

.footerlegend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: #D9D9D9;
  color: #080808;
  border-radius: 12px;
  padding: 16px;
  z-index: 100;
  font-size: 13px;
  width: 381px;
  display: flex;
  align-items: center;
}

.footerlogo {
  width: 70px;
  margin-right: 12px;
}

.checkbox {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #D9D9D9;
  color: #080808;
  border-radius: 30px 30px 0 0;
  padding: 16px;
  z-index: 100;
  font-size: 15px;
  width: 260px;
  display: flex;
  align-items: center;
}

.form-switch {
  padding-left: 0 !important;

}

#searchDimOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 5;
}

#searchDimOverlay.active {
  opacity: 1;
}

.analytics-btn.active {
  background: #ffffff !important;
  /* orange highlight */
  color: #000;
  box-shadow: 0 0 12px rgba(245, 148, 27, 0.6);
  transform: scale(1.05);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 6px;
  margin-top: 12px;
}

.summary-box {

  background: rgba(255, 255, 255, 0.04);

  border-radius: 8px;

  padding: 8px;

  text-align: center;

  border: 1px solid #2f3a42;

}



.summary-value {

  font-size: 20px;

  font-weight: bold;

  margin-top: 4px;

}

.summary-box.assigned {
  border-color: #2563eb;
}

.summary-box.unassigned {
  border-color: #f59e0b;
}



/* ===============================
   PHANTOM VIEW – UI THEME
=============================== */

body.phantom-view {
  background: #050505;
}

/* RIGHT PANEL CONTAINER */
body.phantom-view .right-panel {
  background: rgba(10, 10, 10, 0.92);
  /* border: 1px solid rgba(255,255,255,0.08); */
  /* box-shadow: 0 0 40px rgba(0,0,0,0.9); */
  color: #e5e7eb;
}

/* PANEL BLOCKS */
body.phantom-view .panel {
  background: #262626;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* SECTION INSIDE PANEL */
body.phantom-view .panel-section {
  background: #7c7c7c;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* LABEL + VALUES */
body.phantom-view .kv {
  color: #ffffff;
}

body.phantom-view .kv strong {
  color: #ffffff;
}

/* PROGRESS BAR */
body.phantom-view .progress {
  background: rgba(255, 255, 255, 0.08);
}

body.phantom-view .progress-fill {
  background: #22c55e;
}

/* PRODUCT CARDS */
body.phantom-view .product-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
}

/* MUTED TEXT */
body.phantom-view .muted {
  color: #94a3b8;
}

/* TITLES */
body.phantom-view h4 {
  color: #FFA43C;
}


/* ==================================================
   PHANTOM VIEW – CONTROLS PANEL (LEFT)
================================================== */

body.phantom-view #controls {
  background: #262626;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}

/* Buttons inside controls */
body.phantom-view #controls button {
  background: #ffffff;
  color: #000000;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

body.phantom-view #controls button:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Labels */
body.phantom-view #controls label {
  color: #cbd5e1;
}

/* Inputs */
body.phantom-view #controls input,
body.phantom-view #controls select {
  background: rgba(5, 5, 5, 0.9);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}



/* Logo dim */
body.phantom-view #controls img.logo {
  opacity: 0.85;
}

body.phantom-view #controls .form-control {
  background: #ffffff !important;
  color: #000000 !important;


}

/* ==================================================
   PHANTOM VIEW – FOOTER LEGEND
================================================== */

body.phantom-view .footerlegend {
  background: #262626;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}

/* Footer text */
body.phantom-view .footerlegend .fw-semibold {
  color: #ffffff;
}

body.phantom-view .footerlegend .text-muted {
  color: #94a3b8 !important;
}

/* Logo dim for XRAY feel */
body.phantom-view .footerlogo {
  opacity: 0.85;
  filter: grayscale(100%);
}

/* ==================================================
   PHANTOM VIEW – BOTTOM VIEW SWITCH
================================================== */

body.phantom-view .checkbox {
  background: #262626;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}

/* Labels */
body.phantom-view .checkbox span {
  color: #e5e7eb;
}

/* Toggle track */
body.phantom-view .form-switch .form-check-input {
  background-color: #FFA43C;
  /* border-color: rgba(255,255,255,0.3); */
}

/* ==================================================
   PROFESSIONAL RESPONSIVE VIEWER UI
================================================== */

#container {
  background: #05070a;
}

#controls,
#title-box,
#abcLegend,
.footerlegend,
.checkbox,
#information .panel {
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.74), rgba(241, 245, 249, 0.5));
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

#controls {
  width: min(520px, calc(100vw - 40px));
  padding: 14px;
  border-radius: 8px;
  grid-template-columns: 112px 1fr;
  gap: 12px;
}

.controls-tab {
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 6px;
}

#controls a,
#controls button,
.analytics-btn,
button.bg-dark,
a.bg-dark {
  min-height: 34px;
  margin: 0;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: #111827 !important;
  color: #ffffff !important;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.15;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

#controls a:hover,
#controls button:hover {
  background: #0f766e !important;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.24);
  transform: translateY(-1px);
}

.hu-search-bar {
  gap: 6px;
  padding: 0;
}

.hu-search-bar .form-control,
.hu-search-bar .btn,
.hu-search-bar .analytics-btn {
  height: 31px;
}

.hu-search-bar .form-control {
  min-width: 150px;
  border-radius: 6px;
}

.analytics-btn.active {
  background: #f59e0b !important;
  color: #111827 !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
  transform: none;
}

#controls button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.layout-edit-status {
  display: flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.08);
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.layout-edit-status[data-tone="active"] {
  border-color: rgba(20, 184, 166, 0.42);
  background: rgba(20, 184, 166, 0.12);
  color: #0f766e;
}

.layout-edit-status[data-tone="warning"] {
  border-color: rgba(245, 158, 11, 0.48);
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
}

body.layout-edit-mode #container {
  cursor: grab;
}

body.layout-edit-mode #container:active {
  cursor: grabbing;
}

body.layout-edit-mode #controls {
  border-color: rgba(20, 184, 166, 0.58);
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.16), 0 18px 45px rgba(15, 23, 42, 0.22);
}

.viewer-ui-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 850;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.32);
}

body.viewer-ui-hidden #controls,
body.viewer-ui-hidden #title-box,
body.viewer-ui-hidden #abcLegend,
body.viewer-ui-hidden .footerlegend,
body.viewer-ui-hidden .checkbox,
body.viewer-ui-hidden #information,
body.viewer-ui-hidden #binCount,
body.viewer-ui-hidden #hoverLabel,
body.viewer-ui-hidden #searchDimOverlay {
  display: none !important;
}

.walk-mode-hud {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 820;
  pointer-events: none;
  color: #e5edf7;
  font-family: 'Satoshi', system-ui, -apple-system, sans-serif;
}

body.walkthrough-mode .walk-mode-hud {
  display: block;
}

.walk-mode-hud[aria-hidden="true"] {
  display: none;
}

.walk-hud-panel {
  position: fixed;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(7, 15, 25, 0.74);
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.34);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.walk-hud-panel strong {
  color: #ffffff;
  font-size: 13px;
  line-height: 1.2;
}

.walk-hud-panel span {
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.35;
}

.walk-hud-instructions {
  left: max(18px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: grid;
  gap: 4px;
  min-width: 190px;
  padding: 11px 12px;
}

.walk-hud-status {
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: grid;
  gap: 3px;
  min-width: 170px;
  padding: 10px 12px;
  text-align: right;
}

.walk-hud-compass {
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  transform: translateX(-50%);
}

.walk-hud-compass span {
  position: absolute;
  top: 5px;
  font-size: 10px;
  font-weight: 900;
  color: #dbeafe;
}

.walk-hud-compass strong {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.18);
  color: #22c55e;
  font-size: 22px;
  transform-origin: center;
}

.walk-minimap {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 204px;
  padding: 10px;
}

.walk-minimap canvas {
  display: block;
  width: 180px !important;
  height: 180px !important;
  border-radius: 6px;
}

.walk-minimap-caption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 7px;
}

.walk-minimap-caption span {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.walk-reticle {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
}

.walk-reticle::before,
.walk-reticle::after {
  content: "";
  position: absolute;
  background: rgba(226, 232, 240, 0.86);
}

.walk-reticle::before {
  top: 8px;
  left: 0;
  width: 18px;
  height: 2px;
}

.walk-reticle::after {
  top: 0;
  left: 8px;
  width: 2px;
  height: 18px;
}

@media (max-width: 768px) {
  .walk-hud-instructions {
    right: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: min(220px, calc(100vw - 24px));
  }

  .walk-hud-status {
    top: max(74px, env(safe-area-inset-top));
    right: 12px;
    min-width: 150px;
  }

  .walk-hud-compass {
    top: max(12px, env(safe-area-inset-top));
    width: 48px;
    height: 48px;
  }

  .walk-minimap {
    right: 12px;
    bottom: calc(126px + env(safe-area-inset-bottom));
    width: 148px;
    padding: 8px;
  }

  .walk-minimap canvas {
    width: 132px !important;
    height: 132px !important;
  }

  .walk-minimap-caption {
    display: none;
  }
}

img.logo {
  width: 92px;
  margin-bottom: 0;
}

#title-box {
  width: min(360px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 12px 14px;
}

#information {
  right: 20px;
  top: 122px;
  width: min(340px, calc(100vw - 40px));
  font-size: 14px !important;
}

#information .panel {
  width: 100%;
  height: auto;
  max-height: 245px;
  overflow: auto;
  border-radius: 8px;
  padding: 12px;
}

.panel-section {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.kv {
  gap: 12px;
  font-size: 13px;
  line-height: 1.45;
}

.kv strong {
  text-align: right;
}

.product-card {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.24);
  color: #111827;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.viewer-product-row {
  cursor: pointer;
}

.viewer-product-row:hover {
  background: rgba(15, 118, 110, 0.1);
}

.live-analytics-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.live-analytics-head,
.live-filter-grid,
.live-kpi-grid,
.live-analytics-grid {
  display: grid;
  gap: 10px;
}

.live-analytics-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.live-analytics-head h5 {
  margin: 0;
}

.live-analytics-subtitle {
  color: #64748b;
  font-size: 12px;
}

.live-filter-grid {
  grid-template-columns: minmax(180px, 1.4fr) repeat(7, minmax(90px, 1fr));
}

.live-kpi-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.live-kpi,
.live-card {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  padding: 10px;
}

.live-kpi span {
  display: block;
  color: #64748b;
  font-size: 12px;
}

.live-kpi strong {
  font-size: 18px;
}

.live-analytics-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.live-card h6 {
  margin: 0 0 8px;
}

.live-bar-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  width: 100%;
  margin-bottom: 6px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.82);
  color: #0f172a;
  padding: 7px 9px;
  text-align: left;
}

.live-bar-row span,
.live-bar-row strong {
  position: relative;
  z-index: 1;
}

.live-bar-row i {
  position: absolute;
  inset: auto auto 0 0;
  height: 3px;
  background: #0f766e;
}

.live-product-row {
  display: grid;
  gap: 2px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.live-product-row span,
.live-empty {
  color: #64748b;
  font-size: 12px;
}

.live-table-wrap {
  max-height: 260px;
  overflow: auto;
}

.live-bin-row {
  cursor: pointer;
}

.live-bin-row:hover {
  background: rgba(15, 118, 110, 0.1);
}

#abcLegend,
.footerlegend {
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
}

.footerlegend {
  width: min(330px, calc(100vw - 40px));
}

.checkbox {
  width: auto;
  min-width: 260px;
  border-radius: 999px;
  padding: 10px 14px;
}

.kv-modal {
  display: none;
  position: fixed;
  inset: 0;
  padding: 16px;
  z-index: 900;
}

.kv-modal.is-open {
  display: grid;
  place-items: center;
}

.kv-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(5px);
}

.kv-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(248, 250, 252, 0.92), rgba(226, 232, 240, 0.72));
  color: #111827;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 28px 80px rgba(2, 6, 23, 0.46);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.modal-content {
  border-radius: 8px;
  color: #111827;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(145deg, rgba(248, 250, 252, 0.92), rgba(226, 232, 240, 0.72));
  box-shadow: 0 28px 80px rgba(2, 6, 23, 0.38);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.modal-header,
.modal-footer {
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.54);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.kv-modal__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.kv-modal__eyebrow {
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.kv-modal__header h2 {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

.kv-modal__subtitle {
  margin-top: 4px;
  color: #64748b;
  font-size: 13px;
}

.kv-icon-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 6px;
  background: #e5e7eb !important;
  color: #111827 !important;
  font-size: 18px;
  font-weight: 800;
}

.kv-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 20px;
}

.product-detail-dialog {
  width: min(1040px, calc(100vw - 32px));
}

.viewer-product-detail-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.viewer-product-detail-image {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  background: #e5e7eb;
}

.viewer-product-placeholder {
  display: grid;
  place-items: center;
  color: #64748b;
}

.viewer-product-kv {
  display: grid;
  gap: 10px;
}

.viewer-product-kv dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.viewer-product-kv dd {
  margin: 0;
}

.viewer-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.viewer-reference-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.viewer-reference-link:hover {
  background: rgba(15, 118, 110, 0.1);
}

.kv-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kv-metric,
.kv-detail-card,
.kv-bin-chart-card,
.kv-products-block {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.kv-metric {
  padding: 14px;
}

.kv-metric span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.kv-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.kv-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kv-detail-card,
.kv-bin-chart-card,
.kv-products-block {
  padding: 14px;
}

.kv-detail-card h3,
.kv-section-title h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
}

.kv-bin-chart-card {
  margin-bottom: 12px;
}

.kv-bin-chart-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 18px;
  align-items: center;
}

.kv-bin-donut {
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#14b8a6 0% 0%, #e2e8f0 0% 100%);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08), 0 14px 34px rgba(15, 23, 42, 0.12);
}

.kv-bin-donut__center {
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 12px;
  border-radius: 50%;
  background: rgba(248, 250, 252, 0.94);
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
}

.kv-bin-donut__center span,
.kv-bin-donut__center small {
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
}

.kv-bin-donut__center strong {
  color: #0f172a;
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
}

.kv-bin-chart-details {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.kv-bin-chart-legend {
  display: grid;
  gap: 8px;
}

.kv-bin-chart-item {
  width: 100%;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.7);
  color: #0f172a;
  text-align: left;
  cursor: pointer;
}

.kv-bin-chart-item:hover,
.kv-bin-chart-item:focus-visible,
.kv-bin-chart-item.is-active {
  border-color: rgba(20, 184, 166, 0.55);
  background: rgba(240, 253, 250, 0.85);
  outline: none;
}

.kv-bin-chart-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.kv-bin-chart-item span {
  min-width: 0;
  overflow: hidden;
  color: #475569;
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kv-bin-chart-item strong {
  font-size: 13px;
  font-weight: 850;
}

.kv-bin-product-bars {
  display: grid;
  gap: 9px;
}

.kv-bin-product-bar {
  display: grid;
  gap: 5px;
}

.kv-bin-product-bar__label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #475569;
  font-size: 12px;
  font-weight: 750;
}

.kv-bin-product-bar__label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kv-bin-product-bar__track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.kv-bin-product-bar__fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #14b8a6);
}

.kv-detail-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.kv-detail-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.kv-detail-card dt {
  color: #64748b;
  font-weight: 650;
}

.kv-detail-card dd {
  margin: 0;
  text-align: right;
  font-weight: 750;
}

.kv-products-block {
  margin-top: 12px;
}

.kv-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.kv-section-title span {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.kv-product-table {
  overflow: auto;
}

.kv-product-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.kv-product-table th,
.kv-product-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  text-align: left;
  white-space: nowrap;
}

.kv-product-table th {
  color: #475569;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 800;
}

.equipment-preview-360 {
  position: relative;
  width: 100%;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    #f8fafc;
  background-size: 22px 22px;
}

.equipment-preview-360 canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.kv-empty-state {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px dashed rgba(100, 116, 139, 0.45);
  border-radius: 8px;
  color: #64748b;
  text-align: center;
}

.kv-empty-state strong {
  color: #0f172a;
}

@media (max-width: 1024px) {
  #controls {
    grid-template-columns: 1fr;
    width: min(430px, calc(100vw - 24px));
    top: 12px;
    left: 12px;
  }

  img.logo {
    display: none;
  }

  #title-box {
    top: 12px;
    right: 12px;
    width: min(300px, calc(100vw - 24px));
  }

  #information {
    top: auto;
    right: 12px;
    bottom: 82px;
    width: min(320px, calc(100vw - 24px));
  }
}

@media (max-width: 760px) {
  #controls {
    position: absolute;
    width: calc(100vw - 20px);
    max-height: 36vh;
    overflow: auto;
  }

  .controls-tab {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #title-box {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 130px;
    width: auto;
  }

  #information {
    display: none;
  }

  #abcLegend {
    left: 10px;
    bottom: 74px;
    max-width: calc(50vw - 14px);
  }

  .footerlegend {
    display: none;
  }

  .checkbox {
    bottom: 10px;
    min-width: auto;
    width: calc(100vw - 20px);
    justify-content: center;
  }

  .kv-modal__dialog {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
  }

  .kv-modal__header {
    padding: 14px;
  }

  .kv-modal__header h2 {
    font-size: 18px;
    line-height: 1.15;
  }

  .kv-modal__body {
    padding: 14px;
  }

  .kv-metric-grid,
  .kv-detail-grid,
  .kv-bin-chart-layout {
    grid-template-columns: 1fr;
  }

  .kv-bin-donut {
    width: min(200px, 100%);
    height: auto;
    aspect-ratio: 1;
    margin-inline: auto;
  }

  .kv-product-table table {
    min-width: 640px;
  }
}

/* ==================================================
   PHANTOM VIEW – ABC LEGEND
================================================== */

body.phantom-view #abcLegend {
  background: #262626;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}

/* Legend rows */
body.phantom-view #abcLegend .legend-row {
  color: #e5e7eb;
}

/* Text inside legend */
body.phantom-view #abcLegend span {
  color: #e5e7eb;
}

/* Color dots (keep original colors, just glow a bit) */
body.phantom-view #abcLegend .legend-color {
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.25);
}

/* ==================================================
   PHANTOM VIEW – TITLE + SUMMARY
================================================== */

body.phantom-view #title-box {
  background: #262626;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  padding: 14px;
}

/* Title text */
body.phantom-view #title-box .title {
  color: #ffffff;
}

/* Summary grid container */
body.phantom-view #pickfaceSummary {
  margin-top: 12px;
}

/* Summary cards */
body.phantom-view .summary-box {
  background-color: #7c7c7c;
  border-color: #575656;
  color: #e5e7eb;
}

/* Summary labels + values */
body.phantom-view .summary-label {
  color: #ffffff;
}

body.phantom-view .summary-value {
  color: #ffffff;
}

/* Keep semantic borders */
body.phantom-view .summary-box.assigned {
  border-color: #22c55e;
}

body.phantom-view .summary-box.unassigned {
  border-color: #f59e0b;
}


/* ==================================================
   PHANTOM VIEW – OVERRIDE bg-dark BUTTONS
================================================== */

/* All dark buttons become LIGHT in Phantom */
body.phantom-view .bg-dark {
  background: #ffffff !important;
  color: #000000 !important;
  border: 1px solid #d1d5db;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* Hover */
body.phantom-view .bg-dark:hover {
  background: #f3f4f6 !important;
}

/* Active analytics button (orange highlight) */
body.phantom-view .analytics-btn.active {
  background: #f59e0b !important;
  color: #000000 !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
  transform: scale(1.05);
}

.analytics-btn.active {
  background: #f59e0b !important;
}

.kvgf {

  /* Glass background */
  background: linear-gradient(145deg,
      rgba(255, 255, 255, 0.08),
      rgba(255, 255, 255, 0.02));

  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);

  border-radius: 14px;

  /* soft border */
  border: 1px solid rgba(255, 255, 255, 0.12);

  /* glass highlight */
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);

  /* smooth animation */
  transition: all .25s ease;
}

/* ==================================================
   VIEWER DARK / GLASS OVERRIDES
================================================== */

body.viewer-dark-mode,
body.phantom-view {
  color: #e5e7eb;
}

body.viewer-dark-mode #controls,
body.viewer-dark-mode #title-box,
body.viewer-dark-mode #abcLegend,
body.viewer-dark-mode .footerlegend,
body.viewer-dark-mode .checkbox,
body.viewer-dark-mode #information .panel,
body.viewer-dark-mode .modal-content,
body.phantom-view #controls,
body.phantom-view #title-box,
body.phantom-view #abcLegend,
body.phantom-view .footerlegend,
body.phantom-view .checkbox,
body.phantom-view #information .panel,
body.phantom-view .modal-content {
  color: #e5e7eb;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.38)) !important;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

body.viewer-dark-mode .panel-section,
body.viewer-dark-mode .product-card,
body.viewer-dark-mode .kv-metric,
body.viewer-dark-mode .kv-detail-card,
body.viewer-dark-mode .kv-bin-chart-card,
body.viewer-dark-mode .kv-products-block,
body.phantom-view .panel-section,
body.phantom-view .product-card,
body.phantom-view .kv-metric,
body.phantom-view .kv-detail-card,
body.phantom-view .kv-bin-chart-card,
body.phantom-view .kv-products-block {
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.42) !important;
  border-color: rgba(148, 163, 184, 0.22);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

body.viewer-dark-mode .kv,
body.viewer-dark-mode .kv strong,
body.viewer-dark-mode h4,
body.viewer-dark-mode .summary-label,
body.viewer-dark-mode .summary-value,
body.viewer-dark-mode #abcLegend span,
body.phantom-view .kv,
body.phantom-view .kv strong,
body.phantom-view h4,
body.phantom-view .summary-label,
body.phantom-view .summary-value,
body.phantom-view #abcLegend span {
  color: #f8fafc !important;
}

body.viewer-dark-mode .text-muted,
body.phantom-view .text-muted,
body.viewer-dark-mode .muted,
body.phantom-view .muted {
  color: #cbd5e1 !important;
}

body.viewer-dark-mode #controls a,
body.viewer-dark-mode #controls button,
body.viewer-dark-mode .bg-dark,
body.phantom-view #controls a,
body.phantom-view #controls button,
body.phantom-view .bg-dark {
  background: rgba(15, 23, 42, 0.72) !important;
  color: #ffffff !important;
  border-color: rgba(148, 163, 184, 0.28);
}

body.viewer-dark-mode #controls a:hover,
body.viewer-dark-mode #controls button:hover,
body.phantom-view #controls a:hover,
body.phantom-view #controls button:hover {
  background: rgba(15, 118, 110, 0.82) !important;
}

body.viewer-dark-mode .analytics-btn.active,
body.phantom-view .analytics-btn.active {
  background: #f59e0b !important;
  color: #111827 !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.24);
  transform: none;
}

body.viewer-dark-mode .kv-modal__dialog,
body.phantom-view .kv-modal__dialog {
  color: #e5e7eb;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.7));
  border-color: rgba(148, 163, 184, 0.24);
}

body.viewer-dark-mode .kv-modal__header,
body.phantom-view .kv-modal__header {
  background: rgba(15, 23, 42, 0.56);
  border-bottom-color: rgba(148, 163, 184, 0.22);
}

body.viewer-dark-mode .modal-header,
body.viewer-dark-mode .modal-footer,
body.phantom-view .modal-header,
body.phantom-view .modal-footer {
  background: rgba(15, 23, 42, 0.54);
  border-color: rgba(148, 163, 184, 0.2);
}

body.viewer-dark-mode .kv-product-table th,
body.phantom-view .kv-product-table th {
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.58);
}

body.viewer-dark-mode .kv-product-table td,
body.phantom-view .kv-product-table td {
  border-bottom-color: rgba(148, 163, 184, 0.18);
}

body.viewer-dark-mode .kv-bin-donut__center,
body.phantom-view .kv-bin-donut__center,
body.viewer-dark-mode .kv-bin-chart-item,
body.phantom-view .kv-bin-chart-item {
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(148, 163, 184, 0.24);
}

body.viewer-dark-mode .kv-bin-chart-item:hover,
body.viewer-dark-mode .kv-bin-chart-item:focus-visible,
body.viewer-dark-mode .kv-bin-chart-item.is-active,
body.phantom-view .kv-bin-chart-item:hover,
body.phantom-view .kv-bin-chart-item:focus-visible,
body.phantom-view .kv-bin-chart-item.is-active {
  background: rgba(20, 184, 166, 0.18);
  border-color: rgba(45, 212, 191, 0.55);
}

body.viewer-dark-mode .kv-bin-donut__center strong,
body.viewer-dark-mode .kv-bin-chart-item strong,
body.phantom-view .kv-bin-donut__center strong,
body.phantom-view .kv-bin-chart-item strong {
  color: #f8fafc;
}

body.viewer-dark-mode .kv-bin-donut__center span,
body.viewer-dark-mode .kv-bin-donut__center small,
body.viewer-dark-mode .kv-bin-chart-item span,
body.viewer-dark-mode .kv-bin-product-bar__label,
body.phantom-view .kv-bin-donut__center span,
body.phantom-view .kv-bin-donut__center small,
body.phantom-view .kv-bin-chart-item span,
body.phantom-view .kv-bin-product-bar__label {
  color: #cbd5e1;
}

body.viewer-dark-mode .kv-bin-product-bar__track,
body.phantom-view .kv-bin-product-bar__track {
  background: rgba(51, 65, 85, 0.86);
}

body.viewer-dark-mode .viewer-ui-toggle,
body.phantom-view .viewer-ui-toggle {
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(148, 163, 184, 0.34);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ==================================================
   DISTINCT VIEW MODES
================================================== */

body.prism-view:not(.viewer-dark-mode) #controls,
body.prism-view:not(.viewer-dark-mode) #title-box,
body.prism-view:not(.viewer-dark-mode) #abcLegend,
body.prism-view:not(.viewer-dark-mode) .footerlegend,
body.prism-view:not(.viewer-dark-mode) .checkbox,
body.prism-view:not(.viewer-dark-mode) #information .panel,
body.prism-view:not(.viewer-dark-mode) .modal-content {
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.16);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.22)) !important;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

body.viewer-dark-mode:not(.phantom-view) #controls,
body.viewer-dark-mode:not(.phantom-view) #title-box,
body.viewer-dark-mode:not(.phantom-view) #abcLegend,
body.viewer-dark-mode:not(.phantom-view) .footerlegend,
body.viewer-dark-mode:not(.phantom-view) .checkbox,
body.viewer-dark-mode:not(.phantom-view) #information .panel,
body.viewer-dark-mode:not(.phantom-view) .modal-content {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.28);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.5), rgba(15, 23, 42, 0.24)) !important;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

body.phantom-view #controls,
body.phantom-view #title-box,
body.phantom-view #abcLegend,
body.phantom-view .footerlegend,
body.phantom-view .checkbox,
body.phantom-view #information .panel,
body.phantom-view .modal-content {
  color: #ecfeff;
  border-color: rgba(34, 211, 238, 0.32);
  background: linear-gradient(145deg, rgba(8, 47, 73, 0.42), rgba(2, 6, 23, 0.24)) !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(125, 211, 252, 0.14);
}

body.prism-view:not(.viewer-dark-mode) .panel-section,
body.prism-view:not(.viewer-dark-mode) .product-card,
body.prism-view:not(.viewer-dark-mode) .kv-metric,
body.prism-view:not(.viewer-dark-mode) .kv-detail-card,
body.prism-view:not(.viewer-dark-mode) .kv-products-block {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.4) !important;
  border-color: rgba(15, 23, 42, 0.12);
}

body.viewer-dark-mode:not(.phantom-view) .panel-section,
body.viewer-dark-mode:not(.phantom-view) .product-card,
body.viewer-dark-mode:not(.phantom-view) .kv-metric,
body.viewer-dark-mode:not(.phantom-view) .kv-detail-card,
body.viewer-dark-mode:not(.phantom-view) .kv-products-block {
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.34) !important;
  border-color: rgba(148, 163, 184, 0.24);
}

body.phantom-view .panel-section,
body.phantom-view .product-card,
body.phantom-view .kv-metric,
body.phantom-view .kv-detail-card,
body.phantom-view .kv-products-block {
  color: #ecfeff;
  background: rgba(8, 47, 73, 0.32) !important;
  border-color: rgba(34, 211, 238, 0.26);
}

body.phantom-view #controls a,
body.phantom-view #controls button,
body.phantom-view .bg-dark {
  background: rgba(8, 47, 73, 0.74) !important;
  border-color: rgba(34, 211, 238, 0.28);
  color: #ecfeff !important;
}

body.phantom-view #controls a:hover,
body.phantom-view #controls button:hover {
  background: rgba(14, 116, 144, 0.86) !important;
}

body.prism-view:not(.viewer-dark-mode) .kv,
body.prism-view:not(.viewer-dark-mode) .kv strong,
body.prism-view:not(.viewer-dark-mode) h4,
body.prism-view:not(.viewer-dark-mode) .summary-label,
body.prism-view:not(.viewer-dark-mode) .summary-value,
body.prism-view:not(.viewer-dark-mode) #abcLegend span {
  color: #0f172a !important;
}

body.phantom-view .form-switch .form-check-input {
  background-color: #22d3ee;
  border-color: rgba(34, 211, 238, 0.6);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

/* Tablet and large mobile 3D experience */
#container canvas {
  cursor: grab;
  touch-action: none;
}

#container canvas:active {
  cursor: grabbing;
}

#controls,
#title-box,
#abcLegend,
.footerlegend,
.checkbox,
.kv-modal__dialog {
  transition:
    transform 0.28s ease,
    opacity 0.28s ease,
    box-shadow 0.28s ease,
    background 0.28s ease;
}

.kv-modal.is-open .kv-modal__dialog {
  animation: kvModalRise 0.24s ease both;
}

@keyframes kvModalRise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.movement-task-panel {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.movement-task-drawer {
  position: fixed;
  top: 128px;
  right: 16px;
  z-index: 220;
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100dvh - 156px);
  overflow-y: auto;
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.26s ease,
    opacity 0.26s ease;
}

.movement-task-drawer.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.movement-task-drawer .movement-task-panel {
  margin-top: 0;
}

.movement-task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.movement-task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: #0f172a;
}

.movement-task-head span {
  display: block;
  color: #0f766e;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.movement-task-head strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.movement-task-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.movement-task-grid label {
  display: grid;
  gap: 4px;
  color: #334155;
  font-size: 11px;
  font-weight: 800;
}

.movement-task-grid input,
.movement-task-grid select {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid rgba(100, 116, 139, 0.28);
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.95);
  color: #0f172a;
  font-size: 12px;
}

.movement-icon-btn,
.movement-run-btn {
  border: 0;
  border-radius: 6px;
  background: #0f172a;
  color: #ffffff;
  cursor: pointer;
  font-weight: 900;
}

.movement-icon-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
}

.movement-run-btn {
  min-height: 38px;
  padding: 8px 10px;
}

.movement-run-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.movement-task-status {
  margin-top: 9px;
  padding: 8px 9px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.06);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.movement-task-status[data-tone="active"] {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}

.movement-task-status[data-tone="success"] {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.movement-task-status[data-tone="warning"] {
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
}

.movement-task-status[data-tone="error"] {
  background: rgba(239, 68, 68, 0.12);
  color: #991b1b;
}

body.viewer-dark-mode:not(.phantom-view) .movement-task-panel,
body.phantom-view .movement-task-panel {
  background: rgba(15, 23, 42, 0.58);
  border-color: rgba(148, 163, 184, 0.22);
}

body.viewer-dark-mode:not(.phantom-view) .movement-task-head,
body.viewer-dark-mode:not(.phantom-view) .movement-task-grid label,
body.phantom-view .movement-task-head,
body.phantom-view .movement-task-grid label {
  color: #f8fafc;
}

body.viewer-dark-mode:not(.phantom-view) .movement-task-grid input,
body.viewer-dark-mode:not(.phantom-view) .movement-task-grid select,
body.phantom-view .movement-task-grid input,
body.phantom-view .movement-task-grid select {
  background: rgba(15, 23, 42, 0.76);
  border-color: rgba(148, 163, 184, 0.24);
  color: #f8fafc;
}

@media (min-width: 761px) and (max-width: 1180px) {
  .kv-modal {
    padding: 12px;
  }

  .kv-modal__dialog {
    width: min(860px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
  }

  .kv-modal__body {
    padding: 14px;
  }

  .kv-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kv-bin-chart-layout {
    grid-template-columns: 180px 1fr;
    gap: 14px;
  }

  .kv-bin-donut {
    width: 180px;
    height: 180px;
  }

  .kv-bin-donut__center {
    width: 116px;
    height: 116px;
  }

  #controls {
    width: min(460px, calc(58vw - 24px));
    max-height: calc(100vh - 136px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .controls-tab {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #title-box {
    width: min(330px, calc(42vw - 24px));
  }

  #abcLegend {
    max-width: min(340px, calc(48vw - 24px));
    max-height: 34vh;
    overflow-y: auto;
  }

  .footerlegend {
    max-width: min(340px, calc(46vw - 24px));
  }

  .analytics-btn,
  #controls a,
  #controls button {
    min-height: 42px;
    font-size: 12px;
  }

  .movement-task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .movement-run-btn {
    align-self: end;
  }
}

@media (max-width: 760px) {
  .kv-modal {
    padding: 9px;
  }

  .kv-modal__dialog {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
  }

  .kv-metric strong {
    font-size: 18px;
    overflow-wrap: anywhere;
  }

  .kv-detail-card dl div {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .kv-detail-card dd {
    text-align: left;
    overflow-wrap: anywhere;
  }

  #controls {
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    border-radius: 8px;
    transform: translateY(0);
    overscroll-behavior: contain;
  }

  #controls a,
  #controls button,
  .analytics-btn {
    min-height: 44px;
    font-size: 12px;
  }

  #title-box {
    bottom: calc(114px + env(safe-area-inset-bottom));
    max-height: 25vh;
    overflow: auto;
  }

  #abcLegend {
    bottom: calc(68px + env(safe-area-inset-bottom));
    max-height: 24vh;
    overflow-y: auto;
    font-size: 12px;
  }

  .checkbox {
    bottom: env(safe-area-inset-bottom);
    border-radius: 8px 8px 0 0;
  }

  .viewer-ui-toggle {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
  }

  .movement-task-drawer {
    top: auto;
    right: 10px;
    bottom: calc(62px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: 58dvh;
    transform: translateY(calc(100% + 24px));
  }

  .movement-task-drawer.is-open {
    transform: translateY(0);
  }
}
