/* =============================================
   好購團 - 團購平台 CSS
   ============================================= */

/* ---------- Variables ---------- */
:root {
  --primary: #FF6B35;
  --primary-dark: #e85a25;
  --primary-light: #fff0eb;
  --secondary: #2C3E50;
  --success: #27AE60;
  --warning: #F39C12;
  --danger: #E74C3C;
  --info: #3498DB;
  --bg: #F5F5F7;
  --bg-white: #FFFFFF;
  --border: #E8E8E8;
  --text: #1A1A1A;
  --text-muted: #888;
  --text-light: #BBB;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow: 0 4px 20px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --header-h: 60px;
  --bottom-nav-h: 64px;
  --transition: all 0.2s ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}
a { cursor: pointer; text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }
ul { list-style: none; }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ---------- App Layout ---------- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-white);
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.12);
}

/* ---------- Header ---------- */
#main-header {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--header-h);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-left, .header-right {
  display: flex; align-items: center; gap: 8px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 700; color: var(--primary);
  cursor: pointer;
}
.logo i { font-size: 22px; }

/* ---------- Icon Button ---------- */
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--secondary);
  transition: var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--bg); }

/* ---------- Badge ---------- */
.badge {
  position: absolute;
  top: -2px; right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  min-width: 17px; height: 17px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  font-weight: 700;
}

/* ---------- Avatar ---------- */
.avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  cursor: pointer;
}
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.avatar.xl { width: 64px; height: 64px; font-size: 24px; }

/* ---------- User Dropdown ---------- */
.user-dropdown {
  position: absolute;
  top: var(--header-h);
  right: 0;
  width: 220px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  padding: 8px 0;
}
.user-dropdown .dropdown-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
}
.user-dropdown a {
  display: flex; align-items: center;
  padding: 10px 16px;
  font-size: 14px;
  transition: var(--transition);
}
.user-dropdown a:hover { background: var(--bg); }
.user-dropdown a.text-danger { color: var(--danger); }

/* ---------- Sidebar ---------- */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
  display: none;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }
.sidebar {
  position: fixed;
  left: -280px;
  top: 0; bottom: 0;
  width: 280px;
  background: var(--bg-white);
  z-index: 200;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transition: left 0.3s ease;
}
.sidebar.open { left: 0; }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section-title {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase;
  padding: 8px 20px 4px;
  letter-spacing: 1px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  font-size: 14px;
  transition: var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item i { width: 18px; text-align: center; }
.nav-badge {
  background: var(--danger); color: #fff;
  font-size: 11px; padding: 2px 6px;
  border-radius: 10px; font-weight: 700;
  margin-left: auto;
}
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}

/* ---------- Main Content ---------- */
#main-content {
  padding-top: var(--header-h);
  padding-bottom: var(--bottom-nav-h);
  min-height: 100vh;
}

/* ---------- Pages ---------- */
.page { display: none; }
.page.active { display: block; }

/* ---------- Page Header ---------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px;
}
.page-header h2 {
  font-size: 20px; font-weight: 700;
}

/* ---------- Banner ---------- */
.banner {
  background: linear-gradient(135deg, var(--primary) 0%, #ff4e00 100%);
  color: #fff;
  padding: 32px 20px 40px;
  position: relative;
  overflow: hidden;
}
.banner-content { position: relative; z-index: 1; }
.banner-tag {
  background: rgba(255,255,255,0.2);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  margin-bottom: 12px;
}
.banner h1 { font-size: 28px; font-weight: 900; line-height: 1.3; margin-bottom: 10px; }
.banner p { font-size: 14px; opacity: 0.9; margin-bottom: 20px; }
.banner-decor { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.banner-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
}
.banner-circle.c1 { width: 150px; height: 150px; top: -30px; right: -30px; }
.banner-circle.c2 { width: 80px; height: 80px; top: 60px; right: 60px; }
.banner-circle.c3 { width: 120px; height: 120px; bottom: -40px; right: 20px; }

/* ---------- Section ---------- */
.section { padding: 20px 16px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-size: 18px; font-weight: 700;
  margin-bottom: 12px;
}

/* ---------- Category Grid ---------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.category-chip {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}
.category-chip:hover, .category-chip.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.category-chip .icon { font-size: 22px; margin-bottom: 4px; }
.category-chip .label { font-size: 11px; font-weight: 600; }

/* ---------- Product Grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.product-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.product-img {
  width: 100%; aspect-ratio: 1;
  object-fit: cover;
}
.product-img-placeholder {
  width: 100%; aspect-ratio: 1;
  background: linear-gradient(135deg, #f5f5f5, #e8e8e8);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
}
.product-info { padding: 10px; }
.product-name {
  font-size: 13px; font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}
.product-price-row {
  display: flex; align-items: center; gap: 6px;
}
.product-price { font-size: 15px; font-weight: 700; color: var(--primary); }
.product-original-price {
  font-size: 12px; color: var(--text-muted);
  text-decoration: line-through;
}
.product-tag-row { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.product-tag {
  font-size: 10px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
}
.product-status-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.status-active { background: #e8f8f0; color: var(--success); }
.status-closed { background: #f5f5f5; color: var(--text-muted); }
.status-soldout { background: #fef0ef; color: var(--danger); }
.deadline-chip {
  font-size: 10px; color: var(--warning);
  background: #fff8e7;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex; align-items: center; gap: 3px;
}

/* ---------- Product Detail ---------- */
.product-detail-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.product-detail-body { padding: 16px; }
.product-detail-name { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.product-detail-price-row {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 12px;
}
.product-detail-price { font-size: 26px; font-weight: 900; color: var(--primary); }
.product-detail-original { font-size: 16px; color: var(--text-muted); text-decoration: line-through; }
.discount-badge {
  background: var(--danger); color: #fff;
  padding: 4px 8px; border-radius: 6px;
  font-size: 13px; font-weight: 700;
}
.product-info-box {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 14px;
}
.product-info-box .info-row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
}
.product-info-box .info-row span:last-child { font-weight: 600; }
.product-desc {
  font-size: 14px; color: var(--text);
  line-height: 1.8; margin: 12px 0;
}
.qty-control {
  display: flex; align-items: center; gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: fit-content;
}
.qty-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--primary);
  transition: var(--transition);
}
.qty-btn:hover { background: var(--primary-light); }
.qty-input {
  width: 48px; text-align: center;
  border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  height: 36px; font-size: 15px; font-weight: 600;
  outline: none;
}
.detail-actions {
  display: flex; gap: 10px; margin-top: 16px;
}
.back-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  font-size: 14px; font-weight: 600; color: var(--secondary);
  cursor: pointer;
}
.back-btn:hover { color: var(--primary); }

/* ---------- Filter Bar ---------- */
.filter-bar {
  padding: 8px 16px 12px;
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
}
.search-wrap {
  flex: 1; min-width: 180px;
  position: relative;
}
.search-wrap i {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px;
}
.search-wrap input {
  width: 100%; padding: 9px 12px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--bg);
  outline: none; font-size: 14px;
  transition: var(--transition);
}
.search-wrap input:focus { border-color: var(--primary); background: #fff; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 500;
  background: var(--bg);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---------- Cart ---------- */
.cart-item {
  display: flex; align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cart-item-img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.cart-item-price { font-size: 15px; font-weight: 700; color: var(--primary); }
.cart-item-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.remove-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--danger);
  background: #fef0ef;
  font-size: 12px;
  transition: var(--transition);
}
.remove-btn:hover { background: var(--danger); color: #fff; }
.cart-summary {
  padding: 16px;
  border-top: 2px solid var(--border);
  background: var(--bg);
}
.summary-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 14px;
}
.summary-row.total {
  font-size: 17px; font-weight: 700;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* ---------- Checkout ---------- */
.checkout-layout {
  padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.payment-options {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.payment-option {
  flex: 1; min-width: 80px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 13px;
}
.payment-option input { display: none; }
.payment-option i { font-size: 22px; color: var(--text-muted); }
.payment-option.active, .payment-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.payment-option.active i, .payment-option:has(input:checked) i { color: var(--primary); }

/* ---------- Orders ---------- */
.order-filter-tabs {
  display: flex;
  overflow-x: auto;
  padding: 0 16px 8px;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.order-filter-tabs::-webkit-scrollbar { display: none; }
.tab {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 500;
  background: var(--bg);
  border: 1.5px solid var(--border);
  cursor: pointer; flex-shrink: 0;
  transition: var(--transition);
}
.tab.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.order-card {
  margin: 0 16px 12px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.order-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.order-no { font-size: 13px; font-weight: 700; color: var(--secondary); }
.order-date { font-size: 12px; color: var(--text-muted); }
.order-card-body { padding: 12px 14px; }
.order-item-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.order-item-img {
  width: 48px; height: 48px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0;
}
.order-item-info { flex: 1; font-size: 13px; }
.order-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.order-total { font-weight: 700; color: var(--primary); }

/* Order Status Badges */
.order-status {
  font-size: 12px; padding: 3px 10px;
  border-radius: 20px; font-weight: 600;
}
.os-pending { background: #fff8e7; color: var(--warning); }
.os-confirmed { background: #e8f4fd; color: var(--info); }
.os-shipping { background: #e8f8ff; color: #0099cc; }
.os-arrived { background: #e8f8f0; color: var(--success); }
.os-completed { background: #f0f0f0; color: var(--text-muted); }
.os-cancelled { background: #fef0ef; color: var(--danger); }

/* ---------- Notifications ---------- */
.notif-item {
  display: flex; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: var(--transition);
  position: relative;
}
.notif-item.unread { background: #fff8f5; }
.notif-item:hover { background: var(--bg); }
.notif-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.notif-order_confirm { background: #e8f4fd; color: var(--info); }
.notif-shipping { background: #e8f8ff; color: #0099cc; }
.notif-arrived { background: #e8f8f0; color: var(--success); }
.notif-system { background: var(--bg); color: var(--text-muted); }
.notif-content .title { font-size: 14px; font-weight: 600; }
.notif-content .msg { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.notif-content .time { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.notif-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute; top: 16px; right: 14px;
}

/* ---------- Auth ---------- */
.auth-wrap {
  padding: 20px 16px;
  display: flex; justify-content: center;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center; margin-bottom: 20px;
}
.auth-logo i {
  font-size: 40px; color: var(--primary);
  display: block; margin-bottom: 8px;
}
.auth-logo h2 { font-size: 22px; font-weight: 900; color: var(--secondary); }
.auth-tabs {
  display: flex; background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px; margin-bottom: 20px;
}
.auth-tab {
  flex: 1; padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  transition: var(--transition);
  color: var(--text-muted);
}
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0; color: var(--text-muted); font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ---------- Profile ---------- */
.profile-avatar-wrap {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 4px;
}
.max-w-md { max-width: 400px; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* ---------- Order Success ---------- */
.success-wrap {
  text-align: center;
  padding: 48px 24px;
}
.success-icon {
  font-size: 72px; color: var(--success);
  margin-bottom: 20px;
}
.success-icon i { animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes pop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.success-wrap h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.order-no-display {
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 18px; font-weight: 700; color: var(--primary);
  display: inline-block;
  letter-spacing: 2px;
}

/* ---------- Admin ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px;
}
.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 10px;
}
.stat-value { font-size: 24px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 0 16px;
}
/* Admin Table */
.admin-table { width: 100%; overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-white);
}
.data-table th {
  background: var(--secondary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--bg); }
.product-thumb {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.sticky-card { position: sticky; top: calc(var(--header-h) + 12px); }
.card-title {
  font-size: 15px; font-weight: 700;
  margin-bottom: 14px; color: var(--secondary);
}
.mb-3 { margin-bottom: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.my-3 { margin-top: 12px; margin-bottom: 12px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--secondary); margin-bottom: 5px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; outline: none;
  transition: var(--transition);
  background: var(--bg-white);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,107,53,0.1); }
.form-row { display: flex; gap: 10px; }
.flex-1 { flex: 1; }
.input-icon-wrap { position: relative; }
.toggle-pw {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); cursor: pointer;
  font-size: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  transition: var(--transition);
  gap: 6px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 10px rgba(255,107,53,0.3);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(255,107,53,0.45); transform: translateY(-1px); }
.btn-outline {
  border: 1.5px solid var(--border);
  color: var(--secondary); background: transparent;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-white {
  background: #fff; color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.btn-white:hover { box-shadow: var(--shadow); }
.btn-text { color: var(--primary); font-weight: 600; font-size: 13px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 16px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.w-full { width: 100%; }

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--bottom-nav-h);
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  display: flex;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  z-index: 100;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item i { font-size: 20px; }
.bnav-badge {
  position: absolute; top: 6px;
  left: 50%; margin-left: 4px;
  background: var(--danger); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; font-weight: 700;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--secondary);
  color: #fff; padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 320px; text-align: center;
  pointer-events: none;
  white-space: pre-line;
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: none; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--bg-white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideUp 0.3s ease;
}
.modal-box.large { max-height: 95vh; }
@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-shrink: 0;
}

/* ---------- Loading ---------- */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.8);
  z-index: 9998;
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}

/* ---------- Deadline Banner ---------- */
.deadline-banner {
  background: linear-gradient(135deg, #FF6B35, #e85a25);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.deadline-banner h3 { font-size: 16px; font-weight: 700; }
.deadline-banner p { font-size: 13px; opacity: 0.9; }

/* ---------- Utility ---------- */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.fw-bold { font-weight: 700; }
.fs-lg { font-size: 18px; }
.small { font-size: 12px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-3 { gap: 12px; }
.me-1 { margin-right: 4px; }
.me-2 { margin-right: 8px; }
.ms-1 { margin-left: 4px; }
.ms-2 { margin-left: 8px; }
.error-msg {
  background: #fef0ef; color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border-left: 3px solid var(--danger);
}
.checkout-item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; font-size: 13px;
}
.checkout-item-img {
  width: 40px; height: 40px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0;
}
.tag-badge {
  font-size: 11px; padding: 3px 8px;
  border-radius: 20px; font-weight: 600;
}
.tag-active { background: #e8f8f0; color: var(--success); }
.tag-closed { background: #f5f5f5; color: var(--text-muted); }
.tag-soldout { background: #fef0ef; color: var(--danger); }

/* Notify button for admin */
.btn-notify {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; font-size: 12px; padding: 4px 10px;
  border-radius: 6px;
}
.btn-notify:hover { opacity: 0.9; }
.notified-badge {
  background: #e8f8f0; color: var(--success);
  font-size: 11px; padding: 3px 8px;
  border-radius: 6px; font-weight: 600;
}

/* ===== Responsive ===== */
@media (min-width: 480px) {
  .sidebar {
    left: calc(50% - 240px - 280px);
  }
  .sidebar.open {
    left: calc(50% - 240px);
  }
}

/* =============================================
   新功能追加樣式
   ============================================= */

/* ---------- Quick Access ---------- */
.quick-access {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 0; padding: 0; border-top: 1px solid var(--border);
  background: var(--bg-white);
}
.qa-item {
  text-align: center; padding: 14px 6px;
  font-size: 11px; font-weight: 600; color: var(--secondary);
  cursor: pointer; transition: var(--transition);
  border-right: 1px solid var(--border);
}
.qa-item:last-child { border-right: none; }
.qa-item:hover { background: var(--primary-light); color: var(--primary); }
.qa-item .qa-icon { font-size: 22px; margin-bottom: 4px; }

/* ---------- Banner btn-white-outline ---------- */
.btn-white-outline {
  background: transparent; color: #fff;
  border: 2px solid rgba(255,255,255,0.7);
}
.btn-white-outline:hover { background: rgba(255,255,255,0.15); }

/* ---------- Cashback Mini ---------- */
.cashback-mini {
  font-size: 12px; color: var(--primary);
  font-weight: 600; margin-top: 2px;
}

/* ---------- Toggle Switch ---------- */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { display: none; }
.toggle-slider {
  position: absolute; inset: 0; background: #ccc;
  border-radius: 24px; cursor: pointer; transition: 0.3s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---------- Checkin Page ---------- */
.checkin-hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; border-radius: var(--radius-lg);
  padding: 24px; margin-bottom: 16px; text-align: center;
}
.checkin-hero h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.checkin-hero .big-num { font-size: 48px; font-weight: 900; line-height: 1; margin: 10px 0; }
.checkin-hero p { font-size: 13px; opacity: 0.85; }
.checkin-btn {
  width: 88px; height: 88px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  border: 3px solid rgba(255,255,255,0.7);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: 0 auto 16px; cursor: pointer; transition: var(--transition);
}
.checkin-btn i { font-size: 24px; margin-bottom: 4px; }
.checkin-btn.done { background: rgba(255,255,255,0.5); cursor: default; }
.checkin-btn:not(.done):hover { background: rgba(255,255,255,0.4); transform: scale(1.05); }
.calendar-grid {
  display: grid; grid-template-columns: repeat(7,1fr);
  gap: 5px; text-align: center;
}
.cal-header { font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: var(--bg);
}
.cal-day.checked { background: var(--primary); color: #fff; }
.cal-day.today { border: 2px solid var(--primary); color: var(--primary); background: var(--primary-light); }
.cal-day.today.checked { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.cal-day.empty { background: transparent; }
.reward-rules { display: flex; flex-direction: column; gap: 10px; }
.reward-rule {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.reward-rule.achieved { background: #e8f8f0; }
.reward-rule .rule-icon { font-size: 22px; }
.reward-rule .rule-info { flex: 1; font-size: 13px; }
.reward-rule .rule-reward { font-weight: 700; color: var(--primary); font-size: 15px; }
.progress-bar-wrap { background: var(--border); border-radius: 4px; height: 6px; margin-top: 6px; }
.progress-bar-fill { background: var(--primary); border-radius: 4px; height: 6px; transition: width 0.4s; }

/* ---------- Coupon Cards ---------- */
.coupon-card {
  display: flex; align-items: stretch;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.coupon-card.used, .coupon-card.expired { opacity: 0.55; }
.coupon-left {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 16px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 80px; text-align: center;
}
.coupon-left.percent-type { background: linear-gradient(135deg, #667eea, #764ba2); }
.coupon-value { font-size: 22px; font-weight: 900; line-height: 1; }
.coupon-unit { font-size: 12px; opacity: 0.9; margin-top: 2px; }
.coupon-notch {
  position: absolute;
  left: 70px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px;
  z-index: 1;
}
.coupon-notch::before, .coupon-notch::after {
  content: ''; display: block;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
}
.coupon-right {
  flex: 1; padding: 12px 14px 12px 18px;
  border-left: 2px dashed var(--border);
  display: flex; flex-direction: column; justify-content: center;
}
.coupon-name { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.coupon-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.coupon-meta { font-size: 11px; color: var(--text-light); }
.coupon-meta span { margin-right: 8px; }
.coupon-code-badge {
  display: inline-block;
  background: var(--primary-light); color: var(--primary);
  padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  margin-top: 4px;
}
.claim-btn-area { display: flex; align-items: center; justify-content: flex-end; margin-top: 8px; }
.stock-bar {
  background: var(--border); border-radius: 3px; height: 4px; margin-top: 6px;
}
.stock-fill { background: var(--primary); border-radius: 3px; height: 4px; }
.coupon-claimed-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--success); color: #fff;
  font-size: 10px; padding: 2px 7px; border-radius: 10px;
  font-weight: 700;
}
.coupon-used-stamp {
  position: absolute; top: 50%; right: 12px;
  transform: translateY(-50%) rotate(-15deg);
  border: 2px solid var(--text-muted); color: var(--text-muted);
  font-size: 13px; font-weight: 700; padding: 4px 10px;
  border-radius: 6px; opacity: 0.6;
}

/* ---------- Checkout Coupon Area ---------- */
.coupon-input-row { display: flex; gap: 8px; }
.coupon-applied-box {
  display: flex; align-items: center; justify-content: space-between;
  background: #e8f8f0; border: 1px solid var(--success);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px;
  font-size: 14px; color: var(--success); font-weight: 600;
}
.cashback-use-row {
  display: flex; align-items: center; justify-content: space-between;
}
.my-coupon-mini {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 6px; cursor: pointer;
  transition: var(--transition); font-size: 13px;
}
.my-coupon-mini:hover { border-color: var(--primary); background: var(--primary-light); }
.my-coupon-mini.selected { border-color: var(--primary); background: var(--primary-light); }

/* ---------- Wallet Page ---------- */
.wallet-hero {
  background: linear-gradient(135deg, #f7971e, #ffd200);
  border-radius: var(--radius-lg); padding: 24px;
  text-align: center; margin-bottom: 16px; color: var(--secondary);
}
.wallet-hero .balance-big { font-size: 44px; font-weight: 900; }
.wallet-hero p { font-size: 13px; opacity: 0.7; margin-top: 4px; }
.cashback-record {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.cashback-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.cb-add { background: #e8f8f0; color: var(--success); }
.cb-use { background: #fef0ef; color: var(--danger); }
.cb-admin { background: #e8f4fd; color: var(--info); }
.cashback-record .cb-title { font-size: 14px; font-weight: 600; }
.cashback-record .cb-date { font-size: 12px; color: var(--text-muted); }
.cashback-record .cb-amount { font-size: 15px; font-weight: 700; margin-left: auto; white-space: nowrap; }
.cb-amount.positive { color: var(--success); }
.cb-amount.negative { color: var(--danger); }

/* ---------- Store selection ---------- */
.store-option {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  margin-bottom: 8px; cursor: pointer; transition: var(--transition);
}
.store-option:hover { border-color: var(--primary); background: var(--primary-light); }
.store-option.selected { border-color: var(--primary); background: var(--primary-light); }
.store-option input[type=radio] { display: none; }
.store-option .store-name { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.store-option .store-addr { font-size: 12px; color: var(--text-muted); }
.store-option .store-hours { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.store-info-box {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 13px; margin-top: 10px;
}
.store-success-box {
  background: #e8f8f0; border: 1px solid var(--success);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 14px; margin: 12px auto; max-width: 320px; text-align: left;
}
.store-success-box .sn { font-weight: 700; font-size: 15px; margin-bottom: 4px; }

/* ---------- Admin Coupon Table ---------- */
.coupon-row-type {
  font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 700;
}
.ctype-fixed { background: #fff0eb; color: var(--primary); }
.ctype-percent { background: #e8f0fe; color: #4a6cf7; }

/* ---------- Store Cards (Admin) ---------- */
.store-admin-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow-sm);
}
.store-admin-card .store-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.store-admin-card .store-title { font-size: 16px; font-weight: 700; }
.store-admin-card .store-detail { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ---------- Admin Cashback Table ---------- */
.member-cashback-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.member-cashback-row .m-info { flex: 1; }
.member-cashback-row .m-name { font-size: 14px; font-weight: 600; }
.member-cashback-row .m-email { font-size: 12px; color: var(--text-muted); }
.member-cashback-row .m-balance { font-size: 18px; font-weight: 800; color: var(--warning); margin-right: 8px; }

/* ---------- Role Tags ---------- */
.role-tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px; letter-spacing: 0.3px;
}
.role-admin  { background: #ffecd2; color: #e85a25; }
.role-hq     { background: #e8f4fd; color: #2980b9; }
.role-staff_hq { background: #e8f4fd; color: #2980b9; }
.role-store  { background: #e8f8f0; color: #27ae60; }
.role-staff_store { background: #e8f8f0; color: #27ae60; }
.role-member { background: #f5f5f7; color: #666; }

.role-legend { padding: 16px; }
.role-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.role-row:last-child { border-bottom: none; }

/* ---------- Duty Chip ---------- */
.duty-chip {
  display: flex; align-items: center; gap: 4px;
  background: var(--primary); color: #fff;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Store Orders ---------- */
#store-order-tabs { display: flex; overflow-x: auto; gap: 4px; padding: 8px 12px; background: var(--bg-white); border-bottom: 1px solid var(--border); }
#store-order-tabs .tab { flex-shrink: 0; }

/* ---------- Notified Badge ---------- */
.notified-badge { background: #e8f8f0; color: var(--success); font-weight: 600; border-radius: 8px; padding: 8px; font-size: 13px; }

/* ---------- nav-section-title override ---------- */
.nav-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); padding: 8px 16px 4px; letter-spacing: 0.5px; }

/* ---------- Tag Badges Extended ---------- */
.tag-pending  { background: #fff8e7; color: var(--warning); border: 1px solid #ffe082; }
.tag-active   { background: #e8f8f0; color: var(--success); border: 1px solid #a5d6a7; }
.tag-danger   { background: #fdecea; color: var(--danger); border: 1px solid #ef9a9a; }
.tag-closed   { background: #f5f5f7; color: var(--text-muted); border: 1px solid var(--border); }
.tag-done     { background: #e8f4fd; color: var(--info); border: 1px solid #90caf9; }
.tag-badge    { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 12px; white-space: nowrap; }

/* ---------- Announcement Cards ---------- */
.announcement-card {
  padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 8px; border-left: 4px solid;
}
.ann-normal  { background: #e8f4fd; border-color: var(--info); }
.ann-important { background: #fdecea; border-color: var(--danger); }
.ann-sale    { background: #fff8e7; border-color: var(--warning); }

/* ---------- Finance Stats ---------- */
.stats-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-mini  {
  flex: 1; min-width: 80px; background: var(--bg); border-radius: var(--radius-sm);
  padding: 10px 12px; text-align: center;
}
.stat-mini-val   { font-size: 18px; font-weight: 800; color: var(--primary); }
.stat-mini-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Admin Table ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { background: var(--bg); padding: 8px 10px; text-align: left; font-weight: 700; font-size: 12px; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.admin-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:hover td { background: var(--bg); }
.admin-table code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 12px; }

/* ---------- Inventory Item Row ---------- */
.inv-item-row:last-child { border-bottom: none; }

/* ---------- Return Status Colors ---------- */
.os-completed, .os-arrived { color: var(--success); }
.os-pending   { color: var(--warning); }
.os-cancelled, .os-abandoned { color: var(--text-muted); }
.os-abandoned_no_count { color: var(--text-muted); }
.os-uncollected { color: var(--danger); }
.os-queued    { color: var(--info); }

/* ---------- Wish Pool ---------- */
.wish-card { padding: 14px; background: var(--bg-white); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow-sm); }

/* ---------- Tab Group ---------- */
.tab-group { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.tab-group .tab { flex-shrink: 0; padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--bg); color: var(--text-muted); border: none; }
.tab-group .tab.active { background: var(--primary); color: #fff; }

/* ---------- btn-success ---------- */
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }

