:root {
  --brand: #e8657f;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #fafafa;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 18px 10px 36px;
  background: var(--bg); color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.top {
  max-width: 1600px; margin: 0 auto 14px;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
}
h1 { font-size: 20px; margin: 0 0 2px; letter-spacing: .5px; }
.sub { color: var(--muted); font-size: 13px; margin: 0; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.oms-btn {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px;
  border: 1px solid var(--brand); border-radius: 8px;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.oms-btn:hover { filter: brightness(.95); }
.back { color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; }
.back:hover { color: var(--brand); }

.tabs {
  max-width: 1600px; margin: 0 auto 10px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.tabs button {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 8px; font: inherit; cursor: pointer;
}
.tabs button.on { border-color: var(--brand); color: var(--brand); font-weight: 600; }

.toolbar {
  max-width: 1600px; margin: 0 auto 10px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.toolbar select, .toolbar input, .toolbar textarea {
  height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font: inherit; color: var(--ink);
}
.toolbar input, .toolbar textarea { min-width: 220px; flex: 1 1 220px; }
/* 单号框改成 textarea：支持一次贴多个单号（换行不被吃掉） */
.toolbar textarea { height: 36px; padding: 7px 10px; resize: none; line-height: 1.4; }
/* 日期框不要跟关键词框一样撑满（2026-11-14 用户：太长，缩短一点） */
.toolbar input[type="date"] { min-width: 0; flex: 0 0 auto; width: 140px; padding: 0 6px; }
.btn {
  height: 36px; padding: 0 18px; border: 0; border-radius: 8px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(.95); }
.count { color: var(--muted); font-size: 12px; min-width: 64px; display: inline-block; }

/* 单号后面的小复制按钮 */
.copy-btn {
  /* 固定宽度：文案「复制 → 已复制」不改变列宽，点一下页面不会跳（2026-11-14 用户报） */
  margin-left: 3px; padding: 0; width: 40px; text-align: center;
  font: inherit; font-size: 10px; line-height: 16px;
  color: var(--muted); background: #fff;
  border: 1px solid var(--line); border-radius: 4px;
  cursor: pointer; vertical-align: middle;
}
.copy-btn:hover { color: var(--brand); border-color: var(--brand); }
.copy-btn.copied { color: #059669; border-color: #a7f3d0; background: #ecfdf5; }

/* Shopify单号太长时折叠显示，点「展开」看全 */
.so-cell { white-space: nowrap; }
.so-id {
  display: inline-block; max-width: 110px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: middle; font-weight: 600;
}
.so-id.expanded { max-width: none; }
.fold-btn {
  margin-left: 3px; padding: 0; border: 0; background: none;
  color: #dc2626; font: inherit; font-size: 10px; cursor: pointer;
  vertical-align: middle;
}
td.q { color: #dc2626; font-size: 12px; }
.local-ok { color: #059669; }
.local-bad { color: #dc2626; font-weight: 600; }
.local-warn { color: #d97706; }
.local-na { color: #6b7280; }

/* 异常 / 本地仓：一列两行（上=异常类型，下=本地仓状态） */
/* 异常列不再撑得老大：限宽 + 可换行，内容只有问题部分（2026-11-14 用户：拉近一点） */
td.exc-cell { white-space: normal; max-width: 220px; word-break: break-word; }
td.exc-cell .exc-line { display: block; line-height: 1.4; font-size: 12px; }
.exc-overseas { color: #dc2626; font-weight: 600; }
.exc-local { color: #c2410c; font-weight: 600; }
.exc-other { color: #6b7280; }

/* 领星（海外仓）/ 云仓库存（2026-11-12）：有货绿 / 缺货红 / 未同步灰 */
.oms-ok, .cloud-ok { color: #059669; font-weight: 600; }
.oms-bad, .cloud-bad { color: #dc2626; font-weight: 600; }
.oms-na, .cloud-na { color: #9ca3af; }
.sep { color: #9ca3af; }

/* 内部订单号 / 店铺 两行：上=镜像店铺，下=原单；两行同字号同颜色，用「镜像/原单」小标签区分 */
td.two-line span {
  display: block; line-height: 1.4;
  font-size: 13px; font-weight: 400; color: var(--ink);
  /* 镜像/原单/云仓 两行各占一行：不换行，避免有的排两行、有的排三行（2026-11-14 用户报） */
  white-space: nowrap;
}
td.two-line .line-label {
  display: inline-block; min-width: 26px;
  font-style: normal; font-size: 11px; color: var(--muted);
}

/* 镜像单在聚水潭审成异常（如缺货）：红字提醒 */
.mirror-bad { color: #dc2626; font-weight: 600; }

/* 历史 OBS（同一单多次重建/取消）：默认折叠，镜像已取消时自动展开 */
td.obs-cell { min-width: 180px; }
.obs-hist { margin-top: 3px; font-size: 11px; }
.obs-hist summary { cursor: pointer; color: var(--muted); user-select: none; }
.obs-hist summary:hover { color: var(--brand); }
.obs-hist-row {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  margin-top: 2px; line-height: 1.5;
}
.obs-hist-dot { flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; }
.obs-hist-dot.dead { background: #dc2626; }
.obs-hist-dot.live { background: #059669; }
.obs-hist-dot.cur { background: #2563eb; }
.obs-hist-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.obs-hist-meta { color: var(--muted); }

/* 镜像单在聚水潭被取消（或原单取消）：整行灰色 */
tr.row-cancelled td,
tr.row-cancelled td b,
tr.row-cancelled td .exc-overseas,
tr.row-cancelled td .exc-local,
tr.row-cancelled td .exc-other,
tr.row-cancelled td.oms-ok,
tr.row-cancelled td.oms-bad,
tr.row-cancelled td.oms-na,
tr.row-cancelled td .oms-ok,
tr.row-cancelled td .oms-bad,
tr.row-cancelled td .oms-na,
tr.row-cancelled td .cloud-ok,
tr.row-cancelled td .cloud-bad,
tr.row-cancelled td .cloud-na,
tr.row-cancelled td .local-ok,
tr.row-cancelled td .local-bad,
tr.row-cancelled td .local-warn,
tr.row-cancelled td .local-na {
  color: #9ca3af;
  background: #f9fafb;
}

/* 原单明细改了、镜像单还没发：橙色拦截提醒 */
tr.row-blocked td,
tr.row-blocked td b {
  background: #fff7ed;
  color: #9a3412;
}

/* OBS 变了/领星已取消：整行飘红（2026-11-12） */
tr.row-obs-changed td { background: #fff1f2; }
tr.row-obs-changed td.mirror-status { color: #b91c1c; font-weight: 600; }

.table-wrap {
  max-width: 1600px; margin: 0 auto; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 6px 6px; text-align: left; border-bottom: 1px solid var(--line);
  font-size: 13px; white-space: normal; word-break: break-word;
}
th { background: #f9fafb; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fff7f9; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }
.empty p { margin: 4px 0; }
.empty .meta { font-size: 12px; color: #9ca3af; }

@media (max-width: 760px) {
  .top { align-items: flex-start; flex-direction: column; }
  .toolbar input { min-width: 0; }
  th, td { padding: 8px 9px; font-size: 12px; }
}
