:root {
  --bg: #efede7;
  --bg-deep: #e7e3da;
  --panel: #ffffff;
  --ink: #16181b;
  --ink-2: #3f454c;
  --muted: #7b818a;
  --line: #e4e0d8;
  --line-strong: #d2ccc1;
  --safe: #17795f;
  --safe-soft: #e8f4ef;
  --warn: #b8720c;
  --warn-soft: #fbf1e0;
  --danger: #b23b2c;
  --danger-soft: #fbeae7;
  --accent: #16181b;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(22, 24, 27, .04), 0 14px 38px rgba(22, 24, 27, .07);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 26px clamp(16px, 4vw, 44px) 34px;
  background:
    radial-gradient(120% 80% at 15% 0%, #f7f5f0 0%, transparent 55%),
    radial-gradient(90% 70% at 100% 10%, #f3f0e9 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, dt { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1240px;
  margin: 0 auto 22px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: linear-gradient(150deg, #2b2f34, #101215);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 8px 18px rgba(22, 24, 27, .18);
}

.brand-mark::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 9px;
  width: 11px;
  height: 24px;
  border-radius: 4px;
  background: linear-gradient(90deg, #8d9299, #f4f6f8 42%, #b9bec5 70%, #6f747b);
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 11px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5d3a;
  box-shadow: 0 0 0 4px rgba(255, 93, 58, .16), 0 0 14px rgba(255, 93, 58, .8);
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: .01em;
}

.brand-text p {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--safe);
  box-shadow: 0 0 0 3px rgba(23, 121, 95, .14);
}

/* ---------- 布局 ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(340px, .98fr);
  align-items: start;
  gap: 22px;
  max-width: 1240px;
  margin: 0 auto;
}

/* ---------- 预览 ---------- */
.stage-card {
  position: sticky;
  top: 20px;
  padding: 20px 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.stage-title h2 {
  font-size: 16px;
  font-weight: 650;
}

.stage-title p {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; padding-top: 2px; }

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dot {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  border: 1px dashed currentColor;
}

.dot-safe { color: var(--safe); background: rgba(23, 121, 95, .07); }
.dot-warn { color: var(--warn); background: rgba(184, 114, 12, .07); }
.dot-label { color: var(--ink-2); border-style: solid; background: rgba(22, 24, 27, .06); }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: .66;
  max-height: 74vh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(90% 66% at 50% 14%, rgba(255, 255, 255, .96) 0%, rgba(250, 248, 243, .8) 44%, rgba(232, 228, 219, .92) 100%),
    var(--bg-deep);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(22, 24, 27, .035) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, rgba(22, 24, 27, .035) 0 1px, transparent 1px 26px);
  mask-image: radial-gradient(80% 70% at 50% 45%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(80% 70% at 50% 45%, #000 30%, transparent 100%);
  pointer-events: none;
}

.stage.is-dragging { cursor: grabbing; }

.stage.is-drop::after {
  content: "松开以导入图片";
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(23, 121, 95, .55);
  border-radius: 10px;
  background: rgba(23, 121, 95, .06);
  color: var(--safe);
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

#can {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.stage-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  max-width: calc(100% - 24px);
  box-shadow: 0 3px 10px rgba(22, 24, 27, .1);
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.readout-tip {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 13px;
}

.metrics { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }

.metric {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.metric .k { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.metric b { font-size: 14px; font-weight: 600; }
.metric .u { font-size: 10.5px; color: var(--muted); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.35;
  transition: color .2s ease, background .2s ease;
}

.status i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.status[data-level="safe"] { color: var(--safe); background: var(--safe-soft); }
.status[data-level="warn"] { color: var(--warn); background: var(--warn-soft); }
.status[data-level="danger"] { color: var(--danger); background: var(--danger-soft); }

/* ---------- 右侧面板 ---------- */
.panel { display: grid; gap: 14px; }

.card {
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(22, 24, 27, .03);
}

.card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.step {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #f1eee7;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.card-head h2 { font-size: 15px; font-weight: 650; }

.card-head p {
  margin-top: 1px;
  font-size: 12px;
  color: var(--muted);
}

.field { display: block; margin-bottom: 15px; }

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: .02em;
}

.field-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.field-row .field-label { margin: 0; }

output {
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fbfaf7;
  color: var(--ink);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

textarea {
  min-height: 58px;
  padding: 10px 12px;
  resize: vertical;
  font-size: 15px;
  line-height: 1.45;
}

select {
  height: 40px;
  padding: 0 32px 0 11px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237b818a' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  font-size: 13.5px;
}

textarea:focus,
select:focus {
  outline: none;
  border-color: #9a9489;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(22, 24, 27, .06);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #f2efe9;
  height: 40px;
}

.segmented button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.segmented button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(22, 24, 27, .12);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #d8d3c9, #cfc9be);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(22, 24, 27, .3);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #d8d3c9;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
}

.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 2px; }

.btn {
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .08s ease;
}

.btn:hover { background: #f7f5f0; }
.btn:active { transform: translateY(1px); }

.hint-text {
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.field > .hint-text { display: block; margin-top: 5px; }

.hint-text.is-warn { color: var(--warn); }
.hint-text.is-danger { color: var(--danger); }

.card-spec h3 {
  margin-bottom: 11px;
  font-size: 13px;
  font-weight: 650;
}

.spec-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}

.spec-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #fbfaf7;
}

.spec-list dt { font-size: 11px; color: var(--muted); }
.spec-list dd { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

.card-spec p {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.page-foot {
  max-width: 1240px;
  margin: 22px auto 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- 内容切换 / 图片上传 ---------- */
.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #f2efe9;
}

.tabs button {
  position: relative;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.tabs button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(22, 24, 27, .12);
}

.tab-dot {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--safe);
}

.upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  padding: 16px 12px 15px;
  margin-bottom: 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: #fbfaf7;
  color: var(--ink-2);
  cursor: pointer;
  -webkit-appearance: none;
  transition: border-color .16s ease, background .16s ease;
}

.upload:hover { border-color: #aaa294; background: #f7f5f0; }
.upload.is-drag { border-color: var(--safe); background: var(--safe-soft); }

.upload-plus {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 3px;
  border-radius: 50%;
  background: #efece5;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-2);
}

.upload-main { font-size: 13.5px; font-weight: 600; }
.upload-sub { font-size: 10.5px; color: var(--muted); text-align: center; }

.image-info {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf7;
}

.image-thumb-wrap {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #f1eee8 25%, transparent 25%),
    linear-gradient(-45deg, #f1eee8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1eee8 75%),
    linear-gradient(-45deg, transparent 75%, #f1eee8 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}

#image-thumb { display: block; max-width: 100%; max-height: 100%; }

.image-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.image-meta b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-meta span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.link-btn {
  padding: 5px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 11.5px;
  text-decoration: underline;
  cursor: pointer;
}

.image-warn {
  margin: -2px 0 13px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11.5px;
  line-height: 1.55;
}

.actions-tight { margin: -7px 0 14px; }

/* ---------- 对象列表 / 对齐分布 / 距离读数 ---------- */
.obj-bar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-add { height: 36px; padding: 0 10px; font-size: 12.5px; }

.btn-toggle {
  height: 36px;
  padding: 0 12px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.btn-toggle.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.obj-list {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.obj-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf7;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}

.obj-item:hover { background: #f7f5f0; }

.obj-item.is-selected { border-color: #c9c2b5; background: #fff; }

.obj-item.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.obj-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: transparent;
}

.obj-item.is-selected .obj-dot { border-color: var(--accent); background: var(--accent); }

.obj-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
}

.obj-kind { font-size: 10.5px; color: var(--muted); }

.obj-size {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.obj-del {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.obj-del:hover { background: var(--danger-soft); color: var(--danger); }

.align-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}

.align-grid button {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}

.align-grid button:hover:not(:disabled) { background: #f7f5f0; border-color: #b9b2a5; }

.align-grid button:disabled {
  opacity: .42;
  cursor: default;
}

.gap-block { margin-top: 4px; }

.gap-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.gap-label { font-size: 12px; color: var(--ink-2); }

.num-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

.num-input {
  width: 74px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fbfaf7;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.num-input:focus {
  outline: none;
  border-color: #9a9489;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(22, 24, 27, .06);
}

.dist-block {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
}

.dist-title {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .02em;
}

.dist-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.dist-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.dist-grid span { font-size: 10.5px; color: var(--muted); }

.dist-grid b {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dist-grid b.is-warn { color: var(--warn); }
.dist-grid b.is-danger { color: var(--danger); }
.dist-grid b.is-dim { color: var(--muted); font-weight: 500; }

/* ---------- 罐身外观：材质 / 实拍照片底图 ---------- */

.can-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 11px;
}

.seg-material {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #f2efe9;
}

.seg-material button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.seg-material button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(22, 24, 27, .12);
}

.can-tools .btn {
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.can-tools-note {
  flex: 1 1 100%;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- 空白区校准 ---------- */

.calib-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin-bottom: 10px;
}

.calib-grid .field { margin-bottom: 0; }

.calib-grid .num-input {
  width: 100%;
  text-align: left;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  body { padding: 18px 14px 26px; }

  .topbar { margin-bottom: 16px; }
  .brand-text h1 { font-size: 17px; }
  .topbar-note { display: none; }

  .workspace { grid-template-columns: 1fr; gap: 14px; }

  .stage-card {
    position: static;
    padding: 15px 15px 13px;
  }

  .stage-head { margin-bottom: 11px; }
  .stage-title p { font-size: 11.5px; }
  .legend { gap: 8px 10px; }

  .stage { aspect-ratio: .72; max-height: none; }

  .readout { padding-top: 11px; gap: 9px; }
  .metrics { gap: 10px 14px; }

  .card { padding: 16px 15px 14px; }

  /* 避免 iOS 聚焦输入框时自动放大 */
  textarea, select { font-size: 16px; }
  select { font-size: 15px; }
}

@media (max-width: 400px) {
  .legend-item { font-size: 10.5px; }
  .metric b { font-size: 13px; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}

/* ============================================================
   下单页 / 后台
   ============================================================ */

.brand-link { display: inline-flex; text-decoration: none; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: #2b2f34; }
.btn-primary:disabled { opacity: .5; cursor: default; }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(22, 24, 27, .05); }

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }

.btn-inline { margin-top: 10px; }

.file-label { line-height: 36px; white-space: nowrap; }

/* 表单控件（下单页 / 设置） */
.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="url"],
.field input[type="password"],
.field input[type="date"],
.field input[type="number"] {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fbfaf7;
  font-size: 14px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.field input:focus {
  outline: none;
  border-color: #9a9489;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(22, 24, 27, .06);
}

.field-label em { font-style: normal; color: var(--danger); }
.field > .hint-text { color: var(--muted); }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  font-size: 13px;
  color: var(--ink-2);
}

.check-row input { width: 16px; height: 16px; accent-color: var(--accent); }

/* 预览页下单按钮 */
.order-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.order-cta .hint-text { margin: 0; flex: 1 1 200px; }

/* ---------- 下单页 ---------- */
.order-wrap {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(340px, 1.08fr);
  align-items: start;
  gap: 22px;
  max-width: 1160px;
  margin: 0 auto;
}

.snap-frame {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(80% 60% at 50% 20%, #fbfaf7 0%, #efede7 100%);
}

.snap-frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 8px;
}

.snap-empty {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 26px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.snap-empty b { color: var(--ink); font-size: 14px; }

.snap-detail { margin-top: 12px; }

.snap-detail summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
}

.snap-detail pre {
  margin: 8px 0 0;
  padding: 11px 12px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf7;
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.order-form-card .actions { margin-top: 4px; }

.done-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--safe-soft);
  color: var(--safe);
  font-size: 22px;
  font-weight: 700;
}

.done-title { font-size: 17px; margin-bottom: 4px; }

.done-id {
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.storage-note {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- 后台 ---------- */
.admin-body.is-locked .admin-wrap { display: none; }

.admin-wrap {
  display: grid;
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto;
}

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
}

.filter-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #f2efe9;
}

.filter-seg button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}

.filter-seg button b {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: .75;
}

.filter-seg button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(22, 24, 27, .12);
}

.admin-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-actions .hint-text { margin: 0; }

.admin-table-card { padding: 4px 6px 6px; overflow-x: auto; }

.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.order-table th {
  padding: 10px 10px 8px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.order-table td {
  padding: 9px 10px;
  vertical-align: middle;
  border-bottom: 1px solid #f0ede6;
}

.order-table tbody tr:last-child td { border-bottom: 0; }
.order-table tbody tr:hover { background: #fbfaf6; }

.col-thumb { width: 58px; }
.col-qty { width: 66px; font-variant-numeric: tabular-nums; }
.col-open { width: 62px; text-align: right; }

.row-thumb {
  display: block;
  width: 44px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2efe9;
}

.thumb-none {
  display: grid;
  place-items: center;
  width: 44px;
  height: 56px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  font-size: 10.5px;
  color: var(--muted);
}

.order-no { display: block; font-variant-numeric: tabular-nums; letter-spacing: .01em; }

.row-sub {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-new { color: #1f5fa8; background: #e8f0fa; }
.badge-confirmed { color: var(--warn); background: var(--warn-soft); }
.badge-producing { color: #7a4bb5; background: #f1eafa; }
.badge-done { color: var(--safe); background: var(--safe-soft); }
.badge-cancelled { color: var(--muted); background: #f0eee9; }

.push-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.push-ok { color: var(--safe); background: var(--safe-soft); }
.push-fail { color: var(--danger); background: var(--danger-soft); }
.push-wait { color: var(--warn); background: var(--warn-soft); }
.push-none { color: var(--muted); background: #f2f0eb; }

.empty-state {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 42px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.empty-state b { color: var(--ink); font-size: 14px; }

.data-note h3 { margin-bottom: 8px; font-size: 13.5px; }

.data-note ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
}

.data-note code,
.settings-body code,
.hint-text code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #f2efe9;
  font-family: "Consolas", monospace;
  font-size: 11.5px;
}

/* ---------- 弹层 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px 16px;
  background: rgba(22, 24, 27, .42);
  backdrop-filter: blur(2px);
  overflow: auto;
}

.modal-card {
  width: min(880px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(22, 24, 27, .28);
}

.modal-sm { width: min(380px, 100%); }
.modal-wide { width: min(1040px, 100%); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 { font-size: 16px; font-weight: 650; }

.modal-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.modal-close:hover { color: var(--ink); }

.modal-actions { margin-top: 16px; align-items: center; }

/* 设置 */
.settings-body { display: grid; gap: 16px; }

.settings-group {
  margin: 0;
  padding: 12px 14px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.settings-group legend {
  padding: 0 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink);
}

/* 详情 */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.detail-img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f2efe9;
}

.detail-noimg {
  display: grid;
  place-items: center;
  padding: 60px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
}

.detail-meta {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  font-size: 11.5px;
}

.detail-meta div { display: flex; justify-content: space-between; gap: 10px; }
.detail-meta span { color: var(--muted); }
.detail-meta b { font-weight: 600; text-align: right; }

.detail-info { display: grid; gap: 14px; }

.detail-block {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fdfcf9;
}

.detail-block h3 { font-size: 12.5px; font-weight: 650; margin-bottom: 8px; }

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.block-head h3 { margin-bottom: 0; }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 12.5px; }
.kv div { display: flex; gap: 8px; }
.kv .wide { grid-column: 1 / -1; }
.kv span { color: var(--muted); flex: 0 0 56px; }
.kv b { font-weight: 600; word-break: break-word; }

.status-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.status-row select { width: auto; min-width: 108px; }
.status-row input {
  flex: 1 1 150px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13px;
}

.timeline, .push-log {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 5px;
  font-size: 11.5px;
}

.timeline li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
}

.timeline li b, .timeline li > span { font-weight: 600; }
.timeline li em { color: var(--muted); font-style: normal; font-variant-numeric: tabular-nums; }
.timeline li i { color: var(--ink-2); font-style: normal; }
.timeline li:last-child, .push-log li:last-child { border-bottom: 0; }

.push-log li {
  display: grid;
  gap: 1px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f4f2ec;
}

.push-log li.is-ok { background: var(--safe-soft); }
.push-log li.is-fail { background: var(--danger-soft); }
.push-log b { font-size: 11.5px; }
.push-log li.is-ok b { color: var(--safe); }
.push-log li.is-fail b { color: var(--danger); }
.push-log em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.push-log span { color: var(--ink-2); word-break: break-word; }

.timeline .muted, .push-log .muted { color: var(--muted); }

.param-pre {
  margin: 0;
  padding: 9px 10px;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink-2);
}

@media (max-width: 900px) {
  .order-wrap { grid-template-columns: 1fr; gap: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .admin-bar { padding: 10px; }
  .filter-seg button { padding: 0 9px; }
  .order-table th:nth-child(6), .order-table td:nth-child(6) { display: none; }
  .admin-body { padding: 18px 12px 26px; }
  .modal { padding: 12px; }
  .modal-card { padding: 16px; max-height: calc(100vh - 24px); }
  .field input { font-size: 16px; }
}

/* ---------- 本地服务状态 ---------- */
.svc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .75);
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.svc-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.svc-chip.is-on { color: var(--safe); border-color: rgba(23, 121, 95, .28); background: var(--safe-soft); }
.svc-chip.is-off { color: var(--danger); border-color: rgba(178, 59, 44, .24); background: var(--danger-soft); }

.channel-list { display: grid; gap: 6px; margin: 12px 0 8px; }

.channel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfaf7;
  font-size: 12px;
}

.channel-row b { font-weight: 650; }
.channel-row span:last-child { color: var(--muted); margin-left: auto; text-align: right; }

.channel-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
}

.channel-dot.is-ready { background: var(--safe); box-shadow: 0 0 0 3px rgba(23, 121, 95, .14); }
.channel-dot.is-off { background: var(--line-strong); }

.config-list {
  margin: 4px 0 10px;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  line-height: 1.6;
}

/* ---------- 后台日期筛选 ---------- */
.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--ink-2);
}

.date-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-range input[type="date"] {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fbfaf7;
  font-size: 12.5px;
}

.date-range input[type="date"]:focus {
  outline: none;
  border-color: #9a9489;
  background: #fff;
}

.date-sep { color: var(--muted); }



/* ---------- 手机扫码下载（后台订单详情） ---------- */
.qr-wrap {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 6px;
}
.qr-box {
  width: 168px;
  height: 168px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-loading {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 0 6px;
  line-height: 1.6;
}
.qr-info { flex: 1; min-width: 200px; }
.qr-url {
  margin: 4px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  word-break: break-all;
}
