/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --max-width: 480px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(80px + var(--safe-bottom));
  min-height: 100dvh;
}

/* ========== Header ========== */
.header {
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(79,70,229,0.2);
}
.header-title { font-size: 1.1rem; font-weight: 600; }
.header-subtitle { font-size: 0.8rem; opacity: 0.85; }
.header-btn {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}
.header-btn:active { background: rgba(255,255,255,0.35); }

/* ========== Cards ========== */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* ========== Form Elements ========== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-hint {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 4px;
}
.form-hint.warn { color: var(--warning); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--gray-800);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-input.error, .form-select.error {
  border-color: var(--danger);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select {
  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='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  gap: 6px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: #4338CA; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-sm { padding: 8px 14px; font-size: 0.85rem; width: auto; }
.btn-xs { padding: 5px 10px; font-size: 0.75rem; width: auto; }

/* ========== Tabs ========== */
.tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-500);
  border-radius: 6px;
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.2s;
}
.tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* ========== Badge ========== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  line-height: 1.6;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-info { background: var(--primary-light); color: var(--primary); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
  max-width: 90vw;
  text-align: center;
}
.toast-error { background: var(--danger); }
.toast-success { background: var(--success); }
.toast-info { background: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: var(--max-width);
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  animation: modalIn 0.25s ease;
  max-height: 80vh;
  overflow-y: auto;
}
@keyframes modalIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.modal-body { margin-bottom: 20px; font-size: 0.95rem; color: var(--gray-600); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ========== Order Card (详情页用户卡片) ========== */
.order-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--primary);
}
.order-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.order-card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.order-card-nickname {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
}
.order-card-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--gray-600);
}
.order-card-info-item {
  display: flex;
  align-items: center;
  gap: 3px;
}
.order-card-phone {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.order-card-phone:active { opacity: 0.7; }
.order-card-address {
  flex: 1 1 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gray-500);
  font-size: 0.82rem;
  margin-bottom: 4px;
}
.order-card-address-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 100%;
  min-width: 0;
}
.copy-btn {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  color: var(--gray-500);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.copy-btn:active { background: var(--gray-100); }
.order-card-footer {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--gray-600);
  padding-top: 6px;
  border-top: 1px solid var(--gray-100);
}
.order-card-footer span { display: flex; align-items: center; gap: 3px; }
.upload-btn {
  background: none;
  border: 1px dashed var(--gray-300);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--primary);
  cursor: pointer;
  width: 100%;
  text-align: center;
}
.upload-btn:active { background: var(--primary-light); }


/* ========== Thumbnails ========== */
.order-card-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 0;
}
.thumb-img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  cursor: pointer;
}
.thumb-img:active { opacity: 0.8; }


/* ========== Floating Refresh Button ========== */
.float-refresh {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.4rem;
  box-shadow: 0 4px 12px rgba(79,70,229,0.4);
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.float-refresh:active { transform: scale(0.9); }
.float-refresh.spinning {
  animation: spin 0.6s linear infinite;
}

/* ========== Floating WeChat Button ========== */
.float-wechat {
  position: fixed;
  bottom: 24px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #07C160;
  color: #fff;
  border: none;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px rgba(7,193,96,0.4);
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.float-wechat:active { transform: scale(0.9); }


/* ========== Image Viewer Modal ========== */
.image-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 20px 0;
}
.image-viewer-content {
  width: 100%;
  max-width: 480px;
  padding: 16px;
}
.image-viewer-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-viewer-img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 16px;
  display: block;
}
.image-viewer-expired {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  margin-bottom: 16px;
}

/* ========== Deliver Checkbox ========== */
.deliver-checkbox {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
.deliver-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
  cursor: pointer;
}
.deliver-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-500);
  white-space: nowrap;
}
.deliver-checkbox input:checked + .deliver-label {
  color: var(--success);
  font-weight: 600;
}

/* Delivered card style */
.order-card.delivered {
  border-left-color: var(--success);
  opacity: 0.75;
}
.order-card.delivered .order-card-nickname {
  color: var(--gray-500);
}

/* ========== Agent Order List Item ========== */
.order-list-item {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.order-list-item:active { transform: scale(0.99); }
.order-list-item-left { flex: 1; min-width: 0; }
.order-list-item-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.order-list-item-meta { font-size: 0.8rem; color: var(--gray-500); }

/* ========== Submission Record ========== */
.submission-record {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-left: 3px solid transparent;
}
.submission-record-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.submission-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.submission-header-right .badge {
  flex-shrink: 0;
}
.submission-record-product { font-weight: 600; font-size: 0.95rem; }
.submission-record-detail { font-size: 0.85rem; color: var(--gray-600); }
.submission-record-time { font-size: 0.75rem; color: var(--gray-400); margin-top: 4px; }
.submission-record-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
}
.submission-record-footer .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.payment-btn {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.5;
}
.payment-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Submission card states */
.submission-record.delivered {
  opacity: 1;
}
.submission-record.delivered .submission-record-product {
  color: var(--gray-500);
}
.submission-record.delivered .payment-btn {
  opacity: 1 !important;
  background-color: var(--primary) !important;  /* 确保背景色不变 */
  color: #fff !important;                      /* 确保文字颜色 */
}
.submission-record.cancelled {
  border-left-color: var(--danger);
  background: #FFF5F5;
}
.submission-record.cancelled .submission-record-product {
  color: var(--danger);
}

/* ========== Status Filter Bar ========== */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}
.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ========== Bottom Action Bar ========== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  box-shadow: 0 -1px 8px rgba(0,0,0,0.06);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 50;
  max-width: var(--max-width);
  margin: 0 auto;
}
.bottom-bar .btn {
  flex: 1;
  padding: 10px 0;
  font-size: 0.85rem;
  border-radius: 8px;
  font-weight: 600;
}
.bottom-bar .btn-del {
  flex: 0 0 auto;
  min-width: 48px;
  height: 36px;
  padding: 0 12px;
  font-size: 0.8rem;
  border-radius: 8px;
  background: #fff;
  color: var(--gray-400);
  border: 1px solid var(--gray-200);
}
.bottom-bar .btn-del:active { background: var(--gray-100); color: var(--danger); }

/* ========== User Info Bar ========== */
.user-info-bar {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  border-radius: var(--radius);
  padding: 16px 20px;
  color: #fff;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.user-info-bar .nickname { font-size: 1.1rem; font-weight: 700; margin-bottom: 2px; }
.user-info-bar .address { font-size: 0.82rem; opacity: 0.85; }
.user-info-edit {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.user-info-edit:active { background: rgba(255,255,255,0.35); }

/* ========== Marquee ========== */
.marquee {
  width: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border-radius: var(--radius-sm);
  padding: 8px 0;
  margin-bottom: 16px;
  white-space: nowrap;
}
.marquee-text {
  display: inline-block;
  padding-left: 100%;
  animation: marquee-scroll 12s linear infinite;
  font-size: 0.85rem;
  color: #92400E;
  font-weight: 600;
}
@keyframes marquee-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 8px; opacity: 0.5; }
.empty-state-text { font-size: 0.9rem; }

/* ========== Auth Pages ========== */
.auth-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 20px;
  max-width: var(--max-width);
  margin: 0 auto;
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo h1 { font-size: 1.6rem; color: var(--primary); font-weight: 800; }
.auth-logo p { font-size: 0.85rem; color: var(--gray-500); margin-top: 4px; }
.auth-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow-md);
}
.auth-card h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; color: var(--gray-800); }
.auth-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--gray-500);
}
.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

/* ========== Detail Page Header ========== */
.detail-header {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.detail-header-title { font-size: 1.1rem; font-weight: 700; }

/* ========== Utility ========== */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-gray { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.fw-600 { font-weight: 600; }

/* ========== Loading Overlay ========== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.3);
  justify-content: center;
  align-items: center;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }