/* ===== 调色板：所有颜色都在这里。下面的规则只用变量，夜间模式只需换这一组值。 ===== */
:root {
  color-scheme: light;
  --bg: #f6f5f1; --card: #fff; --ink: #1f2428; --muted: #6b7280; --line: #e4e2dc;
  --accent: #0f6e63; --accent-ink: #fff; --warn: #a4570b; --warn-bg: #fdf1e0; --on-warn: #fff; --warn-hover: #fbe6c8;
  --bad: #a3271f; --bad-bg: #fbe9e7; --ok: #1d6b3a; --ok-bg: #e5f4ea; --ok-line: #cfe6d8;
  --price: #0b5a51; --band-a: #e5f4ea; --band-b: #f3f8ef;
  --field: #fff; --field-line: #cfcdc6; --soft: #f1f0eb; --soft-2: #e6e5dd; --soft-3: #d9d7ce; --faint: #a8a69c;
  --bar: rgba(255, 255, 255, .92); --shade: rgba(31, 36, 40, .10); --shade-strong: rgba(31, 36, 40, .28); --scrim: rgba(31, 36, 40, .45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1413; --card: #191f1d; --ink: #e6eae8; --muted: #9aa6a2; --line: #2b3432;
    --accent: #4cc2b0; --accent-ink: #05221e; --warn: #e6ab5c; --warn-bg: #38290f; --on-warn: #2a1a04; --warn-hover: #463413;
    --bad: #f2928a; --bad-bg: #3c1b18; --ok: #74d39b; --ok-bg: #15301f; --ok-line: #25483a;
    --price: #62d3c2; --band-a: #143029; --band-b: #1a2a22;
    --field: #121817; --field-line: #3a4542; --soft: #232b29; --soft-2: #2c3634; --soft-3: #3a4643; --faint: #6f7b77;
    --bar: rgba(25, 31, 29, .92); --shade: rgba(0, 0, 0, .35); --shade-strong: rgba(0, 0, 0, .6); --scrim: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1413; --card: #191f1d; --ink: #e6eae8; --muted: #9aa6a2; --line: #2b3432;
  --accent: #4cc2b0; --accent-ink: #05221e; --warn: #e6ab5c; --warn-bg: #38290f; --on-warn: #2a1a04; --warn-hover: #463413;
  --bad: #f2928a; --bad-bg: #3c1b18; --ok: #74d39b; --ok-bg: #15301f; --ok-line: #25483a;
  --price: #62d3c2; --band-a: #143029; --band-b: #1a2a22;
  --field: #121817; --field-line: #3a4542; --soft: #232b29; --soft-2: #2c3634; --soft-3: #3a4643; --faint: #6f7b77;
  --bar: rgba(25, 31, 29, .92); --shade: rgba(0, 0, 0, .35); --shade-strong: rgba(0, 0, 0, .6); --scrim: rgba(0, 0, 0, .6);
}
/* ===== 调色板结束 ===== */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* 顶栏：固定在屏幕顶部，一行。左边图标和名字，中间导航，右边账号菜单。 */
header.top { position: sticky; top: 0; z-index: 70; background: var(--bar); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  padding: env(safe-area-inset-top) max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); }
.top-in { display: flex; align-items: center; gap: 20px; max-width: 1088px; margin: 0 auto; min-height: 56px; }
header.top .brand { flex: none; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); }
header.top .brand:hover { text-decoration: none; }
header.top .brand img { width: 30px; height: 30px; border-radius: 8px; display: block; }
header.top nav { flex: 1; min-width: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
header.top nav::-webkit-scrollbar { display: none; }
header.top nav a { flex: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; }
header.top nav a:hover { color: var(--ink); background: var(--soft); text-decoration: none; }
header.top nav a.on { color: var(--accent); background: var(--ok-bg); font-weight: 600; }
.acct { flex: none; position: relative; margin-left: auto; }
.acct > summary { list-style: none; display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 14px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.acct > summary::-webkit-details-marker { display: none; }
.acct > summary:hover, .acct[open] > summary { border-color: var(--accent); }
.acct-avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 14px; line-height: 1; }
.acct-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-caret { display: block; color: var(--muted); transition: transform .15s; }
.acct[open] .acct-caret { transform: rotate(180deg); }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 248px; padding: 6px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 14px 40px var(--shade-strong); }
.acct-who { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.acct-who strong { font-size: 15px; }
.acct-who span { font-size: 13px; color: var(--muted); }
.acct-menu a, .acct-menu .acct-out { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink);
  font-size: 15px; text-align: left; min-height: 0; }
.acct-menu a:hover, .acct-menu .acct-out:hover { background: var(--soft); text-decoration: none; }
.acct-menu form { margin: 0; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 6px; }
.acct-menu .acct-out { color: var(--bad); }
.theme-pick { padding: 8px 10px 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.theme-pick > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.theme-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; border-radius: 10px; background: var(--soft); }
.theme-seg button { min-height: 34px; padding: 4px 0; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 13.5px; }
.theme-seg button[aria-pressed=true] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px var(--shade); }
main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.bar h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn, button { display: inline-block; font: inherit; padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.btn:hover, button:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger, button.danger { color: var(--bad); }
.btn.small, button.small { padding: 3px 9px; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.plain { background: var(--soft); color: var(--muted); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--soft); display: block; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
form.stack p, .field { margin: 0 0 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=search], input[type=month], select, textarea {
  font: inherit; width: 100%; max-width: 520px; padding: 7px 9px; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
textarea { max-width: 100%; min-height: 180px; }
td input[type=number], td input[type=text], td select { max-width: none; min-width: 80px; }
input[type=checkbox] { width: auto; margin-right: 6px; }
label.check { white-space: nowrap;  display: inline-flex; align-items: center; color: var(--ink); font-size: 15px; }
.errorlist { list-style: none; margin: 0 0 4px; padding: 0; color: var(--bad); font-size: 13px; }
.helptext { color: var(--muted); font-size: 13px; }
.messages { list-style: none; margin: 0 0 16px; padding: 0; }
.msg { padding: 9px 12px; border-radius: 6px; background: var(--ok-bg); color: var(--ok); margin-bottom: 6px; }
.msg.error { background: var(--bad-bg); color: var(--bad); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; }
.gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.gallery img { height: 150px; border-radius: 8px; border: 1px solid var(--line); }
.copy { white-space: pre-wrap; margin: 0; font: inherit; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

/* 图片放大查看 */
.gallery a { cursor: zoom-in; display: block; line-height: 0; }
body.lb-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .88); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: calc(100vw - 140px); max-height: calc(100vh - 80px); object-fit: contain; border-radius: 6px; background: #fff; }
.lightbox button { position: absolute; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.lightbox button:hover, .lightbox button:focus-visible { background: rgba(255, 255, 255, .34); outline: none; }
.lightbox button[hidden], .lb-count[hidden] { display: none; }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; }
@media (max-width: 600px) { .lightbox img { max-width: 100vw; max-height: calc(100vh - 120px); border-radius: 0; } }

/* 图片上传区 */
.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: var(--soft); }
.dropzone .dz-hint { margin: 0 0 8px; color: var(--muted); }
.dropzone:not(.js) .dz-hint { display: none; }
.dropzone.js input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone label.dz-pick { display: inline; margin: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 600; }
.dz-previews { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.dz-previews:not(:empty) { margin-top: 12px; }
.dz-item { position: relative; }
.dz-item img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.dz-item button { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); font-size: 16px; line-height: 1; cursor: pointer; }

/* 登录、身份与订单 */
.narrow { max-width: 460px; margin: 0 auto; }
form.inline { display: inline; margin: 0; }
.imp-bar { background: var(--warn); color: var(--on-warn); padding: 8px 16px; text-align: center; font-size: 14px; }
.imp-bar form { display: inline; margin-left: 10px; }
.role-choice { display: block; width: 100%; padding: 14px; font-size: 16px; text-align: left; }
.role-line { margin: 4px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.act { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.act p { margin: 0; }
label.check { white-space: nowrap;  display: flex; align-items: center; gap: 8px; font-weight: normal; margin: 0; }
tr.row-error td { background: var(--bad-bg); }
details summary { cursor: pointer; color: var(--accent); margin: 8px 0; }

/* 登录页 */
.login { max-width: 380px; margin: 8vh auto 0; }
.login h1 { text-align: center; margin-bottom: 20px; }
.login .card { padding: 24px; }
.login .card p { margin: 0 0 16px; }
.login input[type=text], .login input[type=password] { max-width: none; width: 100%; padding: 10px 12px; }
.login button.primary { width: 100%; padding: 10px; font-size: 16px; }
.login .errorlist { margin: 0 0 14px; }
.login .foot { text-align: center; font-size: 13px; margin-top: 14px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* 产品选择器（下单页） */
select.pp-native { position: absolute; width: 1px; height: 1px; min-width: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.pp { position: relative; min-width: 300px; }
.pp-button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; text-align: left; border: 1px solid var(--field-line); border-radius: 8px; background: var(--field); min-height: 56px; }
.pp-button.empty { color: var(--muted); }
.pp.open .pp-button { border-color: var(--accent); }
.pp-caret { margin-left: auto; color: var(--muted); font-size: 13px; }
.pp-thumb { flex: none; width: 42px; height: 42px; border-radius: 6px; object-fit: cover; background: var(--soft); border: 1px solid var(--line); display: block; }
.pp-text { display: flex; flex-direction: column; min-width: 0; }
.pp-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-prices { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pp-panel { position: absolute; z-index: 50; left: 0; top: calc(100% + 4px); width: max(100%, 360px); max-width: calc(100vw - 32px); background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px var(--shade-strong); padding: 8px; }
.pp-panel[hidden] { display: none; }
.pp-panel .pp-search { width: 100%; max-width: none; margin-bottom: 6px; }
.pp-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pp-option { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: none; text-align: left; }
.pp-option[hidden] { display: none; }
.pp-option:hover, .pp-option:focus-visible { background: var(--soft); outline: none; }
.pp-option[aria-selected=true] { background: var(--ok-bg); }
.pp-clear { color: var(--muted); font-size: 13px; padding: 8px; }
.pp-none { padding: 12px; text-align: center; color: var(--muted); font-size: 13px; }
.card.scroll.has-picker { overflow: visible; }

/* 筛选用的标签条 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.chips-label { font-size: 13px; color: var(--muted); margin-right: 4px; }
.chip, button.chip { display: inline-block; padding: 3px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip.on, button.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#id_tags_text + .chips { margin-top: 8px; }
.filters input[type=search] { min-width: 260px; }

/* 整行可点击 */
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--soft); }
/* 粘贴识别收货信息 */
.paste-box { background: var(--soft); border: 1px dashed var(--line); border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.paste-box textarea { min-height: 0; max-width: none; margin-bottom: 8px; }
.paste-box .helptext { margin: 8px 0 0; }
input.just-filled { background: var(--ok-bg); border-color: var(--ok); }

/* 轮到我处理的订单 */
tr.todo td { background: var(--warn-bg); }
tr.todo td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
tr.todo[data-href]:hover td { background: var(--warn-hover); }
.tag.todo-tag { background: var(--warn); color: var(--on-warn); font-weight: 600; }

/* ===== 手机端 ===== */
html { -webkit-text-size-adjust: 100%; }
body { overflow-wrap: anywhere; }
@media (max-width: 700px) {
  /* 输入框字号不小于 16px，否则 iPhone 聚焦时会自动放大页面 */
  input, select, textarea, button, .btn { font-size: 16px; }
  input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number],
  input[type=date], input[type=search], input[type=month], select, textarea { max-width: none; min-height: 44px; }
  .btn, button { min-height: 44px; padding: 10px 16px; }
  .btn.small, button.small, .chip, button.chip { min-height: 36px; padding: 6px 12px; font-size: 14px; }
  input[type=checkbox] { width: 22px; height: 22px; flex: none; }

  main { padding: 16px 12px calc(48px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .card { padding: 12px; }
  .narrow, .login { max-width: none; }

  /* 顶栏：只留图标，导航可左右滑动（两端渐隐提示还能滑），账号只留头像 */
  header.top { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .top-in { gap: 6px; min-height: 52px; }
  header.top .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  header.top .brand:only-child span { position: static; width: auto; height: auto; clip-path: none; }
  header.top .brand img { width: 34px; height: 34px; }
  header.top nav { padding: 0 10px; -webkit-mask-image: linear-gradient(90deg, transparent, black 12px, black calc(100% - 18px), transparent);
    mask-image: linear-gradient(90deg, transparent, black 12px, black calc(100% - 18px), transparent); }
  header.top nav a { padding: 8px 12px; font-size: 15px; }
  .acct > summary { padding: 3px; border-color: transparent; background: none; }
  .acct-avatar { width: 34px; height: 34px; font-size: 15px; }
  .acct-name, .acct-caret { display: none; }
  .acct-menu { width: min(280px, calc(100vw - 20px)); }
  .acct-menu a, .acct-menu .acct-out { padding: 12px 10px; font-size: 16px; }
  .theme-seg button { min-height: 40px; font-size: 14px; }
  .imp-bar { font-size: 13px; }

  .bar .actions, form > .actions { width: 100%; }
  .bar .actions .btn, form > .actions .btn, form > .actions button { flex: 1; text-align: center; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat .value { font-size: 20px; }
  .filters input[type=search] { min-width: 0; width: 100%; }
  .filters select { flex: 1; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips .chip, .chips-label { flex: none; }
  label.check { white-space: normal; align-items: flex-start; flex-wrap: wrap; }
  .act { align-items: stretch; }
  .act button { width: 100%; }
  .act input[type=text], .act input[type=number] { width: 100% !important; }
  details summary { padding: 8px 0; }
  .card.scroll.has-picker { overflow: visible; }

  /* 表格变成一张张卡片：每个格子一行，左边是栏目名，右边是内容 */
  table.cards, table.cards tbody { display: block; }
  table.cards thead { display: none; }
  table.cards tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards td { display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; flex-wrap: wrap;
    padding: 3px 0; border: 0; text-align: right; white-space: normal; background: none !important; box-shadow: none !important; }
  table.cards td::before { content: attr(data-label); flex: none; margin-right: auto; color: var(--muted); font-size: 13px; text-align: left; }
  table.cards td[data-label=""]::before, table.cards td.empty::before { content: none; }
  table.cards td[data-label=""] { justify-content: flex-start; text-align: left; flex-wrap: wrap; gap: 6px; }
  table.cards td.main { font-weight: 600; font-size: 16px; }
  table.cards td.empty { justify-content: center; }
  table.cards td br { display: none; }
  table.cards td:empty { display: none; }
  table.cards tr.todo { background: var(--warn-bg); box-shadow: inset 4px 0 0 var(--warn); }
  table.cards tr[data-href]:active { background: var(--soft); }
  table.cards td .thumb { width: 56px; height: 56px; }
  table.cards td .btn.small { flex: 1; text-align: center; }
  table.cards td input[type=number] { width: 130px !important; min-width: 0; }
  table.cards .role-line { justify-content: flex-end; }

  /* 下单页的商品行：产品占一整行，数量和单价各一行 */
  table.item-table tr { padding: 12px 0; }
  table.item-table tr:first-child { padding-top: 0; }
  table.item-table td { align-items: center; padding: 5px 0; }
  table.item-table td:first-child { display: block; }
  table.item-table td:first-child::before { content: none; }
  table.item-table td > input { width: 55% !important; max-width: 220px; text-align: right; }
  .cols { grid-template-columns: 1fr; }
  table.item-table td .remove-item { margin-left: auto; }
  .pp { min-width: 0; }
  .pp-panel { width: 100%; max-width: none; }
  .pp-list { max-height: 46vh; }
  .pp-option { padding: 8px; min-height: 56px; }
  .pp-prices { white-space: normal; }
  #add-item { width: 100%; }
  .paste-box .actions button { flex: 1; }
}

/* 触屏设备：所有输入控件字号不小于 16px。
   小于 16px 时 iPhone 一点输入框就会把页面放大，而且不会自己缩回去。
   这里的选择器要和上面给输入框定样式的规则一样具体，否则会被那条规则里的 font: inherit 盖掉。 */
@media (max-width: 700px), (pointer: coarse) {
  input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number],
  input[type=date], input[type=search], input[type=month], input:not([type]), select, textarea,
  td input[type=number], td input[type=text], td select, .pp-panel .pp-search, .filters input, .filters select {
    font-size: 16px;
  }
}

/* 以前的收货人、记住登录状态 */
.login label.remember { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.login label.remember input { width: 18px; height: 18px; flex: none; margin: 0; }
.login .helptext { display: block; margin-top: 4px; font-size: 13px; }
.auto-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.3; }
.auto-hint[hidden] { display: none; }
@media (max-width: 700px) { table.cards td .auto-hint { flex-basis: 100%; text-align: right; } }

/* 收货人选择器 */
#recipient-past-box { position: relative; }
.rp { position: relative; max-width: 560px; }
.rp-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 8px 12px; text-align: left; border: 1px solid var(--field-line); border-radius: 10px; background: var(--field); }
.rp.open .rp-button { border-color: var(--accent); }
.rp-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 17px; line-height: 1; }
.rp-avatar.rp-plus { background: var(--ok-bg); color: var(--accent); font-size: 20px; font-weight: 400; }
.rp-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.rp-top { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.rp-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-phone { flex: none; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rp-address { color: var(--muted); font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.rp-button .rp-address { -webkit-line-clamp: 1; line-clamp: 1; }
.rp-count { flex: none; align-self: center; font-size: 12px; color: var(--accent); background: var(--ok-bg); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.rp-caret { flex: none; color: var(--muted); font-size: 13px; }
.rp-panel { position: absolute; z-index: 60; left: 0; top: calc(100% + 4px); width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px var(--shade-strong); padding: 8px; }
.rp-panel[hidden], .rp-backdrop[hidden], .rp-option[hidden], .rp-none[hidden] { display: none; }
.rp-head { display: none; }
.rp-backdrop { display: none; }
.rp-panel .rp-search { width: 100%; max-width: none; margin-bottom: 6px; }
.rp-list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.rp-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none; text-align: left; }
.rp-option:hover, .rp-option:focus-visible { background: var(--soft); outline: none; }
.rp-option[aria-selected=true] { background: var(--ok-bg); }
.rp-new { color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 4px; padding-top: 10px; }
.rp-none { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 700px) {
  /* 手机：从屏幕底部滑出，拇指够得着，行高更大 */
  .rp { max-width: none; }
  .rp-backdrop { display: block; position: fixed; inset: 0; z-index: 90; background: var(--scrim); }
  .rp-panel { position: fixed; z-index: 100; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 82vh; max-height: 82dvh; display: flex; flex-direction: column;
    border: 0; border-radius: 18px 18px 0 0; padding: 6px 14px max(14px, env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px var(--shade-strong); animation: rp-up .18s ease-out; }
  .rp-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 10px; font-size: 17px; }
  .rp-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--soft-3); }
  .rp-close { border: 0; background: var(--soft); width: 36px; height: 36px; min-height: 0; border-radius: 50%; font-size: 22px; line-height: 1; padding: 0; color: var(--muted); }
  .rp-panel .rp-search { font-size: 16px; padding: 10px 12px; margin-bottom: 8px; flex: none; }
  .rp-list { max-height: none; flex: 1; min-height: 0; gap: 0; }
  .rp-option { padding: 12px 4px; min-height: 68px; border-radius: 0; border-bottom: 1px solid var(--line); }
  .rp-option[aria-selected=true] { border-radius: 8px; }
  .rp-name { font-size: 16px; }
  .rp-phone { font-size: 15px; }
  .rp-address { font-size: 14px; }
  .rp-avatar { width: 44px; height: 44px; }
  .rp-new { border-top: 0; border-bottom: 0; margin-top: 0; }
  body.rp-lock { overflow: hidden; }
}
@keyframes rp-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .rp-panel { animation: none; } }

/* 数量加减：左“−”右“＋”，中间是当前数量 */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; background: var(--field);
  overflow: hidden; vertical-align: middle; }
.stepper-btn { flex: none; width: 40px; min-height: 38px; padding: 0; margin: 0; border: 0; border-radius: 0; background: var(--soft);
  font-size: 20px; line-height: 1; color: inherit; cursor: pointer; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.stepper-btn:hover:not(:disabled) { background: var(--soft-2); }
.stepper-btn:active:not(:disabled) { background: var(--soft-3); }
.stepper-btn:disabled { color: var(--faint); cursor: default; }
.stepper-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.stepper input.qty-input, table.cards td .stepper input.qty-input { width: 56px !important; min-width: 0; max-width: none; margin: 0;
  padding: 0 4px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0;
  background: var(--field); text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; box-shadow: none; outline: 0;
  -moz-appearance: textfield; appearance: textfield; cursor: default; }
.stepper input.qty-input::-webkit-inner-spin-button, .stepper input.qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
@media (max-width: 700px) {
  table.cards td:has(.stepper) { align-items: center; }
  .stepper-btn { width: 48px; min-height: 44px; font-size: 22px; }
  .stepper input.qty-input, table.cards td .stepper input.qty-input { width: 60px !important; font-size: 17px; }
}

/* ===== 产品浏览：网格 / 平铺 ===== */
.filters .search-row { display: flex; gap: 8px; align-items: center; flex: 1 1 320px; max-width: 620px; }
.filters .search-row input[type=search] { flex: 1; width: auto; min-width: 0; max-width: none; }
.view-toggle { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; color: var(--muted); }
.filters > .view-toggle { margin-left: auto; }
.view-toggle svg { display: block; }
.view-toggle .icon-list, .view-toggle.is-list .icon-grid { display: none; }
.view-toggle.is-list .icon-list { display: block; }
.view-toggle-text { font-size: 13px; }

.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.plist > .empty { grid-column: 1 / -1; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.pcard { display: flex; flex-direction: column; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; color: var(--ink); -webkit-tap-highlight-color: transparent; transition: box-shadow .15s, transform .15s; }
.pcard:hover { text-decoration: none; box-shadow: 0 6px 18px var(--shade); transform: translateY(-1px); }
.pcard:active { background: var(--soft); }
.pcard-img { display: block; flex: none; aspect-ratio: 1 / 1; background: var(--soft); position: relative; }
.pcard-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard-noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 13px; }
.pcard-body { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px 12px; min-width: 0; flex: 1; }
.pcard-title { font-size: 15px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-tags { display: flex; flex-wrap: wrap; gap: 4px; max-height: 22px; overflow: hidden; }
.pcard-price { margin-top: auto; padding-top: 2px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; color: var(--price); }
.pcard-price small { font-size: 12px; }
.pcard-price b { font-size: 20px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.pcard-sub { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.plist.as-list { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 10px; }
.plist.as-list .pcard { flex-direction: row; }
.plist.as-list .pcard-img { width: 132px; margin: 10px 0 10px 10px; border-radius: 8px; overflow: hidden; align-self: flex-start; }
.plist.as-list .pcard-body { padding: 10px 12px; }
.plist.as-list .pcard-tags { max-height: 46px; }

/* ===== 产品详情：上面图片轮播，下面信息 ===== */
.pd { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 8px; }
.pgal { position: relative; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pgal-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain; aspect-ratio: 1 / 1; outline-offset: -2px; }
.pgal-track::-webkit-scrollbar { display: none; }
.pgal-slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; display: block; cursor: zoom-in; line-height: 0; }
.pgal-slide img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.pgal-none { aspect-ratio: 2 / 1; display: flex; align-items: center; justify-content: center; color: var(--faint); background: var(--soft); }
.pgal-back, .pgal-nav { position: absolute; z-index: 2; width: 38px; height: 38px; min-height: 0; padding: 0 0 3px; border: 0; border-radius: 50%;
  background: rgba(31, 36, 40, .5); color: #fff; font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.pgal-back:hover, .pgal-nav:hover { background: rgba(31, 36, 40, .72); text-decoration: none; }
.pgal-back { top: 12px; left: 12px; }
.pgal-nav { top: calc(50% - 50px); }
.pgal-prev { left: 12px; } .pgal-next { right: 12px; }
.pgal-nav:disabled { opacity: 0; pointer-events: none; }
.pgal-count { position: absolute; z-index: 2; left: 50%; transform: translateX(-50%); bottom: 90px; padding: 1px 12px; border-radius: 999px;
  background: rgba(31, 36, 40, .55); color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; pointer-events: none; }
.pgal-thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; scrollbar-width: none; background: var(--soft); border-top: 1px solid var(--line); }
.pgal-thumbs::-webkit-scrollbar { display: none; }
.pgal-thumb { flex: none; width: 58px; height: 58px; min-height: 0; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #fff; opacity: .7; }
.pgal-thumb.on { border-color: var(--accent); opacity: 1; }
.pgal-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pd-info { min-width: 0; }
.pd-price { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 12px; color: var(--ink);
  background: linear-gradient(100deg, var(--band-a), var(--band-b)); border: 1px solid var(--ok-line); }
.pd-price small { display: block; font-size: 13px; color: var(--muted); }
.pd-price-main b { font-size: 32px; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--price); }
.pd-price-main b.none { font-size: 22px; }
.pd-price-side { text-align: right; }
.pd-price-side span { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pd-title { font-size: 21px; line-height: 1.4; margin: 14px 0 8px; }
.pd-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pd-stats { margin-top: 12px; grid-template-columns: repeat(3, 1fr); }
.pd-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pd-actions .primary { min-width: 140px; text-align: center; }
.pd-danger { margin-top: 28px; }

@media (max-width: 700px) {
  .filters .search-row { flex-basis: 100%; max-width: none; }
  .view-toggle { min-width: 48px; justify-content: center; padding: 8px 10px; }
  .view-toggle-text { display: none; }
  .filters > .view-toggle { margin-left: 0; }

  .plist { grid-template-columns: 1fr 1fr; gap: 8px; }
  .pcard { border-radius: 10px; }
  .pcard-body { padding: 8px 10px 10px; gap: 4px; }
  .pcard-title { font-size: 14.5px; }
  .pcard-price b { font-size: 19px; }
  .plist.as-list { grid-template-columns: 1fr; gap: 8px; }
  .plist.as-list .pcard-img { width: 116px; margin: 8px 0 8px 8px; }
  .plist.as-list .pcard-body { padding: 8px 10px; }
  .plist.as-list .pcard-title { font-size: 15.5px; }

  /* 图片铺满屏幕宽度，紧贴顶栏；操作按钮固定在屏幕底部 */
  .pd { display: block; }
  .pgal { margin: 0 -12px; border: 0; border-radius: 0; }
  main > .pd:first-child .pgal { margin-top: -16px; }
  .pgal-nav { display: none; }
  .pgal-back { width: 40px; height: 40px; }
  .pgal-count { bottom: 86px; }
  .pgal-thumbs { padding: 8px 12px; }
  .pd-price { margin: 0 -12px; border-radius: 0; border-width: 1px 0; padding: 12px 16px; }
  .pd-title { font-size: 19px; margin-top: 12px; }
  .pd-stats { grid-template-columns: repeat(3, 1fr); }
  .pd-stats .stat { padding: 8px 10px; }
  .pd-stats .stat .value { font-size: 16px; }
  .pd-actions { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; margin: 0; flex-wrap: nowrap;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px var(--shade); }
  .pd-actions > * { flex: 1; text-align: center; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
  .pd-actions .primary { flex: 1.6; min-width: 0; }
  body:has(.pd-actions) main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
/* 只有一张图时没有缩略图条，页码也不显示 */
.pgal:not(:has(.pgal-thumbs)) .pgal-count { bottom: 12px; }

/* ===== 购物车 ===== */
.pd-cart { display: inline-flex; align-items: center; gap: 6px; position: relative; }
.pd-cart svg { display: block; flex: none; }
.pd-cart-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.pd-add { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pd-add:hover { background: var(--ok-bg); }

dialog.sheet { width: min(420px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px; color: var(--ink); background: var(--card);
  box-shadow: 0 18px 50px var(--shade-strong); }
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet form { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: flex; gap: 12px; align-items: flex-start; }
.sheet-head img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; }
.sheet-what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sheet-what strong { font-size: 16px; line-height: 1.4; }
.sheet-price { color: var(--price); font-weight: 600; font-variant-numeric: tabular-nums; }
.sheet-close { flex: none; width: 36px; height: 36px; min-height: 0; padding: 0 0 2px; border: 0; border-radius: 50%; background: var(--soft); font-size: 22px; line-height: 1; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.sheet-row label { margin: 0; font-size: 15px; color: var(--ink); }
dialog.sheet .helptext { margin: 0; }
.sheet-submit { width: 100%; padding: 10px 16px; font-weight: 600; }

.cart-box { background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.cart-box-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.cart-box-list { list-style: none; margin: 8px 0 6px; padding: 0; }
.cart-box-list li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px dashed var(--ok-line); }
.cart-box-list li b { flex: none; font-variant-numeric: tabular-nums; }
.cart-box .helptext { margin: 0; }
.cart-box button.danger { background: var(--card); }

@media (max-width: 700px) {
  /* 手机上从底部滑出 */
  dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  dialog.sheet form { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  dialog.sheet[open] { animation: sheet-up .2s ease-out; }
  .sheet-submit { min-height: 48px; }
  .pd-actions .pd-cart { flex: 0 0 auto; flex-direction: column; gap: 0; padding: 2px 10px; font-size: 12px; border: 0; min-width: 56px; }
  .pd-actions .pd-cart .pd-cart-count { position: absolute; top: 0; right: 2px; }
  .pd-actions .pd-add, .pd-actions .primary { flex: 1; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog.sheet[open] { animation: none; } }
