*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  max-width: 450px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}
a { color: inherit; text-decoration: none; }
button { border: none; background: none; cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; outline: none; }

:root {
  --green: #4B9E3F;
  --green-dark: #3D8535;
  --green-light: #EDF7EB;
  --red: #E4393C;
  --orange: #F0A03C;
  --text-1: #333;
  --text-2: #666;
  --text-3: #999;
  --border: #e8e8e8;
  --bg: #f5f5f5;
  --white: #fff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---- Header ---- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--white);
  height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.header .back {
  position: absolute; left: 0; width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text-1);
}
.header .title { font-size: 17px; font-weight: 600; color: var(--text-1); }

/* ---- Section / Card ---- */
.panel {
  background: var(--white);
  margin-bottom: 10px;
}
.panel-title {
  font-size: 15px; font-weight: 600; color: var(--text-1);
  padding: 14px 16px 0;
}
.panel-inner { padding: 12px 16px; }

/* ---- Cell Row (menu item) ---- */
.cell {
  display: flex; align-items: center;
  padding: 14px 16px;
  background: var(--white);
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}
.cell:last-child { border-bottom: none; }
.cell:active { background: #f9f9f9; }
.cell-body { flex: 1; min-width: 0; }
.cell-label { font-size: 15px; color: var(--text-1); }
.cell-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.cell-value { font-size: 14px; color: var(--text-3); margin-right: 4px; white-space: nowrap; }
.cell-arrow { color: #ccc; font-size: 14px; flex-shrink: 0; }
.cell-arrow::after { content: ">"; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; border-radius: 18px;
  font-size: 13px; font-weight: 500;
  padding: 0 20px;
  transition: opacity .15s;
}
.btn:active { opacity: .7; }
.btn-primary { background: var(--green); color: #fff; }

/* 会员端：加载失败 / 账号不一致 */
.auth-load-fail { text-align: center; padding: 48px 24px 32px; max-width: 360px; margin: 0 auto; }
.auth-load-fail-title { font-size: 17px; font-weight: 600; color: var(--text-1); margin-bottom: 10px; }
.auth-load-fail-desc { font-size: 13px; color: var(--text-2); line-height: 1.65; margin: 0 0 8px; text-align: left; }
.auth-load-fail-detail { font-size: 12px; color: var(--text-3); line-height: 1.5; margin: 0 0 16px; word-break: break-word; }
.auth-load-fail-btn { margin-top: 20px; min-width: 140px; }
.loading-wrap.auth-load-fail { padding-top: 56px; max-width: none; }

.wx-subscribe-panel .gf-sub-bind-btn { font-size: 15px; font-weight: 600; padding: 10px 16px; border-radius: 8px; }
.btn-outline { border: 1px solid var(--green); color: var(--green); background: var(--white); }
.btn-outline-gray { border: 1px solid #ddd; color: var(--text-2); background: var(--white); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; height: 44px; border-radius: 22px; font-size: 15px; font-weight: 600; }
.btn-sm { height: 28px; border-radius: 14px; font-size: 12px; padding: 0 12px; }

/* ---- Badge ---- */
.tag {
  display: inline-block;
  font-size: 11px; line-height: 18px;
  padding: 0 6px; border-radius: 2px;
}
.tag-green { background: var(--green-light); color: var(--green); }
.tag-orange { background: #FFF3E0; color: #E68A00; }
.tag-gray { background: #f0f0f0; color: var(--text-3); }
.tag-red { background: #FFEBEE; color: var(--red); }
.tag-blue { background: #E3F2FD; color: #1565C0; }
.service-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; flex-shrink: 0; max-width: 52%; }
.service-tags .tag { white-space: nowrap; font-size: 11px; padding: 3px 8px; }

/* ---- Stat Row ---- */
.stat-row {
  display: flex; text-align: center;
}
.stat-item { flex: 1; padding: 12px 0; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--text-1); line-height: 1.2; }
.stat-label { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ---- Bottom Bar ---- */
.bottom-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 450px;
  background: var(--white);
  padding: 8px 16px;
  padding-bottom: calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  z-index: 99;
}

/* ---- Tab Bar ---- */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 450px;
  background: var(--white);
  display: flex; height: calc(50px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--border);
  z-index: 99;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-3); gap: 2px; padding: 4px 0;
}
.tab-item.active { color: var(--green); }
.tab-icon {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}
.tab-icon svg { width: 22px; height: 22px; }

/* ---- Modal / Bottom Sheet ---- */
.overlay {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: flex-end; justify-content: center;
}
.overlay.show { display: flex; }
.sheet {
  background: var(--white);
  width: 100%; max-width: 450px;
  border-radius: 12px 12px 0 0;
  max-height: 50vh;
  display: flex; flex-direction: column;
  animation: sheetUp .25s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head {
  display: flex; align-items: center; justify-content: center;
  height: 52px; border-bottom: 1px solid var(--border);
  position: relative; flex-shrink: 0;
}
.sheet-head .sheet-title { font-size: 16px; font-weight: 600; color: var(--text-1); }
.sheet-head .close {
  position: absolute; right: 16px;
  font-size: 18px; color: var(--text-3);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
}
.sheet-body { padding: 16px; overflow-y: auto; flex: 1; }
.sheet-foot {
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---- Period Grid (JD style) ---- */
.period-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.period-cell {
  text-align: center; padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.period-cell .p-num { font-size: 14px; font-weight: 600; color: var(--text-1); }
.period-cell .p-date { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.period-cell.past { background: #fafafa; }
.period-cell.past .p-num { color: var(--text-3); }
.period-cell.selectable { border-color: var(--green); }
.period-cell.selectable .p-num { color: var(--green); }
.period-cell.selectable .p-date { color: var(--green); }
.period-cell.selected {
  border-color: var(--green); background: var(--green);
}
.period-cell.selected .p-num { color: #fff; }
.period-cell.selected .p-date { color: rgba(255,255,255,.8); }

/* ---- Delivery Row (JD style) ---- */
.delivery-row {
  padding: 14px 0;
  border-bottom: 1px solid #f0f0f0;
}
.delivery-row:last-child { border-bottom: none; }
.delivery-top {
  display: flex; justify-content: space-between; align-items: baseline;
}
.delivery-period { font-size: 15px; font-weight: 700; color: var(--text-1); }
.delivery-count { font-size: 13px; color: var(--text-2); margin-left: 8px; font-weight: 400; }
.delivery-time { font-size: 14px; font-weight: 600; color: var(--text-1); }
.delivery-detail {
  font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.6;
}

/* ---- Search ---- */
.search-wrap {
  padding: 10px 16px;
  background: var(--white);
}
.search-box {
  display: flex; align-items: center;
  height: 32px; background: #f5f5f5;
  border-radius: 16px; padding: 0 12px;
}
.search-box input {
  flex: 1; border: none; background: none;
  font-size: 13px; color: var(--text-1); margin-left: 6px;
}
.search-box input::placeholder { color: #bbb; }

/* ---- User Card (admin) ---- */
.user-item {
  padding: 14px 16px;
  background: var(--white);
  border-bottom: 1px solid #f0f0f0;
}
.user-top { display: flex; align-items: center; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #f0f0f0; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0; margin-right: 10px;
}
.user-meta { flex: 1; }
.user-name { font-size: 15px; font-weight: 600; color: var(--text-1); }
.user-phone { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.user-nums {
  display: flex; gap: 16px;
  padding: 10px 0; margin-top: 8px;
  border-top: 1px solid #f5f5f5;
}
.user-num-item { text-align: center; flex: 1; }
.user-num-val { font-size: 18px; font-weight: 700; color: var(--text-1); }
.user-num-label { font-size: 11px; color: var(--text-3); }
.user-actions { display: flex; gap: 8px; margin-top: 10px; }
.user-actions .btn { flex: 1; }

/* ---- Profile ---- */
.profile-bg {
  background: var(--white);
  padding: 24px 16px 16px;
}
.profile-row { display: flex; align-items: center; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green-light); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0; margin-right: 14px;
}
.profile-name { font-size: 20px; font-weight: 700; color: var(--text-1); }
.profile-phone { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ---- Admin Tabs ---- */
.admin-tabs {
  display: flex; background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 44px; z-index: 50;
}
.admin-tab {
  flex: 1; text-align: center;
  padding: 12px 0; font-size: 14px;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
}
.admin-tab.active {
  color: var(--green); font-weight: 600;
  border-bottom-color: var(--green);
}

/* ---- Notice Bar ---- */
.notice-bar {
  display: flex; align-items: center; gap: 6px;
  background: #FFFBE6; padding: 10px 16px;
  font-size: 12px; color: #8B7000;
  border-bottom: 1px solid #f0e68c;
}

/* ---- Stepper ---- */
.stepper { display: flex; align-items: center; }
.stepper button {
  width: 32px; height: 32px;
  border: 1px solid #ddd; background: var(--white);
  font-size: 16px; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.stepper button:first-child { border-radius: 4px 0 0 4px; }
.stepper button:last-child { border-radius: 0 4px 4px 0; }
.stepper-val {
  width: 48px; height: 32px;
  border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: var(--text-1);
}

/* ---- 会员子页顶栏（配送记录等） ---- */
.member-subpage-top {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.member-back-link {
  flex-shrink: 0;
  font-size: 14px;
  color: var(--green);
  text-decoration: none;
  line-height: 1.3;
}
.member-subpage-title {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
}

/* ---- Filter Tabs ---- */
.filter-bar {
  display: flex; gap: 8px;
  padding: 10px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.filter-btn {
  padding: 4px 14px; border-radius: 14px;
  font-size: 13px; background: #f5f5f5; color: var(--text-3);
  border: none;
}
.filter-btn.active { background: var(--green-light); color: var(--green); }

/* ---- Record Card ---- */
.record-card {
  background: var(--white);
  margin-bottom: 10px;
}
.record-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.record-head .period { font-size: 14px; font-weight: 600; color: var(--text-1); }
.record-body { padding: 12px 16px; }
.record-row {
  display: flex; justify-content: space-between;
  font-size: 13px; line-height: 2;
}
.record-row .rl { color: var(--text-3); }
.record-row .rv { color: var(--text-1); }
.record-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #f0f0f0;
}

/* ---- Toast ---- */
.toast {
  display: none; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.76); color: #fff;
  padding: 10px 24px; border-radius: 6px;
  font-size: 14px; z-index: 999;
}
.toast.show { display: block; animation: toastAnim 2s ease forwards; }
@keyframes toastAnim {
  0% { opacity: 0; } 10% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; }
}

/* ---- Calendar ---- */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0 8px;
}
.cal-header .cal-title { font-size: 16px; font-weight: 600; color: var(--text-1); }
.cal-nav {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-2); background: var(--bg);
  -webkit-appearance: none; cursor: pointer;
}
.cal-nav:active { background: #e8e8e8; }
.cal-nav.disabled { opacity: .3; pointer-events: none; }
.cal-week {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 12px; color: var(--text-3);
  padding-bottom: 6px; border-bottom: 1px solid #f0f0f0; margin-bottom: 2px;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px 0; text-align: center;
}
.cal-day {
  position: relative;
  width: 36px; height: 36px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-1); border-radius: 50%;
  cursor: pointer; transition: background .15s;
}
.cal-day:active { background: #f0f0f0; }
.cal-day.today { border: 1.5px solid var(--green); color: var(--green); font-weight: 600; }
.cal-day.past { color: #ccc; pointer-events: none; }
/* 管理端手工录入可选历史日（勿用 .past，避免 pointer-events:none） */
.cal-day.history { color: var(--text-2); }
.cal-day.unavailable { color: #d0d0d0; pointer-events: none; text-decoration: line-through; }
.cal-day.selected { background: var(--green); color: #fff; font-weight: 600; }
.cal-day.selected.today { border-color: var(--green); }
.cal-day.empty { pointer-events: none; }
.cal-hint {
  font-size: 11px; color: var(--text-3); text-align: center;
  padding: 8px 0 0; border-top: 1px solid #f0f0f0; margin-top: 8px;
}
.cal-hint span { color: var(--green); font-weight: 500; }

/* ---- Delivery date picker popover ---- */
.ddp-trigger {
  width: 100%;
  min-width: 118px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border, #e8e8e8);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: var(--text-1, #333);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ddp-trigger-empty { color: var(--text-3, #999); }
.ddp-popup {
  position: fixed;
  z-index: 500;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  padding: 12px;
  width: min(300px, calc(100vw - 16px));
  border: 1px solid var(--border, #e8e8e8);
}
.ddp-popup .ddp-cal { min-width: 0; }
.ddp-popup .cal-day {
  width: 34px;
  height: 34px;
  font-size: 12px;
}
.ddp-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f0f0f0;
}
.ddp-actions button {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.ddp-cancel {
  border: 1px solid #ddd;
  background: #fff;
  color: #666;
}
.ddp-confirm {
  border: none;
  background: var(--green, #4B9E3F);
  color: #fff;
  font-weight: 500;
}

/* ---- Address ---- */
.addr-page {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 200;
  max-width: 450px; margin: 0 auto;
  flex-direction: column;
}
.addr-page.show { display: flex; }
.addr-page .header { flex-shrink: 0; }
.addr-page .header .add-btn {
  position: absolute; right: 12px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--text-1);
}
.addr-list { flex: 1; overflow-y: auto; padding-bottom: 20px; }
.addr-empty {
  text-align: center; padding: 60px 0;
  font-size: 14px; color: var(--text-3);
}
.addr-card {
  background: var(--white); margin-bottom: 10px;
  padding: 16px;
}
.addr-card .addr-region { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.addr-card .addr-detail { font-size: 16px; font-weight: 600; color: var(--text-1); line-height: 1.4; }
.addr-card .addr-contact {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2); margin-top: 8px;
}
.addr-card .addr-tag-default {
  font-size: 11px; color: var(--green); background: var(--green-light);
  padding: 1px 6px; border-radius: 2px;
}
.addr-card .addr-ops {
  display: flex; align-items: center; gap: 16px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid #f0f0f0;
}
.addr-card .addr-op {
  font-size: 13px; color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.addr-card .addr-op:active { color: var(--text-1); }
.addr-card .addr-op-default { margin-right: auto; }
.addr-card .addr-op-del { color: var(--red); }

.addr-form-group { margin-bottom: 16px; }
.addr-form-group label {
  display: block; font-size: 13px; color: var(--text-3); margin-bottom: 6px;
}
.addr-form-group input,
.addr-form-group textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; color: var(--text-1);
  background: var(--white);
}
.addr-form-group input:focus,
.addr-form-group textarea:focus { border-color: var(--green); }
.addr-form-group textarea { resize: none; min-height: 60px; }

.addr-picker {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--bg); border-radius: 8px;
  margin-bottom: 12px; cursor: pointer;
}
.addr-picker .addr-picker-icon {
  flex-shrink: 0; width: 20px; height: 20px; color: var(--green);
}
.addr-picker .addr-picker-text { flex: 1; min-width: 0; }
.addr-picker .addr-picker-name { font-size: 13px; font-weight: 500; color: var(--text-1); }
.addr-picker .addr-picker-addr {
  font-size: 12px; color: var(--text-3); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.addr-picker .addr-picker-arrow { flex-shrink: 0; color: #ccc; font-size: 12px; }
.addr-picker:active { background: #eee; }

.addr-select-item {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0; cursor: pointer;
}
.addr-select-item:active { background: #f9f9f9; }
.addr-select-item.active { background: var(--green-light); }
.addr-select-item .addr-select-info { flex: 1; }
.addr-select-item .addr-select-name { font-size: 14px; color: var(--text-1); }
.addr-select-item .addr-select-addr { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.addr-select-item .addr-select-check { color: var(--green); font-size: 16px; font-weight: 700; }

/* ---- Image Upload ---- */
.upload-area {
  margin-top: 16px;
}
.upload-area label { display: block; font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.upload-zone {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.upload-btn {
  width: 72px; height: 72px; border: 1px dashed #ccc; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; background: #fafafa; color: var(--text-3); font-size: 11px; gap: 2px;
}
.upload-btn:active { background: #f0f0f0; }
.upload-btn .upload-icon { font-size: 22px; line-height: 1; color: #bbb; }
.upload-preview {
  width: 72px; height: 72px; border-radius: 8px; position: relative;
  overflow: hidden; border: 1px solid #eee;
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview .upload-del {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ---- Helpers ---- */
.text-green { color: var(--green) !important; }
.text-red { color: var(--red) !important; }
.text-orange { color: var(--orange) !important; }
.text-3 { color: var(--text-3) !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.px-16 { padding-left: 16px; padding-right: 16px; }

/* ---- ICP 备案 ---- */
.site-icp-footer {
  text-align: center;
  padding: 14px 16px 18px;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.5;
  background: transparent;
}
.site-icp-footer a {
  color: var(--text-3);
  text-decoration: none;
}
.site-icp-footer a:hover,
.site-icp-footer a:active {
  color: var(--green);
  text-decoration: underline;
}
.site-icp-footer--above-tab {
  padding-bottom: 10px;
}
