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

:root {
  --primary: #0066ff;
  --primary-dark: #0052cc;
  --primary-light: #e6f0ff;
  --accent: #ff6b35;
  --accent-dark: #e85a2a;
  --bg: #f5f7fa;
  --white: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #5a6275;
  --text-light: #8b95a7;
  --border: #e4e8f0;
  --border-dark: #d1d7e0;
  --success: #00b87c;
  --warning: #f5a623;
  --danger: #e53e3e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --max-width: 1200px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; outline: none; }

/* ===== Layout ===== */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  cursor: pointer;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}
.nav { display: flex; align-items: center; gap: 28px; }
.nav-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s;
}
.nav-link:hover, .nav-link.active { color: var(--primary); }
.nav-actions { display: flex; align-items: center; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border-dark);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { background: var(--accent-dark); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Hero Section ===== */
.hero {
  background: linear-gradient(135deg, #0066ff 0%, #0044cc 100%);
  color: white;
  padding: 60px 0;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 500px; height: 500px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -30%; left: -5%;
  width: 300px; height: 300px;
  background: rgba(255,107,53,0.15);
  border-radius: 50%;
}
.hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.hero-visual {
  flex-shrink: 0;
}
@media (max-width: 900px) {
  .hero-inner { justify-content: center; }
  .hero-visual { display: none; }
}
.hero-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
}
.hero p {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 28px;
}
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-stats {
  display: flex;
  gap: 40px;
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid rgba(255,255,255,0.15);
}
.hero-stat .num { font-size: 1.8rem; font-weight: 800; }
.hero-stat .label { font-size: 0.8rem; opacity: 0.8; }

/* ===== How It Works ===== */
.section { padding: 60px 0; }
.section-title {
  text-align: center;
  margin-bottom: 48px;
}
.section-title h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.section-title p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}
.step-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.step-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.step-num {
  width: 40px; height: 40px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin: 0 auto 16px;
}
.step-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.step-card p { font-size: 0.85rem; color: var(--text-secondary); }

/* ===== Products Grid ===== */
.products-section { background: var(--bg); }
.products-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}
.products-header h2 { font-size: 1.6rem; font-weight: 700; }
.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cat-tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.cat-tab:hover { border-color: var(--primary); }
.cat-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.product-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.product-img {
  width: 100%;
  aspect-ratio: 1;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  position: relative;
}
.product-brand {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}
.product-body { padding: 16px; }
.product-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-spec { font-size: 0.8rem; color: var(--text-light); margin-bottom: 10px; }
.product-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.price-kws { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.price-cny { font-size: 0.75rem; color: var(--text-light); }

/* ===== Sourcing Section ===== */
.sourcing-section {
  background: var(--white);
}
.sourcing-banner {
  background: linear-gradient(135deg, #ff6b35 0%, #e85a2a 100%);
  border-radius: var(--radius);
  padding: 40px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 40px;
}
.sourcing-banner-content { flex: 1; }
.sourcing-banner h2 { font-size: 1.6rem; font-weight: 700; margin-bottom: 10px; }
.sourcing-banner p { opacity: 0.9; margin-bottom: 20px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000; /* above the mobile bottom nav (950) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 1.2rem;
  color: var(--text-light);
  background: transparent;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-label .req { color: var(--danger); }
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: border-color 0.2s;
  background: var(--white);
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-error {
  background: #fff0f0;
  border: 1px solid #ffccc0;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.form-success {
  background: #f0fff5;
  border: 1px solid #c0ffd6;
  color: var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ===== Orders Page ===== */
.orders-list { display: flex; flex-direction: column; gap: 16px; }
.order-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.order-no { font-size: 0.9rem; font-weight: 600; }
.order-date { font-size: 0.8rem; color: var(--text-light); }
.order-body { display: flex; gap: 20px; }
.order-info { flex: 1; }
.order-product { font-size: 0.95rem; font-weight: 500; margin-bottom: 4px; }
.order-meta { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; }
.order-price { font-size: 1.1rem; font-weight: 700; color: var(--accent); }

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-pending { background: #fff8e1; color: var(--warning); }
.status-confirmed { background: #e3f2fd; color: var(--primary); }
.status-purchasing { background: #e3f2fd; color: var(--primary); }
.status-warehouse { background: #e8f5e9; color: var(--success); }
.status-shipping { background: #fce4ec; color: #c2185b; }
.status-customs { background: #f3e5f5; color: #7b1fa2; }
.status-delivered { background: #e8f5e9; color: var(--success); }
.status-cancelled { background: #ffebee; color: var(--danger); }

/* Logistics timeline */
.logistics-timeline {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: 7px; top: 20px; bottom: -4px;
  width: 2px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--border-dark);
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 1;
}
.timeline-dot.active { background: var(--primary); }
.timeline-dot.current { background: var(--accent); box-shadow: 0 0 0 4px rgba(255,107,53,0.2); }
.timeline-content { flex: 1; }
.timeline-title { font-size: 0.85rem; font-weight: 600; }
.timeline-meta { font-size: 0.75rem; color: var(--text-light); }
.timeline-note { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* ===== Admin Dashboard ===== */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}
.admin-sidebar {
  width: 220px;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}
.admin-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.admin-menu-item:hover { background: var(--bg); }
.admin-menu-item.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-light);
}
.admin-content {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}
.admin-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 24px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 30px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 1.5rem; margin-bottom: 8px; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--text-light); }

/* ===== Table ===== */
.data-table {
  width: 100%;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  z-index: 300;
  animation: slideInRight 0.3s;
  box-shadow: var(--shadow-lg);
}
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ===== User Menu ===== */
.user-menu {
  position: relative;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.user-dropdown {
  position: absolute;
  top: 100%; right: 0;
  margin-top: 8px;
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  overflow: hidden;
  z-index: 10;
}
.user-dropdown-item {
  padding: 10px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.user-dropdown-item:hover { background: var(--bg); }

/* ===== Responsive ===== */
/* Mobile bottom navigation (desktop nav is hidden <=768px) */
.mobile-bottom-nav { display: none; }
@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 950;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-bottom-nav .mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.66rem;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-bottom-nav .mbn-item .mbn-ico { font-size: 1.25rem; line-height: 1; }
  .mobile-bottom-nav .mbn-item.active { color: var(--primary); font-weight: 600; }
  /* keep the floating buttons above the bottom bar */
  .wa-float { bottom: 84px !important; }
  .sourcing-float { bottom: 84px !important; padding: 12px 18px !important; font-size: 0.85rem !important; }
  body { padding-bottom: 66px; }
}
@media (max-width: 1024px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .nav { display: none; }
  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: 0.95rem; }
  .hero-stats { flex-direction: column; gap: 16px; }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: 1fr; }
  .sourcing-banner { flex-direction: column; text-align: center; padding: 24px; }
  .admin-sidebar { display: none; }
  .admin-content { padding: 16px; }
  .order-body { flex-direction: column; }
  /* Sourcing guide responsive */
  [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:repeat(2,1fr)"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2,1fr) !important; }
}
@media (max-width: 480px) {
  .products-grid { grid-template-columns: 1fr; }
}
