body {
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  margin: 0;
  overflow: hidden;
}

#warehouse-app {
  display: none;
  width: 100%;
  height: 100vh;
  box-sizing: border-box;
}

#app-stage {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: auto;
}

/* =========================
   MAP HEADER (attached to map)
========================= */
.map-header {
  position: absolute;
  left: 60px;
  top: 0;
  width: 1680px;
  height: 72px;
  background: #1f2d3d;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-sizing: border-box;
  z-index: 1500;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.header-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: bold;
  color: white;
  cursor: pointer;
  min-width: 120px;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.header-btn:hover {
  filter: brightness(1.06);
}

.header-btn:active {
  transform: translateY(1px);
}

#training-btn {
  background: #0056b3;
  min-width: 110px;
}

#training-btn:hover {
  filter: brightness(1.08);
}

#edit-mode-btn {
  background: #16a085;
}

#edit-mode-btn.off {
  background: #7f8c8d;
}

#excel-export-btn {
  background: #1f8f3a;
}

#inventory-summary-btn {
  background: #3498db;
}

#history-btn {
  background: #f39c12;
}

#logout-btn {
  background: #e74c3c;
}

/* =========================
   WAREHOUSE MAP
========================= */
#warehouse-container {
  position: absolute;
  width: 1950px;
  height: 1488px;
  transform-origin: top left;
}

.grid-stack {
  position: absolute;
  left: 60px;
  top: 110px;
  width: 1680px;
  height: 1280px;
  background: #add8e6;
  border: 2px solid #000000;
  user-select: none;
  touch-action: none;
  transform-origin: top left;
  box-sizing: border-box;
}

.label-cell {
  position: absolute;
  border: 1px solid #000000;
  text-align: center;
  padding: 5px;
  font-size: 12px;
  background-color: #ffffff;
  box-sizing: border-box;
}

.office-zone,
.restroom-zone,
.drop-zone,
.history-panel {
  font-weight: bold;
}

.office-zone {
  background-color: #ffffff;
}

.restroom-zone {
  background-color: #ffffff;
}

.drop-zone {
  border: 2px dashed white;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: default;
}

.drop-zone#SHIPPED {
  background-color: #e74c3c;
}

.drop-zone#TO-8412-OFFICE {
  background-color: #2980b9;
}

/* =========================
   AXIS LABELS
========================= */
.axis-label {
  position: absolute;
  font-weight: bold;
  font-size: 16px;
  color: #1f2d3d;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 6px;
}

.axis-col-top,
.axis-col-bottom {
  width: 80px;
  height: 28px;
}

.axis-row-left {
  width: 40px;
  height: 50px;
}

/* =========================
   PALLETS
========================= */
.pallet {
  position: absolute;
  background: orange;
  color: black;
  font-weight: bold;
  border: 2px solid #000000;
  text-align: center;
  cursor: grab;
  user-select: none;
  box-sizing: border-box;
  padding: 4px 2px 10px 2px;
  font-size: 12px;
  white-space: pre-line;
  transition: transform 0.2s ease-out, opacity 0.2s ease;
  touch-action: none;
}

.pallet.dragging {
  opacity: 0.6;
  cursor: grabbing;
  z-index: 1000;
}

.pallet.view-only {
  cursor: default;
}

.split-arrow,
.merge-arrow {
  position: absolute;
  top: 2px;
  background: black;
  color: white;
  font-weight: bold;
  font-size: 12px;
  width: 18px;
  height: 18px;
  line-height: 18px;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  z-index: 10;
  text-align: center;
}

.split-arrow {
  right: 4px;
}

.merge-arrow {
  left: 4px;
}

.split-arrow.disabled,
.merge-arrow.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* =========================
   CONTROL PANELS INSIDE MAP
========================= */
.control-panel {
  position: absolute;
  background: #27ae60;
  padding: 10px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  width: 220px;
  box-sizing: border-box;
  transform-origin: top left;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

#add-product-panel {
  position: absolute;
  width: 255px;
  top: 650px;
  left: 1380px;
  background: #27ae60;
  z-index: 120;
  padding: 10px;
  border-radius: 8px;
}

#add-product-panel input {
  box-sizing: border-box;
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 6px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
}

#add-product-panel input::placeholder {
  color: #888;
}

#add-product-panel button {
  width: 100%;
  padding: 8px;
  font-weight: bold;
  font-size: 14px;
  background: #2ecc71;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: white;
}

#add-product-panel button:hover {
  background: #27ae60;
}

#add-product-panel.disabled {
  opacity: 0.65;
}

#add-product-panel.disabled input,
#add-product-panel.disabled button {
  pointer-events: none;
}

/* =========================
   UNDO BUTTON
========================= */
#undo-btn {
  position: absolute;
  left: 1380px;
  top: 850px;
  background: #8e44ad;
  color: white;
  border: none;
  border-radius: 10px;
  width: 255px;
  height: 90px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1300;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
  transition: transform 0.1s;
}

#undo-btn:hover {
  filter: brightness(1.15);
  transform: scale(1.02);
}

#undo-btn:active {
  transform: scale(0.98);
}

/* =========================
   MODALS
========================= */
.modal {
  display: none;
  position: fixed;
  z-index: 2500;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.45);
}

.modal-content {
  background-color: #fefefe;
  margin: 4% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 92%;
  max-width: 980px;
  border-radius: 10px;
  box-sizing: border-box;
}

.close-btn {
  color: #888;
  float: right;
  font-size: 28px;
  font-weight: bold;
  line-height: 1;
}

.close-btn:hover,
.close-btn:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

#history-output,
#inventory-summary-modal-output {
  max-height: 560px;
  overflow-y: auto;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f3f3f3;
  font-size: 14px;
  line-height: 1.5;
}

.summary-row {
  padding: 8px 0;
  border-bottom: 1px solid #ddd;
}

.summary-row:last-child {
  border-bottom: none;
}

/* =========================
   TABLES
========================= */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.data-table th,
.data-table td {
  border: 1px solid #d9d9d9;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #e9eef4;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* =========================
   LOGIN / SIGNUP
========================= */
#login-container,
#signup-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  z-index: 3000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-box {
  background: #f5f5f5;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  width: 320px;
  text-align: center;
}

.login-box input {
  width: 100%;
  padding: 0.6rem;
  margin: 0.5rem 0;
  box-sizing: border-box;
}

.login-box button {
  width: 100%;
  padding: 0.65rem;
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 1rem;
  font-weight: bold;
}

.login-box a {
  font-size: 12px;
  color: #3498db;
  cursor: pointer;
  display: block;
  margin-top: 10px;
}

/* =========================
   LOADING
========================= */
#loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 1.5rem;
  z-index: 3500;
}

/* =========================
   TRAINING MODAL
========================= */
.training-modal-content {
  max-width: 760px;
  padding: 24px;
}

#training-title {
  margin-bottom: 14px;
  color: #1f2d3d;
}

#training-body {
  min-height: 260px;
  background: #f7f9fc;
  border: 1px solid #d8e1ea;
  border-radius: 10px;
  padding: 20px;
  box-sizing: border-box;
  line-height: 1.6;
}

.training-step-badge {
  display: inline-block;
  background: #6c5ce7;
  color: white;
  font-weight: bold;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.training-step-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1f2d3d;
}

.training-step-text {
  font-size: 16px;
  color: #2d3436;
  margin-bottom: 14px;
}

.training-step-tip {
  background: #eafaf1;
  border-left: 5px solid #27ae60;
  padding: 12px 14px;
  border-radius: 8px;
  color: #1f2d3d;
  font-size: 14px;
}

.training-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.training-nav-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: bold;
  color: white;
  background: #34495e;
  cursor: pointer;
}

.training-nav-btn:hover {
  filter: brightness(1.08);
}

.training-nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#training-progress {
  font-weight: bold;
  color: #2c3e50;
  min-width: 70px;
  text-align: center;
}

/* ==========================================================================
   PALLET SEARCH HIGHLIGHT & SIDE-BY-SIDE SIDEBAR PLACEMENT
   ========================================================================== */
.search-panel {
  position: absolute;
  left: 1380px;
  top: 960px; /* Positions perfectly below the UNDO button (top: 850px + height: 90px + 20px gap) */
  width: 255px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}

#search-item-id {
  box-sizing: border-box;
  width: 100%;
  padding: 10px;
  border: 2px solid #8e44ad;
  border-radius: 6px;
  font-size: 14px;
  background: #ffffff;
  color: #333333;
  outline: none;
}

#search-btn {
  width: 100%;
  padding: 10px;
  background: #6c5ce7;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: background 0.2s ease, transform 0.1s ease;
}

#search-btn:hover {
  background: #5b4bc4;
}

#search-btn:active {
  transform: scale(0.98);
}

/* The active visual focus animation state */
.pallet.search-match-pop {
  z-index: 99999 !important; /* Float explicitly above grid tracks */
  box-shadow: 0 0 25px 8px rgba(0, 51, 170, 0.85) !important;
  border: 3px solid #0033aa !important;
  animation: palletBounce 1.5s ease-out forwards;
}

@keyframes palletBounce {
  0% {
    transform: translate(0, 0) scale(1);
  }
  20% {
    transform: translate(var(--search-shift-x, 0px), var(--search-shift-y, -20px)) scale(1.6);
  }
  40% {
    transform: translate(var(--search-shift-x, 0px), var(--search-shift-y, -20px)) scale(1.35);
  }
  60% {
    transform: translate(var(--search-shift-x, 0px), var(--search-shift-y, -20px)) scale(1.45);
  }
  100% {
    transform: translate(var(--search-shift-x, 0px), var(--search-shift-y, -20px)) scale(1.4);
  }
}
