:root {
  --bg: #0a0e14;
  --bg-glow-1: #123a3a;
  --bg-glow-2: #1a1440;
  --text: #f0f2f5;
  --hint: #8b93a3;
  --primary: #2dd4bf;     /* xanh ngọc, giống ảnh mẫu */
  --primary-dark: #14b8a6;
  --accent: #7c6cf0;      /* tím nhạt cho badge/nút phụ */
  --card: #131a24;
  --card-2: #1a2230;
  --border: #232c3a;
  --danger: #ff6b6b;
  --success: #21c17c;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(circle at 15% 10%, var(--bg-glow-1) 0%, transparent 35%),
    radial-gradient(circle at 85% 25%, var(--bg-glow-2) 0%, transparent 40%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text); padding-bottom: 84px; min-height: 100vh;
}
.hidden { display: none !important; }

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

.auth-error {
  position: fixed; inset: 0; z-index: 998; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px; background: var(--bg);
}
.auth-error-icon { font-size: 42px; margin-bottom: 12px; }
.auth-error h2 { margin: 0 0 10px; font-size: 18px; }
.auth-error p { color: var(--hint); font-size: 13px; line-height: 1.6; max-width: 320px; margin-bottom: 20px; }
.auth-error .btn-primary { width: auto; padding: 12px 24px; }

/* ===== Header ===== */
.shop-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; position: sticky; top: 0; z-index: 10;
  background: rgba(10,14,20,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: #08110f;
  box-shadow: 0 0 14px rgba(45,212,191,.5);
}
.avatar-lg { width: 64px; height: 64px; font-size: 24px; margin: 0 auto 10px; }
.user-name { font-weight: 700; font-size: 15px; }
.user-id { color: var(--hint); font-size: 12px; }
.header-right { text-align: right; }
.balance-num { font-weight: 800; color: var(--primary); font-size: 15px; }
.role-badge {
  display: inline-block; margin-top: 4px; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 10px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--border); color: var(--hint);
}
.role-badge.role-ctv { color: var(--success); border-color: var(--success); }
.role-badge.role-admin { color: var(--accent); border-color: var(--accent); }

.admin-enter-row { padding: 10px 16px 0; }
.btn-admin-enter {
  width: 100%; background: linear-gradient(135deg, #ffb020, #ff8a00); color: #1a1200; border: none;
  padding: 10px; border-radius: 12px; font-weight: 800; font-size: 13px;
}

/* ===== Main content ===== */
#app { padding: 14px 16px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-title {
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .05em;
  color: var(--hint); margin: 18px 0 10px;
}
.section-title:first-child { margin-top: 4px; }
.section-icon { font-size: 14px; }

/* ===== Category grid (giống ảnh mẫu) ===== */
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.category-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; text-align: center;
  transition: border-color .15s, box-shadow .15s;
}
.category-card .cat-icon {
  width: 46px; height: 46px; border-radius: 14px; background: var(--card-2); display: flex; align-items: center;
  justify-content: center; font-size: 22px;
}
.category-card .cat-name { font-size: 12px; font-weight: 600; line-height: 1.3; }
.category-card.active {
  border-color: var(--primary); box-shadow: 0 0 16px rgba(45,212,191,.35);
}
.category-card.active .cat-icon { background: rgba(45,212,191,.15); }

/* ===== Search ===== */
.search-row input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 14px;
}

/* ===== Product list (dạng hàng ngang giống ảnh, kèm giá + tồn kho) ===== */
.product-list { display: flex; flex-direction: column; gap: 10px; }
.product-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.product-row:active { border-color: var(--primary); }
.product-row .pr-left { display: flex; align-items: center; gap: 12px; }
.product-row img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--card-2); }
.product-row .pr-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.product-row .pr-meta { color: var(--hint); font-size: 11px; }
.product-row .pr-price-box { text-align: right; }
.product-row .pr-price { background: var(--card-2); border: 1px solid var(--border); color: var(--primary); font-weight: 800;
  font-size: 13px; padding: 6px 12px; border-radius: 10px; }
.product-row .pr-listprice { display: block; color: var(--hint); font-size: 10px; text-decoration: line-through; margin-top: 3px; }
.ctv-badge { display: inline-block; background: rgba(33,193,124,.15); color: var(--success); font-size: 10px; padding: 2px 8px; border-radius: 8px; margin-bottom: 4px; font-weight: 700; }

.btn-primary {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #06120f; font-weight: 800; font-size: 15px; margin-top: 10px;
}

/* ===== Deposit ===== */
.amount-picker { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 12px 0; }
.amount-chip { padding: 10px 0; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
.amount-chip.active { background: var(--primary); color: #06120f; border-color: var(--primary); font-weight: 700; }
#depositAmountInput { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); margin-bottom: 8px; }

.deposit-qr-box { text-align: center; margin-top: 16px; background: var(--card); border: 1px solid var(--border); padding: 16px; border-radius: 14px; }
.deposit-qr-box img { width: 220px; height: 220px; border-radius: 10px; background: #fff; padding: 8px; }
.deposit-qr-box .hint { color: var(--hint); font-size: 12px; }

/* ===== Profile tab ===== */
.profile-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 22px 16px; text-align: center; margin-bottom: 16px;
}
.profile-name { font-weight: 800; font-size: 16px; }
.profile-id { color: var(--hint); font-size: 12px; margin-top: 2px; }
.profile-role { display: inline-block; margin-top: 8px; font-size: 11px; font-weight: 700; padding: 3px 12px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--border); color: var(--hint); }
.profile-balance-row { display: flex; justify-content: space-between; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; }
.profile-balance-row b { color: var(--primary); font-size: 16px; }

.subtab-row { display: flex; gap: 8px; margin-bottom: 12px; }
.subtab-btn { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--hint); }
.subtab-btn.active { background: var(--primary); color: #06120f; border-color: var(--primary); font-weight: 700; }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

.history-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.history-item .hi-top { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 4px; }
.history-item .hi-meta { color: var(--hint); font-size: 12px; }
.delivered-mini { margin-top: 6px; background: var(--card-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--hint); }
.status-pill { font-size: 11px; padding: 2px 8px; border-radius: 8px; }
.status-pending { background: #443b17; color: #ffcf5c; }
.status-approved, .status-success { background: #16341f; color: var(--success); }
.status-rejected, .status-failed { background: #3a1616; color: var(--danger); }

/* ===== Tabbar ===== */
.tabbar {
  display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(19,26,36,.92); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); z-index: 10; padding: 4px 0;
}
.tab-btn { flex: 1; padding: 10px 0; background: none; border: none; color: var(--hint); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tab-icon { font-size: 19px; }
.tab-btn.active { color: var(--primary); font-weight: 700; }

/* ===== Floating buttons (hỗ trợ + chuông) ===== */
.fab-support, .fab-bell {
  position: fixed; right: 16px; width: 52px; height: 52px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #06120f; font-size: 22px;
  box-shadow: 0 6px 20px rgba(45,212,191,.4); z-index: 20; display: flex; align-items: center; justify-content: center;
}
.fab-support { bottom: 92px; }
.fab-bell { bottom: 158px; background: var(--card-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.dot { position: absolute; top: 8px; right: 10px; width: 9px; height: 9px; background: var(--danger); border-radius: 50%; }

/* ===== Support popup (thẻ nổi giữa màn hình, giống ảnh mẫu) ===== */
.support-popup { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 24px; }
.support-popup.hidden { display: none; }
.support-popup-content {
  background: linear-gradient(160deg, #171236, #0e1a2e); border: 1px solid #362a6b; border-radius: 20px;
  padding: 28px 22px; text-align: center; max-width: 340px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.support-kicker { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--primary); text-transform: uppercase; margin-bottom: 6px; }
.support-title { font-size: 20px; font-weight: 800; background: linear-gradient(90deg, var(--accent), var(--primary)); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 10px; }
.support-message { color: #c7cbe0; font-size: 14px; margin-bottom: 18px; }

/* ===== Modal chung ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100; display: flex; align-items: flex-end; }
.modal.hidden { display: none; }
.modal-content { background: var(--bg); border-top: 1px solid var(--border); width: 100%; max-height: 85vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px; position: relative; }
.modal-close { position: absolute; top: 12px; right: 12px; background: var(--card); border: none; color: var(--text); border-radius: 50%; width: 30px; height: 30px; }
#modalImg { width: 100%; height: 160px; object-fit: cover; border-radius: 12px; background: var(--card-2); }
.price-row { margin: 10px 0; }
.price { font-size: 20px; font-weight: 800; color: var(--primary); }
.list-price { color: var(--hint); text-decoration: line-through; margin-left: 8px; }
.delivered-box { margin-top: 14px; background: #16341f; border: 1px solid var(--success); padding: 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-all; font-size: 13px; }

.notif-item { padding: 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-item .n-time { color: var(--hint); font-size: 11px; margin-top: 4px; }

.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: var(--card);
  border: 1px solid var(--primary); padding: 12px 18px; border-radius: 12px; z-index: 200; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); max-width: 90%;
}
