*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: #f4f4f4;
  color: #333;
  min-height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.top-bar .action-button {
  min-width: 80px;
}

.action-button {
  border: none;
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transition: background 0.2s ease;
}

.submit-button {
  background: #4a7cff;
}

.submit-button:hover {
  background: #3b63cc;
}

.clear-button {
  background: #ff6b6b;
}

.clear-button:hover {
  background: #d75a5a;
}

.mega-toggle-button {
  background: #b052ff;
}

.mega-toggle-button:hover {
  background: #8f3bd8;
}

.mega-toggle-button.return-mode {
  background: #34c38f;
}

.mega-toggle-button.return-mode:hover {
  background: #28a273;
}

.total-display {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.item-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e3e3e3;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  min-height: 250px;
}

.item-image {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.item-image.missing {
  width: 100%;
  height: 120px;
  background: repeating-linear-gradient(
    45deg,
    #f2f2f2,
    #f2f2f2 10px,
    #e0e0e0 10px,
    #e0e0e0 20px
  );
}

.item-name {
  margin-top: 12px;
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
  min-height: 42px;
  width: 100%;
}

.quantity-control {
  display: flex;
  width: 100%;
  margin-top: auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.quantity-button {
  width: 36px;
  height: 36px;
  border: 1px solid #d0d0d0;
  background: #fafafa;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.quantity-button:hover {
  background: #f0f0f0;
}

.quantity-input {
  width: 72px;
  height: 36px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  text-align: center;
  font-size: 16px;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.quantity-input {
  -moz-appearance: textfield;
}

.error-message {
  color: #c00;
  text-align: center;
  grid-column: 1 / -1;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 10px;
  width: min(480px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.selected-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
  line-height: 1.6;
  font-size: 14px;
}

.modal-total {
  font-weight: 600;
  text-align: right;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-button {
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  background: #e0e0e0;
  color: #333;
}

.modal-button.primary {
  background: #4a7cff;
  color: #fff;
}

.toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translate(-50%, -20px);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1100;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1200;
}

.confirm-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.confirm-dialog {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.confirm-message {
  font-size: 15px;
  line-height: 1.6;
  color: #333;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.confirm-button {
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  cursor: pointer;
  font-size: 14px;
  background: #f0f0f0;
  color: #333;
}

.confirm-button.primary {
  background: #4a7cff;
  color: #fff;
}

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  .top-bar {
    flex-wrap: wrap;
    row-gap: 12px;
  }

  .top-bar .action-button {
    flex: 1 1 calc(50% - 8px);
  }

  .total-display {
    order: 3;
    width: 100%;
    font-size: 14px;
  }

  .items-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 12px;
  }

  .item-card {
    padding: 12px;
    min-height: 200px;
  }

  .item-image {
    width: 80px;
    height: 80px;
  }

  .quantity-control {
    gap: 4px;
  }

  .quantity-button {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .quantity-input {
    width: 48px;
    height: 32px;
    font-size: 14px;
  }
}


/* 针对该按钮的 ID 设置 */
#megaToggleButton:disabled {
    cursor: not-allowed;  /* 关键：这会让鼠标变成红色的禁止圆圈 */
    opacity: 0.6;         /* 可选：让按钮变暗，表示不可用 */
}