/* 烟草比价 · 移动端优先样式 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e1e4e8;
  --text: #1f2328;
  --muted: #57606a;
  --low-price: #16a34a;
  --high-price: #dc2626;
  --row-alt: #f8fafc;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "HarmonyOS Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* 顶部栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: white;
  padding: 8px 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}
.logo { font-size: 20px; }
.title { font-size: 16px; font-weight: 600; }
.cloud-mark { font-size: 14px; opacity: 0.8; }
.save-status {
  font-size: 11px;
  margin-left: auto;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.tab.active {
  color: white;
  font-weight: 600;
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 8px; right: 8px;
  height: 2px;
  background: white;
  border-radius: 2px;
}

/* 视图容器 */
.view {
  padding: 12px;
  display: none;
}
.view.active { display: block; }

/* 筛选区 */
.filters, .manage-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filters input[type="search"],
.manage-toolbar input[type="search"] {
  flex: 1;
  min-width: 140px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--card);
}
.filters select, .manage-toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  font-size: 14px;
}
.manage-toolbar button,
.snapshot-toolbar button {
  padding: 8px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

/* 表格 */
.table-wrap {
  background: var(--card);
  border-radius: 8px;
  overflow: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  max-height: calc(100vh - 200px);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead {
  position: sticky;
  top: 0;
  background: #f0f4f9;
  z-index: 1;
}
th {
  text-align: left;
  padding: 10px 8px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:nth-child(even) td { background: var(--row-alt); }
tr:hover td { background: #eef4fc; }

/* 价格列：表头和单元格都居中对齐，让数字与抬头视觉对齐 */
.cmp-table th:nth-child(n+3),
.cmp-table td:nth-child(n+3) { text-align: center; }
.mgr-table th:nth-child(3),
.mgr-table td:nth-child(3) { text-align: center; }
.price { font-variant-numeric: tabular-nums; }
.price-low {
  color: var(--low-price);
  font-weight: 700;
  background: rgba(22, 163, 74, 0.08);
}
.price-high { color: var(--muted); }
.price-missing { color: #cbd5e1; text-align: center; }
.master-name { font-weight: 600; color: var(--text); }
.region-tag {
  display: inline-block;
  padding: 2px 6px;
  background: #eef4fc;
  color: var(--primary);
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
}

/* 空状态 */
.empty-hint {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

/* 主商品名标签（在商品管理页显示） */
.master-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(22,163,74,0.1);
  color: var(--low-price);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.row-unmapped td { background: rgba(220,38,38,0.03); }

/* 管理页操作按钮 */
.action-btn {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 4px;
}
.action-btn.danger { color: var(--high-price); border-color: #fee; }

/* 快照列表 */
.snapshot-list {
  background: var(--card);
  border-radius: 8px;
  padding: 12px;
}
.snapshot-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.snapshot-item:last-child { border-bottom: none; }
.hint { color: var(--muted); font-size: 13px; }

/* 设置页 */
.settings-panel {
  background: var(--card);
  padding: 16px;
  border-radius: 8px;
}
.settings-panel h3 {
  margin: 16px 0 8px;
  font-size: 14px;
  color: var(--muted);
}
.settings-panel button {
  padding: 8px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  margin-right: 8px;
  margin-bottom: 8px;
}

/* 弹窗 */
.modal {
  border: none;
  border-radius: 12px;
  padding: 20px;
  max-width: 90vw;
  width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal::backdrop { background: rgba(0,0,0,0.4); }
.modal form { display: flex; flex-direction: column; gap: 10px; }
.modal h3 { margin: 0 0 8px; }
.modal label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.modal input, .modal select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.modal menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 12px 0 0;
}
.modal button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
#edit-cancel { background: #f0f4f9; color: var(--text); }
#edit-save { background: var(--primary); color: white; }

/* 映射管理表格 */
.map-table td:nth-child(3),
.map-table td:nth-child(4),
.map-table td:nth-child(5) {
  font-size: 12.5px;
}
.map-table .linked { color: var(--text); }
.map-table .unlinked { color: #cbd5e1; font-style: italic; }
.map-table .row-full td { background: rgba(22,163,74,0.04); }

/* 宽弹窗（映射编辑） */
.modal-wide {
  width: 440px;
  max-width: 92vw;
}

/* 槽位行（每家供应商一行） */
.slot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
}
.slot-row {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 8px;
  align-items: center;
}
.slot-label {
  font-weight: 600;
  color: var(--primary);
  font-size: 13px;
}
.slot-current {
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  min-height: 32px;
  display: flex;
  align-items: center;
}
.slot-name { font-weight: 500; }
.slot-name.has-price::after {
  content: " ¥" attr(data-price);
  color: var(--low-price);
  font-weight: 600;
  margin-left: 6px;
}
.slot-actions { display: flex; gap: 4px; }

/* 选择器列表 */
.picker-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 8px;
}
.picker-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:hover { background: #eef4fc; }
.picker-item.disabled {
  background: #f8fafc;
  color: #9ca3af;
  cursor: not-allowed;
}
.picker-item.disabled::after {
  content: '已被其他主商品占用';
  color: #dc2626;
  font-size: 11px;
}
.picker-name { font-weight: 500; }
.picker-meta { font-size: 12px; color: var(--muted); }
.picker-empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
}

.btn-danger { background: #fee2e2 !important; color: #dc2626 !important; }

/* 上传批次 */
.primary-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}
.primary-btn:hover { background: var(--primary-dark); }
.batch-tag {
  padding: 6px 12px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}
.batch-sources {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}
.batch-source {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg);
}
.batch-label {
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.batch-source textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: -apple-system, "PingFang SC", monospace;
  font-size: 12px;
  resize: vertical;
}
.batch-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
}
.badge.required { background: #fee; color: #dc2626; }
.badge.ok { background: #d1fae5; color: #047857; }
.batch-summary {
  margin: 8px 0;
  padding: 10px;
  background: #f0f9ff;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  font-size: 13px;
  max-height: 30vh;
  overflow-y: auto;
}
.batch-summary h4 { margin: 4px 0 6px; }
.batch-summary ul { margin: 4px 0; padding-left: 20px; }
.batch-summary .unmatched { color: #dc2626; }

/* 移动端紧凑表格 */
@media (max-width: 600px) {
  th, td { padding: 8px 4px; font-size: 12px; }
  .title { font-size: 14px; }
  .filters { flex-direction: column; }
  .filters select { width: 100%; }
  .slot-row { grid-template-columns: 44px 1fr; }
  .slot-actions { grid-column: 2; justify-content: flex-end; }
}
