* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6f8;
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
  color: #222;
  padding-bottom: 86px;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  padding: 12px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.home-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f4f6f8;
  padding: 8px 0 8px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 8px;
  align-items: center;
}

#searchInput {
  height: 48px;
  border-radius: 16px;
  font-size: 16px;
  background: #fff;
}

.top-add-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #111;
  color: #fff;
  font-size: 32px;
  line-height: 52px;
  padding: 0;
  margin: 0;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 8px;
  margin-bottom: 4px;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-pill {
  width: auto;
  flex-shrink: 0;
  background: #fff;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  color: #666;
  border: 1px solid #eee;
}

.category-pill.active {
  background: #e8fff0;
  color: #17b45a;
  font-weight: bold;
  border-color: #d6f8e2;
}

.count-text {
  margin: 2px 0 10px;
  color: #666;
  font-size: 14px;
}

.card {
  background: #fff;
  border-radius: 20px;
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.05);
}

.card h2 {
  margin-top: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 0 14px;
  font-size: 16px;
  margin-bottom: 12px;
  background: #fff;
}

input,
select {
  height: 48px;
}

textarea {
  min-height: 90px;
  padding-top: 12px;
  resize: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.result {
  font-size: 19px;
  font-weight: bold;
}

button {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 15px;
  background: #111;
  color: #fff;
  font-size: 16px;
  margin-top: 8px;
}

.gray-btn {
  background: #666;
}

.green-action {
  background: #17b45a;
}

.import-label {
  display: block;
  width: 100%;
  height: 46px;
  line-height: 46px;
  border-radius: 15px;
  background: #444;
  color: #fff;
  text-align: center;
  font-size: 16px;
  margin-top: 10px;
}

.product-section {
  padding-bottom: 20px;
}

.product {
  background: #fff;
  border-radius: 18px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.05);
  cursor: pointer;
}

.product-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-thumb,
.no-image {
  width: 92px;
  height: 92px;
  border-radius: 14px;
  flex-shrink: 0;
}

.product-thumb {
  object-fit: cover;
  background: #eee;
}

.no-image {
  background: #eee;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.product-title-row h3 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  color: #111;
}

.category-tag {
  background: #e8fff0;
  color: #17b45a;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.product-info p {
  margin: 3px 0;
  color: #444;
  font-size: 14px;
  line-height: 1.3;
}

.volume-text {
  font-weight: 800;
  color: #111 !important;
}

.product-arrow {
  font-size: 32px;
  color: #999;
  padding-left: 2px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-top: 10px;
}

.category-header h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
}

.small-add-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #111;
  color: #fff;
  font-size: 30px;
  margin: 0;
}

.category-list-wrap {
  padding-bottom: 20px;
}

.category-item {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.05);
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-name {
  font-size: 22px;
  font-weight: 800;
}

.category-count {
  color: #17b45a;
  font-size: 18px;
  font-weight: 800;
}

.category-actions-mini {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.category-actions-mini button {
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  background: transparent;
  font-size: 15px;
  border-radius: 0;
}

.cat-edit {
  color: #17b45a;
}

.cat-delete {
  color: #e53935;
}

.delete-btn {
  background: #d93025;
}

.edit-btn {
  background: #1677ff;
}

.green-btn {
  background: #e8fff0;
  color: #17b45a;
  border: 1px solid #cdeed9;
}

.red-btn {
  background: #fff0f0;
  color: #e53935;
  border: 1px solid #ffd6d6;
}

/* 数据页升级 */

.data-header {
  padding: 12px 2px 10px;
}

.data-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.data-header p {
  margin: 8px 0 0;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}

.data-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 10px 0 16px;
}

.data-stat-card {
  background: #fff;
  border-radius: 18px;
  padding: 14px 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.05);
  text-align: center;
}

.data-stat-card span {
  display: block;
  color: #777;
  font-size: 13px;
  margin-bottom: 8px;
}

.data-stat-card strong {
  font-size: 24px;
  color: #111;
}

.backup-tip {
  background: #f7f8fa;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
}

.backup-tip p {
  margin: 6px 0;
  color: #555;
  font-size: 14px;
  line-height: 1.5;
}

.danger-card {
  border: 1px solid #ffe0e0;
}

.danger-card p {
  color: #777;
  font-size: 14px;
  line-height: 1.5;
}

.preview-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.preview-list img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid #ddd;
  flex-shrink: 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 999;
}

.hidden {
  display: none !important;
}

.modal-content {
  width: 100%;
  max-width: 430px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 22px;
  padding: 14px;
  position: relative;
}

.close-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 24px;
  float: right;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.detail-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  color: #111;
}

.detail-close {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  border: none;
  font-size: 30px;
  margin: 0;
  flex-shrink: 0;
}

.detail-images {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-top: 8px;
  margin-bottom: 16px;
}

.detail-images img {
  width: 100%;
  height: 300px;
  object-fit: contain;
  background: #f7f7f7;
  border-radius: 24px;
  flex-shrink: 0;
}

.detail-info {
  background: #f7f8fa;
  border-radius: 24px;
  padding: 20px;
}

.detail-info p {
  margin: 0 0 12px;
  font-size: 18px;
  color: #222;
  line-height: 1.45;
}

.detail-info strong {
  color: #111;
}

.detail-volume {
  font-weight: 800;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 16px;
}

.mini-btn {
  height: 46px;
  border-radius: 15px;
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  background: #fff;
}

.detail-actions .green-btn {
  border: 2px solid #21b45a;
  color: #21b45a;
}

.detail-actions .red-btn {
  border: 2px solid #f04444;
  color: #f04444;
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.image-modal img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 12px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 430px;
  height: 62px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.14);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px;
  z-index: 888;
}

.nav-btn {
  height: 46px;
  margin-top: 0;
  border-radius: 16px;
  background: transparent;
  color: #999;
  font-weight: 600;
}

.nav-btn.active {
  background: #e8fff0;
  color: #17b45a;
}

@media (max-width: 380px) {
  .app {
    padding: 10px;
  }

  .product-thumb,
  .no-image {
    width: 84px;
    height: 84px;
  }

  .product-title-row h3 {
    font-size: 19px;
  }

  .product-info p {
    font-size: 13px;
  }
}

@supports (padding: max(0px)) {
  body {
    padding-bottom: max(86px, env(safe-area-inset-bottom));
  }
}