:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e6e8eb;
  --text: #16181d;
  --sub: #6b7280;
  --brand: #111827;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- 顶部 ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 14px;
}
header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.2px;
}
header .shop {
  font-size: 12px;
  color: var(--sub);
  margin-top: 2px;
}
.badge-shop {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  white-space: nowrap;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .n {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* ---------- 表单 ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field:last-child { margin-bottom: 0; }
label.field .lb {
  display: block;
  font-size: 12.5px;
  color: var(--sub);
  margin-bottom: 6px;
}
input[type=text], input[type=password], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  font-size: 15px;
  font-family: inherit;
  background: #fbfbfc;
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
}
input:focus, textarea:focus { border-color: #9ca3af; background: #fff; }
textarea { resize: vertical; min-height: 74px; line-height: 1.45; }

.btn {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: opacity .15s, transform .06s;
}
.btn:active { transform: scale(.988); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- 类目选择 ---------- */
.cat-box { position: relative; }
.cat-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  font-size: 15px;
  font-family: inherit;
  background: #fbfbfc;
  outline: none;
}
.cat-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13.5px;
  color: #065f46;
  line-height: 1.4;
}
.cat-selected .x {
  margin-left: auto;
  flex: none;
  color: #059669;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.cat-list {
  position: absolute;
  z-index: 30;
  left: 0; right: 0;
  top: calc(100% + 6px);
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15,23,42,.12);
  display: none;
}
.cat-list.open { display: block; }
.cat-item {
  padding: 10px 13px;
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.cat-item:last-child { border-bottom: 0; }
.cat-item:active { background: #f9fafb; }
.cat-item .p { flex: 1; line-height: 1.4; word-break: break-word; }
.cat-item .tag {
  flex: none;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  margin-top: 1px;
}
.tag.ok { background: #ecfdf5; color: #047857; }
.tag.denied { background: #fef2f2; color: #b91c1c; }
.tag.unknown { background: #f3f4f6; color: #6b7280; }
.cat-empty { padding: 16px 13px; font-size: 13px; color: var(--sub); text-align: center; }

/* ---------- 步骤条 ---------- */
.steps { display: flex; flex-direction: column; gap: 0; }
.step {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 7px 0;
  font-size: 13.5px;
  color: var(--sub);
}
.step .dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex: none;
  margin-top: 2px;
  position: relative;
  background: #fff;
}
.step.done { color: var(--text); }
.step.done .dot { background: var(--ok); border-color: var(--ok); }
.step.done .dot::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.step.active { color: var(--text); font-weight: 600; }
.step.active .dot { border-color: var(--brand); }
.step.active .dot::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  border-top-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.step.fail { color: var(--danger); font-weight: 600; }
.step.fail .dot { background: var(--danger); border-color: var(--danger); }
.step.fail .dot::after {
  content: "×";
  position: absolute;
  inset: 0;
  color: #fff;
  font-size: 13px;
  line-height: 15px;
  text-align: center;
}

/* ---------- 日志 ---------- */
.logs {
  margin-top: 12px;
  background: #0f1115;
  border-radius: 10px;
  padding: 11px 12px;
  max-height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font: 11.5px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #9ca3af;
  white-space: pre-wrap;
  word-break: break-word;
}
.logs .l-err { color: #f87171; }
.logs .l-ok { color: #34d399; }
.logs .l-warn { color: #fbbf24; }

/* ---------- 预览 ---------- */
.preview-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 12px;
  word-break: break-word;
}
.imgs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.imgs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f3f4f6;
}
.kv { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.kv .row { display: flex; gap: 10px; }
.kv .k { color: var(--sub); flex: none; width: 74px; }
.kv .v { flex: 1; word-break: break-word; }

.sku-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.sku-table th {
  text-align: right;
  font-weight: 500;
  color: var(--sub);
  padding: 5px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.sku-table th:first-child { text-align: left; }
.sku-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #f3f4f6;
  text-align: right;
  white-space: nowrap;
}
.sku-table td:first-child {
  text-align: left;
  white-space: normal;
  word-break: break-word;
  max-width: 150px;
  font-size: 11.5px;
}
.sku-table .pos { color: var(--ok); }
.sku-table .neg { color: var(--danger); }
.sku-table tr:last-child td { border-bottom: 0; }

.alert {
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.alert.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert.danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #065f46; }
.alert b { font-weight: 650; }

.phys-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.phys-row label { font-size: 12px; color: var(--sub); flex: none; width: 52px; }
.phys-row input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  width: 100%;
  background: #fbfbfc;
  outline: none;
  font-family: inherit;
}
.phys-dims { display: flex; gap: 6px; flex: 1; }
.phys-dims input { text-align: center; }

.spin-inline {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 7px;
}

.muted { color: var(--sub); font-size: 12.5px; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.copy {
  color: #2563eb;
  text-decoration: none;
  font-size: 12.5px;
  cursor: pointer;
}

/* ---------- 批量列表 ---------- */
.item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
}
.item:last-child { margin-bottom: 0; }
.item.err { border-color: #fecaca; background: #fffafa; }
.item-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.item-idx {
  flex: none;
  width: 20px; height: 20px;
  border-radius: 6px;
  background: #f3f4f6;
  color: var(--sub);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.item-title {
  flex: 1;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 550;
  word-break: break-word;
}
.item-del {
  flex: none;
  color: #9ca3af;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 10px;
}
.item-meta b { color: var(--text); font-weight: 600; }
.item-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed #d1d5db;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12.5px;
  color: var(--sub);
  cursor: pointer;
  line-height: 1.4;
}
.item-cat.picked {
  border-style: solid;
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #065f46;
}
.item-cat .arrow { margin-left: auto; flex: none; color: #9ca3af; }
.item-note {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--warn);
  line-height: 1.5;
}

/* 状态小标签 */
.chip {
  flex: none;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: #f3f4f6;
  color: #6b7280;
}
.chip.ok { background: #ecfdf5; color: #047857; }
.chip.run { background: #eff6ff; color: #1d4ed8; }
.chip.wait { background: #fffbeb; color: #b45309; }
.chip.err { background: #fef2f2; color: #b91c1c; }

/* 进度条 */
.bar {
  height: 3px;
  border-radius: 2px;
  background: #f3f4f6;
  overflow: hidden;
  margin-top: 8px;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--brand);
  transition: width .3s ease;
}
.bar.done > i { background: var(--ok); }
.bar.err > i { background: var(--danger); }

/* ---------- 类目浮层 ---------- */
.picker {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15,23,42,.4);
  display: flex;
  align-items: flex-end;
}
.picker-panel {
  width: 100%;
  max-height: 78vh;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.picker-close { font-size: 22px; line-height: 1; color: var(--sub); cursor: pointer; padding: 0 4px; }
.picker-list {
  margin-top: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 120px;
}
.picker-list .cat-item { border-bottom: 1px solid #f3f4f6; }

/* 预览卡片 */
.pv-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.pv-card .imgs { grid-template-columns: repeat(4, 1fr); }
.pv-nums { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--sub); margin-bottom: 10px; }
.pv-nums b { color: var(--text); }
.pv-actions { display: flex; gap: 8px; margin-top: 10px; }
.pv-actions .btn { padding: 11px; font-size: 14px; }

/* ---------- 顶部 tab ---------- */
.tabs {
  display: flex;
  gap: 3px;
  background: #e9ebef;
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 12px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #6b7280;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.1); }
.tab-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--danger);
  margin-left: 5px;
  vertical-align: 2px;
}

/* ---------- 日期栏 ---------- */
.datebar { display: flex; align-items: center; gap: 8px; }
.dnav {
  flex: none;
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font-size: 19px;
  line-height: 1;
  color: #374151;
  font-family: inherit;
  cursor: pointer;
}
.dnav:disabled { opacity: .32; }
.dinput {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fbfbfc;
  color: var(--text);
  text-align: center;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.dinput:focus { border-color: #9ca3af; background: #fff; }

.datechips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.dchip {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-family: inherit;
  color: #4b5563;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.dchip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 数据源切换 ---------- */
.srcbar {
  display: flex;
  gap: 3px;
  padding: 3px;
  margin-bottom: 12px;
  background: #e9ebef;
  border-radius: 11px;
}
.src {
  flex: 1;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--sub);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.src.on {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}

/* 空态里的行内链接按钮，比如「回到这天」 */
.btn-link {
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: #2563eb;
  background: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  cursor: pointer;
}
.btn-link:hover { color: #1d4ed8; }

/* ---------- 榜单概览 ---------- */
.rank-sum {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 5px;
  text-align: center;
}
.stat b {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat span { display: block; font-size: 10px; color: var(--sub); margin-top: 2px; }
.rank-note {
  font-size: 11.5px;
  color: var(--sub);
  line-height: 1.6;
  margin: 0 2px 12px;
}

/* ---------- 榜单条目 ---------- */
.rk {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 9px;
}
.rk-rank {
  flex: none;
  width: 22px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: #b6bcc6;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.rk-rank.top { color: var(--text); }
.rk-img {
  flex: none;
  width: 54px; height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
  border: 1px solid var(--line);
}
.rk-img.ph {
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  color: #c3c9d2;
  font-size: 10px;
}
.rk-body { flex: 1; min-width: 0; }
.rk-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
  margin-bottom: 4px;
}
.rk-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  font-size: 11.5px;
  color: var(--sub);
}
.rk-meta b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.rk-meta .up { color: #d97706; font-weight: 600; }
.rk-meta .down { color: #9ca3af; }
.rk-src {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed #eef0f3;
  font-size: 11.5px;
}
.rk-src .q { color: #6b7280; flex: none; }
.rk-src a {
  color: #2563eb;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rk-src .p { flex: none; color: #b45309; font-variant-numeric: tabular-nums; }

/* 复制 1688 链接，去「一键上架」粘贴 */
.rk-copy {
  flex: none;
  padding: 1px 9px;
  font: inherit;
  font-size: 11px;
  line-height: 1.7;
  color: var(--sub);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.rk-copy:hover { color: #2563eb; border-color: #2563eb; }
.rk-copy:active { transform: translateY(1px); }
.rk-copy.done { color: #fff; background: var(--ok); border-color: var(--ok); }
.rk-copy.fail { color: #fff; background: var(--danger); border-color: var(--danger); }

.rk-badge {
  flex: none;
  width: 21px; height: 21px;
  border-radius: 6px;
  border: 1px solid;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.g-S { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.g-A { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.g-B { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.g-C { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
