/* ============ 基础 ============ */
:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e6e8ee;
  --line-strong: #d5d9e2;
  --bg: #f4f5f7;
  --card: #ffffff;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eef3ff;
  --danger: #e11d48;
  --ok: #0f766e;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 26px -12px rgba(15, 23, 42, .18);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body.locked { overflow: hidden; }

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, textarea, select {
  font: inherit;
  color: inherit;
}

h1, h2, h3, p { margin: 0; }

.app {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(96px + var(--safe-b));
}

/* ============ 顶栏 ============ */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 10px;
  background: linear-gradient(180deg, #fff 0%, #fff 62%, rgba(255, 255, 255, 0) 100%);
}

.topbar h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .02em;
}

.sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, background .15s ease;
}

.icon-btn:active { transform: scale(.94); background: #f8fafc; }

/* ============ 提示条 ============ */
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 16px 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fff8ed;
  border: 1px solid #f6e3c4;
  color: #8a5a12;
  font-size: 12.5px;
}

.notice span { flex: 1; min-width: 0; }

.link-btn {
  flex: none;
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============ 搜索 ============ */
.search-wrap {
  position: relative;
  margin: 0 16px 10px;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}

#search {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 15px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}

#search::placeholder { color: var(--muted-2); }

#search:focus {
  border-color: #b9ccff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

#search::-webkit-search-cancel-button { display: none; }

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #eef1f6;
  font-size: 12px;
}

/* ============ 分类 ============ */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 16px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
  transition: all .15s ease;
}

.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 600;
}

.chip:active { transform: scale(.97); }

/* ============ 大项目入口 ============ */
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.cat-card:active { background: #fbfcff; }

.cat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cat-name {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
}

.cat-meta { font-size: 12px; color: var(--muted); }

.cat-side {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-picked {
  font-style: normal;
  font-size: 10.5px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  padding: 2px 6px;
  border-radius: 6px;
}

.cat-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -16px 8px;
  padding: 8px 16px 10px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(244, 245, 247, 0));
}

.back-btn {
  flex: none;
  padding: 6px 10px 6px 2px;
  font-size: 13px;
  color: var(--brand-dark);
}

.cat-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.item-cat {
  margin-bottom: 1px;
  font-size: 10.5px;
  color: var(--muted-2);
}

.search-head {
  margin: 2px 2px 8px;
  font-size: 12px;
  color: var(--muted);
}

/* ============ 汇率卡片 ============ */
.fx-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 16px 10px;
  padding: 11px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.fx-left { flex: 1; min-width: 0; }

.fx-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.fx-pair {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--muted);
}

.fx-rate {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.fx-flag {
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
}

.fx-flag.live { background: #e6f6ee; color: #0f766e; }
.fx-flag.cached { background: #fff4e5; color: #b45309; }
.fx-flag.manual { background: #eef3ff; color: #1d4ed8; }
.fx-flag.base { background: #f1f3f7; color: #64748b; }

.fx-meta {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fx-refresh {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 12.5px;
  color: var(--ink-2);
}

.fx-refresh:active { background: #f1f5f9; }
.fx-refresh:disabled { opacity: .5; }

.fx-delta {
  margin-left: 6px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.fx-delta.up { color: var(--danger); }
.fx-delta.down { color: var(--ok); }

.fx-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted-2);
}

.fx-warn { color: var(--danger); font-weight: 600; }

.fx-live {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}

.fx-live .mini-btn {
  flex: none;
  white-space: nowrap;
  height: 28px;
}

/* ============ 商品列表 ============ */
.list {
  padding: 0 16px;
}

.group-title {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 -16px;
  padding: 8px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--muted);
  background: linear-gradient(180deg, var(--bg) 62%, rgba(244, 245, 247, 0) 100%);
  backdrop-filter: blur(2px);
}

.group-title > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-add {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 15px;
  line-height: 1;
}

.group-add:active { background: #eef3ff; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.item.picked {
  border-color: #c7d7fe;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .06);
}

.item-info { flex: 1; min-width: 0; }

.item { cursor: pointer; }

.item:active { background: #fbfcff; }

.item-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  margin-top: 1px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-price {
  margin-top: 5px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -.01em;
}

.item-price .unit {
  margin-left: 1px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted-2);
}

.item-action { flex: none; }

.add-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  font-weight: 400;
  color: var(--brand);
  background: var(--brand-soft);
  transition: transform .12s ease, background .15s ease;
}

.add-btn:active { transform: scale(.9); background: #dfe8ff; }

/* 数量步进 */
.stepper {
  display: inline-flex;
  align-items: center;
  height: 36px;
  border-radius: 11px;
  background: var(--brand-soft);
  overflow: hidden;
}

.stepper .step {
  width: 32px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 17px;
  color: var(--brand-dark);
}

.stepper .step:active { background: #dfe8ff; }

.stepper .step-val,
.stepper .step-input {
  min-width: 26px;
  width: 34px;
  height: 100%;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
  padding: 0;
}

.stepper .step-input { -webkit-appearance: none; appearance: none; }

/* 空状态 */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #e9ecf2;
  color: var(--muted);
  font-size: 22px;
}

.empty p { font-size: 14px; }
.empty .hint { margin-top: 4px; font-size: 12.5px; color: var(--muted-2); }

/* ============ 底部购物条 ============ */
.cartbar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 30;
  width: calc(100% - 24px);
  max-width: 656px;
  height: 58px;
  padding: 0 8px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 18px;
  background: rgba(17, 24, 39, .96);
  color: #fff;
  box-shadow: 0 12px 30px -10px rgba(15, 23, 42, .55);
  backdrop-filter: blur(10px);
  transition: transform .2s ease, opacity .2s ease;
}

.cartbar:active { transform: translateX(-50%) scale(.985); }

.cartbar-left, .cartbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cart-badge {
  flex: none;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, .14);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cart-label {
  font-size: 13px;
  color: rgba(255, 255, 255, .66);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-total {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.cartbar-right svg { color: rgba(255, 255, 255, .5); }

/* ============ 面板（报价单编辑） ============ */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32, .72, 0, 1), visibility 0s linear .32s;
  visibility: hidden;
}

.sheet.open {
  transform: translateY(0);
  visibility: visible;
  transition: transform .32s cubic-bezier(.32, .72, 0, 1), visibility 0s linear 0s;
}

.sheet-head {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  font-size: 16px;
  font-weight: 700;
}

.sheet-head .text-btn:last-child { justify-self: end; }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 20px;
}

.sheet-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px -14px rgba(15, 23, 42, .3);
}

.foot-total { flex: 1; min-width: 0; }

.foot-label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

.foot-total strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.text-btn {
  font-size: 14px;
  color: var(--brand-dark);
  padding: 8px 4px;
  border-radius: 8px;
}

.text-btn:active { opacity: .6; }

.text-btn.danger { color: var(--danger); }

.primary-btn {
  flex: none;
  height: 46px;
  padding: 0 22px;
  border-radius: 13px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 6px 16px -8px rgba(37, 99, 235, .8);
  transition: transform .12s ease, background .15s ease;
}

.primary-btn:active { transform: scale(.97); background: var(--brand-dark); }

.primary-btn.small { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 10px; }

.ghost-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 13px;
  color: var(--ink-2);
}

.ghost-btn:active { background: #f1f5f9; }

/* ============ 明细行 ============ */
.line {
  padding: 10px 12px 12px;
  margin-bottom: 8px;
  background: #fff;
  border-radius: 13px;
  box-shadow: var(--shadow-sm);
}

.line-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.line-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.line-spec {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 1px;
}

.line-del {
  flex: none;
  width: 26px;
  height: 26px;
  margin: -4px -4px 0 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted-2);
  background: #f6f7f9;
}

.line-del:active { background: #eef1f5; color: var(--danger); }

.line-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
}

.stepper.small { height: 32px; }
.stepper.small .step { width: 30px; height: 32px; font-size: 16px; }
.stepper.small .step-val,
.stepper.small .step-input { width: 32px; font-size: 13px; }

.price-box {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  font-size: 13px;
  color: var(--muted);
}

.price-box input {
  width: 68px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  padding: 0;
}

.price-box:focus-within {
  border-color: #b9ccff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

.line-amt {
  margin-left: auto;
  font-size: 14.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-lines {
  padding: 34px 16px;
  margin-bottom: 8px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: #fff;
  border-radius: 13px;
  border: 1px dashed var(--line-strong);
}

/* ============ 表单 ============ */
.section-label {
  margin: 18px 2px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--muted);
}

.form {
  background: #fff;
  border-radius: 13px;
  padding: 2px 12px;
  box-shadow: var(--shadow-sm);
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f2f5;
}

.field:last-child { border-bottom: 0; }

.field > span {
  flex: none;
  width: 72px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.field input,
.field textarea,
.field select {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.field textarea {
  text-align: left;
  resize: none;
  line-height: 1.5;
  padding: 6px 0;
  min-height: 58px;
}

.field input::placeholder,
.field textarea::placeholder { color: var(--muted-2); }

.field.stack {
  display: block;
  padding: 10px 0;
}

.field.stack > span {
  display: block;
  width: auto;
  margin-bottom: 6px;
}

.field.stack textarea { width: 100%; }

.discount-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.field.stack .discount-row {
  flex: none;
  justify-content: flex-start;
  margin-top: 2px;
}

.discount-row .chip {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.discount-input {
  flex: 0 0 46px !important;
  width: 46px !important;
  text-align: center !important;
  border-bottom: 1px solid var(--line-strong) !important;
  font-weight: 600;
}

.switch {
  flex: none;
  position: relative;
  width: 46px;
  height: 28px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  z-index: 1;
}

.switch i {
  display: block;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: #dfe3ea;
  transition: background .18s ease;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .18s ease;
}

.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ============ 合计 ============ */
.totals {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 13px;
  box-shadow: var(--shadow-sm);
}

.trow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.trow span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.trow.minus span:last-child { color: var(--danger); }

.trow.grand {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-strong);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.trow.grand span:last-child { font-size: 19px; font-weight: 700; }

.trow .muted { color: var(--muted); font-weight: 400; }

.trow.quote-no {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--muted);
}

.trow.quote-no span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}

.mini-btn {
  height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 11.5px;
  color: var(--brand-dark);
}

.mini-btn:active { background: #f1f5f9; }

.switch-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-left: 4px;
  white-space: nowrap;
}

.primary-btn:disabled {
  opacity: .38;
  box-shadow: none;
}

.primary-btn:disabled:active { transform: none; background: var(--brand); }

/* ============ 预览 / 文档 ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #e9ebef;
  animation: fadeUp .2s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.overlay-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.overlay-bar h2 {
  font-size: 15px;
  font-weight: 700;
}

.bar-spacer { width: 52px; }

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

.overlay-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 40px;
}

.quote-doc {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 30px 28px 34px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 30px -12px rgba(15, 23, 42, .35);
  color: #111827;
  font-size: 12.5px;
  line-height: 1.6;
}

.quote-doc::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--wm, none);
  background-repeat: repeat;
  pointer-events: none;
}

.doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid #111827;
}

.doc-company h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
}

.doc-company p {
  margin-top: 3px;
  font-size: 11px;
  color: #4b5563;
  line-height: 1.5;
}

.doc-title {
  flex: none;
  text-align: right;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .28em;
  color: #111827;
  padding-right: 2px;
}

.doc-title small {
  display: block;
  margin-top: 2px;
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: .16em;
  color: #6b7280;
  text-transform: uppercase;
}

.doc-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 10px;
  font-size: 11.5px;
  color: #374151;
}

.doc-meta > div:last-child { text-align: right; }

.doc-customer {
  padding: 0 0 10px;
  font-size: 11.5px;
  color: #374151;
}

.doc-meta b { font-weight: 600; color: #111827; }

.doc-meta .span2 { grid-column: span 2; }

table.doc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
  margin-top: 4px;
}

table.doc-table th {
  padding: 7px 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  background: #1f2937;
  border: 1px solid #1f2937;
  white-space: nowrap;
}

table.doc-table td {
  padding: 6px 5px;
  border: 1px solid #d1d5db;
  vertical-align: top;
  word-break: break-word;
}

table.doc-table .c { text-align: center; }
table.doc-table .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.doc-table .muted { color: #6b7280; }

table.doc-table tr.grp td {
  background: #f3f4f6;
  padding: 7px 8px;
  font-weight: 600;
  color: #111827;
}

table.doc-table tr.sub td {
  background: #fafafa;
  font-weight: 600;
  color: #111827;
}

table.doc-table tr.sub td:first-child {
  text-align: right;
  font-weight: 500;
  color: #4b5563;
}

.doc-summary {
  margin: 0 0 0 auto;
  width: 62%;
  min-width: 240px;
  border: 1px solid #d1d5db;
  border-top: 0;
  padding: 8px 10px;
  font-size: 11.5px;
}

.doc-summary .srow {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}

.doc-summary .srow em { font-style: normal; color: #4b5563; }
.doc-summary .srow b { font-variant-numeric: tabular-nums; }

.doc-summary .srow.total {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed #9ca3af;
  font-size: 13px;
  font-weight: 700;
}

.doc-capital {
  margin-top: 8px;
  font-size: 11.5px;
  color: #111827;
}

.doc-capital span { color: #6b7280; }

.doc-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #374151;
  white-space: pre-line;
}

.doc-foot {
  border-top: 0;
  padding-top: 6px;
  color: #9ca3af;
  font-size: 10.5px;
}

.doc-sign {
  display: flex;
  gap: 24px;
  margin-top: 26px;
  font-size: 11px;
  color: #374151;
}

.doc-sign div { flex: 1; }
.doc-sign u { display: block; margin-top: 26px; border-bottom: 1px solid #9ca3af; text-decoration: none; }

/* ============ 预览底部操作 ============ */
.preview-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px -18px rgba(15, 23, 42, .5);
}

.preview-actions .ghost-btn { height: 46px; flex: none; padding: 0 16px; }
.preview-actions .save-btn { flex: 1; }

/* ============ 报价单图片 ============ */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: #0b1220;
  animation: fadeUp .2s ease both;
}

.image-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  color: #fff;
}

.image-bar .text-btn { color: #fff; }

.image-title {
  font-size: 15px;
  font-weight: 600;
}

.image-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(26px + var(--safe-b));
  text-align: center;
}

.image-scroll img {
  display: block;
  width: 100%;
  max-width: 620px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 50px -14px rgba(0, 0, 0, .7);
}

.image-tip {
  margin: 14px auto 12px;
  max-width: 420px;
  font-size: 12.5px;
  line-height: 1.6;
  color: rgba(255, 255, 255, .72);
}

.image-scroll .ghost-btn {
  height: 40px;
  background: transparent;
  border-color: rgba(255, 255, 255, .35);
  color: #fff;
}

/* ============ 票价标签 / 项目内切换 ============ */
.spec-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.spec-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 9px;
  background: #f4f6f9;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.spec-pill em {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.spec-pill.on {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.spec-pill.on em { color: var(--brand-dark); }

.chev {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--muted-2);
  font-size: 22px;
  line-height: 1;
}

.spec-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 12px;
  padding: 2px 2px 4px;
  scrollbar-width: none;
}

.spec-tabs::-webkit-scrollbar { display: none; }

.spec-tab {
  flex: none;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
}

.spec-tab span { font-size: 12px; color: var(--muted); }

.spec-tab b {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.spec-tab i {
  font-style: normal;
  font-size: 10px;
  color: var(--ok);
}

.spec-tab.on {
  border-color: var(--brand);
  background: #f5f8ff;
}

.spec-tab.on span { color: var(--brand-dark); font-weight: 600; }
.spec-tab.on b { color: var(--brand-dark); }

/* 报价汇率选择 */
.rate-card {
  margin: 0 0 12px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.rate-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 9px;
}

.rate-head span {
  font-size: 12px;
  color: var(--muted);
}

.rate-head b {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rate-head em {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  color: var(--muted-2);
}

.rate-chips {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.rate-chip {
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  color: var(--ink-2);
}

.rate-chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 600;
}

.rate-input {
  width: 66px;
  height: 30px;
  padding: 0 8px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfd;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.rate-input:focus {
  border-color: #b9ccff;
  background: #fff;
}

.rate-real {
  margin: 10px 2px 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: #eef7f1;
  color: #0f766e;
  font-size: 12px;
  line-height: 1.6;
}

/* ============ 单品定价面板 ============ */
.price-head { padding: 2px 2px 14px; }

.price-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -.01em;
}

.price-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.amount-card {
  padding: 13px 16px 14px;
  margin-bottom: 10px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.amount-card label {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--muted);
}

.amount-input {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.amount-input > span {
  font-size: 22px;
  font-weight: 600;
  color: var(--muted);
}

.amount-input input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.profit-card {
  padding: 12px 16px 13px;
  margin-bottom: 12px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.profit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profit-row label {
  font-size: 13px;
  color: var(--ink-2);
}

.profit-input {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.profit-input > span {
  font-size: 15px;
  color: var(--muted);
}

.profit-input input {
  width: 96px;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  outline: none;
  background: transparent;
  text-align: right;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.profit-card em {
  display: block;
  margin-top: 9px;
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted-2);
}

.bd-card {
  padding: 4px 16px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.bd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid #f0f2f5;
  font-size: 13.5px;
}

.bd-row:last-child { border-bottom: 0; }

.bd-row span {
  flex: none;
  width: 92px;
  color: var(--ink-2);
}

.bd-row em {
  flex: 1;
  min-width: 0;
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted-2);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-row b {
  flex: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bd-row.strong b { font-size: 15px; }

.bd-row.cur {
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  background: #f5f8ff;
}

.bd-row.cur span { color: var(--brand-dark); font-weight: 600; }
.bd-row.cur b { color: var(--brand-dark); }

.bd-sep {
  height: 1px;
  margin: 5px -16px;
  background: var(--line);
}

.price-tip {
  margin: 12px 2px 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted-2);
}

.price-foot { gap: 12px; }
.price-foot .ghost-btn { height: 46px; flex: none; padding: 0 18px; }
.price-foot .primary-btn { flex: 1; }

.picked-tag {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 10px;
  font-weight: 600;
  vertical-align: 2px;
}

.add-btn.picked {
  background: var(--brand);
  color: #fff;
  font-size: 15px;
}

.add-item-card {
  display: block;
  width: 100%;
  margin: 6px 0 14px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 14px;
  font-weight: 600;
}

.add-item-card:active { background: #f7faff; }

.add-sub-link {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}

.add-sub-link:active { background: #f7faff; }

/* ============ 截图模式 ============ */
#preview.capture { background: #fff; }

#preview.capture .overlay-bar,
#preview.capture .preview-actions,
#preview.capture .no-print { display: none !important; }

#preview.capture .overlay-scroll {
  padding: 0;
  background: #fff;
}

#preview.capture .quote-doc {
  max-width: none;
  width: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

.capture-hint {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .84);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}

/* ============ 设置 ============ */
.settings { max-width: 680px; margin: 0 auto; }

.settings .card {
  background: #fff;
  border-radius: 13px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.settings h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 6px;
}

.settings .field > span { width: 84px; }

.settings .field.stack > span { width: auto; }

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 6px 0 10px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn-row .ghost-btn { height: 38px; }

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

.file-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-b));
  transform: translate(-50%, 12px);
  z-index: 90;
  max-width: min(88vw, 460px);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(17, 24, 39, .94);
  color: #fff;
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============ 打印 ============ */
@media (max-width: 480px) {
  /* iOS 上输入框小于 16px 会自动放大页面，这里统一顶到 16px */
  #search,
  .field input,
  .field textarea,
  .field select,
  .discount-input,
  .price-box input,
  .rate-input {
    font-size: 16px;
  }

  .price-box input { width: 76px; }
}

@media (max-width: 520px) {
  .quote-doc { padding: 22px 16px 26px; }
  .doc-company h1 { font-size: 15px; }
  .doc-title { font-size: 17px; letter-spacing: .2em; }
  .doc-summary { width: 100%; min-width: 0; }
  table.doc-table { font-size: 10.5px; }
  table.doc-table th,
  table.doc-table td { padding: 5px 4px; }
  .doc-sign { gap: 14px; }
}

@media print {
  @page { size: A4; margin: 13mm; }

  html, body {
    background: #fff !important;
    height: auto !important;
    overflow: visible !important;
  }

  .app, .sheet, .toast, .no-print, .overlay-bar, #settings { display: none !important; }

  #preview {
    position: static !important;
    display: block !important;
    background: #fff !important;
    animation: none !important;
    overflow: visible !important;
  }

  .overlay-scroll {
    overflow: visible !important;
    padding: 0 !important;
  }

  .quote-doc {
    max-width: none !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    font-size: 10.5pt;
  }

  table.doc-table, .doc-summary { page-break-inside: avoid; }
  tr { page-break-inside: avoid; }

  table.doc-table { font-size: 9.5pt; }
  table.doc-table th,
  table.doc-table td { padding: 6px 6px; }

  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
