:root {
  --bg: #f6f5f1; --card: #fff; --ink: #1f2428; --muted: #6b7280; --line: #e4e2dc;
  --accent: #0f6e63; --accent-ink: #fff; --warn: #a4570b; --warn-bg: #fdf1e0;
  --bad: #a3271f; --bad-bg: #fbe9e7; --ok: #1d6b3a; --ok-bg: #e5f4ea;
}
* { 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 { background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; padding: 12px 24px; }
header.top .brand { font-weight: 700; font-size: 17px; color: var(--ink); }
header.top nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
header.top nav a { color: var(--muted); }
header.top nav a.on { color: var(--accent); font-weight: 600; }
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: #eeede8; color: var(--muted); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #eee; 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 #cfcdc6; border-radius: 6px; background: #fff; }
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: rgba(0, 0, 0, .04); }
.dropzone .dz-hint { margin: 0 0 8px; color: var(--muted, #666); }
.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: #333; color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }

/* 登录、身份与订单 */
.narrow { max-width: 460px; margin: 0 auto; }
.top .who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.top .who form, form.inline { display: inline; margin: 0; }
.imp-bar { background: var(--warn); color: #fff; 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 #cfcdc6; border-radius: 8px; background: #fff; 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: #eeece6; 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: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .14); 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: #f1f0eb; 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; }
