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

html, body {
  margin: 0;
  padding: 0;
  background: #FDFBF8;
  color: #2E2A24;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body { max-width: 1080px; margin: 0 auto; padding: 0 14px 40px; }

/* ---------- 页头 ---------- */
.hd { padding: 18px 0 12px; border-bottom: 1px solid #E4D8C3; margin-bottom: 14px; }
.hd-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hd h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .5px; color: #6E5530; }
.edit-btn {
  flex: none;
  display: inline-block;
  padding: 5px 12px;
  font-size: 12px;
  color: #6E5530;
  background: #FBF6EC;
  border: 1px solid #E0CFAE;
  border-radius: 999px;
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
}
.hd-sub { margin-top: 6px; font-size: 12px; color: #9A9082; }
.hd-sub .dot { margin: 0 5px; color: #CFC3B0; }
.save-note { flex: none; font-size: 11px; color: #9A9082; }

/* ---------- 页签（进行中 / 已完成） ---------- */
.tabs { display: flex; margin: 10px 0 -1px; }
.tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 6px;
  font-size: 13px;
  color: #9A9082;
  background: #FDFAF5;
  border: 1px solid #E4D8C3;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  margin-right: -1px;
  cursor: pointer;
  font-family: inherit;
}
.tab:last-child { margin-right: 0; }
.tab.on { color: #6E5530; font-weight: 700; background: #fff; }
.tab em { font-style: normal; margin-left: 5px; font-size: 11px; color: #B3A793; }

/* ---------- 总榜 ---------- */
.rank-wrap { border: 1px solid #E4D8C3; border-radius: 10px; overflow: hidden; background: #fff; margin-bottom: 18px; }
.rank-row, .rank-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1.25fr) minmax(0, 1.05fr) minmax(0, 1.15fr) 60px;
  align-items: stretch;
}
.rank-row > *, .rank-head > * { display: flex; align-items: center; }
.rank-row > * + *, .rank-head > * + * { border-left: 1px solid #EFE6D6; }
.rank-head { font-size: 11px; color: #9A9082; background: #FDFAF5; border-bottom: 1px solid #EFE6D6; }
.rank-head > * { padding: 6px 0; }
.rank-head > *:first-child { padding-left: 10px; }
.rank-head > *:last-child { padding-right: 10px; justify-content: flex-end; }
.rank-row { border-bottom: 1px solid #EFE6D6; background: #fff; }
.rank-row:last-child { border-bottom: 0; }
.rank-row > * { padding: 8px 0; }
.rank-row > *:first-child { padding-left: 10px; }
.rank-row > *:last-child { padding-right: 10px; justify-content: flex-end; }
.rank-row[role="button"] { cursor: pointer; }
.rank-row[role="button"]:active { background: #FBF6EC; }
.rk { font-size: 12px; font-weight: 700; color: #B3A793; font-variant-numeric: tabular-nums; }
.rank-row.top1 { background: #FEFAF1; }
.rank-row.top1 .rk { color: #B08D57; }
.nm { min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center; padding-right: 8px; }
.nm b { font-size: 14px; font-weight: 700; color: #2E2A24; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nm em { font-style: normal; font-size: 11px; color: #9A9082; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.fd { flex-direction: column; align-items: flex-start; justify-content: center; padding-right: 6px; }
.fd b { font-size: 16px; font-weight: 700; color: #A97435; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.fd .bar { display: block; height: 2px; margin-top: 5px; background: #E7D6B4; border-radius: 2px; max-width: 100%; }
.am, .us { font-size: 12px; color: #6B6355; font-variant-numeric: tabular-nums; justify-content: flex-end; padding-right: 8px; white-space: nowrap; }
.us { color: #9A9082; }

/* ---------- 卡片 / 按钮 / 输入框 ---------- */
.card { border: 1px solid #E4D8C3; border-radius: 10px; background: #fff; margin-bottom: 14px; overflow: hidden; }
.card-title { padding: 9px 12px; font-size: 13px; font-weight: 700; color: #6E5530; background: #FBF6EC; border-bottom: 1px solid #E4D8C3; }
.hint { margin-left: 8px; font-style: normal; font-weight: 400; font-size: 11px; color: #B3A793; }
.btns { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex-wrap: wrap; }
.btn {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #E0CFAE;
  background: #FBF6EC;
  color: #6E5530;
  font-family: inherit;
  cursor: pointer;
}
.btn.primary { background: #6E5530; border-color: #6E5530; color: #fff; }
.btn:disabled { opacity: .55; }

input[type="text"], input[type="number"], input[type="date"], select {
  border: 1px solid #E4D8C3;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  color: #2E2A24;
  background: #fff;
  font-family: inherit;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus { outline: none; border-color: #D8BE8A; background: #FFFDF8; }

/* ---------- 空态 / 页脚 ---------- */
.empty { padding: 46px 16px; text-align: center; color: #8A8175; }
.empty .dim { font-size: 12px; color: #B3A793; margin-top: 6px; line-height: 1.7; }
.ft { margin-top: 22px; padding-top: 12px; border-top: 1px solid #EFE6D6; font-size: 11px; color: #B3A793; text-align: center; line-height: 1.8; }
.ft .warn { color: #A85B50; }
.dim { color: #B3A793; }
.warn { color: #A85B50; }
.ok { color: #5E7C4A; }

/* ---------- 弹层 ---------- */
.mask { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(46, 42, 36, .46); }
.mask[hidden] { display: none; }
.dlg { width: 100%; max-width: 440px; background: #fff; border: 1px solid #E4D8C3; border-radius: 12px; overflow: hidden; }
.dlg-title { padding: 12px 14px; font-size: 14px; font-weight: 700; color: #6E5530; background: #FBF6EC; border-bottom: 1px solid #E4D8C3; }
.dlg-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #F8F2E7; }
.dlg-row > span { flex: none; width: 74px; font-size: 12px; color: #9A9082; }
.dlg-row input, .dlg-row select { flex: 1 1 auto; min-width: 0; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; }
.dlg-btns.lft { justify-content: flex-start; padding: 8px 14px; }
.dlg-note { padding: 10px 14px; font-size: 12px; color: #9A9082; border-bottom: 1px solid #F8F2E7; }
.probe-out { font-size: 11px; color: #8A7A5E; min-width: 0; }
.probe-out select { max-width: 100%; }
/* 抓取时间窗：开始 → 结束 两个 datetime 挤在一行，窄屏也要能填完 */
.dlg-row .win { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; }
.dlg-row .win input { flex: 1 1 0; min-width: 0; padding: 6px 4px; font-size: 12px; }
.dlg-row .win i { flex: none; font-style: normal; font-size: 11px; color: #C9BFAE; }

/* ---------- 项目页：顶部 ---------- */
.tgrid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) 104px auto; gap: 1px; background: #F3EADB; }
.tf { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; background: #fff; min-width: 0; }
.tf > span { font-size: 11px; color: #9A9082; }
.tf input { padding: 5px 8px; font-size: 13px; }
.tf .kv { padding: 6px 0; font-size: 14px; font-weight: 700; color: #A97435; font-variant-numeric: tabular-nums; }
.tf-act { justify-content: flex-end; align-items: flex-start; }
.tf-act .btn { padding: 6px 12px; font-size: 12px; }

/* ---------- 项目页：汇总条 ---------- */
.kpi {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #E4D8C3;
  border-radius: 10px;
  background: #FBF6EC;
  font-size: 12px;
  color: #8A7A5E;
}
.kpi b { font-size: 14px; font-weight: 700; color: #A97435; font-variant-numeric: tabular-nums; }
.kpi b.big { font-size: 20px; letter-spacing: -.5px; }
.kpi .sep { display: inline-block; width: 1px; height: 12px; background: #E4D8C3; align-self: center; }

/* ---------- 项目页：明细表格（直接在格子里填） ---------- */
.gt { width: 100%; border-collapse: collapse; table-layout: fixed; }
.gt col.g2 { width: 64px; }
.gt col.g3 { width: 88px; }
.gt col.g4 { width: 110px; }
.gt col.g5 { width: 84px; }
.gt col.g6 { width: 32px; }
.gt th {
  padding: 6px;
  font-size: 11px;
  font-weight: 400;
  color: #9A9082;
  background: #FDFAF5;
  border-bottom: 1px solid #EFE6D6;
  text-align: right;
  white-space: nowrap;
}
.gt th:first-child { padding-left: 12px; text-align: left; }
.gt th + th { border-left: 1px solid #EFE6D6; }
.gt td { padding: 0; border-bottom: 1px solid #F5EEE1; vertical-align: top; }
.gt td + td { border-left: 1px solid #F5EEE1; }
.gt tbody tr:last-child td { border-bottom: 0; }
.gt .cell {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.35;
  color: #2E2A24;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.gt .cell:focus { outline: none; background: #FFFCF3; box-shadow: inset 0 0 0 1px #D8BE8A; }
.gt .cell.auto { color: #A79C88; }
.gt .cell::placeholder { color: #C9BFAE; }
/* 明细表分主次（用户口径）：单价 / 销量退成灰，
   金额 / 折合用黑体压住（这两列才是要一眼看到的）。
   必须排在 .auto 之后，才能盖掉上面「系统算出来的值一律灰」那条。 */
.gt .cell[data-k="price"], .gt .cell[data-k="sold"] { color: #B3A793; }
.gt .cell.auto[data-k="price"], .gt .cell.auto[data-k="sold"] { color: #C6BAA6; }
.gt .cell[data-k="amount"], .gt .cell[data-k="fold"] { color: #1F1B16; font-weight: 700; }
.gt td.cnm { padding: 2px 0 3px; }
.gt td.cnm .cell.nm { padding: 6px 4px 0 12px; text-align: left; font-size: 12.5px; font-weight: 700; color: #3A342B; }
.src-chip {
  display: block;
  width: 100%;
  margin: 0;
  padding: 1px 4px 5px 12px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 10.5px;
  line-height: 1.4;
  text-align: left;
  color: #A79C88;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.src-chip.live { color: #5E7C4A; }
.src-chip.bad { color: #A85B50; }
.src-chip.off { color: #B3A793; }
/* 子项头：名称 → 小计 → 加一行 → 删子项 排成一行。
   以前小计和按钮用 absolute 钉在右边，屏幕一窄就互相叠字。
   现在是一行 flex（.ghd）：名称撑满剩余、但至少留 96px，
   小计跟在名称后面，真挤不下时自己出省略号，绝不压到按钮上。 */
.gt tr.grow td { padding: 0; background: #FBF7EF; border-top: 1px solid #EFE6D6; border-bottom: 1px solid #EFE6D6; }
.ghd { display: flex; align-items: center; gap: 8px; padding-right: 6px; }
.gt tr.grow .cell.gname { flex: 1 1 auto; width: auto; min-width: 96px; padding: 5px 4px 5px 12px; text-align: left; font-size: 11.5px; font-weight: 700; color: #8A7A5E; background: transparent; }
.gt tr.grow .cell.gname:focus { background: #FFFCF3; }
.gsum {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  color: #8A7A5E;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gt tr.grow.gempty { background: #FCFAF6; }
.gt tr.grow.gempty .cell.gname { color: #A79C88; }
.gt tr.grow.gempty .gsum { color: #C9BFAE; }
.gt tr.grow.gempty .gadd { border-color: #E8DCC4; color: #A79C88; }
.gadd {
  flex: none;
  padding: 2px 7px;
  border: 1px solid #E0CFAE;
  border-radius: 999px;
  background: #FFFDF8;
  font-family: inherit;
  font-size: 10.5px;
  line-height: 1.4;
  color: #8A7A5E;
  cursor: pointer;
  white-space: nowrap;
}
.gadd:active { background: #F3E7D0; }
.gadd[disabled] { opacity: .4; }
.gt td.cx { padding: 0; }
.x {
  display: block;
  width: 100%;
  padding: 8px 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.2;
  color: #CFC3B0;
  cursor: pointer;
}
.x:active { color: #A85B50; }
.gt .empt { padding: 24px 12px; font-size: 12px; color: #B3A793; text-align: center; }

/* ---------- 窄屏紧凑 ---------- */
@media (max-width: 620px) {
  body { padding: 0 10px 32px; font-size: 13px; }
  .hd { padding: 14px 0 10px; }
  .hd h1 { font-size: 17px; }
  .rank-row, .rank-head { grid-template-columns: 28px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.05fr) 52px; }
  .rank-row > *:first-child, .rank-head > *:first-child { padding-left: 8px; }
  .rank-row > *:last-child, .rank-head > *:last-child { padding-right: 8px; }
  .fd b { font-size: 15px; }
  .am, .us { font-size: 11px; padding-right: 6px; }
  .nm b { font-size: 13px; }
  .dlg-row > span { width: 58px; }
}

@media (max-width: 400px) {
  .rank-row, .rank-head { grid-template-columns: 24px minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr) 46px; }
  .fd b { font-size: 14px; }
}

/* ---------- 字号被 App 放大时的兜底 ---------- */
html.tzup .hd h1 { font-size: 17px; }
html.tzup .rank-row, html.tzup .rank-head { grid-template-columns: 30px minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.05fr) 54px; }
html.tzup .nm em, html.tzup .am, html.tzup .us { font-size: 11px; }
html.tzup .gt col.g2 { width: 68px; }
html.tzup .gt col.g3 { width: 92px; }
html.tzup .gt col.g4 { width: 116px; }
html.tzup .gt col.g5 { width: 88px; }
html.tzup .kpi b.big { font-size: 18px; }

/* ---------- 项目页窄屏（必须放在最后，否则会被上面的桌面值盖掉） ---------- */
@media (max-width: 620px) {
  .gt col.g2 { width: 42px !important; }
  .gt col.g3 { width: 52px !important; }
  .gt col.g4 { width: 60px !important; }
  .gt col.g5 { width: 48px !important; }
  .gt col.g6 { width: 24px !important; }
  .gt .cell { font-size: 11.5px; padding: 7px 4px; }
  .gt td.cnm .cell.nm { font-size: 12px; padding-left: 10px; }
  .gt th { padding: 5px 4px; }
  .gt th:first-child { padding-left: 10px; }
  .src-chip { padding-left: 10px; font-size: 10px; }
  .ghd { gap: 6px; padding-right: 4px; }
  .gt tr.grow .cell.gname { min-width: 76px; padding-left: 10px; font-size: 11px; }
  .gsum { font-size: 9.5px; }
  .gadd { padding: 2px 6px; font-size: 10px; }
  .tgrid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .tf { padding: 7px 10px; }
  .tf .kv { font-size: 13px; }
  .kpi { padding: 9px 10px; gap: 3px 8px; }
  .kpi b.big { font-size: 18px; }
  html.tzup .gt col.g2 { width: 48px !important; }
  html.tzup .gt col.g3 { width: 58px !important; }
  html.tzup .gt col.g4 { width: 68px !important; }
  html.tzup .gt col.g5 { width: 54px !important; }
}

/* ===== 整店汇总（来源弹层里逐档填「限量」） =====
   微店不给规格级销量，只能用 限量 − 当前库存 反推，再乘各自单价加总。
   每档一行，最后一行是合计。 */
.sum-list { margin: 6px 0 4px; border: 1px solid #edd5da; border-radius: 8px; overflow: hidden; }
.sum-head, .sum-row { display: grid; grid-template-columns: 1fr 52px 52px 60px 44px 64px; align-items: center; }
.sum-head { background: #faf1f3; color: #8a6b72; font-size: 11px; padding: 4px 8px; }
.sum-head span, .sum-row > span { padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-row { padding: 3px 8px; border-top: 1px solid #f7e8eb; font-size: 12px; }
.sum-row .sn { color: #4a3a3e; }
.sum-row .sp, .sum-row .ss, .sum-row .sv { color: #9a8188; font-size: 11px; text-align: right; }
.sum-row .sa { text-align: right; color: #a8344a; font-weight: 600; }
.sum-row .sl { display: flex; }
.sum-row .sbase { width: 100%; min-width: 0; border: 1px solid #edd5da; border-radius: 5px;
  padding: 2px 4px; font-size: 12px; color: #4a3a3e; background: #fff; text-align: right; }
.sum-row .sbase:focus { outline: none; border-color: #d98a9c; }
.sum-total { display: flex; align-items: baseline; gap: 8px; padding: 5px 8px 2px; font-size: 12px; color: #8a6b72; }
.sum-total b { font-size: 15px; color: #a8344a; }
.sum-total em { font-style: normal; font-size: 11px; color: #b08a93; }
.sum-total .stv { margin-left: auto; color: #8a6b72; font-size: 11px; white-space: nowrap; }
.sum-total .stv b { font-size: 13px; }
.sum-total .stv i { font-style: normal; font-size: 10.5px; color: #b08a93; margin-left: 4px; }

@media (max-width: 420px) {
  .sum-head, .sum-row { grid-template-columns: 1fr 44px 40px 50px 38px 56px; }
  .sum-head { font-size: 10px; }
  .sum-row { font-size: 11px; }
}

/* 删空子项按钮：空组头右侧，紧挨「+ 加一行」左边 */
.gdel {
  flex: none;
  padding: 2px 7px;
  border: 1px solid #E6C9CF;
  border-radius: 999px;
  background: #FFF8F9;
  font-family: inherit;
  font-size: 10.5px;
  line-height: 1.4;
  color: #B5737F;
  cursor: pointer;
  white-space: nowrap;
}
.gdel:active { background: #FBE9ED; }

@media (max-width: 420px) {
  .gdel { padding: 2px 5px; font-size: 10px; }
}
