/* ============================================================
   八方汇 H5 设计系统 v1.0 ·「炭灰翡翠」
   最高级别标准：真实摄影 / 发丝线分割 / 大留白 / 微动效 / 安全区适配
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --ink: #232E38;
  --ink-2: #5B6B79;
  --ink-3: #93A1AC;
  --jade: #0E9F74;
  --jade-deep: #0B7A59;
  --jade-50: #E9F6F1;
  --jade-100: #D2EDE3;
  --gold: #C9A961;
  --gold-deep: #A8863D;
  --gold-50: #F8F1E2;
  --red: #E5484D;
  --red-50: #FDECEC;
  --amber: #E8871E;
  --amber-50: #FDF1E3;
  --blue: #2E7CD6;
  --blue-50: #E9F2FC;
  --violet: #7A5AF8;
  --violet-50: #F0EDFE;
  --bg: #F5F7F6;
  --card: #FFFFFF;
  --line: rgba(24, 39, 52, .08);
  --line-2: rgba(24, 39, 52, .16);
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --shadow-s: 0 1px 2px rgba(18, 32, 44, .05);
  --shadow-m: 0 2px 6px rgba(18, 32, 44, .05), 0 12px 32px rgba(18, 32, 44, .08);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 56px;
}

/* ---------- Reset & Base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + var(--sab) + 12px);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { text-decoration: none; color: inherit; }
ul, li, ol { list-style: none; }
img { display: block; }
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Page header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 100;
  padding: calc(var(--sat) + 10px) 16px 10px;
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 0.5px solid var(--line);
}
.app-header.transparent {
  background: transparent; border-bottom: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
  transition: background .25s, border-color .25s;
}
.app-header.transparent.solid {
  background: rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 0.5px solid var(--line);
}
.hdr-row { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.hdr-title { font-size: 17px; font-weight: 500; flex: 1; display: flex; align-items: center; gap: 8px; }
.hdr-title .sub { font-size: 11px; color: var(--ink-3); font-weight: 400; }
.hdr-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--jade-deep);
  padding: 6px 12px; border-radius: 999px;
  background: var(--jade-50); font-weight: 500;
}
.hdr-btn:active { transform: scale(.95); }
.hdr-back {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); border: 0.5px solid var(--line);
  color: var(--ink); margin-right: 2px;
}
.hdr-back:active { transform: scale(.92); }

/* ---------- Search ---------- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: rgba(24, 39, 52, .05);
  border-radius: 12px; padding: 9px 12px; margin-top: 10px;
  border: 1px solid transparent;
  transition: border-color .2s, background .2s;
}
.search-box:focus-within { background: #fff; border-color: var(--jade); }
.search-box svg { color: var(--ink-3); flex-shrink: 0; }
.search-box input { flex: 1; border: none; outline: none; background: transparent; font-size: 14px; color: var(--ink); }
.search-box input::placeholder { color: var(--ink-3); }

/* ---------- Section ---------- */
.sec { padding: 0 16px; }
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 22px 16px 12px;
}
.sec-head .t { font-size: 18px; font-weight: 500; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.sec-head .t .en { font-size: 11px; color: var(--ink-3); font-weight: 400; letter-spacing: 1px; text-transform: uppercase; }
.sec-head .more { font-size: 13px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 2px; }
.sec-head .more:active { color: var(--jade-deep); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 200;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--line);
  display: flex;
  padding-bottom: var(--sab);
}
.tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px; color: var(--ink-3); position: relative;
  transition: color .18s;
}
.tabbar .tab .lbl { font-size: 10px; letter-spacing: .3px; }
.tabbar .tab.active { color: var(--jade-deep); font-weight: 500; }
.tabbar .tab:active { transform: scale(.94); }
.tabbar .tab .ic-wrap {
  width: 44px; height: 26px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s;
}
.tabbar .tab.active .ic-wrap { background: var(--jade-50); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 12px; font-size: 15px; font-weight: 500;
  padding: 13px 22px; transition: transform .12s, opacity .12s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--jade-deep); color: #fff; box-shadow: var(--shadow-s); }
.btn-jade { background: var(--jade); color: #fff; }
.btn-gold { background: linear-gradient(135deg, #D9BC7E, #B9924B); color: #fff; }
.btn-ghost { border: 1px solid var(--line-2); color: var(--ink); background: #fff; }
.btn-soft { background: var(--jade-50); color: var(--jade-deep); }
.btn-danger-soft { background: var(--red-50); color: var(--red); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 15px 24px; font-size: 16px; border-radius: 14px; }

/* ---------- Chips / filter ---------- */
.chip-scroll {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.chip-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; color: var(--ink-2);
  background: #fff; border: 1px solid var(--line);
  scroll-snap-align: start; transition: all .15s;
}
.chip:active { transform: scale(.95); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 500; }
.chip svg { width: 14px; height: 14px; }

.seg {
  display: flex; background: rgba(24, 39, 52, .05); border-radius: 11px; padding: 3px; margin: 12px 16px 0;
}
.seg button {
  flex: 1; padding: 8px 0; font-size: 13px; color: var(--ink-2);
  border-radius: 9px; transition: all .18s; font-weight: 400;
}
.seg button.active { background: #fff; color: var(--ink); font-weight: 500; box-shadow: var(--shadow-s); }

/* ---------- Tags ---------- */
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; padding: 2.5px 7px; border-radius: 6px; font-weight: 500; line-height: 1.4; }
.tag-l1 { background: rgba(24, 39, 52, .06); color: var(--ink-2); }
.tag-l2 { background: var(--blue-50); color: var(--blue); }
.tag-l3 { background: var(--jade-50); color: var(--jade-deep); }
.tag-l4 { background: var(--amber-50); color: var(--amber); }
.tag-l5 { background: linear-gradient(135deg, #2B3A47, #17222B); color: #E8D9AE; }
.tag-urgent { background: var(--red); color: #fff; border-radius: 6px; }
.tag-gold { background: var(--gold-50); color: var(--gold-deep); }
.tag-role-farmer { background: var(--jade-50); color: var(--jade-deep); }
.tag-role-buyer { background: var(--blue-50); color: var(--blue); }
.tag-role-agent { background: var(--violet-50); color: var(--violet); }
.tag-role-admin { background: var(--gold-50); color: var(--gold-deep); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--r-m);
  border: 0.5px solid var(--line); box-shadow: var(--shadow-s);
}
.pressable { transition: transform .15s ease; }
.pressable:active { transform: scale(.977); }

/* 供应卡片（双列瀑布） */
.sup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px; }
.sup-card { overflow: hidden; display: flex; flex-direction: column; }
.sup-card .ph {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--jade-50);
}
.sup-card .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease, opacity .4s; opacity: 0; }
.sup-card .ph img.loaded { opacity: 1; }
.sup-card:active .ph img { transform: scale(1.04); }
.sup-card .ph .lvl {
  position: absolute; top: 8px; left: 8px;
}
.sup-card .ph .pts {
  position: absolute; right: 8px; bottom: 8px;
  font-size: 10px; color: #fff; background: rgba(18, 32, 44, .62);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 2.5px 8px; border-radius: 999px; font-weight: 500;
}
.sup-card .ph .pts.free { background: rgba(14, 159, 116, .85); }
.sup-card .bd { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sup-card .bd h4 {
  font-size: 13.5px; font-weight: 500; line-height: 1.45; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 39px;
}
.sup-card .meta { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 4px; }
.sup-card .ft { display: flex; align-items: baseline; justify-content: space-between; margin-top: auto; }
.price { color: var(--red); font-weight: 500; font-variant-numeric: tabular-nums; }
.price .cur { font-size: 12px; margin-right: 1px; }
.price .v { font-size: 18px; letter-spacing: -.3px; }
.price .u { font-size: 11px; color: var(--ink-3); font-weight: 400; margin-left: 1px; }

/* 采购卡片（横向列表） */
.pc-card { display: flex; padding: 14px 16px; gap: 12px; align-items: flex-start; }
.pc-card + .pc-card { border-top: 0.5px solid var(--line); }
.pc-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pc-card h4 { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.pc-card h4 .tt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-card .spec { font-size: 12px; color: var(--ink-2); }
.pc-card .meta { font-size: 11px; color: var(--ink-3); display: flex; gap: 10px; }

/* 通用列表项 */
.cell { display: flex; align-items: center; gap: 12px; padding: 14px 16px; position: relative; }
.cell + .cell { border-top: 0.5px solid var(--line); }
.cell:active { background: rgba(24, 39, 52, .028); }
.cell .ic {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.cell .bd { flex: 1; min-width: 0; }
.cell .bd .t1 { font-size: 14.5px; color: var(--ink); }
.cell .bd .t2 { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.cell .arrow { color: var(--ink-3); flex-shrink: 0; }

/* ---------- Category strip ---------- */
.cat-strip { display: flex; gap: 0; overflow-x: auto; padding: 4px 16px 6px; scrollbar-width: none; }
.cat-strip::-webkit-scrollbar { display: none; }
.cat-item { flex-shrink: 0; width: 62px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 0; }
.cat-item .av {
  width: 50px; height: 50px; border-radius: 50%; overflow: hidden;
  border: 2.5px solid #fff; box-shadow: 0 0 0 1px var(--line), var(--shadow-s);
  transition: transform .15s;
}
.cat-item:active .av { transform: scale(.92); }
.cat-item .av img { width: 100%; height: 100%; object-fit: cover; }
.cat-item span { font-size: 11px; color: var(--ink-2); }

/* ---------- Stats ---------- */
.stat-strip { display: flex; gap: 10px; padding: 0 16px; }
.stat-cell {
  flex: 1; border-radius: var(--r-m); padding: 14px 8px 12px; text-align: center;
  background: var(--card); border: 0.5px solid var(--line);
}
.stat-cell .n { font-size: 21px; font-weight: 500; letter-spacing: -.4px; color: var(--ink); }
.stat-cell .l { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.stat-cell.jade .n { color: var(--jade-deep); }
.stat-cell.gold .n { color: var(--gold-deep); }

/* ---------- Skeleton ---------- */
.skel {
  position: relative; overflow: hidden;
  background: rgba(24, 39, 52, .06); border-radius: 8px;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .75) 50%, transparent 70%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 56px 24px; color: var(--ink-3); }
.empty svg { margin: 0 auto 14px; opacity: .8; }
.empty .t { font-size: 14px; color: var(--ink-2); }
.empty .s { font-size: 12px; margin-top: 5px; }
.empty .act { margin-top: 18px; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; top: calc(var(--sat) + 54px); left: 50%; transform: translateX(-50%);
  z-index: 900; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: max-content; max-width: 86vw;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  background: rgba(28, 38, 48, .92); color: #fff;
  font-size: 13.5px; padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow-m);
  animation: toast-in .28s cubic-bezier(.21, 1.02, .73, 1);
}
.toast.ok svg { color: #4ADE97; }
.toast.err svg { color: #FF8589; }
.toast.out { animation: toast-out .25s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.92); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(.95); } }

/* ---------- Sheet / Dialog ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 30, .5); z-index: 800;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%) translateY(105%);
  width: 100%; max-width: 520px; z-index: 850;
  background: #fff; border-radius: 22px 22px 0 0;
  padding: 0 20px calc(var(--sab) + 16px);
  transition: transform .32s cubic-bezier(.32, .72, .24, 1);
  max-height: 86vh; display: flex; flex-direction: column;
}
.sheet.show { transform: translateX(-50%) translateY(0); }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: rgba(24, 39, 52, .14); margin: 10px auto 2px; flex-shrink: 0; }
.sheet .sh-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 4px; }
.sheet .sh-head .t { font-size: 17px; font-weight: 500; }
.sheet .sh-close { width: 30px; height: 30px; border-radius: 50%; background: rgba(24, 39, 52, .05); display: flex; align-items: center; justify-content: center; color: var(--ink-2); }
.sheet .sh-body { overflow-y: auto; padding: 8px 0; }

.dialog-wrap {
  position: fixed; inset: 0; z-index: 860; display: flex; align-items: center; justify-content: center;
  padding: 32px; opacity: 0; pointer-events: none; transition: opacity .22s;
}
.dialog-wrap.show { opacity: 1; pointer-events: auto; }
.dialog {
  background: #fff; border-radius: 20px; width: 100%; max-width: 330px;
  padding: 26px 22px 18px; text-align: center;
  transform: scale(.92); transition: transform .22s cubic-bezier(.34, 1.4, .64, 1);
  box-shadow: var(--shadow-m);
}
.dialog-wrap.show .dialog { transform: scale(1); }
.dialog h3 { font-size: 17px; font-weight: 500; margin-bottom: 8px; }
.dialog .d-body { font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }
.dialog .d-btns { display: flex; gap: 10px; margin-top: 20px; }
.dialog .d-btns .btn { flex: 1; padding: 11px 0; font-size: 14.5px; }

/* ---------- Forms ---------- */
.f-group { margin-bottom: 18px; }
.f-label { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; font-weight: 500; }
.f-label .req { color: var(--red); }
.f-input, .f-select, .f-textarea {
  width: 100%; padding: 13px 14px; font-size: 15px; color: var(--ink);
  background: rgba(24, 39, 52, .04); border: 1.5px solid transparent; border-radius: 12px;
  outline: none; transition: border-color .18s, background .18s;
  -webkit-appearance: none; appearance: none;
}
.f-input:focus, .f-select:focus, .f-textarea:focus { background: #fff; border-color: var(--jade); }
.f-input::placeholder, .f-textarea::placeholder { color: var(--ink-3); }
.f-textarea { min-height: 108px; resize: vertical; line-height: 1.65; }
.f-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2393A1AC' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.f-row { display: flex; gap: 12px; }
.f-row > * { flex: 1; min-width: 0; }
.f-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.5; }

/* switch */
.switch { width: 46px; height: 27px; border-radius: 999px; background: rgba(24, 39, 52, .16); position: relative; transition: background .2s; flex-shrink: 0; }
.switch::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%; transition: left .22s cubic-bezier(.34, 1.3, .64, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.switch.on { background: var(--jade); }
.switch.on::after { left: 21.5px; }

/* stepper-ish numeric row */
.num-row { display: flex; align-items: center; gap: 12px; }
.num-row .f-input { text-align: center; }

/* ---------- Gallery ---------- */
.gallery { position: relative; }
.gallery .track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.gallery .track::-webkit-scrollbar { display: none; }
.gallery .track img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; flex-shrink: 0; scroll-snap-align: center; }
.gallery .dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; }
.gallery .dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .5); transition: all .25s; }
.gallery .dots i.on { width: 16px; background: #fff; }

/* ---------- Footer ---------- */
.page-foot {
  padding: 28px 24px calc(var(--sab) + 20px); text-align: center;
  color: var(--ink-3); font-size: 11.5px; line-height: 1.9;
}
.page-foot a { color: var(--ink-3); text-decoration: underline; text-underline-offset: 2px; }
.page-foot .brand { font-size: 12px; color: var(--ink-2); font-weight: 500; margin-bottom: 2px; }

/* ---------- Sticky action bar (detail) ---------- */
.action-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 210;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 0.5px solid var(--line);
  padding: 10px 16px calc(var(--sab) + 10px);
  display: flex; align-items: center; gap: 10px;
}

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.px-16 { padding-left: 16px; padding-right: 16px; }
.text-c { text-align: center; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.c-ink2 { color: var(--ink-2); }
.c-ink3 { color: var(--ink-3); }
.c-jade { color: var(--jade-deep); }
.c-red { color: var(--red); }
.c-gold { color: var(--gold-deep); }
.fw-5 { font-weight: 500; }
.hide { display: none !important; }
