:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-soft: #f1f5f9;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #64748b;
  --shopee: #ee4d2d;
  --shopee-dark: #d73818;
  --shopee-light: #fff5f2;
  --tiktok: #111827;
  --emerald: #059669;
  --emerald-dark: #047857;
  --emerald-light: #ecfdf5;
  --blue: #2563eb;
  --amber: #d97706;
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

@media (display-mode: standalone) {
  .navbar {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

.nav-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.nav-top-row {
  display: contents;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  order: 1;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--shopee), #ff7337);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(238, 77, 45, 0.22);
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  order: 2;
}

.nav-btn {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

@media (hover: hover) {
  .nav-btn:hover {
    background: var(--bg-soft);
    color: var(--text-main);
  }
}

.nav-btn:active {
  background: var(--bg-soft);
  transform: scale(0.97);
}

.nav-btn.active {
  background: var(--shopee-light);
  color: var(--shopee);
}

.nav-btn.nav-admin {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: var(--amber);
}

.nav-btn.nav-admin.active {
  background: var(--amber);
  color: #fff;
  border-color: var(--amber);
}

.nav-auth,
.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  order: 3;
}

@media (max-width: 768px) {
  .nav-container {
    padding: 8px 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .nav-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    order: 1;
  }

  .brand {
    gap: 8px;
    order: 1;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
    border-radius: 8px;
  }

  .brand-name {
    font-size: 16px;
  }

  .nav-auth,
  .nav-user {
    order: 2;
    gap: 6px;
  }

  .nav-auth .btn,
  .nav-user .btn {
    padding: 6px 14px;
    font-size: 13px;
    min-height: 38px;
    height: 38px;
  }

  .nav-links {
    width: 100%;
    order: 2;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 4px;
    padding: 2px 0 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-btn {
    padding: 5px 11px;
    font-size: 12.5px;
    flex-shrink: 0;
  }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13.5px;
}

.user-name-label {
  font-weight: 600;
}

.user-balance-pill {
  font-weight: 700;
  color: var(--emerald);
  background: var(--emerald-light);
  padding: 2px 9px;
  border-radius: 999px;
}

/* Main Container */
.main-container {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 64px;
  flex: 1;
}

.view-section {
  display: none;
  flex-direction: column;
  gap: 32px;
}

.view-section.active {
  display: flex;
}

/* Hero Card */
.hero-card {
  background: radial-gradient(circle at top, #fff5f2, #ffffff 70%);
  border: 1px solid #fed7aa;
  border-radius: var(--radius-xl);
  padding: 44px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hero-pill {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #c2410c;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 999px;
}

.hero-title {
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 800;
  line-height: 1.24;
  max-width: 760px;
}

.text-shopee {
  color: var(--shopee);
}

.text-tiktok {
  color: var(--tiktok);
}

.hero-desc {
  color: var(--text-sub);
  font-size: 14.5px;
  max-width: 680px;
}

.platform-badges {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.plat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.plat-pill {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  background: #fff;
  color: var(--text-main);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}

.plat-pill.shopee {
  color: #ee4d2d;
  background: #fff5f2;
  border-color: #ffccbc;
}

.plat-pill.tiktok {
  color: #0f172a;
  background: #f8fafc;
  border-color: #cbd5e1;
}

.plat-svg-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.plat-badge-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.plat-badge-inline.shopee {
  color: #ee4d2d;
  background: #fff5f2;
  border-color: #fed7aa;
}

.plat-badge-inline.tiktok {
  color: #0f172a;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Search Bar */
.search-bar-wrap {
  width: 100%;
  max-width: 760px;
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* Quick 3-Step Guide (Hero) */
.quick-guide-strip {
  width: 100%;
  max-width: 760px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #fed7aa;
  border-radius: 14px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  box-shadow: 0 2px 8px rgba(238, 77, 45, 0.05);
}

.qg-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #334155;
}

.qg-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--shopee), #ff7337);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qg-text {
  line-height: 1.25;
}

.qg-text strong {
  color: #0f172a;
}

.qg-arrow {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .main-container {
    padding: 12px 12px 48px;
  }

  .view-section {
    gap: 18px;
  }

  .hero-card {
    padding: 16px 14px;
    gap: 10px;
    border-radius: 18px;
  }

  .hero-pill {
    font-size: 11.5px;
    padding: 3px 10px;
  }

  .hero-title {
    font-size: 20px;
    line-height: 1.25;
    margin: 2px 0;
  }

  .hero-desc {
    display: none; /* Ẩn bớt mô tả dài dòng trên điện thoại để user mở lên thấy ngay ô dán & cách dùng */
  }

  .platform-badges {
    gap: 6px;
    margin-bottom: 2px;
  }

  .plat-label {
    display: none;
  }

  .plat-pill {
    font-size: 11.5px;
    padding: 3px 10px;
  }

  .search-bar-wrap {
    flex-direction: column;
    margin-top: 4px;
    gap: 8px;
  }

  .quick-guide-strip {
    padding: 8px 10px;
    gap: 6px;
    border-radius: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .qg-item {
    font-size: 12px;
    gap: 6px;
  }

  .qg-num {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .qg-arrow {
    font-size: 11px;
  }
}

.search-input-group {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-group input {
  width: 100%;
  height: 52px;
  padding: 0 114px 0 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 14.5px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input-group input:focus {
  outline: none;
  border-color: var(--shopee);
  box-shadow: 0 0 0 4px rgba(238, 77, 45, 0.1);
}

.btn-paste-inline {
  position: absolute;
  right: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

@media (hover: hover) {
  .btn-paste-inline:hover {
    background: #e2e8f0;
    color: var(--text-main);
  }
}

.btn-paste-inline:active {
  background: #cbd5e1;
  transform: scale(0.96);
}

.btn-clear-inline {
  position: absolute;
  right: 68px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

/* ==================== INSTANT PREVIEW CARD ==================== */
.instant-preview-wrap {
  width: 100%;
  max-width: 760px;
  margin-top: 14px;
  animation: pwaSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.instant-preview-card {
  background: #ffffff;
  border: 1.5px solid #a7f3d0;
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.08), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.instant-preview-card.loading {
  opacity: 0.75;
}

.ip-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ip-badge-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ip-badge-cashback {
  background: #dcfce7;
  color: #15803d;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ip-product-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.ip-thumb {
  width: 74px;
  height: 74px;
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ip-details {
  flex: 1;
  min-width: 0;
}

.ip-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ip-numbers {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13.5px;
}

.ip-price {
  color: #475569;
}

.ip-price strong {
  color: #0f172a;
}

.ip-cashback {
  color: #059669;
  font-weight: 700;
}

.ip-note {
  font-size: 12.5px;
  color: #64748b;
  font-style: italic;
}

.ip-footer-row {
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.ip-guest-hint {
  font-size: 12.5px;
  color: #64748b;
}

.ip-guest-hint strong {
  color: #0f172a;
}

/* Result Section */
.result-section {
  max-width: 760px;
  width: 100%;
  margin: -10px auto 0;
}

.result-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cashback-product-card {
  background: #fff;
  border: 2px solid #a7f3d0;
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (max-width: 640px) {
  .cashback-product-card {
    padding: 14px 12px;
    gap: 12px;
    border-radius: 16px;
  }
}

.cp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.valid-badge {
  background: var(--emerald-light);
  color: var(--emerald-dark);
  border: 1px solid #6ee7b7;
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}

.product-meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-page);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.product-thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.product-meta-info {
  flex: 1;
  min-width: 0;
}

.product-meta-info h4 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.product-meta-sub {
  font-size: 13px;
  color: var(--text-sub);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.prod-price-tag {
  color: var(--text-sub);
  font-size: 13.5px;
}

.prod-price-tag strong {
  color: var(--text-main);
}

.est-cashback-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #047857;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.est-cashback-badge strong {
  color: #059669;
  font-size: 15px;
  font-weight: 800;
}

.est-cashback-badge.normal {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

/* Nổi bật phần quan trọng: Nút Mua Hàng to rõ */
.cp-cta-block {
  width: 100%;
}

.btn-open-aff {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--shopee), #ff5722);
  color: #ffffff !important;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(238, 77, 45, 0.28);
  transition: transform 0.15s, box-shadow 0.15s;
}

@media (hover: hover) {
  .btn-open-aff:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(238, 77, 45, 0.38);
  }
}

.btn-open-aff:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(238, 77, 45, 0.2);
}

/* Rút gọn link aff thành 1 ô ngang duy nhất (Bỏ QR) */
.cp-link-single-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.aff-input-box {
  flex: 1;
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 0 12px;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.aff-input-box:focus-within {
  border-color: var(--shopee);
  background: #ffffff;
}

@media (hover: hover) {
  .aff-input-box:hover {
    border-color: var(--shopee);
    background: #ffffff;
  }
}

.aff-link-icon {
  font-size: 14px;
  color: #94a3b8;
  flex-shrink: 0;
}

.aff-single-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 13px;
  color: #334155;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  outline: none;
  cursor: pointer;
  padding: 0;
}

.btn-copy-inline {
  height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #0f172a;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  transition: all 0.15s ease;
  white-space: nowrap;
}

@media (hover: hover) {
  .btn-copy-inline:hover {
    border-color: var(--shopee);
    color: var(--shopee);
    background: #fff5f2;
  }
}

.btn-copy-inline:active {
  background: #f1f5f9;
  transform: scale(0.97);
}

.guest-card-note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12.5px;
  padding: 10px 14px;
  border-radius: 10px;
}

.inline-link {
  background: none;
  border: none;
  color: var(--shopee);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

/* Referral & Order Sync Notices */
.referral-banner {
  background: linear-gradient(135deg, #f0fdf4, #ffffff);
  border-color: #a7f3d0;
  margin-bottom: 20px;
}

.referral-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ref-link-group {
  display: flex;
  gap: 8px;
  min-width: 0;
  flex: 1;
  max-width: 420px;
}

.order-sync-notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 12.5px;
  padding: 10px 14px;
  border-radius: 10px;
}

/* FAQ & Legal */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
}

.faq-item {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.faq-item h4 {
  font-size: 14.5px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.faq-item p {
  font-size: 13.5px;
  color: var(--text-sub);
}

/* Section Blocks (Roadmap & 5 Golden Rules) */
.section-block {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title-wrap {
  text-align: center;
}

.section-kicker {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--shopee);
  text-transform: uppercase;
}

.section-title-wrap h2 {
  font-size: 22px;
  font-weight: 800;
  margin-top: 4px;
}

.section-title-wrap p {
  font-size: 14px;
  color: var(--text-sub);
  margin-top: 4px;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

@media (max-width: 860px) {
  .steps-grid {
    grid-template-columns: 1fr;
  }
}

.step-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.step-1 {
  background: var(--shopee-light);
  color: var(--shopee);
}
.step-2 {
  background: #fef3c7;
  color: #b45309;
}
.step-3 {
  background: var(--emerald-light);
  color: var(--emerald-dark);
}

.rules-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.rule-item {
  display: flex;
  gap: 12px;
  background: var(--bg-page);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.rule-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--shopee);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rule-item h4 {
  font-size: 14px;
  margin-bottom: 4px;
}

.rule-item p {
  font-size: 12.5px;
  color: var(--text-sub);
}

/* Panels & Wallet & Admin */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-sub {
  font-size: 13px;
  color: var(--text-sub);
}

.empty-auth-box {
  text-align: center;
  padding: 48px 24px;
}

.wallet-header-banner,
.admin-banner {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.stats-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 920px) {
  .stats-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  .stats-grid-4 {
    grid-template-columns: 1fr;
  }
}

.stat-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.stat-box.stat-green {
  border-left: 5px solid var(--emerald);
}
.stat-box.stat-orange {
  border-left: 5px solid var(--shopee);
}
.stat-box.stat-blue {
  border-left: 5px solid var(--blue);
}
.stat-box.stat-gray {
  border-left: 5px solid #64748b;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
}

.wallet-two-col,
.admin-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 980px) {
  .wallet-two-col,
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.inline-form-grid {
  display: grid;
  grid-template-columns: 120px 1fr 1fr auto;
  gap: 8px;
}

@media (max-width: 720px) {
  .inline-form-grid {
    grid-template-columns: 1fr;
  }
}

/* Forms & Inputs */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.two-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.three-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (max-width: 680px) {
  .two-inputs,
  .three-inputs {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-main);
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--shopee);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-cta {
  background: linear-gradient(135deg, var(--shopee), #ff6533);
  color: #fff;
  height: 52px;
  padding: 0 26px;
  font-size: 15px;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(238, 77, 45, 0.3);
  white-space: nowrap;
}

.btn-primary {
  background: var(--shopee);
  color: #fff;
}

.btn-success {
  background: var(--emerald);
  color: #fff;
}

.btn-outline {
  background: #fff;
  color: var(--text-main);
  border-color: var(--border);
}

.btn-ghost {
  background: var(--bg-soft);
  color: var(--text-sub);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
  line-height: 1.2;
}

.btn-warning {
  background: #f59e0b;
  color: #ffffff;
  border-color: #f59e0b;
}

.btn-secondary {
  background: #64748b;
  color: #ffffff;
  border-color: #64748b;
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
}

@media (hover: hover) {
  .btn-cta:hover:not(:disabled) {
    background: var(--shopee-dark);
  }

  .btn-primary:hover:not(:disabled) {
    background: var(--shopee-dark);
  }

  .btn-success:hover:not(:disabled) {
    background: var(--emerald-dark);
  }

  .btn-outline:hover {
    background: var(--bg-soft);
  }

  .btn-ghost:hover {
    background: #e2e8f0;
    color: var(--text-main);
  }

  .btn-warning:hover:not(:disabled) {
    background: #d97706;
  }

  .btn-secondary:hover:not(:disabled) {
    background: #475569;
  }

  .btn-danger:hover:not(:disabled) {
    background: #b91c1c;
  }
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
  opacity: 0.9;
}

.text-danger {
  color: #dc2626 !important;
}

.btn-full {
  width: 100%;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: var(--bg-page);
  font-weight: 700;
  color: var(--text-sub);
}

.text-center {
  text-align: center !important;
  color: var(--text-muted);
}

.status-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.st-pending {
  background: #fef3c7;
  color: #b45309;
}
.st-approved,
.st-paid {
  background: var(--emerald-light);
  color: var(--emerald-dark);
}
.st-cancelled,
.st-rejected {
  background: #fee2e2;
  color: #b91c1c;
}

/* Guide Steps */
.guide-steps-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.guide-step-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--bg-page);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.step-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--shopee);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Footer */
.footer {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-sub);
}

.footer-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-box {
  background: #fff;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  min-width: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.15s ease;
}

@media (hover: hover) {
  .close-btn:hover {
    background: var(--bg-soft);
    color: var(--text-main);
  }
}

.close-btn:active {
  background: #e2e8f0;
}

.auth-tabs {
  display: flex;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 11px;
  border: none;
  background: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  background: #fff;
  color: var(--shopee);
  border-bottom-color: var(--shopee);
}

.modal-body-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Toast */
.toast {
  position: fixed;
  top: calc(24px + env(safe-area-inset-top, 0px));
  bottom: auto;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 250;
}

/* ==================== PWA INSTALL FLOATING BANNER ==================== */
.pwa-install-banner {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 24px;
  max-width: 400px;
  width: calc(100% - 48px);
  z-index: 150;
  animation: pwaSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pwaSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.pwa-banner-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #ffffff;
  border: 1.5px solid #a7f3d0;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 14px 34px -6px rgba(15, 23, 42, 0.16), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pwa-banner-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #f0fdf4;
  border: 1.5px solid #d1fae5;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.12);
}

.pwa-app-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pwa-banner-body {
  flex: 1;
  min-width: 0;
}

.pwa-banner-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 3px;
  line-height: 1.3;
}

.pwa-banner-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.45;
  margin-bottom: 12px;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-pwa-install {
  background: #059669;
  color: #ffffff;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 18px;
  min-height: 38px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

@media (hover: hover) {
  .btn-pwa-install:hover {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35);
  }
}

.btn-pwa-install:active {
  transform: scale(0.97);
  background: #047857;
}

.btn-pwa-dismiss {
  background: #ffffff;
  color: #475569;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  min-height: 38px;
  border-radius: 9px;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

@media (hover: hover) {
  .btn-pwa-dismiss:hover {
    background: #f8fafc;
    color: #1e293b;
    border-color: #94a3b8;
  }
}

.btn-pwa-dismiss:active {
  background: #f1f5f9;
  transform: scale(0.97);
}

/* PWA Guide Modal */
.pwa-guide-box {
  max-width: 480px;
}

.pwa-guide-content {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pwa-step-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.pwa-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #059669;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-step-text {
  flex: 1;
  font-size: 13.5px;
  color: #334155;
  line-height: 1.45;
}

.pwa-step-text strong {
  color: #0f172a;
}

.pwa-guide-highlight {
  display: inline-block;
  background: #ecfdf5;
  color: #047857;
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 700;
  border: 1px solid #a7f3d0;
}

@media (max-width: 640px) {
  /* iOS Safari Auto-Zoom Fix (< 16px triggers zoom on focus) */
  input,
  select,
  textarea,
  .search-input-group input,
  .aff-single-input,
  .modal-box input,
  .form-group input,
  .form-group select {
    font-size: 16px !important;
  }

  /* Search Input & Action Buttons sizing on Mobile (Wins over base rules) */
  .search-input-group input {
    height: 48px;
    padding: 0 110px 0 14px;
    border-radius: 12px;
  }

  .btn-paste-inline {
    right: 8px;
    padding: 0 14px;
    min-height: 40px;
    height: 40px;
    border-radius: 8px;
  }

  .btn-cta {
    height: 46px;
    font-size: 14.5px;
    border-radius: 12px;
  }

  /* Product Card Meta on Mobile */
  .product-meta-row {
    padding: 10px;
    gap: 10px;
  }

  .product-thumb {
    width: 56px;
    height: 56px;
  }

  /* Card padding reduction for mobile real-estate (excluding empty state) */
  .panel:not(.empty-auth-box),
  .step-card,
  .rules-card {
    padding: 16px 14px;
    border-radius: 14px;
  }

  .wallet-header-banner,
  .admin-banner,
  .stat-box,
  .modal-body-form,
  .pwa-guide-content {
    padding: 14px 16px;
  }

  /* Touch targets minimum size */
  .btn:not(.btn-xs) {
    min-height: 40px;
  }

  .nav-btn {
    min-height: 40px;
    font-size: 13.5px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
  }

  .btn-pwa-install,
  .btn-pwa-dismiss {
    min-height: 40px;
    height: 40px;
    flex: 1;
  }

  /* Hide quick-guide orphaned arrow when steps wrap on small mobile */
  .qg-arrow {
    display: none;
  }

  /* Safe Area positioning on iPhone & Toast separated to Top */
  .toast {
    top: calc(16px + env(safe-area-inset-top, 0px));
    bottom: auto;
    left: 14px;
    right: 14px;
    text-align: center;
    width: auto;
    max-width: none;
  }

  .pwa-install-banner {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 14px;
    right: 14px;
    width: auto;
    max-width: none;
  }
}

/* Accessibility: Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
