:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: #eff6ff;
  --blue: #3b82f6;
  --blue-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.52;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 14px;
}

/* Storefront Top Navigation */
body.admin-mode .topbar { display: none; }
body.admin-mode main.page-wrap { padding: 0; }
body.admin-mode main.page-wrap > .container { max-width: none; padding: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 60px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--ink);
  cursor: pointer;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.48; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-accent { background: var(--blue); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #1d4ed8; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--ink-2); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--ink-2); padding: 6px 10px; }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 11px 20px; font-size: 15px; border-radius: 11px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-virtual { background: var(--primary-soft); color: var(--primary-hover); }
.badge-physical { background: #f1f5f9; color: #334155; }
.badge-success { background: var(--primary-soft); color: var(--primary-hover); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #f1f5f9; color: #475569; }

.cart-pill {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

main.page-wrap {
  padding: 18px 0 56px;
}

/* Storefront Customer Trust Hero (Light Sky-Blue Theme) */
.hero-bar {
  background: linear-gradient(135deg, #eff6ff 0%, #e0ecff 100%);
  color: var(--ink);
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.hero-bar h1 { font-size: 20px; font-weight: 800; margin-bottom: 4px; color: #1e293b; }
.hero-trust-line {
  color: #475569;
  font-size: 13.5px;
  font-weight: 600;
}

/* P0 Item #1: 2-Column Green Brand Tile Grid (holds 2 columns on desktop & 375px mobile) */
.store-layout {
  display: block;
}
.store-main-col {
  min-width: 0;
}
@media (min-width: 900px) {
  .store-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }
  .store-layout .brand-tile-section {
    position: sticky;
    top: 76px;
    margin-bottom: 0;
  }
  .store-layout .brand-tile-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.brand-tile-section {
  margin-bottom: 16px;
}
.brand-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.brand-tile {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  min-width: 0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}
.brand-tile:hover {
  transform: translateY(-1px);
  border-color: #93c5fd;
  background: #f8fbff;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.08);
}
.brand-tile.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.14);
}
.brand-tile-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-logo-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-tile.active .brand-logo-box {
  background: var(--primary);
  color: #ffffff;
}
.brand-logo-box svg {
  width: 21px;
  height: 21px;
  display: block;
}
.brand-tile-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-tile.active .brand-tile-name {
  color: var(--primary-hover);
}
.brand-count-pill {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}
.brand-tile.active .brand-count-pill {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: var(--primary-hover);
}

/* Search & Sort Toolbar */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.toolbar-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}
.search-box {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}
.input, select.input, textarea.input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14); }

/* Product Grid & P0 Item #3 Sold-Out Greyscale Styling */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 14px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  cursor: pointer;
  min-width: 0;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.09);
}

/* Item #3: Sold-out product cards are fully greyscaled + reduced opacity */
.product-card.is-sold-out {
  filter: grayscale(1);
  opacity: 0.62;
}
.product-card.is-sold-out:hover {
  opacity: 0.76;
}

.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #0f172a;
  overflow: hidden;
}
.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.soldout-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-weight: 700;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.28);
}

.card-body {
  padding: 11px 12px 13px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 41px;
}

.card-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  margin-top: auto;
}

.price-tag {
  color: #dc2626;
  font-size: 18px;
  font-weight: 800;
}

.stock-sales {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid #f1f5f9;
  padding-top: 7px;
}

.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* Product Detail */
.sold-out-top-banner {
  background: #1e293b;
  color: #fff;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 15.5px;
  font-weight: 800;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.detail-grid {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 26px;
}
.gallery-main {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f172a;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 10px; margin-top: 10px; }
.thumb-item {
  width: 74px;
  height: 74px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  position: relative;
}
.thumb-item.active { border-color: var(--primary); }
.thumb-item img { width: 100%; height: 100%; object-fit: cover; }
.thumb-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(15, 23, 42, 0.76);
  color: #fff;
  font-size: 10px;
  text-align: center;
}

.sku-btn {
  padding: 7px 14px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}
.sku-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}
.stepper button {
  width: 34px; height: 34px;
  border: none;
  background: var(--surface-alt);
  cursor: pointer;
  font-weight: 700;
}
.stepper input {
  width: 54px; height: 34px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  font-weight: 700;
}

.desc-dual {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.desc-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  white-space: pre-line;
  font-size: 13.5px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.panel h2 { font-size: 17.5px; margin-bottom: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap .input { padding-right: 40px; width: 100%; }
.pw-eye-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  border-radius: 6px;
}
.pw-eye-btn:hover { color: #0f172a; background: rgba(148, 163, 184, 0.14); }

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.channel-card {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  background: #fff;
}
.channel-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.usdt-highlight {
  background: var(--primary-soft);
  color: var(--ink);
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  padding: 16px 18px;
  margin: 14px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.usdt-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary-hover);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Payment Verification Animated Progress Bar */
.pay-verify-box {
  background: #f8fbff;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  padding: 16px 18px;
  margin-top: 14px;
}
.pay-verify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.pay-verify-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14.5px;
  color: #1e293b;
}
.pay-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.55);
  animation: pay-pulse 1.5s infinite;
  flex-shrink: 0;
}
.pay-progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  position: relative;
}
.pay-progress-fill {
  height: 100%;
  width: 15%;
  border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
  background-size: 200% 100%;
  position: relative;
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  animation: pay-shimmer 1.6s linear infinite;
}
.pay-progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.42) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: pay-sweep 1.4s ease-in-out infinite;
}
.pay-verify-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12.5px;
  color: #475569;
}
@keyframes pay-pulse {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}
@keyframes pay-shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
@keyframes pay-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ==========================================================================
   P0 Item #2: Fixed 232px Left Admin Sidebar + <900px Mobile Drawer (Light Theme)
   ========================================================================== */
.admin-layout {
  min-height: 100vh;
  background: var(--bg);
}

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 232px;
  background: var(--surface);
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  z-index: 320;
  border-right: 1px solid var(--border);
  transition: transform 0.2s ease;
}

.admin-sidebar-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
}

.admin-nav-list {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.admin-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.admin-nav-item:hover {
  background: var(--surface-alt);
  color: var(--ink);
}
.admin-nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.admin-sidebar-footer {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 250;
}

.admin-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  z-index: 310;
}

.admin-main {
  margin-left: 232px;
  padding: 22px 24px 48px;
  min-height: 100vh;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 800; color: var(--ink); margin-top: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th, table.data-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.data-table th {
  background: var(--surface-alt);
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
}

.subcat-chip {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
}
.subcat-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

/* Toast & Modal */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(0,0,0,0.2);
  max-width: 340px;
}
.toast.error { background: #dc2626; }
.toast.success { background: #2563eb; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

/* Responsive Breakpoints (< 900px Admin Drawer & 375px 2-Column Mobile Check) */
@media (max-width: 899px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-drawer-backdrop.open { display: block; }
  .admin-mobile-topbar { display: flex; }
  .admin-main { margin-left: 0; padding: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .desc-dual { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  /* Item #1 & #11: Both brand tiles AND product grid strictly maintain 2 columns at 375px */
  .brand-tile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .brand-tile {
    padding: 10px 10px;
    border-radius: 12px;
  }
  .brand-logo-box { width: 30px; height: 30px; border-radius: 8px; }
  .brand-tile-name { font-size: 13.5px; }
  .brand-count-pill { font-size: 11px; padding: 2px 7px; }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .card-body { padding: 9px 10px 11px; }
  .card-title { font-size: 13px; min-height: 38px; }
  .price-tag { font-size: 16px; }
  .stock-sales { font-size: 11px; }
  .hero-bar { padding: 15px 16px; }
  .hero-bar h1 { font-size: 17px; }
  .hero-trust-line { font-size: 12px; }
}
