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

:root {
  --bg: #0f1117;
  --bg-2: #161922;
  --card: #1c2030;
  --card-bg: #1c2030;
  --border: #2a2f42;
  --text: #e7e9ee;
  --muted: #8b91a3;
  --primary: #6366f1;
  --primary-hover: #5558e3;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --cyan: #06b6d4;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --overlay-rgb: 15, 17, 23;       /* RGB ของ --bg (สำหรับ overlay สี) */
}

[data-theme="light"] {
  --bg: #f5f6fa;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-bg: #ffffff;
  --border: #e1e4eb;
  --text: #1a1c25;
  --muted: #6b7280;
  --primary-hover: #4f52d8;
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --overlay-rgb: 245, 246, 250;
  color-scheme: light;
}

/* Light mode: ปรับ component บางอย่างที่ใช้ dark-only colors */
[data-theme="light"] .navbar { border-bottom-color: #e5e7eb; }
[data-theme="light"] .nav-links a:hover { background: rgba(0,0,0,0.05); }
[data-theme="light"] .user-menu-trigger { background: var(--bg-2); }
[data-theme="light"] .form-group input,
[data-theme="light"] .form-group textarea,
[data-theme="light"] .form-group select,
[data-theme="light"] .admin-form input,
[data-theme="light"] .admin-form textarea,
[data-theme="light"] .admin-form select { background: #f9fafb; color: var(--text); }
[data-theme="light"] .chat-customer { color: white; }
[data-theme="light"] .chat-sys { background: #f3f4f6; }
[data-theme="light"] .order-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
[data-theme="light"] .dash-stat-card {
  background: linear-gradient(135deg, #ffffff, #f9fafb);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
[data-theme="light"] .dash-stat-card.topup {
  background: linear-gradient(135deg, #f0fdf4, #ffffff);
}
[data-theme="light"] .dash-stat-value { color: var(--text); }
[data-theme="light"] .product-image,
[data-theme="light"] .product-detail-image {
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(6,182,212,0.06));
}
[data-theme="light"] .cat-banner {
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(6,182,212,0.08));
}
[data-theme="light"] .hero { background: linear-gradient(135deg, #eef2ff 0%, #f5f6fa 100%); }
[data-theme="light"] .image-emoji { color: #4b5563; }

body {
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ===== Layout ===== */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-header {
  margin-bottom: 2rem;
}
.page-header h1 { font-size: 2rem; margin-bottom: 0.25rem; }
.subtitle { color: var(--muted); }

.section-title {
  font-size: 1.5rem;
  margin: 2rem 0 1rem;
}

.back-link {
  display: inline-block;
  color: var(--muted);
  margin-bottom: 1rem;
  text-decoration: none;
}
.back-link:hover { color: var(--text); }

/* ===== Navbar ===== */
.navbar {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  /* นาฬิกาวิเศษ: ห้าม user-info ตกบรรทัดเพราะ pill admin เพิ่ม */
}
.logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.logo-img {
  height: 44px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  display: block;
}
.nav-links {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  flex: 1 1 0;
  min-width: 0;
  flex-wrap: nowrap;
}
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.88rem;
  transition: all 0.15s;
  white-space: nowrap;
}
.nav-links a:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-links a.active { background: var(--primary); color: white; }
.nav-links .ni {
  display: inline-block;
  color: initial;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
  -webkit-text-fill-color: initial;
}
.umd-link span:first-child,
.umd-stat-icon {
  color: initial;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
  -webkit-text-fill-color: initial;
}
.wallet-badge {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
}
.user-avatar-sm {
  width: 22px; height: 22px;
  border-radius: 50%;
  vertical-align: middle;
}
.user-name { font-size: 0.9rem; color: var(--muted); }
.btn-logout {
  color: var(--danger);
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  text-decoration: none;
}
.btn-logout:hover { text-decoration: underline; }

/* ===== Admin sub-nav ===== */
.admin-subnav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0 2rem;
  padding: 0.5rem;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.admin-subnav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.admin-subnav a:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.admin-subnav a.active { background: var(--primary); color: white; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--card); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-discord { background: #5865F2; color: white; padding: 1rem 2rem; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn-lg { padding: 0.85rem 1.8rem; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #1c2030 100%);
  padding: 5rem 1.5rem;
  text-align: center;
}
.hero-title { font-size: 3rem; margin-bottom: 1rem; }
.hero-subtitle { font-size: 1.2rem; color: var(--muted); margin-bottom: 2rem; }
.hero-actions { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }

/* Hero with image only */
.hero-image {
  width: 100%;
  max-width: 1200px;
  margin: 1.5rem auto 0;
  padding: 0 1.5rem;
  box-sizing: border-box;
}
.hero-image-wrap {
  display: block;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.hero-image-wrap:hover { transform: translateY(-2px); }
.hero-image-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

/* ===== Hero Slider ===== */
.hero-slider {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--bg-2);
  width: 100%;
  height: 380px;
}
@media (max-width: 900px) { .hero-slider { height: 220px; } }
@media (max-width: 480px) { .hero-slider { height: 140px; } }
.hero-slides {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.hero-slide.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}
.hero-slide a {
  display: block;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}
.hero-slide img {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 2rem;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding-bottom: 4px;
  transition: background 0.15s, transform 0.15s;
}
.hero-arrow:hover { background: rgba(0,0,0,0.8); transform: translateY(-50%) scale(1.1); }
.hero-prev { left: 12px; }
.hero-next { right: 12px; }

.hero-dots {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
  z-index: 5;
}
.hero-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid white;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.hero-dot.active {
  background: white;
  width: 28px;
  border-radius: 999px;
}

@media (max-width: 600px) {
  .hero-arrow { width: 36px; height: 36px; font-size: 1.5rem; }
  .hero-prev { left: 8px; }
  .hero-next { right: 8px; }
}

/* ===== Login ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-card {
  background: var(--bg-2);
  padding: 3rem 2.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 4rem; margin-bottom: 1rem; }
.login-title { font-size: 1.75rem; margin-bottom: 0.5rem; }
.login-subtitle { color: var(--muted); margin-bottom: 2rem; }

/* ===== Empty state ===== */
.empty-state, .empty-card {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.empty-card p { margin: 1rem 0; }

/* ===== Category tabs ===== */
.category-tabs, .filter-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.cat-tab {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--muted);
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.cat-tab:hover { color: var(--text); }
.cat-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== Product Grid ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.product-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}
.product-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.product-image {
  font-size: 4rem;
  text-align: center;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(6,182,212,0.1));
  aspect-ratio: 1 / 1;          /* รูปสินค้าเป็น 1:1 */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-image .image-emoji { font-size: 5rem; }
.product-body { padding: 1rem; }
.product-category {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.product-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.product-meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.product-price {
  color: var(--cyan);
  font-weight: 600;
  font-size: 1.1rem;
}
.admin-product-card.inactive { opacity: 0.5; }
.card-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; }
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 4px; font-size: 0.75rem; }
.badge-muted { background: var(--border); color: var(--muted); }

/* ===== Product Detail ===== */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}
@media (max-width: 768px) {
  .product-detail { grid-template-columns: 1fr; }
}
.product-detail-image {
  font-size: 8rem;
  text-align: center;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(6,182,212,0.1));
  border-radius: 12px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}
.product-detail-info h1 { margin: 0.5rem 0; }
.product-detail-price {
  color: var(--cyan);
  font-size: 2rem;
  font-weight: 700;
  margin: 1rem 0;
}
.product-description {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 1rem;
  white-space: pre-wrap; /* แสดงบรรทัด + spaces ตามที่ admin พิมพ์ */
  word-wrap: break-word;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}
.form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.form-group input[type=text],
.form-group input[type=password],
.form-group input[type=number],
.form-group input[type=email],
.form-group input[type=file],
.form-group textarea,
.form-group select,
.admin-form input[type=text],
.admin-form input[type=number],
.admin-form textarea,
.admin-form select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
.form-group textarea, .admin-form textarea { resize: vertical; }
.form-group input:focus, .admin-form input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.required { color: var(--danger); }
.encrypted-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  background: rgba(34,197,94,0.15);
  color: var(--success);
  border-radius: 4px;
  margin-left: 0.5rem;
}

/* ===== Stats ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.stat-card.warn { border-color: var(--warn); }
.stat-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--cyan); }

/* ===== Order List ===== */
.order-list { display: flex; flex-direction: column; gap: 0.5rem; }
.order-row {
  display: grid;
  grid-template-columns: 130px 1fr auto auto auto;
  gap: 1rem;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}
.order-row:hover { border-color: var(--primary); text-decoration: none; }
.order-code { font-family: monospace; color: var(--muted); font-size: 0.85rem; }
.order-name { font-weight: 500; }
.order-price { color: var(--cyan); font-weight: 600; }
.order-status {
  font-size: 0.8rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}
.order-date { font-size: 0.8rem; color: var(--muted); }

@media (max-width: 768px) {
  .order-row { grid-template-columns: 1fr 1fr; }
  .order-date { display: none; }
}

/* Status colors */
.status-warning { background: rgba(245,158,11,0.15); color: var(--warn); }
.status-info { background: rgba(59,130,246,0.15); color: var(--info); }
.status-primary { background: rgba(99,102,241,0.15); color: var(--primary); }
.status-success { background: rgba(34,197,94,0.15); color: var(--success); }
.status-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-muted { background: rgba(139,145,163,0.15); color: var(--muted); }

/* ===== Order Detail ===== */
.order-detail-wrap {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
}
@media (max-width: 900px) {
  .order-detail-wrap { grid-template-columns: 1fr; }
}
.order-main { display: flex; flex-direction: column; gap: 1.5rem; }
.order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}
.order-status-big {
  font-size: 1rem;
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
}
.info-section, .info-card, .payment-box, .chat-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
.info-section h3, .payment-box h3, .chat-section h3 {
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); font-size: 0.9rem; }
.info-value { text-align: right; word-break: break-all; }
.info-value code.copyable {
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}
.info-value code.copyable:hover { background: var(--primary); color: white; }

.payment-box { border-color: var(--warn); }
.payment-info { margin: 1rem 0; line-height: 2; }
.slip-thumb { max-width: 300px; border-radius: 8px; border: 1px solid var(--border); }
.file-upload {
  display: inline-block;
  cursor: pointer;
  padding: 0.6rem 1.2rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.file-upload:hover { border-color: var(--primary); }
.file-upload input[type=file] { display: none; }

.admin-action-panel {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

/* ===== Chat ===== */
.chat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.chat-msg {
  max-width: 75%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.92rem;
}
.chat-customer {
  align-self: flex-end;
  background: var(--primary);
  color: white;
}
.chat-admin {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
}
.chat-system {
  align-self: center;
  background: transparent;
  max-width: 100%;
}
.chat-sys {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 0.3rem 0.8rem;
  background: var(--bg-2);
  border-radius: 999px;
}
.chat-meta {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-bottom: 0.2rem;
}
.chat-body { white-space: pre-wrap; word-break: break-word; }
.chat-img { max-width: 220px; max-height: 220px; border-radius: 6px; margin-top: 0.4rem; display: block; }
.chat-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.chat-input input[type=text] {
  flex: 1;
  padding: 0.6rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}
.chat-attach {
  cursor: pointer;
  padding: 0.5rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chat-attach:hover { background: var(--card); }

/* ===== 2-column edit grid ===== */
.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 900px) { .edit-grid { grid-template-columns: 1fr; } }
.big-select {
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem !important;
}

/* ===== Discount badge + strikethrough ===== */
.price-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.price-strike {
  color: var(--muted);
  text-decoration: line-through;
  font-size: 1.1rem;
}
.price-strike.sm { font-size: 0.85rem; }
.discount-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
  padding: 0.2rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgba(239,68,68,0.3);
}
.discount-badge.sm {
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
}

/* ===== Variants (customer) ===== */
.variant-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.variant-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.variant-option:hover { border-color: var(--primary); transform: translateY(-1px); }
.variant-option.selected {
  border-color: var(--cyan);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 2px var(--cyan) inset;
}
.vopt-name { font-weight: 500; }
.vopt-price-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}
.vopt-price {
  color: var(--cyan);
  font-weight: 700;
  font-size: 1.05rem;
}

/* ===== Variant builder (admin) ===== */
.variant-row {
  display: grid;
  grid-template-columns: 32px 1fr 100px 110px 90px auto;
  gap: 0.5rem;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
}
.variant-row input { padding: 0.4rem 0.6rem !important; }

/* ===== Field builder ===== */
.fields-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 130px auto auto auto;
  gap: 0.5rem;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
}
.field-row input, .field-row select {
  padding: 0.4rem 0.6rem !important;
  font-size: 0.85rem !important;
}
.field-row label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 768px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  margin-top: auto;
}
.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
}
@media (max-width: 700px) { .footer-container { grid-template-columns: 1fr; } }
.footer-col h4 { margin-bottom: 0.7rem; font-size: 1rem; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: 0.4rem; }
.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.footer-links a:hover { color: var(--text); }
.footer-bottom {
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  padding-top: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ===== Search bar ===== */
.navbar-search { display: flex; }
.navbar-search input {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: inherit;
  font-family: inherit;
  font-size: 0.88rem;
  width: 120px;
  min-width: unset;
  transition: width 0.25s ease;
}
.navbar-search input:focus { outline: none; border-color: rgba(255,255,255,0.4); width: 200px; }
.navbar-search input::placeholder { color: rgba(255,255,255,0.6); }

/* ===== Hamburger (mobile) ===== */
.hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: inherit;
  width: 38px; height: 38px;
  border-radius: 8px;
  font-size: 1.3rem;
  cursor: pointer;
}
@media (max-width: 800px) {
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    flex-direction: column;
    padding: 0.5rem;
    z-index: 100;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 0.6rem 1rem; }
  .navbar-search { display: none; }
  .navbar-container {
    position: relative;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }
  .user-info { margin-left: auto; gap: 0.35rem; }
}

/* ===== FAQ ===== */
.faq-list { display: flex; flex-direction: column; gap: 0.5rem; }
.faq-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.faq-item summary::before { content: '▸ '; color: var(--primary); }
.faq-item[open] summary::before { content: '▾ '; }
.faq-item p { color: var(--muted); margin-top: 0.5rem; line-height: 1.7; }

/* ===== Reviews / Stars ===== */
.stars-display { display: inline-flex; gap: 0.1rem; }
.stars-display.sm .star { font-size: 0.85rem; }
.star { color: #475569; font-size: 1.25rem; }
.star.on { color: #fbbf24; }
.stars-input {
  display: inline-flex;
  gap: 0.2rem;
  cursor: pointer;
}
.stars-input .star { font-size: 1.8rem; transition: transform 0.1s; }
.stars-input .star:hover { transform: scale(1.15); }

.review-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
.review-box textarea {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}

.reviews-section { margin-top: 2.5rem; }
.rating-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.big-rating {
  font-size: 3rem;
  font-weight: 800;
  color: #fbbf24;
  line-height: 1;
}
.reviews-list { display: flex; flex-direction: column; gap: 0.5rem; }
.review-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.review-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ===== Leaderboard ===== */
.leaderboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
@media (max-width: 800px) { .leaderboard-grid { grid-template-columns: 1fr; } }
.lb-list { display: flex; flex-direction: column; gap: 0.4rem; }
.lb-row {
  display: grid;
  grid-template-columns: 40px 32px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1rem;
}
.lb-row.top-1 { border-color: gold; background: linear-gradient(90deg, rgba(255,215,0,0.1), transparent); }
.lb-row.top-2 { border-color: silver; background: linear-gradient(90deg, rgba(192,192,192,0.08), transparent); }
.lb-row.top-3 { border-color: #cd7f32; background: linear-gradient(90deg, rgba(205,127,50,0.08), transparent); }
.lb-rank {
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  color: var(--muted);
}
.lb-row.is-me { outline: 2px solid var(--success); background: rgba(34,197,94,0.06); }
.lb-row.top-1 .lb-rank { color: gold; }
.lb-row.top-2 .lb-rank { color: silver; }
.lb-row.top-3 .lb-rank { color: #cd7f32; }
.lb-name { font-weight: 600; }
.lb-value { color: var(--cyan); font-weight: 700; }

/* ===== Gacha ===== */
.gacha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.gacha-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gacha-img {
  aspect-ratio: 1/1;
  background: linear-gradient(135deg, rgba(168,85,247,0.15), rgba(236,72,153,0.1));
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem;
  overflow: hidden;
}
.gacha-img img { width: 100%; height: 100%; object-fit: cover; }
.gacha-info { padding: 1rem; }
.gacha-info h3 { margin-bottom: 0.4rem; }
.gacha-items-preview { display: flex; gap: 0.3rem; flex-wrap: wrap; margin: 0.5rem 0; }
.gacha-price { color: var(--cyan); font-weight: 700; font-size: 1.2rem; margin: 0.75rem 0; }

.rarity-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
}
.rarity-common { background: #6b7280; }
.rarity-rare { background: #3b82f6; }
.rarity-epic { background: #a855f7; }
.rarity-legendary { background: linear-gradient(135deg, #f59e0b, #ef4444); }

/* Gacha result modal */
.gacha-result {
  max-width: 420px;
  width: 100%;
  text-align: center;
  padding: 2rem 2rem 1.5rem;
  position: relative;
  overflow: hidden;
}

/* Slot frame */
.gacha-slot-frame {
  width: 150px; height: 150px;
  margin: 0 auto 1.25rem;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35);
  border: 3px solid var(--border);
  font-size: 5.5rem;
  position: relative;
  transition: border-color 0.4s, box-shadow 0.4s;
  overflow: hidden;
}
.gacha-slot-frame::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 50%, rgba(0,0,0,0.1) 100%);
  pointer-events: none;
}
.gacha-slot-frame.rarity-legendary {
  border-color: #f59e0b;
  box-shadow: 0 0 50px rgba(245,158,11,0.9), inset 0 0 30px rgba(245,158,11,0.15);
  animation: legendaryPulse 1.2s ease-in-out infinite;
}
.gacha-slot-frame.rarity-epic {
  border-color: #a855f7;
  box-shadow: 0 0 40px rgba(168,85,247,0.8), inset 0 0 20px rgba(168,85,247,0.1);
}
.gacha-slot-frame.rarity-rare {
  border-color: #3b82f6;
  box-shadow: 0 0 30px rgba(59,130,246,0.6);
}
.gacha-slot-frame.rarity-common {
  border-color: #6b7280;
}
@keyframes legendaryPulse {
  0%, 100% { box-shadow: 0 0 50px rgba(245,158,11,0.9), inset 0 0 30px rgba(245,158,11,0.15); }
  50% { box-shadow: 0 0 90px rgba(245,158,11,1), 0 0 140px rgba(239,68,68,0.5), inset 0 0 40px rgba(245,158,11,0.25); }
}

/* Slot spin animation */
.gacha-slot-frame .slot-symbol {
  display: inline-block;
  transition: transform 0.05s;
}
.gacha-slot-frame.rolling .slot-symbol {
  animation: slotRoll 0.12s steps(1) infinite;
}
@keyframes slotRoll {
  0%   { transform: translateY(-8px); opacity: 0.7; }
  50%  { transform: translateY(0);    opacity: 1; }
  100% { transform: translateY(8px);  opacity: 0.7; }
}

/* Reveal bounce */
@keyframes revealBounce {
  0%   { transform: scale(0.4) rotate(-10deg); opacity: 0; }
  55%  { transform: scale(1.18) rotate(3deg); opacity: 1; }
  75%  { transform: scale(0.93) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.gacha-slot-frame.revealed {
  animation: revealBounce 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Rarity overlay flash */
#gachaOverlay.rarity-flash-legendary { animation: flashLegendary 0.6s ease-out; }
#gachaOverlay.rarity-flash-epic      { animation: flashEpic 0.5s ease-out; }
#gachaOverlay.rarity-flash-rare      { animation: flashRare 0.5s ease-out; }
@keyframes flashLegendary {
  0%,100% { background: rgba(0,0,0,0.7); }
  40% { background: rgba(245,158,11,0.35); }
}
@keyframes flashEpic {
  0%,100% { background: rgba(0,0,0,0.7); }
  40% { background: rgba(168,85,247,0.3); }
}
@keyframes flashRare {
  0%,100% { background: rgba(0,0,0,0.7); }
  40% { background: rgba(59,130,246,0.25); }
}

/* Confetti */
.confetti-piece {
  position: absolute;
  top: -12px;
  pointer-events: none;
  border-radius: 3px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(380px) rotate(900deg) scale(0.5); opacity: 0; }
}

/* Rarity badge */
.rarity-result {
  display: inline-block;
  padding: 0.4rem 1.4rem;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: white;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.rarity-result.rarity-common { background: #6b7280; }
.rarity-result.rarity-rare { background: #3b82f6; box-shadow: 0 0 15px rgba(59,130,246,0.5); }
.rarity-result.rarity-epic { background: #a855f7; box-shadow: 0 0 25px rgba(168,85,247,0.7); animation: epicGlow 1.5s ease-in-out infinite alternate; }
.rarity-result.rarity-legendary {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 0 30px rgba(245,158,11,0.9);
  animation: legendaryBadge 1s ease-in-out infinite alternate;
}
@keyframes epicGlow {
  from { box-shadow: 0 0 20px rgba(168,85,247,0.5); }
  to   { box-shadow: 0 0 40px rgba(168,85,247,0.9); }
}
@keyframes legendaryBadge {
  from { box-shadow: 0 0 25px rgba(245,158,11,0.7); }
  to   { box-shadow: 0 0 50px rgba(239,68,68,0.9); }
}

/* Opening status text */
.gacha-opening-status {
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.4em;
  margin: 0.25rem 0 0.75rem;
  animation: statusPulse 1s ease-in-out infinite alternate;
}
@keyframes statusPulse {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}
.gacha-opening-status.done { animation: none; opacity: 1; }

/* Reward text */
.gacha-reward-text {
  background: rgba(255,215,0,0.12);
  border: 1px solid rgba(255,215,0,0.4);
  border-radius: 10px;
  padding: 0.5rem 1rem;
  color: #ffd700;
  font-weight: 700;
  margin-top: 0.75rem;
  display: inline-block;
  animation: revealBounce 0.5s ease-out;
}

/* Spin bar (3 reels) */
.gacha-reels {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin: 0 auto 1rem;
  width: fit-content;
}
.gacha-reel {
  width: 52px; height: 64px;
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  position: relative;
}
.gacha-reel.locked {
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  animation: none;
}

.gacha-spin {
  font-size: 5rem;
  margin-bottom: 1rem;
  display: inline-block;
  transition: transform 0.3s;
}
.gacha-spin.spinning { animation: spin 0.3s linear infinite; }
@keyframes spin {
  from { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.1); }
  to { transform: rotate(360deg) scale(1); }
}
.gacha-result.celebrate { animation: celebrate 0.5s ease-out; }
@keyframes celebrate {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ===== Commission tier stairs ===== */
.commission-info {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.tier-stairs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}
@media (max-width: 700px) { .tier-stairs { grid-template-columns: 1fr; } }
.tier-stair {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.tier-stair.tier-1 { background: rgba(136,135,128,.12); border: 1px solid rgba(136,135,128,.3); }
.tier-stair.tier-2 { background: rgba(29,158,117,.12); border: 1px solid rgba(29,158,117,.3); }
.tier-stair.tier-3 { background: rgba(127,119,221,.15); border: 1px solid rgba(127,119,221,.4); }
.ts-name { font-weight: 700; font-size: 0.95rem; }
.ts-detail { color: var(--muted); font-size: 0.8rem; line-height: 1.4; }
.ts-total { font-weight: 700; align-self: flex-end; }
.tier-stair.tier-1 .ts-total { color: var(--gray-400); }
.tier-stair.tier-2 .ts-total { color: var(--teal-400); }
.tier-stair.tier-3 .ts-total { color: var(--purple-400); }
.tier-stair.current {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  position: relative;
}
.tier-stair.current::after {
  content: '◉';
  position: absolute;
  top: -8px; right: -8px;
  background: var(--cyan);
  color: white;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
}

.tier-progress {
  margin-top: 0.5rem;
}
.tier-progress-bar {
  height: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}
.tier-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--cyan), var(--primary));
  border-radius: 999px;
  transition: width 0.5s ease;
}
.tier-progress-marks {
  position: relative;
  height: 18px;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 4px;
}
.tier-progress-marks span {
  position: absolute;
  transform: translateX(-50%);
}

.agent-table { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

/* ===== Earnings cards (wallet) ===== */
.earnings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.earnings-grid.earnings-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .earnings-grid.earnings-grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .earnings-grid { grid-template-columns: 1fr; } }
.earnings-card.sales {
  border-color: var(--cyan);
  background: linear-gradient(135deg, rgba(6,182,212,0.08), transparent);
}
.earnings-card.sales .ec-value { color: var(--cyan); }
.earnings-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
}
.earnings-card.pending { border-color: var(--warn); background: linear-gradient(135deg, rgba(245,158,11,0.08), transparent); }
.earnings-card.withdrawable { border-color: var(--success); background: linear-gradient(135deg, rgba(34,197,94,0.08), transparent); }
.ec-icon { font-size: 1.8rem; margin-bottom: 0.3rem; }
.ec-label { color: var(--muted); font-size: 0.85rem; }
.ec-value { font-size: 2rem; font-weight: 800; margin: 0.3rem 0; }
.earnings-card.pending .ec-value { color: var(--warn); }
.earnings-card.withdrawable .ec-value { color: var(--success); }
.earnings-card small { color: var(--muted); font-size: 0.75rem; }

/* ===== Commission edit cards (settings) ===== */
.commission-edit-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.commission-edit-card.tier-1 { border-left: 4px solid var(--gray-400, #888); }
.commission-edit-card.tier-2 { border-left: 4px solid var(--success); }
.commission-edit-card.tier-3 { border-left: 4px solid var(--primary); }
.commission-edit-card h4 { margin-bottom: 0.75rem; }
.tier-edit-row {
  display: grid;
  grid-template-columns: 60px 1.5fr 1fr 1fr 1fr;
  gap: 0.5rem;
  align-items: end;
  margin-top: 0.5rem;
}
@media (max-width: 800px) {
  .tier-edit-row { grid-template-columns: 1fr 1fr; }
}
.tier-edit-row .form-group { margin-bottom: 0; }
.tier-edit-row label { font-size: 0.7rem; }
.tier-edit-row input { padding: 0.4rem 0.6rem !important; font-size: 0.85rem !important; }

/* Admin box card */
.admin-box-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.abx-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }

/* ===== Alerts ===== */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
}
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid var(--info); color: var(--info); }

/* ===== Order Form ===== */
.order-form { margin-top: 1.5rem; }

/* ===== Admin Dashboard ===== */
.dash-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) { .dash-stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .dash-stat-grid { grid-template-columns: 1fr; } }

.dash-stat-card {
  position: relative;
  background: linear-gradient(135deg, #1f2433, #161922);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  overflow: hidden;
}
.dash-stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(99,102,241,0.15), transparent 60%);
  pointer-events: none;
}
.dash-stat-card.topup {
  background: linear-gradient(135deg, #1a2e1f, #161922);
}
.dash-stat-card.topup::before {
  background: radial-gradient(circle at top right, rgba(34,197,94,0.2), transparent 60%);
}
.dash-stat-icon {
  font-size: 1.6rem;
  margin-bottom: 0.3rem;
  position: relative;
}
.dash-stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  position: relative;
}
.dash-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  position: relative;
}
.dash-stat-card.topup .dash-stat-value { color: var(--success); }

.dash-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 2rem 0;
}
@media (max-width: 900px) { .dash-chart-grid { grid-template-columns: 1fr; } }

.dash-chart-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
.dash-chart-card h3 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}
.dash-chart-card canvas {
  max-height: 260px;
}

/* ===== Admin form layout ===== */
.admin-form { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; }
.admin-form h3 { margin: 1.5rem 0 0.5rem; }

/* Auto-bordered card: any element with inline background var(--card-bg) ได้ border + shadow โดยอัตโนมัติ */
[style*="--card-bg"] {
  background: var(--bg-2) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* ===== Image uploader (product edit) ===== */
.image-uploader {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 600px) {
  .image-uploader { grid-template-columns: 1fr; }
}
.image-preview {
  width: 160px;
  height: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-emoji { font-size: 4rem; }
.image-controls { display: flex; flex-direction: column; gap: 0.5rem; }

/* ===== CTA Banner row (4 ช่องหน้าแรก) ===== */
.cta-banner-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.cta-banner-card {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.cta-banner-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.cta-banner-card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}
@media (max-width: 900px) {
  .cta-banner-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .cta-banner-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   ✨ VISUAL ENHANCEMENT PACK
   ============================================================ */

/* ── Page fade-in ── */
body { animation: pageFadeIn 0.35s ease both; }
@keyframes pageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Custom scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Glassmorphism Navbar ── */
.navbar {
  background: rgba(22, 25, 34, 0.75) !important;
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border-bottom: 1px solid rgba(255,255,255,0.06) !important;
  box-shadow: 0 1px 24px rgba(0,0,0,0.3);
}
[data-theme="light"] .navbar {
  background: rgba(255,255,255,0.72) !important;
  border-bottom: 1px solid rgba(0,0,0,0.08) !important;
}

/* ── Gradient Primary Button ── */
.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
  box-shadow: 0 2px 12px rgba(99,102,241,0.35);
  transition: all 0.2s !important;
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #5558e3 0%, #7c3aed 100%) !important;
  box-shadow: 0 4px 20px rgba(99,102,241,0.55);
  transform: translateY(-2px) !important;
}
.btn-primary:active { transform: translateY(0) !important; box-shadow: 0 2px 8px rgba(99,102,241,0.3); }

/* ── Gradient Discord Button ── */
.btn-discord {
  background: linear-gradient(135deg, #5865F2, #7289da) !important;
  box-shadow: 0 2px 12px rgba(88,101,242,0.4);
}
.btn-discord:hover { box-shadow: 0 4px 20px rgba(88,101,242,0.6); transform: translateY(-2px) !important; }

/* ── Product card glow on hover ── */
.product-card {
  transition: all 0.22s cubic-bezier(0.23, 1, 0.32, 1) !important;
  border-color: transparent !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.product-card:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px var(--primary), 0 8px 32px rgba(99,102,241,0.25) !important;
  transform: translateY(-4px) !important;
}

/* ── Gacha card glow on hover ── */
.gacha-card {
  transition: all 0.22s cubic-bezier(0.23, 1, 0.32, 1);
  border-color: transparent !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.gacha-card:hover {
  border-color: rgba(168,85,247,0.6) !important;
  box-shadow: 0 0 0 1px rgba(168,85,247,0.5), 0 8px 32px rgba(168,85,247,0.2) !important;
  transform: translateY(-4px);
}
.gacha-img {
  background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(236,72,153,0.15)) !important;
}

/* ── Animated Hero gradient ── */
.hero {
  background: linear-gradient(135deg, #0f0c29, #1e1b4b, #1c2030, #0f1117) !important;
  background-size: 400% 400% !important;
  animation: heroShift 10s ease infinite, pageFadeIn 0.35s ease both !important;
}
@keyframes heroShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
[data-theme="light"] .hero {
  background: linear-gradient(135deg, #eef2ff, #f0f4ff, #f5f6fa, #e8f4fd) !important;
  animation: heroShiftLight 10s ease infinite, pageFadeIn 0.35s ease both !important;
}
@keyframes heroShiftLight {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Gradient active category tab ── */
.cat-tab.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
  border-color: transparent !important;
  box-shadow: 0 2px 10px rgba(99,102,241,0.35);
}
.admin-subnav a.active, .nav-links a.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

/* ── Input focus glow ── */
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus,
.chat-input input:focus {
  outline: none !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.18) !important;
}

/* ── Wallet pill gradient ── */
.wallet-pill {
  background: linear-gradient(135deg, rgba(6,182,212,0.15), rgba(99,102,241,0.15)) !important;
  border: 1px solid rgba(6,182,212,0.3) !important;
}

/* ── Stat card subtle glow ── */
.stat-card {
  transition: box-shadow 0.2s, border-color 0.2s;
}
.stat-card:hover {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 4px 20px rgba(99,102,241,0.12);
}
.stat-card.warn:hover { border-color: var(--warn); box-shadow: 0 4px 20px rgba(245,158,11,0.15); }

/* ── Dash stat card hover ── */
.dash-stat-card {
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
}
.dash-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
}

/* ── Order row hover ── */
.order-row {
  transition: all 0.18s !important;
}
.order-row:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 2px 16px rgba(99,102,241,0.15) !important;
  transform: translateX(2px);
}

/* ── Gacha multi-result rarity glow ── */
.rarity-card-legendary {
  border-color: #f59e0b !important;
  background: rgba(245,158,11,0.08) !important;
  box-shadow: 0 0 16px rgba(245,158,11,0.25), inset 0 0 12px rgba(245,158,11,0.06) !important;
}
.rarity-card-epic {
  border-color: #a855f7 !important;
  background: rgba(168,85,247,0.08) !important;
  box-shadow: 0 0 12px rgba(168,85,247,0.2) !important;
}
.rarity-card-rare {
  border-color: #3b82f6 !important;
  background: rgba(59,130,246,0.08) !important;
  box-shadow: 0 0 8px rgba(59,130,246,0.15) !important;
}

/* ── Rarity badge shadow glow ── */
.rarity-rare   { box-shadow: 0 0 6px rgba(59,130,246,0.5); }
.rarity-epic   { box-shadow: 0 0 8px rgba(168,85,247,0.6); }
.rarity-legendary { box-shadow: 0 0 10px rgba(245,158,11,0.7); }

/* ── Login card polish ── */
.login-card {
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04) !important;
}

/* ── Modal content shadow ── */
.modal-content {
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05) !important;
}

/* ── Variant option hover ── */
.variant-option:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px rgba(99,102,241,0.3) !important;
}
.variant-option.selected {
  border-color: var(--cyan) !important;
  box-shadow: 0 0 0 2px rgba(6,182,212,0.25) !important;
}
.variant-option.vopt-soldout {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  border-color: rgba(239,68,68,0.3) !important;
}

/* ── CTA banner hover ── */
.cta-banner-card:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 6px 24px rgba(99,102,241,0.2) !important;
  transform: translateY(-4px);
}

/* ── Page header subtle accent ── */
.page-header h1 {
  letter-spacing: -0.01em;
}
.page-header .subtitle {
  color: var(--muted);
}

/* ── Smooth image load ── */
img { transition: opacity 0.3s; }

/* ── Pull select button polish ── */
.pull-select {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pull-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.18) !important;
  outline: none !important;
}

/* ===== Admin banner list ===== */
.banner-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.banner-admin-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.banner-admin-card.inactive { opacity: 0.5; }
.banner-preview {
  aspect-ratio: 16 / 9;
  background: var(--bg);
  overflow: hidden;
}
.banner-preview img { width: 100%; height: 100%; object-fit: cover; }
.banner-info { padding: 0.85rem 1rem; }

/* ===== Category cards (browse) ===== */
.category-banner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.cat-banner-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: block;
}
.cat-banner-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  text-decoration: none;
}
.cat-banner {
  aspect-ratio: 16 / 5;     /* รูปหมวด = banner กว้าง */
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(6,182,212,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.cat-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cat-banner-fallback { font-size: 3.5rem; }
.cat-card-body { padding: 0.85rem 1rem; }
.cat-card-name { font-weight: 600; }
.cat-card-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }

/* Mobile: ลด min size ลง */
@media (max-width: 600px) {
  .category-banner-grid { grid-template-columns: 1fr; }
}

/* ===== Shop page big category cards ===== */
.shop-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.shop-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
.shop-breadcrumb a:hover { color: var(--text); }
.shop-breadcrumb span { color: var(--muted); }
.shop-breadcrumb strong { color: var(--text); }

.shop-category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
@media (max-width: 900px) { .shop-category-grid { grid-template-columns: 1fr; } }

.shop-category-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.2s;
}
.shop-category-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.shop-cat-banner {
  aspect-ratio: 16 / 5;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(6,182,212,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.shop-cat-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-cat-info {
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.shop-cat-info h3 { font-size: 1.1rem; margin-bottom: 0.2rem; }
.shop-cat-info .cat-meta { font-size: 0.85rem; color: var(--muted); }

/* ===== Admin category list ===== */
.category-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.category-admin-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.cat-body { padding: 1rem; }
.cat-meta { font-size: 0.85rem; color: var(--muted); margin: 0.4rem 0; }
.cat-meta code { background: var(--bg); padding: 0.1rem 0.4rem; border-radius: 4px; }
.cat-desc { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.75rem; }

.cat-create-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.cat-create-box summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.cat-create-box[open] summary { margin-bottom: 0.5rem; }

/* Category tree (admin) */
.category-tree { display: flex; flex-direction: column; gap: 0.4rem; }
.cat-tree-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 1rem;
}
.cat-tree-banner {
  width: 80px; height: 50px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cat-tree-banner img { width: 100%; height: 100%; object-fit: cover; }
.cat-tree-info .cat-meta { margin-top: 0.2rem; }
.cat-tree-actions { display: flex; gap: 0.3rem; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}
.modal-content,
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text);
}
.modal-content h2,
.modal-card h2 { margin-bottom: 1rem; }
/* ฟิลด์ dynamic ที่สร้างด้วย JS (ไม่อยู่ใน .form-group) ก็ต้องใช้ theme เดียวกัน */
.modal-card input[type=text],
.modal-card input[type=number],
.modal-card input[type=password],
.modal-card input[type=email],
.modal-card textarea,
.modal-card select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
}
.modal-card input:focus,
.modal-card textarea:focus,
.modal-card select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== App modal (custom confirm/alert) ===== */
.app-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  animation: fadeIn 0.15s ease;
}
.app-modal-overlay.promo-overlay {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.app-modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  position: relative;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.app-modal h3 { margin-bottom: 0.75rem; font-size: 1.15rem; }
.app-modal-close {
  position: absolute;
  top: 0.75rem; right: 0.75rem;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.app-modal-close:hover { background: var(--card); color: var(--text); }
#appModalBody {
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}
.app-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.app-modal-actions .btn { min-width: 100px; }

.confirm-product {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
}
.confirm-product .cp-img {
  width: 56px; height: 56px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
}
.confirm-product .cp-img img { width: 100%; height: 100%; object-fit: cover; }
.confirm-product .cp-img .image-emoji { font-size: 1.5rem; }
.cp-name { font-weight: 600; }
.cp-variant { font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; }

/* Discount list */
.discount-list { display: flex; flex-direction: column; gap: 0.4rem; }
.discount-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
}
.discount-item .dl-name { flex: 1; font-weight: 500; }
.discount-item .dl-percent {
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
  padding: 0.2rem 0.7rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ===== Theme toggle ===== */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.theme-toggle:hover { background: var(--card); transform: scale(1.05); }
.theme-toggle .theme-icon-light { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-dark { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-light { display: inline; }

/* ===== Order badge (admin) ===== */
.order-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--danger);
  color: white;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  animation: pulseGlow 2s ease-in-out infinite;
}
.order-badge:hover { background: #dc2626; text-decoration: none; transform: translateY(-1px); }
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* ===== Contact modal ===== */
.contact-modal { max-width: 460px; }
.contact-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.contact-header h2 { margin-bottom: 0.2rem; }
.contact-close {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}
.contact-close:hover { background: var(--card); color: var(--text); }
.contact-list { display: flex; flex-direction: column; gap: 0.5rem; }
.contact-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}
.contact-item:hover {
  border-color: var(--primary);
  transform: translateX(3px);
  text-decoration: none;
}
.contact-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.contact-info { min-width: 0; flex: 1; }
.contact-name { font-weight: 600; }
.contact-url {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Wallet badge ===== */
.wallet-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(34, 197, 94, 0.08));
  border: 1.5px solid rgba(34, 197, 94, 0.45);
  color: #4ade80;
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1;
  transition: all 0.18s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 6px rgba(0,0,0,0.15);
}
.wallet-badge:hover {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(34, 197, 94, 0.15));
  border-color: #4ade80;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 4px 14px rgba(34, 197, 94, 0.3);
}
.wallet-badge:active { transform: translateY(0); }
.wallet-badge span { font-variant-numeric: tabular-nums; }

.wallet-balance-card {
  background: linear-gradient(135deg, #16a34a, #0891b2);
  color: white;
  border-radius: 16px;
  padding: 1.5rem 2rem;
  text-align: center;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.wallet-label { font-size: 0.95rem; opacity: 0.9; margin-bottom: 0.4rem; }
.wallet-amount { font-size: 2.5rem; font-weight: 700; }

.wallet-section-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.topup-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}
.topup-section h2 { margin-bottom: 0.5rem; font-size: 1.2rem; }
.topup-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.topup-form input {
  flex: 1;
  min-width: 250px;
  padding: 0.7rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}
.topup-result {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
}
.topup-result.success {
  background: rgba(34,197,94,0.15);
  border: 1px solid var(--success);
  color: var(--success);
}
.topup-result.error {
  background: rgba(239,68,68,0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
}
.howto-box {
  margin-top: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.howto-box summary { cursor: pointer; color: var(--muted); }

.wallet-tx-list { display: flex; flex-direction: column; gap: 0.4rem; }
.wallet-tx-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  gap: 1rem;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
}
.wallet-tx-icon { font-size: 1.5rem; text-align: center; }
.wallet-tx-label { font-size: 0.95rem; }
.wallet-tx-date { font-size: 0.8rem; color: var(--muted); }
.wallet-tx-amount { font-weight: 700; font-size: 1.05rem; }
.wallet-tx-amount.pos { color: var(--success); }
.wallet-tx-amount.neg { color: var(--danger); }
.wallet-tx-balance { font-size: 0.85rem; color: var(--muted); min-width: 80px; text-align: right; }

@media (max-width: 600px) {
  .wallet-tx-row { grid-template-columns: 32px 1fr auto; }
  .wallet-tx-balance { display: none; }
}

/* wallet history 2-column → stack on mobile */
@media (max-width: 768px) {
  .wallet-history-cols { grid-template-columns: 1fr !important; }
  .wallet-main-cols { grid-template-columns: 1fr !important; }
}

/* ===== User dropdown menu ===== */
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.15);
  padding: 0.25rem 0.65rem 0.25rem 0.25rem;
  border-radius: 999px;
  cursor: pointer;
  color: inherit;
  transition: all 0.18s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.user-menu-trigger:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 4px 12px rgba(0,0,0,0.2);
}
.user-menu-trigger .user-avatar {
  width: 30px; height: 30px;
  border: 2px solid rgba(255,255,255,0.3);
}
.user-menu-trigger .caret {
  font-size: 0.65rem;
  opacity: 0.75;
  transition: transform 0.2s;
}
.user-menu.open .user-menu-trigger .caret { transform: rotate(180deg); }

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  z-index: 200;
}
.user-menu.open .user-menu-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.umd-header {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.7rem;
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 0.5rem;
}
.umd-header .user-avatar { width: 44px; height: 44px; border: 2px solid var(--primary); }
.umd-name { font-weight: 600; font-size: 1rem; }
.umd-id { font-size: 0.7rem; color: var(--muted); }

.umd-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.umd-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.4rem;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}
.umd-stat:hover { border-color: var(--primary); transform: translateY(-1px); text-decoration: none; }
.umd-stat-icon { font-size: 1.2rem; }
.umd-stat-label { font-size: 0.7rem; color: var(--muted); margin-top: 0.15rem; }
.umd-stat-value { font-weight: 700; font-size: 0.95rem; margin-top: 0.15rem; }

.umd-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
  transition: background 0.1s;
}
.umd-link:hover { background: var(--card); text-decoration: none; }
.umd-link.active { background: rgba(99,102,241,0.15); color: var(--primary); }
.umd-link span { font-size: 1.1rem; }
.umd-logout { color: var(--danger); }
.umd-logout:hover { background: rgba(239,68,68,0.1); }

.umd-divider {
  height: 1px;
  background: var(--border);
  margin: 0.4rem 0;
}

/* (มือถือ: ดูบรรทัดที่ MOBILE TIGHTENING ด้านล่าง — ใช้ rule นั้นแทน เพื่อกัน rule ซ้อน) */

/* ===== Point badges (navbar) ===== */
.point-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  border: 1px solid var(--border);
}
.point-badge:hover { text-decoration: none; transform: translateY(-1px); }
.point-farm {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warn);
  border-color: var(--warn);
}
.point-farm:hover { background: var(--warn); color: white; }
.point-topup {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border-color: #a855f7;
}
.point-topup:hover { background: #a855f7; color: white; }

/* ===== Point summary cards (dashboard) ===== */
.point-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
@media (max-width: 768px) { .point-cards { grid-template-columns: 1fr; } }
.point-card-big {
  border-radius: 16px;
  padding: 1.5rem;
  color: white;
  text-align: center;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.point-card-big:hover { transform: translateY(-3px); text-decoration: none; }
.point-card-big.wallet { background: linear-gradient(135deg, #16a34a, #0891b2); }
.point-card-big.farm { background: linear-gradient(135deg, #d97706, #ea580c); color: white; }
.point-card-big.topup { background: linear-gradient(135deg, #a855f7, #6366f1); color: white; }
.pcb-icon { font-size: 2.5rem; margin-bottom: 0.3rem; }
.pcb-label { font-size: 0.95rem; opacity: 0.9; }
.pcb-value { font-size: 2rem; font-weight: 700; margin-top: 0.3rem; }

/* ===== Dashboard grid ===== */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* Point transactions */
.point-tx-list { display: flex; flex-direction: column; gap: 0.4rem; }
.point-tx-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}
.point-tx-icon { font-size: 1.3rem; text-align: center; }
.point-tx-label { font-size: 0.9rem; }
.point-tx-date { font-size: 0.75rem; color: var(--muted); }
.point-tx-amount { font-weight: 700; }
.point-tx-amount.pos { color: var(--success); }
.point-tx-amount.neg { color: var(--danger); }

/* ===== Checkout summary ===== */
.checkout-summary {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
}
.cs-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.95rem;
}
.cs-warning {
  margin-top: 0.5rem;
  padding: 0.7rem;
  background: rgba(245,158,11,0.1);
  border: 1px solid var(--warn);
  border-radius: 8px;
  color: var(--warn);
  font-size: 0.9rem;
}

/* ===== Admin users list ===== */
.user-admin-list { display: flex; flex-direction: column; gap: 0.5rem; }
.user-admin-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.user-info-cell { display: flex; align-items: center; gap: 0.6rem; }
.user-stat-cell { display: flex; gap: 1.2rem; }
.stat-mini { display: flex; flex-direction: column; align-items: flex-end; }
.stat-mini-label { font-size: 0.7rem; color: var(--muted); }
.user-actions-cell { display: flex; gap: 0.3rem; flex-wrap: wrap; }

@media (max-width: 768px) {
  .user-admin-row { grid-template-columns: 1fr; }
  .user-actions-cell { justify-content: flex-start; }
}

/* ===== Product Management Table ===== */
.product-table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.product-table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.quick-search {
  flex: 1;
  max-width: 400px;
  padding: 0.55rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}
.quick-search:focus { outline: none; border-color: var(--primary); }

.product-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.product-table thead th {
  background: var(--bg);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.product-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
  background: var(--bg-2);
}
.product-table tbody tr:last-child td { border-bottom: none; }
.product-table tbody tr:hover { background: rgba(99,102,241,0.04); }

.th-action, .td-action { width: 80px; text-align: right; }
.th-price, .td-price { white-space: nowrap; color: var(--cyan); font-weight: 600; }
.th-date, .td-date { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.th-status { width: 110px; }
.th-type, .td-type { font-size: 0.85rem; white-space: nowrap; }

.pt-name-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.pt-thumb {
  width: 44px; height: 44px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(6,182,212,0.1));
  display: flex;
  align-items: center;
  justify-content: center;
}
.pt-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pt-thumb .image-emoji { font-size: 1.4rem; }
.pt-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.15rem; }
.pt-cat { font-size: 0.75rem; color: var(--muted); }

.pt-status {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.pt-status.active { background: rgba(34,197,94,0.15); color: var(--success); }
.pt-status.inactive { background: rgba(139,145,163,0.15); color: var(--muted); }

.pt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  margin-left: 0.2rem;
  transition: all 0.15s;
}
.pt-btn:hover { transform: translateY(-1px); text-decoration: none; }
.pt-btn.edit:hover { border-color: var(--primary); color: var(--primary); }
.pt-btn.delete { color: var(--danger); border-color: var(--danger); }
.pt-btn.delete:hover { background: var(--danger); color: white; }

@media (max-width: 800px) {
  .th-type, .td-type, .th-date, .td-date { display: none; }
}
@media (max-width: 500px) {
  .th-status, .td-status { display: none; }
}

/* ===== Wallet tabs ===== */
.wallet-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.4rem;
}
.wallet-tab {
  flex: 1;
  min-width: 100px;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
}
.wallet-tab:hover { background: rgba(99,102,241,0.08); color: var(--text); }
.wallet-tab.active { background: var(--primary); color: white; }
.wallet-tab-panel { display: none; }
.wallet-tab-panel.active { display: block; }

/* ===== Omise amount buttons ===== */
.omise-amount-btn.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

/* ===== Referral box ===== */
.referral-box {
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.ref-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.ref-link-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.ref-link-row input {
  flex: 1;
  padding: 0.6rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: monospace;
  font-size: 0.85rem;
}
.ref-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
@media (max-width: 600px) { .ref-stat-row { grid-template-columns: 1fr; } }
.ref-stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}
.ref-stat-label { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.2rem; }
.ref-stat-value { font-weight: 700; }
.ref-stat-value code { font-family: monospace; color: var(--primary); }

.agent-box {
  background: rgba(34,197,94,0.08);
  border: 1px solid var(--success);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.agent-box h3 { color: var(--success); margin-bottom: 0.75rem; }
.agent-details { font-size: 0.95rem; line-height: 1.8; }
.agent-details code { background: var(--bg); padding: 0.2rem 0.5rem; border-radius: 4px; cursor: pointer; }

.withdraw-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.withdraw-form h3 { margin-bottom: 0.5rem; }
.withdraw-form input {
  flex: 1;
  padding: 0.6rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

/* ===== Role badges ===== */
.role-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  margin-left: 0.4rem;
  font-weight: 600;
}
.role-user { background: rgba(139,145,163,0.2); color: var(--muted); }
.role-agent { background: rgba(6,182,212,0.2); color: var(--cyan); }
.role-sponsor { background: rgba(245,158,11,0.2); color: var(--warn); }
.role-admin { background: rgba(99,102,241,0.2); color: var(--primary); }
.role-owner { background: rgba(239,68,68,0.2); color: var(--danger); }

/* ===== Gift product (instant code) ===== */
.gift-badge {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(236, 72, 153, 0.1));
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
  color: #c084fc;
}

.gift-code-box {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  border-radius: 16px;
  padding: 1.5rem;
  color: white;
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.3);
}
.gift-code-box h3 { margin-bottom: 0.5rem; color: white; }
.gift-code-display {
  background: rgba(0,0,0,0.3);
  border: 2px dashed rgba(255,255,255,0.4);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.gift-code-display code {
  font-family: 'Courier New', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  word-break: break-all;
  color: white;
  flex: 1;
  min-width: 200px;
}

/* ===== Payment method options ===== */
.pay-method-options { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.75rem 0 1.25rem; }
.pay-method-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.pay-method-option:hover { border-color: var(--primary); }
.pay-method-option.disabled { opacity: 0.5; cursor: not-allowed; }
.pay-method-option input[type=radio] { margin-top: 0.25rem; }
.pay-method-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(99,102,241,0.05);
}
.pm-title { font-weight: 600; }
.pm-desc { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

/* ===== Avatar Level Ring (Phase 3) ===== */
.avatar-ring {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(var(--ring-color) calc(var(--ring-pct) * 1%), rgba(255,255,255,0.1) 0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px var(--ring-color);
}
.avatar-ring .user-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--card-bg);
}
.avatar-ring-lg {
  width: 64px;
  height: 64px;
  padding: 4px;
}
.avatar-tier-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--card-bg);
  border: 2px solid var(--ring-color);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1;
}
.avatar-ring-lg .avatar-tier-badge {
  width: 26px;
  height: 26px;
  font-size: 0.95rem;
  bottom: -2px;
  right: -2px;
}
.avatar-level-num {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ring-color);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1.5px solid var(--card-bg);
  white-space: nowrap;
  line-height: 1.2;
}

/* ===== Admin nav dropdown ===== */
.admin-subnav { gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.anav-dropdown { position: relative; }
.anav-trigger {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}
.anav-trigger:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.anav-trigger.active { background: rgba(99,102,241,0.15); color: var(--primary); }
.anav-trigger .caret { font-size: 0.75rem; opacity: 0.7; transition: transform 0.15s; }
.anav-dropdown.open .anav-trigger .caret { transform: rotate(180deg); }
.anav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem;
  min-width: 220px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
}
.anav-dropdown.open .anav-menu { display: block; }
.anav-menu a {
  display: block;
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  white-space: nowrap;
}
.anav-menu a:hover { background: rgba(255,255,255,0.05); text-decoration: none; }
.anav-menu a.active { background: var(--primary); color: white; }

/* ============================================
   ===== Mobile Responsive Improvements =====
   ============================================ */

/* All tables: wrap in scroll container on mobile */
@media (max-width: 768px) {
  .product-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .product-table thead,
  .product-table tbody,
  .product-table tr { display: table; width: 100%; table-layout: auto; }
  .product-table td,
  .product-table th { white-space: nowrap; }
}

/* Container padding tighter on mobile */
@media (max-width: 600px) {
  .container { padding: 1rem 0.75rem; }
  .page-header h1 { font-size: 1.5rem; }
  .section-title { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
}

/* Form rows: stack on mobile */
@media (max-width: 700px) {
  .form-row { grid-template-columns: 1fr !important; gap: 0.75rem; }
  .form-group input,
  .form-group select,
  .form-group textarea { font-size: 16px; /* iOS no zoom */ }
}

/* Admin subnav: scroll horizontally on mobile, dropdowns expand inline */
@media (max-width: 700px) {
  .admin-subnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.4rem;
  }
  .admin-subnav a,
  .admin-subnav .anav-trigger {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.4rem 0.7rem;
  }
  .anav-menu {
    position: fixed;
    top: auto !important;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 14px 14px 0 0;
    padding: 1rem;
    min-width: unset;
    width: 100%;
  }
  .anav-menu a { padding: 0.8rem; font-size: 1rem; }
  /* backdrop เวลาเปิด dropdown บน mobile */
  .anav-dropdown.open .anav-menu::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
  }
}

/* Order list rows: stack vertical on small */
@media (max-width: 600px) {
  .order-row {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .order-row .order-code,
  .order-row .order-name,
  .order-row .order-price,
  .order-row .order-status,
  .order-row .order-date { width: auto; text-align: left; }
}

/* User menu dropdown on mobile: ผูกกับปุ่ม trigger เป็น popup ปกติ
   ไม่ใช้ position: fixed เพราะ body มี transform (จาก pageFadeIn animation)
   ซึ่งทำให้ body กลายเป็น containing block ของ fixed → ตำแหน่งเพี้ยน
   ใช้ position: absolute ผูกกับ .user-menu (position: relative) แทน */
@media (max-width: 600px) {
  .user-menu-dropdown {
    position: absolute !important;
    top: calc(100% + 0.5rem) !important;
    right: 0 !important;
    left: auto !important;
    bottom: auto !important;
    width: calc(100vw - 1rem) !important;
    max-width: 320px !important;
    min-width: 0 !important;
    max-height: calc(100vh - 90px) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    border-radius: 12px !important;
    z-index: 1000;
    -webkit-overflow-scrolling: touch;
  }
}

/* Wallet badge + bell on mobile: smaller */
@media (max-width: 600px) {
  .wallet-badge { font-size: 0.8rem; padding: 0.3rem 0.5rem; }
  .navbar-container { gap: 0.35rem; padding: 0 0.6rem; }
  .logo-img { height: 34px; max-width: 120px; }
  .bell-pill { padding: 0.3rem 0.5rem; }
}
@media (max-width: 400px) {
  .wallet-pill span { display: none; }
}

/* Reward / Badge grids - smaller on mobile */
@media (max-width: 500px) {
  .reward-grid,
  .badge-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem;
  }
}

/* Daily 7-day grid */
@media (max-width: 500px) {
  .daily-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* Hero text smaller on mobile */
@media (max-width: 600px) {
  .hero { padding: 2.5rem 1rem; }
  .hero-title { font-size: 1.8rem; }
  .hero-subtitle { font-size: 0.95rem; }
}

/* Flash sale banner on mobile */
@media (max-width: 600px) {
  .flash-countdown { display: block; margin-top: 0.2rem; }
}

/* Modal full-width on mobile */
@media (max-width: 600px) {
  .modal-content,
  .modal-card {
    width: 96% !important;
    max-width: 96% !important;
    margin: 0.5rem;
  }
}

/* Stat cards: minimum 1 col on tiny screens */
@media (max-width: 400px) {
  .dash-stat-grid { grid-template-columns: 1fr !important; }
}

/* Footer tighter */
@media (max-width: 600px) {
  .footer-container { padding: 1rem; gap: 1rem; }
}

/* Bulk action bar — stack on mobile */
@media (max-width: 600px) {
  #bulkBar { flex-direction: column; align-items: stretch !important; }
  #bulkBar .btn { width: 100%; }
}

/* ===== Pill-style navbar items ===== */
.wallet-badge,
.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.wallet-badge:hover,
.nav-pill:hover {
  background: rgba(0,0,0,0.5);
  border-color: rgba(255,255,255,0.3);
  text-decoration: none;
  transform: translateY(-1px);
}
.navbar .orders-pill,
.navbar .wallet-badge.orders-pill,
.orders-pill {
  background: linear-gradient(135deg, #dc2626, #991b1b) !important;
  border-color: #ef4444 !important;
  color: #fff !important;
  box-shadow: 0 0 12px rgba(239,68,68,0.6) !important;
  animation: pulseRed 1.6s ease-in-out infinite;
}
.navbar .orders-pill:hover {
  background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
}
@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 10px rgba(239,68,68,0.5); }
  50% { box-shadow: 0 0 22px rgba(239,68,68,0.9); }
}
.wallet-pill {
  background: linear-gradient(135deg, #92400e, #78350f) !important;
  border-color: rgba(245,158,11,0.5) !important;
  color: #ffd700 !important;
}

/* Mobile navbar: compact pills */
@media (max-width: 700px) {
  .navbar-container { gap: 0.3rem; padding: 0 0.5rem; }
  .nav-pill,
  .wallet-badge {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    gap: 0.25rem;
  }
  /* ซ่อน label ใน orders pill เก็บแค่ตัวเลข */
  .orders-pill span::after { content: ''; }
  .logo-img { height: 30px; max-width: 110px; }
  .logo { font-size: 0.95rem; }
  /* search button → ทรงกลม ไอคอนอย่างเดียว */
  .navbar-search { width: 38px; height: 38px; padding: 0 !important; border-radius: 50%; }
  .navbar-search input { display: none; }
  .navbar-search::after { content: '🔍'; }
}

/* Tighter spacing on very small screens */
@media (max-width: 380px) {
  .navbar-container { gap: 0.25rem; }
  .nav-pill,
  .wallet-badge { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
  .logo-img { max-width: 80px; }
}

/* CTA banner cards: force 2x2 on mobile (not 1 column) */
@media (max-width: 900px) and (min-width: 481px) {
  .cta-banner-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .cta-banner-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
}

/* Product grid: 2 columns on mobile */
@media (max-width: 600px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem;
  }
  .product-card { font-size: 0.85rem; }
  .product-card .product-body { padding: 0.6rem; }
  .product-card .product-price { font-size: 1rem; }
}

/* ===== ลดขนาด Product card 40% ===== */
.product-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
  gap: 0.6rem !important;
}
.product-card .product-body { padding: 0.6rem !important; }
.product-card .product-name { font-size: 0.85rem; }
.product-card .product-price { font-size: 0.95rem; }
.product-card .product-category { font-size: 0.7rem; }
@media (max-width: 600px) {
  .product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 0.4rem !important; }
}

/* ===== Footer เล็กลง ===== */
.footer-container { padding: 1rem 1.5rem !important; gap: 1rem !important; }
.footer-container h3, .footer-container .footer-brand { font-size: 0.95rem !important; }
.footer-container p, .footer-container a, .footer-container small { font-size: 0.78rem !important; }
.footer-links a { padding: 0.2rem 0 !important; }
.footer-bottom { padding: 0.5rem 1.5rem !important; font-size: 0.72rem !important; }

/* ===== Bell pill ===== */
.navbar .bell-pill,
.bell-pill {
  background: rgba(0,0,0,0.35) !important;
  border: 1px solid rgba(255,255,255,0.25) !important;
  color: #fff !important;
  padding: 0.45rem 0.7rem !important;
  font-size: 1.05rem !important;
}
.navbar .bell-pill:hover {
  background: rgba(0,0,0,0.5) !important;
  border-color: rgba(255,255,255,0.45) !important;
}
.bell-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(239,68,68,0.6);
  animation: bellPulse 1.5s ease-in-out infinite;
}
@keyframes bellPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ============================================================
   📱 MOBILE TIGHTENING
   แก้ปัญหา mobile: stat cards เปลืองพื้นที่, profile card padding เยอะ
   ============================================================ */
@media (max-width: 600px) {
  /* Container: padding น้อยลงให้ใช้พื้นที่หน้าจอเต็ม */
  .container { padding: 1rem 0.875rem; }

  /* Stat grid: บังคับ 2 คอลัมน์บนมือถือ (ทุกจอ >= 340px) */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem;
    margin-bottom: 1rem;
  }
  .stat-card { padding: 0.85rem 0.9rem; }
  .stat-label { font-size: 0.72rem; margin-bottom: 0.25rem; line-height: 1.2; }
  .stat-value { font-size: 1.4rem; line-height: 1.1; }

  /* Profile card บน dashboard: padding น้อยลง, gap แคบลง */
  .profile-card {
    padding: 1rem !important;
    gap: 0.875rem !important;
    border-radius: 14px !important;
  }
  .profile-card .avatar-ring-lg img,
  .profile-card > img {
    width: 56px !important;
    height: 56px !important;
  }
  .profile-card .profile-name { font-size: 1.1rem !important; }

  /* Section title เล็กลง */
  .section-title { font-size: 1.1rem; }
  .page-header h1 { font-size: 1.4rem; }
}

/* จอเล็กมาก (iPhone SE, etc) */
@media (max-width: 380px) {
  .stat-value { font-size: 1.2rem; }
  .stat-card { padding: 0.7rem; }
}

/* ============================================================
   🖥️ Desktop ระยะกลาง 800-1200px: บีบ navbar ให้พอดี
   (โดยเฉพาะ admin ที่มี pill "1 ออเดอร์" เพิ่ม)
   ============================================================ */
@media (min-width: 801px) and (max-width: 1200px) {
  .navbar-container { gap: 0.6rem !important; padding: 0 1rem !important; }
  .nav-links { gap: 0.1rem !important; }
  .nav-links a { padding: 0.4rem 0.5rem !important; font-size: 0.82rem !important; }
  .navbar-search input { width: 100px !important; }
  .navbar-search input:focus { width: 160px !important; }
  .user-info { gap: 0.35rem !important; }
  .wallet-badge, .nav-pill { padding: 0.35rem 0.7rem !important; font-size: 0.8rem !important; }
}

/* ระยะ 1000-1200px ยังพอจะแสดง orders pill เต็มได้ — ปล่อย */
/* แต่ถ้าแคบกว่า 1000px (admin จะแน่นมาก) → ซ่อนคำว่า "ออเดอร์" เหลือแค่ตัวเลข */
@media (min-width: 801px) and (max-width: 999px) {
  .orders-pill span { display: none; }
  .orders-pill::after { content: ' รออยู่'; font-size: 0.7rem; opacity: 0.85; }
}

/* หน้า Badge Collection — header สเกลลงบนมือถือ */
@media (max-width: 600px) {
  .badge-container { margin: 1rem auto !important; }
  .badge-wrap { padding: 1.25rem !important; border-radius: 14px !important; }
  .badge-header h1 { font-size: 1.25rem !important; line-height: 1.2; }
  .badge-count { font-size: 1.4rem !important; }
  .badge-header small { font-size: 0.7rem !important; }
}
@media (max-width: 380px) {
  .badge-header h1 { font-size: 1.1rem !important; }
  .badge-count { font-size: 1.2rem !important; }
}

/* ===== Payment Method Grid (Omise) ===== */
.pay-method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}
.pay-method-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  user-select: none;
}
.pay-method-card input[type="radio"] { display: none; }
.pay-method-card img { width: 44px; height: 44px; border-radius: 8px; }
.pay-method-card span { font-size: 0.75rem; color: var(--muted); font-weight: 600; line-height: 1.25; }
.pay-method-card.active { border-color: var(--primary); background: rgba(99,102,241,0.08); }
.pay-method-card.active span { color: var(--primary); }
.pay-method-card:hover:not(.active) { border-color: var(--primary); opacity: 0.85; }

/* Bank select grid */
.bank-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.bank-select-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.4rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  user-select: none;
}
.bank-select-card input[type="radio"] { display: none; }
.bank-select-card img { width: 40px; height: 40px; border-radius: 8px; }
.bank-select-card span { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.bank-select-card.active { border-color: var(--primary); background: rgba(99,102,241,0.08); }
.bank-select-card.active span { color: var(--primary); }
.bank-select-card:hover:not(.active) { border-color: var(--primary); opacity: 0.85; }

@media (max-width: 480px) {
  .pay-method-grid { grid-template-columns: repeat(3, 1fr); }
  .bank-select-grid { grid-template-columns: repeat(3, 1fr); }
}
