/* ============ 全局样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  -webkit-tap-highlight-color: transparent;
}
:root {
  --primary: #ff4d4f;
  --primary-light: #ff7875;
  --bg: #f5f5f5;
  --card-bg: #fff;
  --border: #e8e8e8;
  --text-secondary: #999;
  --radius: 12px;
}

/* ============ 通用组件 ============ */
.step-page { max-width: 480px; margin: 0 auto; padding: 16px; min-height: 100vh; }
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.header h2 { font-size: 20px; flex: 1; }
.btn-back {
  width: 36px; height: 36px; border: none; background: #fff; border-radius: 50%;
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.hint { color: var(--text-secondary); font-size: 13px; }

.btn-primary {
  background: var(--primary); color: #fff; border: none; border-radius: var(--radius);
  padding: 14px 20px; font-size: 16px; cursor: pointer; width: 100%; transition: opacity .2s;
}
.btn-primary:active { opacity: 0.8; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.btn-secondary {
  background: #fff; color: #333; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 20px; font-size: 16px; cursor: pointer; width: 100%; transition: opacity .2s;
}
.btn-secondary:active { opacity: 0.8; }

.btn-xl { padding: 16px 20px; font-size: 18px; border-radius: 14px; margin-top: 16px; }
.btn-lg { padding: 14px 20px; font-size: 16px; border-radius: 12px; }

.btn-text {
  background: none; border: none; color: var(--primary); font-size: 14px; cursor: pointer;
}

.input-large {
  width: 100%; padding: 14px 16px; font-size: 16px; border: 1px solid var(--border);
  border-radius: var(--radius); outline: none; transition: border-color .2s;
}
.input-large:focus { border-color: var(--primary); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 15px; font-weight: 500; }

.badge {
  background: var(--primary); color: #fff; padding: 2px 10px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
}

.loading-text { text-align: center; color: var(--text-secondary); padding: 40px 0; font-size: 14px; }

/* ============ Spinner ============ */
.spinner {
  width: 40px; height: 40px; border: 4px solid #f0f0f0;
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { text-align: center; padding: 30px 0; }
.loading-block p { margin-top: 8px; }

/* ============ 采集人信息 ============ */
.collector-info {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px;
  font-size: 14px;
}
.collector-info span { font-weight: 500; }

/* ============ 商家搜索 ============ */
.search-box { margin-bottom: 12px; }

.merchant-list { display: flex; flex-direction: column; gap: 8px; }
.merchant-item {
  background: var(--card-bg); padding: 14px 16px; border-radius: var(--radius);
  cursor: pointer; transition: background .15s;
}
.merchant-item:active { background: #fafafa; }
.merchant-item .m-name { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.merchant-item .m-info { font-size: 13px; color: var(--text-secondary); }
.merchant-item .m-info span { margin-right: 12px; }

/* ============ 商家卡片（采集页） ============ */
.merchant-card {
  background: #fff; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px;
  border-left: 4px solid var(--primary);
}
.merchant-card .mc-name { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.merchant-card .mc-info { font-size: 13px; color: var(--text-secondary); }
.merchant-card .mc-info span { margin-right: 16px; }

/* ============ 上传区域 ============ */
.upload-area {
  background: #fff; border: 2px dashed #d9d9d9; border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer; transition: border-color .2s;
}
.upload-area:active { border-color: var(--primary); }
.upload-icon { font-size: 40px; margin-bottom: 8px; }
.upload-area p { margin-bottom: 4px; }

.image-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.image-preview .img-thumb {
  position: relative; width: 80px; height: 80px; border-radius: 8px; overflow: hidden;
}
.image-preview .img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.image-preview .img-thumb .remove-btn {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 50%;
  font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ============ 商品卡片 ============ */
.result-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 0 12px;
}
.result-header h3 { font-size: 17px; }

.product-card {
  background: #fff; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 10px;
}
.product-card .pc-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.product-card .pc-row:last-child { margin-bottom: 0; }
.product-card .pc-label { width: 80px; font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.product-card .pc-input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none;
}
.product-card .pc-input:focus { border-color: var(--primary); }
.product-card .pc-toggle {
  display: flex; gap: 8px;
}
.product-card .pc-toggle button {
  padding: 6px 16px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; cursor: pointer; background: #fff;
}
.product-card .pc-toggle button.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.product-card .pc-delete {
  width: 100%; padding: 6px; border: none; background: #fff0f0; color: var(--primary);
  border-radius: 8px; font-size: 13px; cursor: pointer; margin-top: 8px;
}

/* ============ 保存区 ============ */
.save-summary {
  text-align: center; padding: 20px; background: #fff; border-radius: var(--radius);
  margin: 20px 0 12px; font-size: 16px;
}
.save-summary strong { color: var(--primary); font-size: 22px; }

/* ============ 成功页 ============ */
#step-success {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; min-height: 80vh;
}
.success-icon {
  width: 64px; height: 64px; background: #52c41a; color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  margin-bottom: 16px;
}
#step-success h2 { margin-bottom: 8px; }

/* ============ 管理后台 ============ */
.admin-page { max-width: 1200px; margin: 0 auto; padding: 20px; }
.admin-nav {
  display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid var(--border);
}
.admin-nav button {
  padding: 10px 24px; border: none; background: none; font-size: 15px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; color: var(--text-secondary);
}
.admin-nav button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.admin-section { display: none; }
.admin-section.active { display: block; }

.admin-card {
  background: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.admin-filters {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; align-items: flex-end;
}
.admin-filters .filter-group { display: flex; flex-direction: column; gap: 4px; }
.admin-filters label { font-size: 12px; color: var(--text-secondary); }
.admin-filters select, .admin-filters input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  min-width: 120px;
}
.admin-filters button { padding: 8px 20px; }

.admin-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.admin-table th {
  background: #fafafa; padding: 10px 12px; text-align: left; font-weight: 600;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.admin-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.admin-table tr:hover { background: #fafafa; }

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 16px; align-items: center; }
.pagination button {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff;
  cursor: pointer; font-size: 14px;
}
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination span { font-size: 14px; color: var(--text-secondary); }

.stat-row { display: flex; gap: 16px; margin-bottom: 16px; }
.stat-card {
  flex: 1; background: #fff; border-radius: var(--radius); padding: 16px 20px;
  text-align: center;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.upload-zone {
  border: 2px dashed #d9d9d9; border-radius: var(--radius); padding: 40px;
  text-align: center; cursor: pointer; transition: border-color .2s;
}
.upload-zone:active { border-color: var(--primary); }
.upload-zone p { margin-top: 8px; color: var(--text-secondary); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px;
}
.tag-yes { background: #fff0f0; color: var(--primary); }
.tag-no { background: #f5f5f5; color: var(--text-secondary); }

.config-form { max-width: 500px; }
.config-form .form-group { margin-bottom: 16px; }
.config-form input { width: 100%; }
.config-status {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
}
.config-status.ok { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.config-status.warn { background: #fff7e6; color: #fa8c16; border: 1px solid #ffd591; }
