:root {
  --primary: #1e3a5f;
  --primary-light: #2563eb;
  --accent: #0ea5e9;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(30, 58, 95, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; border: none; background: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.container {
  width: min(1200px, 92%);
  margin: 0 auto;
}

.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-lg { width: 24px; height: 24px; }
.icon-sm { width: 16px; height: 16px; }

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 40px;
  height: 40px;
}
.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  transition: 0.2s;
}
.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background: rgba(30, 58, 95, 0.04);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mobile-menu-btn {
  display: none;
  padding: 8px;
  color: var(--primary);
}

@media (max-width: 900px) {
  .nav {
    display: none;
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px 16px;
    gap: 4px;
  }
  .nav.open { display: flex; }
  .nav-link { width: 100%; }
  .mobile-menu-btn { display: inline-flex; }
  .brand-name { font-size: 15px; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  transition: 0.2s;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(37, 99, 235, 0.3); }
.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* Hero */
.hero {
  background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border);
  padding: 64px 0 56px;
}
.hero-title {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.25;
  color: var(--primary);
  margin: 0 0 16px;
}
.hero-subtitle {
  font-size: 18px;
  color: var(--muted);
  max-width: 640px;
  margin: 0 0 28px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Module cards on home */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  padding: 48px 0;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  transition: 0.2s;
  display: flex;
  flex-direction: column;
}
.module-card:hover { transform: translateY(-4px); }
.module-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.module-icon.blue { background: #eff6ff; color: var(--primary-light); }
.module-icon.teal { background: #f0fdfa; color: #0d9488; }
.module-title { font-size: 22px; font-weight: 700; margin: 0 0 10px; }
.module-desc { color: var(--muted); margin: 0 0 20px; flex: 1; }

/* Section */
.section { padding: 48px 0; }
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.section-title { font-size: 24px; font-weight: 700; margin: 0; color: var(--primary); }
.section-subtitle { color: var(--muted); margin: 4px 0 0; }

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(30, 58, 95, 0.04);
  transition: 0.2s;
  display: flex;
  flex-direction: column;
}
.card:hover { box-shadow: var(--shadow); }
.card-image {
  aspect-ratio: 4 / 3;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: 0.3s;
}
.card:hover .card-image img { transform: scale(1.03); }
.card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}
.card-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-light);
}
.card-original {
  font-size: 13px;
  color: var(--muted);
  text-decoration: line-through;
  margin-left: 4px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.badge-blue { background: #eff6ff; color: var(--primary-light); }
.badge-green { background: #ecfdf5; color: #047857; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: var(--muted); }

/* Forms */
.form-card {
  max-width: 480px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.form-title { font-size: 24px; font-weight: 700; margin: 0 0 8px; text-align: center; }
.form-subtitle { color: var(--muted); text-align: center; margin: 0 0 24px; }
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}
.form-textarea { min-height: 120px; resize: vertical; }
.form-hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
}
.checkbox-row input { margin-top: 3px; }
.checkbox-row a { color: var(--primary-light); text-decoration: underline; }

/* Auth pages */
.auth-page { padding: 40px 0; }

/* Footer */
.footer {
  background: var(--primary);
  color: rgba(255, 255, 255, 0.85);
  padding: 40px 0 24px;
  margin-top: auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr; }
}
.footer-brand { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 12px; }
.footer-brand .brand-logo { filter: brightness(0) invert(1); }
.footer-title { color: #fff; font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.footer-link {
  display: block;
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
  padding: 4px 0;
  transition: 0.2s;
}
.footer-link:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 20px;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}
.footer-bottom a { color: rgba(255, 255, 255, 0.85); text-decoration: underline; }

/* Detail pages */
.detail-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.8fr;
  gap: 28px;
  padding: 40px 0;
  align-items: start;
}
@media (max-width: 980px) {
  .detail-layout { grid-template-columns: 1fr 1fr; }
  .detail-merchant { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
  .detail-layout { grid-template-columns: 1fr; }
  .detail-merchant { grid-column: auto; }
}
.detail-media {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.detail-main-image {
  aspect-ratio: 4 / 3;
  background: var(--bg);
}
.detail-main-image img { width: 100%; height: 100%; object-fit: cover; }
.detail-gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.detail-gallery::-webkit-scrollbar { width: 6px; }
.detail-gallery::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.detail-gallery img {
  width: 100%;
  height: 84px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  flex: 0 0 auto;
}
.detail-gallery img.active { border-color: var(--primary-light); }
.detail-info { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.detail-merchant { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; position: sticky; top: 88px; }
.merchant-title { font-size: 17px; font-weight: 700; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.merchant-block { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.merchant-logo { width: 46px; height: 46px; border-radius: 12px; background: var(--bg); color: var(--primary); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.merchant-name { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.merchant-intro { color: var(--muted); line-height: 1.7; font-size: 14px; margin: 0 0 16px; }
.merchant-note { color: var(--text); line-height: 1.7; font-size: 13px; margin: 0; padding-top: 14px; border-top: 1px dashed var(--border); }
.detail-title { font-size: 26px; font-weight: 700; margin: 0 0 12px; }
.detail-meta { color: var(--muted); margin-bottom: 16px; }
.detail-price { font-size: 32px; font-weight: 700; color: var(--primary-light); margin-bottom: 20px; }
.detail-desc { color: var(--text); line-height: 1.7; margin-bottom: 24px; }
.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.detail-long {
  margin-top: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.detail-long-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.detail-long-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}
.detail-long-images {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 760px;
  overflow-y: auto;
  padding-right: 6px;
  scroll-behavior: smooth;
}
.detail-long-images::-webkit-scrollbar { width: 6px; }
.detail-long-images::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.detail-long-images img {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: block;
}
@media (max-width: 768px) {
  .detail-long { padding: 20px; margin-top: 32px; }
  .detail-long-header { flex-direction: column; gap: 6px; }
  .detail-long-images { max-height: none; }
}

/* Info detail */
.info-detail-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 32px;
  padding: 40px 0;
  align-items: start;
}
@media (max-width: 768px) {
  .info-detail-layout { grid-template-columns: 1fr; }
}
.info-detail-image {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.info-detail-image img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.info-detail-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.info-detail-title { font-size: 24px; font-weight: 700; margin: 0 0 12px; }
.info-detail-section { margin-bottom: 20px; }
.info-detail-section h3 { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
.info-detail-section p { color: var(--muted); margin: 0; line-height: 1.7; }
.phone-mask {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}
.phone-login-tip { color: var(--muted); font-size: 14px; margin-top: 8px; }

/* Filters */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: center;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.filter-btn.active, .filter-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface);
  min-width: 240px;
}
.search-box input { border: none; outline: none; background: transparent; flex: 1; }

/* Cart */
.cart-table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cart-table th, .cart-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.cart-table th { background: #f8fafc; font-size: 14px; color: var(--muted); font-weight: 500; }
.cart-item-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.qty-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.qty-control button {
  width: 32px;
  height: 32px;
  background: var(--bg);
}
.qty-control span {
  width: 40px;
  text-align: center;
  font-size: 14px;
}
.cart-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.cart-total { font-size: 20px; font-weight: 700; }
.cart-total span { color: var(--primary-light); font-size: 28px; }

/* Admin */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  padding: 32px 0;
}
@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
}
.admin-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  height: fit-content;
}
.admin-sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}
.admin-sidebar a.active, .admin-sidebar a:hover {
  background: rgba(30, 58, 95, 0.06);
  color: var(--primary);
}
.admin-main { min-width: 0; }
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.admin-card-title { font-size: 18px; font-weight: 700; margin: 0 0 16px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.stat-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 18px;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 14px; color: var(--muted); margin-top: 4px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th, .data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 500; background: #f8fafc; }
.data-table td { color: var(--text); }
.data-table tr:hover td { background: #f8fafc; }
.td-actions { display: flex; gap: 8px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: min(680px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; margin: 0; }
.modal-close { color: var(--muted); padding: 4px; }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed;
  top: 84px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 300;
  max-width: 320px;
}
.toast.active { display: flex; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state p { margin: 8px 0 0; }

/* Loading */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Publish image preview */
.image-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  overflow: hidden;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }

/* Misc */
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
