:root {
  --bg: #f2f4f7;
  --bg-soft: #fafbfc;
  --card: #ffffff;
  --line: #e3e7ed;
  --line-strong: #cfd6df;
  --fg: #161d26;
  --dim: #6b7684;
  --dim-soft: #96a0ad;
  --accent: #b85c0a;
  --accent-strong: #9a4a05;
  --accent-soft: #fff4e6;
  --ok: #17804a;
  --warn: #a76a06;
  --err: #c22b2b;
  --used: #1d5cb5;
  --used-soft: #eaf1fb;
  --shadow: 0 1px 1px rgba(18, 26, 38, .04), 0 6px 18px -10px rgba(18, 26, 38, .18);
  --shadow-lift: 0 2px 4px rgba(18, 26, 38, .05), 0 14px 28px -14px rgba(18, 26, 38, .28);
  --radius: 13px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font: 15px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  max-width: 700px; margin: 0 auto; padding-bottom: 48px;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: 240px; pointer-events: none; z-index: -1;
  background: linear-gradient(180deg, #e9edf3 0%, rgba(242, 244, 247, 0) 100%);
}
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
.tiny { font-size: 12px; color: var(--dim); line-height: 1.5; }
b { color: var(--fg); font-weight: 600; }
.hidden { display: none !important; }
.mb8 { margin-bottom: 8px; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── 顶栏 ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 6;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px 10px; border-bottom: 1px solid rgba(227, 231, 237, .8);
  background: rgba(242, 244, 247, .86); backdrop-filter: blur(10px) saturate(1.2);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .mark {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 10px;
  background: linear-gradient(145deg, #262e3a, #121820); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.brand-text { min-width: 0; }
.brand-text b { display: block; font-size: 16.5px; letter-spacing: -.2px; line-height: 1.2; }
.brand .sub { display: block; font-size: 10.5px; color: var(--dim); letter-spacing: .1px; }
.asof {
  font-size: 10.5px; color: var(--dim); text-align: right; max-width: 46%;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── 标签页 ─────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px; padding: 8px 16px; position: sticky; top: 59px; z-index: 5;
  background: rgba(242, 244, 247, .86); backdrop-filter: blur(10px) saturate(1.2);
}
.tab, .tab-btn {
  flex: 1; background: transparent; color: var(--dim); border: 1px solid transparent;
  border-radius: 10px; padding: 8px 0; font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.tab:hover, .tab-btn:hover { color: var(--fg); background: rgba(255, 255, 255, .6); }
.tab.active, .tab-btn.active {
  background: var(--card); color: var(--fg); border-color: var(--line);
  font-weight: 600; box-shadow: var(--shadow);
}

.view { display: none; padding: 0 16px; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ── 工具条与状态 ───────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; margin-bottom: 8px;
}
.counter {
  font-size: 11.5px; color: var(--dim); background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.statusbar { display: flex; align-items: center; gap: 8px; min-height: 0; }
.status:empty { display: none; }
.status {
  flex: 1; font-size: 11.5px; color: var(--dim); background: var(--accent-soft);
  border: 1px solid #f0dcc2; border-radius: 9px; padding: 5px 9px;
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 13px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.card h4 { margin: 0 0 9px; font-size: 13.5px; letter-spacing: -.1px; }
h4 .badge { font-size: 11px; font-weight: 400; color: var(--dim); }

/* ── 选件格 ─────────────────────────────────────────── */
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.slot {
  display: flex; gap: 9px; align-items: flex-start; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; cursor: pointer; text-align: left; color: var(--fg);
  box-shadow: var(--shadow); transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.slot:hover { border-color: var(--accent); box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.slot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.slot .body { min-width: 0; flex: 1; }
.slot .cat { font-size: 10.5px; color: var(--dim); letter-spacing: .2px; }
.slot .pname { font-size: 12.5px; line-height: 1.4; margin: 2px 0 4px; font-weight: 500; }
.slot .pp { font-size: 12px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.slot .pp .u { color: var(--used); font-weight: 500; }
.slot.empty { background: var(--bg-soft); box-shadow: none; border-style: dashed; border-color: var(--line-strong); }
.slot.empty:hover { border-color: var(--accent); background: #fff; }
.slot.empty .pname { color: var(--dim-soft); }
.slot-placeholder {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center;
  color: var(--dim-soft); background: #f1f4f8; font-size: 17px; font-weight: 400;
}
.slot .warn-inline { font-size: 10.5px; }
.slot .kv { font-size: 10.5px; }
.xy-new-info { margin-top: 4px; color: #0f7c86; font-size: 11px; line-height: 1.5; }
.xy-new-info .kv { font-size: 10.5px; }

/* 缩略图 */
.thumb {
  width: var(--ts, 42px); height: var(--ts, 42px); flex: 0 0 auto; border-radius: 9px;
  overflow: hidden; background: #fff; border: 1px solid var(--line);
}
.thumb svg { display: block; width: 100%; height: 100%; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* 角标 */
.added-tag {
  font-style: normal; display: inline-block; margin-left: 4px; padding: 0 4px;
  border-radius: 4px; background: #e9f6ee; color: var(--ok); font-size: 9.5px; line-height: 14px;
  vertical-align: 1px; white-space: nowrap;
}
.ttag {
  font-style: normal; display: inline-block; margin-left: 3px; padding: 0 4px; white-space: nowrap;
  border: 1px solid #ecdcbf; border-radius: 6px; background: #fdf9f0; color: #8a6418;
  font-size: 10px; line-height: 15px; vertical-align: 1px;
}
.ttag.bad { border-color: #e5c3c3; background: #fdf4f4; color: #a14545; }

/* ── 总价 ───────────────────────────────────────────── */
.totals { position: relative; overflow: hidden; }
.totals::after {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--accent), #e0a25e 40%, transparent 85%);
}
.total-line {
  display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0;
  font-size: 14px; font-variant-numeric: tabular-nums;
}
.total-line b { font-size: 16px; }
.total-line.accent { color: var(--accent); font-weight: 700; margin-top: 2px; padding-top: 6px; border-top: 1px dashed var(--line); }
.total-line.accent b { color: var(--accent); font-size: 19px; }
.totals .tiny { margin: 6px 0 0; }
.totals .tiny + .tiny { margin-top: 2px; }
.warn-inline { display: block; margin-top: 4px; color: var(--warn); font-size: 11.5px; }
.kv { color: var(--dim); font-size: 11px; }

/* ── 校验结果 ───────────────────────────────────────── */
.issue {
  border-left: 3px solid var(--line); padding: 7px 10px; margin-bottom: 6px;
  background: var(--bg-soft); border-radius: 0 9px 9px 0;
}
.issue.error { border-color: var(--err); background: #fdf3f3; }
.issue.warning { border-color: var(--warn); background: #fdf8ee; }
.issue.info { border-color: #c4ceda; }
.issue .t { font-size: 12.5px; font-weight: 600; }
.issue.error .t { color: var(--err); }
.issue.warning .t { color: var(--warn); }
.issue .d { font-size: 11.5px; color: var(--dim); }

/* ── 表单控件 ───────────────────────────────────────── */
select, input[type="search"] {
  background: var(--card); color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 13.5px; min-width: 0;
  transition: border-color .16s ease, box-shadow .16s ease;
}
select:focus, input[type="search"]:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184, 92, 10, .12);
}
input[type="search"] { flex: 1; }
button.ghost {
  background: var(--card); color: var(--dim); border: 1px solid var(--line);
  border-radius: 9px; padding: 6px 11px; font-size: 12px; cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
button.ghost:hover { color: var(--accent); border-color: var(--accent); background: #fff; }
button.ghost.danger:hover { color: var(--err); border-color: var(--err); }

.filterbar { display: flex; gap: 8px; margin-bottom: 8px; }
.filterbar select { flex: 0 0 auto; max-width: 42%; }

.legend {
  font-size: 11px; color: var(--dim); margin: 0 0 8px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
.legend summary { cursor: pointer; color: var(--dim); font-weight: 500; list-style: none; }
.legend summary::-webkit-details-marker { display: none; }
.legend summary::before { content: "口径说明"; }
.legend summary { font-size: 0; }
.legend summary::before { font-size: 11px; }
.legend[open] summary { margin-bottom: 6px; }
.legend b { font-weight: 600; }

/* ── 行情行 ─────────────────────────────────────────── */
.mrow {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 7px; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.mrow:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lift); }
.mrow .head { display: flex; gap: 9px; align-items: flex-start; }
.mrow .n { font-size: 13px; flex: 1; min-width: 0; line-height: 1.4; }
.mrow .cat {
  font-size: 10px; color: var(--dim); border: 1px solid var(--line); padding: 0 4px;
  border-radius: 4px; margin-right: 6px; white-space: nowrap;
}
.mrow .cols { display: flex; justify-content: space-between; align-items: baseline; margin-top: 5px; gap: 8px; flex-wrap: wrap; }
.mrow .cols .grp { font-size: 12px; }
.new-p { color: var(--accent); font-weight: 650; font-variant-numeric: tabular-nums; }
.used-p { color: var(--used); font-weight: 650; font-variant-numeric: tabular-nums; }
.deal-p { color: #6b4fa0; font-weight: 650; } /* 第三口径：社区到手价，既非全新也非二手 */
.xynew-p { color: #0f7c86; font-weight: 650; font-variant-numeric: tabular-nums; } /* 第四口径：闲鱼未拆封挂单价，不是电商全新价 */
.deal-line, .xy-line { border-top: 1px dashed var(--line); padding-top: 5px; margin-top: 6px; }
.mrow .detail { display: none; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 7px; }
.mrow.open .detail { display: block; }
.mrow.open { border-color: var(--line-strong); }
.spark { width: 100%; height: 46px; display: block; }

/* ── 天梯 ───────────────────────────────────────────── */
.tier-row { display: flex; align-items: center; gap: 7px; cursor: default; }
.tier-row .rk { width: 18px; text-align: right; color: var(--dim); font-size: 11.5px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.tier-row .nm { flex: 1; font-size: 12.5px; min-width: 0; line-height: 1.35; }
.tier-row .barbox { width: 54px; background: #edf0f4; border-radius: 3px; height: 5px; flex: 0 0 auto; overflow: hidden; }
.tier-row .bar { height: 5px; background: linear-gradient(90deg, #d99a55, var(--accent)); border-radius: 3px; }
.tier-row .sc { width: 48px; text-align: right; font-size: 11.5px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.tier-row .pp { width: 62px; text-align: right; font-size: 11px; color: var(--dim); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.tier-row.best { border-color: #bfe0cb; background: linear-gradient(180deg, #fbfefc, #f4faf6); }
.tier-row.best .nm::after {
  content: "性价比"; font-size: 9.5px; color: #fff; background: var(--ok);
  border-radius: 4px; padding: 1px 4px; margin-left: 6px; vertical-align: 1px;
}

/* ── 选件面板 ───────────────────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; }
.sheet-mask { position: absolute; inset: 0; background: rgba(18, 26, 38, .42); backdrop-filter: blur(2px); }
.sheet-body {
  position: relative; background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 8px 16px 18px; width: 100%; max-width: 700px; margin: 0 auto;
  max-height: 84vh; display: flex; flex-direction: column;
  box-shadow: 0 -20px 50px -20px rgba(18, 26, 38, .45); animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 2px auto 8px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.sheet-head b { font-size: 15px; }
.sheet-list { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px; }
.opt {
  display: flex; gap: 9px; padding: 10px; border: 1px solid var(--line);
  border-radius: 11px; margin-bottom: 6px; cursor: pointer; background: var(--card);
  width: 100%; text-align: left; color: var(--fg); font: inherit;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.opt:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.opt.disabled { opacity: .55; background: #f3f5f7; border-color: #e3e7ec; cursor: not-allowed; }
.opt.disabled .on, .opt.disabled .om, .opt.disabled .price { color: #96a0ad; }
.opt.disabled:hover { border-color: #e3e7ec; box-shadow: none; }
.opt.checked { border-color: #8bbfa0; background: #f4faf6; }
.opt .otext { flex: 1; min-width: 0; }
.opt .on { font-size: 13px; font-weight: 600; line-height: 1.4; }
.opt .om { font-size: 11px; color: var(--dim); }
.opt .price { text-align: right; font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.opt .price .u { color: var(--used); }
.empty-state { padding: 26px 10px; text-align: center; color: var(--dim); font-size: 12.5px; }

/* 页脚：备案号必须悬挂并可点击跳转到工信部（管局专项核查项） */
.site-foot {
  margin: 18px 0 8px; padding: 12px 4px 0; text-align: center;
  border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px;
}
.site-foot .icp { font-size: 12px; color: var(--dim); text-decoration: none; }
.site-foot .icp:hover { color: var(--accent); text-decoration: underline; }

body.sheet-open { overflow: hidden; }

@media (max-width: 420px) {
  .grid2 { grid-template-columns: 1fr; }
  .brand .sub { display: none; }
  .filterbar { flex-wrap: wrap; }
  .filterbar select { max-width: none; }
}
