/* 代理专属系统 - Mobile First */
:root {
  --ap-primary: #ff4d4f;
  --ap-primary-dark: #cf1322;
  --ap-bg: #fdf6f0;
  --ap-card: #fff;
  --ap-text: #2c2c2c;
  --ap-muted: #888;
  --ap-radius: 20px;
  --ap-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #fdf6f0 0%, #fef9f5 45%, #ffffff 100%);
  background-attachment: fixed;
  color: var(--ap-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  overflow-x: hidden;
}

/* 代理 UI 背景（仅手机端） */
@media (max-width: 768px) {
  html.ap-has-ui-bg,
  body.ap-has-ui-bg {
    background: transparent !important;
  }

  .ap-ui-bg-stack {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
  }

  .ap-ui-bg-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
  }

  .ap-ui-bg-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    transform-origin: center center;
    display: block;
    pointer-events: none;
    user-select: none;
  }

  body.ap-has-ui-bg > *:not(.ap-ui-bg-stack) {
    position: relative;
    z-index: 1;
  }
}

.ap-wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  min-height: 100vh;
}

.ap-card {
  background: var(--ap-card);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.ap-page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 16px;
  text-align: center;
}

.ap-title { font-size: 22px; font-weight: 700; margin: 0 0 8px; }

.ap-section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 4px 4px 10px;
  line-height: 1.35;
}

.ap-card--flush {
  padding-top: 8px;
}

.ap-card--flush .ap-member:first-child {
  padding-top: 4px;
}

/* 代理成员登录页 */
.agent-login-page .ap-login-wrap {
  padding-top: 20vh;
  box-sizing: border-box;
}
.agent-login-page .ap-login-brand {
  text-align: center;
  font-size: 24px;
  margin-bottom: 12px;
}
.agent-login-page .ap-login-sub {
  text-align: center;
}
.ap-sub { color: var(--ap-muted); font-size: 14px; line-height: 1.6; margin: 0 0 16px; }

.ap-field {
  background: #faf7f5;
  border: 1px solid #ece5df;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.ap-field label { display: block; font-size: 12px; color: var(--ap-muted); margin-bottom: 6px; }
.ap-field .val { font-size: 18px; font-weight: 700; word-break: break-all; }

.ap-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.ap-btn-primary { background: linear-gradient(135deg, #ff4d4f, #cf1322); color: #fff; }
.ap-btn-secondary { background: #fff; color: var(--ap-primary); border: 1px solid #e8d5cf; margin-top: 10px; }
.ap-btn-logout {
  background: linear-gradient(90deg, #ff4d4f 0%, #cf1322 100%);
  color: #fff;
  border: none;
  margin-top: 4px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(255, 77, 79, 0.28);
}
.ap-btn-danger { background: #fff; color: #f5222d; border: 1px solid #ffccc7; margin-top: 0; }
.ap-btn-inline { width: auto; min-width: 0; flex: 1 1 auto; padding: 10px 12px; font-size: 14px; margin-top: 0; }
.ap-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ap-order-quota-tip {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7e6;
  border: 1px solid #ffe7ba;
  color: #ad6800;
  font-size: 13px;
  line-height: 1.5;
}

.ap-order-head,
.ap-order-no-row {
  display: block;
  margin-bottom: 6px;
  max-width: 100%;
  overflow: hidden;
}

.ap-order-status-row {
  margin-bottom: 8px;
}

.ap-order-no {
  display: block;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  word-break: keep-all;
  overflow-wrap: normal;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  line-height: 1.45;
  padding-bottom: 2px;
}

.ap-order-no::-webkit-scrollbar {
  display: none;
  height: 0;
}

.ap-status-block {
  display: block;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  line-height: 1.55;
  font-size: 13px;
  text-align: left;
  padding: 0;
  border-radius: 0;
}

.ap-status-block .ap-cs-link {
  font-size: inherit;
  font-weight: 600;
  vertical-align: baseline;
  padding: 0;
}

.ap-order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ap-order-hint {
  margin: 0;
  flex: 1 1 100%;
}

.ap-order-card .ap-status-long {
  font-size: 13px;
  padding: 0;
  white-space: normal;
  max-width: 100%;
  text-align: left;
}

.ap-warn {
  background: #fff7e6;
  border: 1px solid #ffe7ba;
  color: #ad6800;
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.ap-input {
  width: 100%;
  border: 1px solid #e5ddd6;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  margin-bottom: 12px;
}

.ap-profile-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ap-profile-hero {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ap-profile-hero-main {
  flex: 1;
  min-width: 0;
}

.ap-profile-name {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ap-text);
  margin-bottom: 4px;
}

.ap-contact-text {
  flex: 1;
  min-width: 0;
  line-height: 1.45;
}

.ap-profile-kv {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px;
  min-width: 0;
}

.ap-kv-label {
  flex-shrink: 0;
  font-size: 13px;
  color: #606266;
  white-space: nowrap;
}

.ap-kv-value {
  font-size: 13px;
  color: #303133;
  word-break: break-all;
  line-height: 1.45;
}

.ap-contact-item-referrer {
  grid-column: 1 / -1;
  padding: 6px 0 4px;
  margin-top: 2px;
  border-top: 1px dashed #ffe0e0;
}

.ap-referrer-line {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ap-referrer-line::-webkit-scrollbar {
  display: none;
}

.ap-referrer-part {
  flex: 0 0 auto;
  color: #ff4d4f;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.ap-profile-contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  background: #fafafa;
  border-radius: 12px;
  padding: 12px;
}

.ap-contact-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.ap-contact-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}

.ap-contact-icon-phone {
  background: #e8f3ff;
  color: #1677ff;
}

.ap-contact-icon-phone::before {
  content: '📞';
  font-size: 12px;
}

.ap-contact-icon-wechat {
  background: #e8f8ef;
  color: #18a058;
}

.ap-contact-icon-wechat::before {
  content: '💬';
  font-size: 12px;
}

.ap-contact-icon-phone-ref {
  background: #f3e8ff;
  color: #7c3aed;
}

.ap-contact-icon-phone-ref::before {
  content: '📱';
  font-size: 12px;
}

.ap-contact-icon-phone-back {
  background: #e8f3ff;
  color: #1677ff;
}

.ap-contact-icon-phone-back::before {
  content: '📞';
  font-size: 12px;
}

.ap-profile-meta-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ap-meta-box {
  background: #f5f6f8;
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
}

.ap-meta-box-level {
  background: #eef4ff;
}

.ap-meta-box-status {
  background: #f0faf4;
}

.ap-meta-box-team {
  background: #f5f6f8;
}

.ap-meta-box-team .ap-meta-value {
  font-weight: 600;
}

.ap-profile-summary-row {
  margin-top: 0;
}

.ap-meta-label {
  color: #606266;
  white-space: nowrap;
}

.ap-meta-value {
  color: #303133;
  word-break: break-all;
}

.ap-profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ap-stat-box {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}

.ap-stat-box-cart {
  background: linear-gradient(135deg, #e6f4ff 0%, #fffbe6 100%);
}

.ap-stat-box-money {
  background: linear-gradient(135deg, #ffeef3 0%, #fff0e0 100%);
}

.ap-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.ap-stat-icon-cart {
  background: #e8f3ff;
}

.ap-stat-icon-money {
  background: #fff7e6;
}

.ap-stat-content {
  min-width: 0;
}

.ap-stat-label {
  font-size: 12px;
  color: #909399;
  margin-bottom: 2px;
}

.ap-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: #303133;
  line-height: 1.3;
}

.ap-level-progress-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.ap-level-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 10px;
  font-size: 13px;
}

.ap-level-progress-title {
  font-weight: 600;
  color: #303133;
  flex-shrink: 0;
}

.ap-level-progress-remain {
  color: #606266;
  font-size: 14px;
  line-height: 1.35;
  text-align: right;
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  word-break: keep-all;
}

.ap-level-progress-remain strong {
  color: #ff4d4f;
  font-weight: 700;
  font-size: 1.08em;
}

.ap-level-progress-track {
  position: relative;
  height: 26px;
  background: #e8ebf0;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.ap-level-progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  min-width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #69c0ff 0%, #1890ff 100%);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.ap-level-progress-text {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #4a5568;
  white-space: nowrap;
  padding: 0 12px;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.ap-level-progress-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ap-muted);
  line-height: 1.5;
}

.ap-activate-tip {
  margin: 0;
}

.ap-level-text {
  font-weight: 600;
  color: #1890ff;
}

.ap-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ff4d4f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255, 77, 79, 0.35);
}
.ap-meta { font-size: 13px; color: var(--ap-muted); line-height: 1.7; }
.ap-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #fff1f0;
  color: #cf1322;
}
.ap-status.ok { background: transparent; color: #52c41a; font-weight: 600; }
.ap-status-long {
  max-width: 58%;
  border-radius: 8px;
  line-height: 1.45;
  text-align: right;
  white-space: normal;
}
.ap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ap-action {
  background: #fff;
  border: none;
  border-radius: 10px;
  padding: 15px 10px;
  text-align: center;
  font-size: 14px;
  color: var(--ap-text);
  text-decoration: none;
  box-shadow: 0 2px 0 #f0e0d0, 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ap-action:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #f0e0d0;
}

.ap-page-center #activeCard .ap-title {
  font-size: 18px;
  margin-bottom: 14px;
}
.ap-action-badge-wrap {
  position: relative;
  display: block;
}
.ap-action-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f5222d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}
.ap-countdown { font-size: 20px; font-weight: 700; color: var(--ap-primary); text-align: center; margin: 12px 0; }
.ap-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99;
}
.ap-toast.show { opacity: 1; }

.ap-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 15px;
}
.ap-nav a { color: var(--ap-primary); text-decoration: none; font-weight: 600; flex-shrink: 0; }
.ap-nav span { flex: 1; min-width: 0; text-align: right; }

.ap-product { display: flex; gap: 12px; padding: 16px; align-items: flex-start; }
.ap-product-img { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; flex-shrink: 0; background: #f5f5f5; }
.ap-product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 88px; }
.ap-product-name { font-weight: 700; margin-bottom: 6px; font-size: 16px; line-height: 1.35; }
.ap-product-price { color: var(--ap-primary); font-size: 18px; font-weight: 700; line-height: 1.3; }
.ap-product-meta { margin-top: 2px; }
.ap-retail { color: var(--ap-muted); font-size: 12px; font-weight: 400; text-decoration: line-through; margin-left: 6px; }
.ap-qty-row { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 10px; }
.ap-qty-row button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid #e5ddd6;
  background: #fff; font-size: 18px; cursor: pointer;
}
.ap-qty-input {
  width: 56px; height: 32px; text-align: center;
  border: 1px solid #e5ddd6; border-radius: 8px;
  font-size: 16px; font-weight: 600; color: var(--ap-text); background: #fff;
  padding: 0 4px; -moz-appearance: textfield;
}
.ap-qty-input::-webkit-outer-spin-button,
.ap-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

@media (max-width: 768px) {
  #productList {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  #productList .ap-card.ap-product {
    flex-direction: row;
    align-items: flex-start;
    padding: 16px;
    margin-bottom: 0;
    height: auto;
  }

  #productList .ap-product-img {
    width: 88px;
    height: 88px;
  }

  #productList .ap-product-info {
    min-height: 88px;
  }

  #productList .ap-product-name {
    font-size: 16px;
  }

  #productList .ap-product-price {
    font-size: 18px;
  }

  #productList .ap-qty-row {
    gap: 12px;
    margin-top: auto;
    padding-top: 10px;
  }

  #productList .ap-qty-input {
    width: 56px;
  }
}
.ap-qty-input:focus { outline: none; border-color: var(--ap-primary); }
.ap-cart-bar { position: sticky; bottom: 12px; z-index: 10; }
.ap-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 200;
}
.ap-modal.is-picker-open { pointer-events: none; background: transparent; }
.ap-modal-body {
  background: #fff; width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; border-radius: 16px 16px 0 0; padding: 20px;
}
.ap-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: center; }
.ap-stat .num { font-size: 28px; font-weight: 700; color: var(--ap-primary); line-height: 1.2; word-break: break-all; }
.ap-stat .label { font-size: 13px; color: var(--ap-muted); margin-top: 4px; line-height: 1.4; }
.ap-member { padding: 12px 0; border-bottom: 1px solid #f0ebe6; }
.ap-member:last-child { border-bottom: none; }
.ap-member-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 15px;
  line-height: 1.45;
}
.ap-member-head strong { font-weight: 700; }
.ap-member-commission {
  margin-left: auto;
  font-size: 13px;
  color: var(--ap-primary);
  font-weight: 600;
  white-space: nowrap;
}
.ap-member-meta { margin-top: 4px; font-size: 13px; color: var(--ap-muted); line-height: 1.5; }
.ap-member-actions {
  margin-top: 8px;
}
.ap-member-actions .ap-btn-inline {
  width: auto;
  min-width: 0;
  padding: 6px 14px;
  font-size: 13px;
  margin-top: 0;
}
.ap-qr { max-width: 200px; margin: 12px auto; display: block; border-radius: 8px; }
.ap-qr-tip { margin: 8px 0 0; font-size: 14px; color: var(--ap-text); font-weight: 600; }
.ap-upload-label { display: block; margin-bottom: 12px; cursor: pointer; }

.ap-form-label { display: block; font-size: 13px; color: var(--ap-muted); margin: 0 0 6px; }
.ap-field-block { margin-bottom: 12px; }
.ap-form-group { margin-bottom: 14px; }
.ap-form-group:last-child { margin-bottom: 0; }
.ap-label { display: block; font-size: 13px; color: var(--ap-muted); margin: 0 0 6px; font-weight: 500; }
.ap-label--inline { margin-bottom: 0; }
.ap-form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.ap-btn-sm {
  display: inline-block;
  width: auto;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  flex-shrink: 0;
}
.ap-file-input {
  display: block;
  width: 100%;
  max-width: 100%;
  font-size: 14px;
  color: var(--ap-text);
}
.ap-qrcode-preview img {
  display: block;
  max-width: 120px;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #f0ebe6;
}
.ap-qrcode-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.ap-qrcode-row .ap-qrcode-preview {
  flex: 0 0 auto;
}
.ap-qrcode-actions {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
}
.ap-qrcode-actions .ap-btn {
  width: 100%;
  margin-top: 0;
}
.ap-commission-reversed {
  opacity: 0.55;
}
.ap-commission-reversed strong,
.ap-commission-reversed .ap-member-commission {
  color: var(--ap-muted);
  text-decoration: line-through;
  font-weight: 500;
}
.ap-commission-reversed .ap-member-meta {
  color: #b0a8a0;
}

.ap-record-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0ebe6;
}

.ap-record-pager__btn {
  width: auto;
  min-width: 72px;
  margin-top: 0;
  padding: 8px 14px;
  font-size: 14px;
}

.ap-record-pager__info {
  min-width: 56px;
  text-align: center;
  font-size: 13px;
  color: var(--ap-muted);
}

.ap-select {
  width: 100%; padding: 12px 14px; border: 1px solid #e5ddd6; border-radius: 10px;
  font-size: 16px; background: #fff; color: var(--ap-text); outline: none;
}
.ap-select:focus { border-color: var(--ap-primary); }
.ap-select:disabled { background: #faf7f5; color: var(--ap-muted); opacity: 1; }
.ap-level-picker { position: relative; }
.ap-level-picker__trigger {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e5ddd6;
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: var(--ap-text);
  outline: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}
.ap-level-picker__trigger:focus,
.ap-level-picker.is-open .ap-level-picker__trigger {
  border-color: var(--ap-primary);
}
.ap-level-picker__arrow {
  color: var(--ap-muted);
  font-size: 14px;
  flex-shrink: 0;
}
.ap-level-picker__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 300;
  background: #fff;
  border: 1px solid #e5ddd6;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ap-level-picker__item {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: #fff;
  color: var(--ap-text);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
.ap-level-picker__item + .ap-level-picker__item {
  border-top: 1px solid #f3ece6;
}
.ap-level-picker__item.is-active {
  background: #2c2c2c;
  color: #fff;
}
.ap-level-picker__item.is-disabled {
  color: #b0a8a0;
  background: #faf7f5;
  cursor: not-allowed;
}
.ap-level-picker__item.is-disabled.is-active {
  background: #ece7e2;
  color: #b0a8a0;
}
.ap-level-picker__empty {
  padding: 12px 14px;
  color: var(--ap-muted);
  font-size: 14px;
}
.ap-level-card {
  margin-bottom: 12px;
  overflow: visible;
}
.ap-level-picker.is-open {
  position: relative;
  z-index: 220;
}
.ap-level-picker__trigger {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ap-level-picker__item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.04);
  min-height: 44px;
}
.ap-prefill-hint {
  background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d;
  border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; margin-bottom: 12px;
}

.input-with-picker {
  display: flex; align-items: stretch; width: 100%;
  border: 1px solid #e5ddd6; border-radius: 10px; overflow: hidden; background: #fff;
}
.input-with-picker:focus-within { border-color: var(--ap-primary); }
.input-with-picker input {
  flex: 1; min-width: 0; border: none; padding: 12px 14px; font-size: 16px;
  background: transparent; outline: none;
}
.input-picker-btn {
  flex-shrink: 0; border: none; border-left: 1px solid #e5ddd6; background: #faf7f5;
  padding: 0 14px; font-size: 14px; font-weight: 600; color: var(--ap-primary); cursor: pointer;
}

.region-picker-root { position: fixed; inset: 0; z-index: 10050; display: none; }
.region-picker-root.show { display: block; }
.region-picker-mask { position: absolute; inset: 0; z-index: 1; background: rgba(0,0,0,.45); }
.region-picker-panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; background: #fff;
  border-radius: 16px 16px 0 0; max-height: 70vh; display: flex; flex-direction: column;
  pointer-events: auto;
}
.region-picker-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #eee; flex-shrink: 0;
}
.region-picker-title { font-size: 16px; font-weight: 600; }
.region-picker-btn { border: none; background: none; font-size: 15px; padding: 4px 8px; cursor: pointer; }
.region-picker-cancel { color: #888; }
.region-picker-confirm { color: var(--ap-primary); font-weight: 600; }
.region-picker-columns { display: flex; flex: 1; min-height: 220px; max-height: calc(70vh - 52px); overflow: hidden; }
.region-picker-col { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; border-right: 1px solid #f3f4f6; }
.region-picker-col:last-child { border-right: none; }
.region-picker-col ul { list-style: none; margin: 0; padding: 8px 0; }
.region-picker-col li { padding: 10px 12px; font-size: 15px; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; }
.region-picker-col li.active { color: var(--ap-primary); font-weight: 600; background: #fff7f5; }

.ap-pay-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 2147483646;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  touch-action: none;
  box-sizing: border-box;
}

.ap-pay-overlay .ap-pay-panel {
  position: absolute;
  top: 10vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 32px));
  max-width: 360px;
  max-height: 80vh;
  max-height: 80dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
}

.ap-pay-panel {
  background: #fff; border-radius: 16px; padding: 24px 20px;
  width: min(360px, 100%); text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  margin: auto;
}
.ap-pay-title { margin: 0 0 8px; font-size: 20px; font-weight: 700; }
.ap-pay-amount { margin: 0 0 16px; color: var(--ap-muted); font-size: 15px; }
.ap-pay-amount strong { color: var(--ap-primary); font-size: 24px; }
.ap-pay-qr-wrap {
  display: flex; justify-content: center; margin-bottom: 12px;
  padding: 12px; background: #faf7f5; border-radius: 12px;
}
.ap-pay-qr { display: block; width: 220px; height: 220px; }
.ap-pay-hint { margin: 0 0 8px; font-size: 14px; color: var(--ap-text); line-height: 1.5; }

.ap-service-qr-hint {
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.45;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  word-break: keep-all;
}

.ap-service-qr-hint::-webkit-scrollbar {
  display: none;
  height: 0;
}
.ap-pay-warn { color: #b45309; font-size: 13px; }
#payMobileBlock .ap-btn-primary,
a.ap-btn { text-decoration: none; text-align: center; display: block; box-sizing: border-box; }
.ap-pay-status { margin: 0 0 16px; font-size: 13px; color: var(--ap-muted); }
.ap-btn-ghost {
  background: #f5f0ec; color: var(--ap-text); margin-top: 8px;
}

.ap-service-recruit-btn {
  display: block;
  margin-top: 12px;
  margin-bottom: 8px;
  text-decoration: none;
  box-sizing: border-box;
}
.ap-btn-ghost:hover { background: #ebe4de; }

.ap-btn-inline {
  display: inline-block;
  width: auto;
  margin-top: 12px;
  padding: 10px 18px;
  font-size: 14px;
}
.ap-order-card .ap-btn-secondary { margin-top: 12px; }
.ap-link-btn {
  border: none;
  background: none;
  color: var(--ap-primary);
  font-size: 13px;
  padding: 0 4px;
  cursor: pointer;
}

body.ap-modal-open {
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.ap-logistics-overlay {
  position: fixed; inset: 0; z-index: 10070;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.ap-logistics-panel {
  background: #fff; width: 100%; max-width: 520px;
  max-height: 85vh; border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
}
.ap-logistics-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #f0ebe6; flex-shrink: 0;
}
.ap-logistics-head h3 { margin: 0; font-size: 18px; }
.ap-logistics-close {
  border: none; background: none; font-size: 28px; line-height: 1;
  color: #999; cursor: pointer; padding: 0 4px;
}
.ap-logistics-summary {
  padding: 14px 20px 0; flex-shrink: 0;
}
.ap-logistics-body {
  padding: 12px 20px 24px; overflow-y: auto; flex: 1;
}
.ap-timeline {
  list-style: none; margin: 0; padding: 0 0 0 8px;
  border-left: 2px solid #f0ebe6;
}
.ap-timeline-item {
  position: relative; padding: 0 0 18px 16px;
}
.ap-timeline-item::before {
  content: ''; position: absolute; left: -7px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #ddd; border: 2px solid #fff;
}
.ap-timeline-item.current::before { background: var(--ap-primary); }
.ap-timeline-item.current .ap-timeline-text { color: var(--ap-text); font-weight: 600; }
.ap-timeline-time { font-size: 12px; color: var(--ap-muted); margin-bottom: 4px; }
.ap-timeline-text { font-size: 14px; color: #666; line-height: 1.5; }

@media (min-width: 768px) {
  .ap-logistics-overlay { align-items: center; padding: 16px; }
  .ap-logistics-panel { border-radius: 16px; max-height: 80vh; }
}

@media (max-width: 767px) {
  .ap-page-center .ap-profile-card {
    padding: 16px;
    gap: 12px;
  }

  .ap-page-center .ap-profile-hero {
    gap: 12px;
  }

  .ap-page-center .ap-avatar {
    width: 52px;
    height: 52px;
    font-size: 20px;
  }

  .ap-page-center .ap-profile-name {
    font-size: 20px;
    line-height: 1.3;
  }

  .ap-page-center .ap-profile-contact-grid {
    gap: 8px 10px;
    padding: 12px;
    border-radius: 12px;
  }

  .ap-page-center .ap-contact-icon {
    width: 24px;
    height: 24px;
  }

  .ap-page-center .ap-contact-text .ap-kv-label,
  .ap-page-center .ap-contact-text .ap-kv-value {
    font-size: 12px;
  }

  .ap-page-center .ap-contact-item-referrer {
    padding: 6px 0 4px;
  }

  .ap-page-center .ap-referrer-line {
    justify-content: flex-start;
    gap: 12px;
  }

  .ap-page-center .ap-referrer-part {
    font-size: 12px;
    line-height: 1.35;
    letter-spacing: -0.15px;
  }

  .ap-page-center .ap-meta-box {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 12px;
  }

  .ap-page-center .ap-stat-box {
    padding: 12px;
    border-radius: 12px;
  }

  .ap-page-center .ap-stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .ap-page-center .ap-stat-value {
    font-size: 15px;
  }

  .ap-page-center .ap-level-progress-track {
    height: 24px;
  }

  .ap-page-center .ap-level-progress-text {
    font-size: 11px;
  }

  .ap-page-center .ap-action {
    padding: 14px 10px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .ap-wrap { padding-left: 12px; padding-right: 12px; }
  .ap-card { padding: 14px; }
  .ap-stat .num { font-size: 24px; }
  .ap-stat .label { font-size: 12px; }
  .ap-action { padding: 12px 8px; font-size: 13px; }
  .ap-member-head { flex-direction: column; align-items: flex-start; }
  .ap-member-commission { margin-left: 0; }
  .ap-nav { font-size: 14px; gap: 8px; }
  .ap-nav span { text-align: right; flex: 1; min-width: 0; }

  .ap-page-center .ap-profile-contact-grid {
    padding: 10px;
    gap: 6px 8px;
  }

  .ap-page-center .ap-referrer-part {
    font-size: 10px;
    letter-spacing: -0.2px;
  }

  .ap-page-center .ap-referrer-line {
    gap: 8px;
  }
}

@media (max-width: 360px) {
  .ap-profile-meta-row {
    grid-template-columns: 1fr;
  }

  .ap-profile-stats {
    grid-template-columns: 1fr;
  }

  .ap-level-progress-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 4px 8px;
  }

  .ap-level-progress-remain {
    margin-left: 0;
    text-align: right;
    justify-self: end;
    width: 100%;
  }

  .ap-stat-grid { gap: 8px; }
  .ap-stat .num { font-size: 22px; }
}

@media (min-width: 768px) {
  .region-picker-panel {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, calc(100% - 32px));
    border-radius: 12px; max-height: 420px;
  }
  .region-picker-columns { max-height: 360px; }
  .ap-wrap { padding-top: 32px; }
  .ap-title { font-size: 26px; }

  /* 电脑端：头像卡片更紧凑 */
  .ap-profile-card {
    padding: 12px;
    gap: 8px;
  }

  .ap-profile-hero {
    gap: 10px;
  }

  .ap-avatar {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  .ap-profile-name {
    font-size: 18px;
    margin-bottom: 2px;
  }

  .ap-profile-contact-grid {
    gap: 6px 8px;
  }

  .ap-contact-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .ap-contact-icon-phone::before,
  .ap-contact-icon-wechat::before,
  .ap-contact-icon-phone-ref::before,
  .ap-contact-icon-phone-back::before {
    font-size: 10px;
  }

  .ap-kv-label,
  .ap-kv-value {
    font-size: 12px;
    line-height: 1.35;
  }

  .ap-profile-meta-row {
    gap: 8px;
  }

  .ap-meta-box {
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.35;
    border-radius: 8px;
  }

  .ap-profile-stats {
    gap: 8px;
  }

  .ap-stat-box {
    padding: 8px 10px;
    gap: 8px;
    border-radius: 10px;
  }

  .ap-stat-icon {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .ap-stat-label {
    font-size: 11px;
    margin-bottom: 0;
  }

  .ap-stat-value {
    font-size: 15px;
  }

  .ap-level-progress-card {
    padding: 10px;
    border-radius: 10px;
  }

  .ap-level-progress-head {
    margin-bottom: 6px;
    font-size: 12px;
  }

  .ap-level-progress-remain {
    font-size: 12px;
  }

  .ap-level-progress-track {
    height: 18px;
  }

  .ap-level-progress-text {
    font-size: 10px;
    padding: 0 6px;
  }

  .ap-level-progress-hint {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.35;
  }

  .ap-activate-tip {
    font-size: 12px;
    line-height: 1.4;
  }
}

.ap-action-btn {
  font-family: inherit;
  cursor: pointer;
  box-sizing: border-box;
  width: 100%;
}

.ap-level-readonly {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e5ddd6;
  border-radius: 10px;
  font-size: 16px;
  background: #faf7f5;
  color: var(--ap-text);
  line-height: 1.45;
  font-weight: 600;
}

.ap-guide-boxes-readonly {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  background: #faf7f5;
  color: var(--ap-text);
  font-weight: 600;
  cursor: default;
  user-select: none;
}

.ap-guide-body[hidden] {
  display: none !important;
}

/* 代理采购 - 佣金与升级说明 */
.ap-guide-card {
  padding: 0;
  overflow: hidden;
  margin-bottom: 16px;
}

.ap-guide-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border: none;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  color: var(--ap-text);
  cursor: pointer;
  text-align: left;
}

.ap-guide-toggle__arrow {
  color: var(--ap-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.ap-guide-card.is-expanded .ap-guide-toggle__arrow {
  transform: rotate(180deg);
}

.ap-guide-body {
  padding: 0 16px 16px;
  border-top: 1px solid #f0e8e2;
}

.ap-guide-loading {
  margin: 12px 0;
  font-size: 14px;
  color: var(--ap-muted);
}

.ap-guide-sync-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #fff7f6;
  border: 1px solid #ffd6d6;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.6;
  color: #8c4a4a;
}

.ap-guide-section + .ap-guide-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed #ece4de;
}

.ap-guide-section__title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ap-text);
}

.ap-guide-note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ap-muted);
}

.ap-guide-list {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.65;
  color: #666;
}

.ap-guide-list li + li {
  margin-top: 6px;
}

.ap-upgrade-ladder-wrap {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  margin-bottom: 12px;
}

.ap-upgrade-ladder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 4px;
  padding: 12px;
  background: #faf7f5;
  border-radius: 12px;
  border: 1px solid #f0e8e2;
  box-sizing: border-box;
}

.ap-upgrade-step__node {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #e5ddd6;
  border-radius: 10px;
  min-width: 72px;
  box-sizing: border-box;
}

.ap-upgrade-step__node strong {
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
}

.ap-upgrade-step__tag {
  font-size: 11px;
  color: var(--ap-muted);
  text-align: center;
}

.ap-upgrade-step__arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ap-primary);
  flex-shrink: 0;
}

.ap-upgrade-step__arrow i {
  font-style: normal;
  font-size: 16px;
  font-weight: 700;
}

.ap-guide-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #f0e8e2;
  border-radius: 10px;
}

.ap-guide-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13px;
}

.ap-guide-table th,
.ap-guide-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3ece6;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}

.ap-guide-table th {
  background: #faf7f5;
  color: #666;
  font-weight: 600;
  white-space: nowrap;
}

.ap-guide-table tr:last-child td {
  border-bottom: none;
}

.ap-guide-calc {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.ap-guide-calc-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto 40px;
  gap: 6px 8px;
  align-items: stretch;
  width: 100%;
}

.ap-guide-calc-label {
  display: flex;
  align-items: flex-end;
  min-height: 32px;
  font-size: 12px;
  line-height: 1.25;
  color: #666;
  word-break: keep-all;
}

.ap-guide-control {
  width: 100%;
  min-width: 0;
  height: 40px;
  margin: 0;
  box-sizing: border-box;
  border: 1px solid #e5ddd6;
  border-radius: 10px;
  background: #fff;
  color: var(--ap-text);
  font-size: 13px;
  line-height: 1.2;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.ap-guide-control:focus {
  border-color: var(--ap-primary);
}

.ap-guide-select {
  padding: 0 24px 0 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ap-guide-input {
  padding: 0 8px;
  text-align: center;
  -moz-appearance: textfield;
}

.ap-guide-input::-webkit-outer-spin-button,
.ap-guide-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ap-guide-calc-result {
  margin-top: 0;
  padding: 10px;
  background: #fff7f6;
  border: 1px solid #ffd6d6;
  border-radius: 12px;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.ap-guide-calc-result__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
}

.ap-guide-calc-result__item--formula {
  flex: 1.6 1 0;
}

.ap-guide-calc-result__item--amount {
  flex: 0 0 78px;
  align-items: flex-end;
  text-align: right;
}

.ap-guide-calc-result span {
  font-size: 11px;
  color: var(--ap-muted);
  white-space: nowrap;
}

.ap-guide-calc-result strong {
  font-size: 13px;
  line-height: 1.4;
  color: var(--ap-text);
  font-weight: 600;
  word-break: break-word;
}

.ap-guide-calc-result__item--formula strong {
  font-size: 12px;
  line-height: 1.35;
}

.ap-guide-calc-result__item--amount strong {
  font-size: 18px;
  color: var(--ap-primary);
  white-space: nowrap;
}

@media (max-width: 768px) {
  .ap-guide-table {
    min-width: 480px;
    font-size: 12px;
  }

  .ap-upgrade-ladder-wrap {
    overflow: hidden;
  }

  .ap-upgrade-ladder {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: space-between;
    gap: 0;
    width: 100%;
    padding: 8px 4px;
  }

  .ap-upgrade-step__node {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 2px;
    border-radius: 8px;
    justify-content: center;
  }

  .ap-upgrade-step__node strong {
    font-size: 10px;
    line-height: 1.25;
    word-break: keep-all;
  }

  .ap-upgrade-step__tag {
    display: none;
  }

  .ap-upgrade-step__arrow {
    flex: 0 0 16px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1px;
    font-size: 8px;
    line-height: 1.1;
    padding: 0;
  }

  .ap-upgrade-step__arrow span {
    white-space: nowrap;
    transform: scale(0.92);
    transform-origin: center;
  }

  .ap-upgrade-step__arrow i {
    font-size: 10px;
    line-height: 1;
  }

  .ap-guide-calc-inputs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto 36px;
    gap: 5px 6px;
  }

  .ap-guide-calc-label {
    min-height: 28px;
    font-size: 10px;
    line-height: 1.2;
  }

  .ap-guide-control {
    height: 36px;
    font-size: 11px;
    border-radius: 8px;
  }

  .ap-guide-select {
    padding: 0 20px 0 6px;
    background-position: right 5px center;
    background-size: 10px;
  }

  .ap-guide-input {
    padding: 0 4px;
  }

  .ap-guide-calc-result {
    padding: 8px 6px;
    gap: 6px;
  }

  .ap-guide-calc-result span {
    font-size: 10px;
  }

  .ap-guide-calc-result strong {
    font-size: 11px;
  }

  .ap-guide-calc-result__item--formula strong {
    font-size: 10px;
  }

  .ap-guide-calc-result__item--amount {
    flex: 0 0 64px;
  }

  .ap-guide-calc-result__item--amount strong {
    font-size: 15px;
  }
}
