:root {
  --primary: #0f63d9;
  --primary-dark: #0a4fb3;
  --primary-light: #e8f0fe;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --text: #1f2937;
  --text-soft: #6b7280;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 70px;
}

.hidden { display: none !important; }

/* ============ HEADER ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 800; font-size: 16px; letter-spacing: 0.2px; }
.topbar .sub { font-size: 11px; opacity: 0.85; }
.topbar .spacer { flex: 1; }
.topbar .btn-icon {
  background: rgba(255,255,255,0.16);
  border: none;
  color: #fff;
  font-size: 16px;
  width: 36px; height: 36px;
  border-radius: 10px;
  cursor: pointer;
}

/* ============ BALANCE CARD ============ */
.balance-card {
  background: linear-gradient(135deg, #1d6fe8, #0a4fb3);
  margin: 14px 16px;
  padding: 18px;
  border-radius: var(--radius);
  color: #fff;
  box-shadow: 0 6px 18px rgba(15, 99, 217, 0.35);
  position: relative;
  overflow: hidden;
}
.balance-card::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.balance-card .lbl { font-size: 12px; opacity: 0.85; }
.balance-card .amount { font-size: 26px; font-weight: 800; margin: 4px 0 12px; letter-spacing: 0.5px; }
.balance-card .actions { display: flex; gap: 10px; position: relative; z-index: 1; }
.balance-card .chip {
  background: rgba(255,255,255,0.18);
  border: none; color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.balance-card .chip:active { background: rgba(255,255,255,0.3); }

/* ============ SECTION ============ */
.section { margin: 18px 16px 6px; }
.section .title { font-size: 14px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.section .title .more { margin-left: auto; font-size: 12px; color: var(--primary); font-weight: 600; cursor: pointer; }

/* ============ CATEGORY GRID ============ */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 8px;
  box-shadow: var(--shadow);
}
.cat-item { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
.cat-item .ico {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--primary-light);
}
.cat-item .nm { font-size: 11px; text-align: center; color: var(--text); font-weight: 500; }
.cat-item:active .ico { transform: scale(0.92); }

/* ============ PRODUCT LIST ============ */
.prod-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.prod-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.prod-row:last-child { border-bottom: none; }
.prod-row .ico {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.prod-row .info { flex: 1; min-width: 0; }
.prod-row .nm { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-row .meta { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.prod-row .price { font-size: 14px; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.prod-row:active { background: #f8fafc; }

/* ============ BUTTONS ============ */
.btn {
  display: block; width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-dark); }
.btn.success { background: var(--success); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: var(--card); color: var(--primary); border: 1px solid var(--primary); }
.btn:disabled { opacity: 0.55; }

/* ============ FORM ============ */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%; padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: #fff;
  outline: none;
  transition: border 0.15s;
}
.form-control:focus { border-color: var(--primary); }

/* ============ CARD ============ */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 16px 14px; }

/* ============ STATUS BADGE ============ */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.success { background: #dcfce7; color: #166534; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.failed, .badge.gagal { background: #fee2e2; color: #991b1b; }
.badge.expired { background: #e5e7eb; color: #374151; }

/* ============ LOGIN ============ */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .box {
  width: 72px; height: 72px; margin: 0 auto 12px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #fff;
  box-shadow: 0 8px 20px rgba(15, 99, 217, 0.35);
}
.login-logo h1 { font-size: 20px; font-weight: 800; }
.login-logo p { font-size: 13px; color: var(--text-soft); margin-top: 4px; }
.login-step { display: none; }
.login-step.active { display: block; }
.hint { font-size: 12px; color: var(--text-soft); margin-top: 8px; line-height: 1.5; }

/* ============ QRIS ============ */
.qris-box { text-align: center; padding: 20px; }
.qris-box img { width: 220px; height: 220px; border-radius: 12px; border: 1px solid var(--border); background: #fff; }
.qris-amount { font-size: 24px; font-weight: 800; color: var(--primary); margin: 12px 0 4px; }
.qris-count { font-size: 14px; color: var(--text-soft); }
.qris-countdown { font-size: 18px; font-weight: 800; color: var(--danger); margin-top: 6px; }
.qris-status { margin-top: 14px; }
.qris-status.pending { color: var(--warning); font-weight: 700; }
.qris-status.confirmed { color: var(--success); font-weight: 800; }
.qris-status.expired { color: var(--danger); font-weight: 700; }

/* ============ HISTORY ============ */
.hist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.hist-item .nm { font-size: 13.5px; font-weight: 600; }
.hist-item .meta { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.hist-item .amt { margin-left: auto; text-align: right; }
.hist-item .amt .plus { color: var(--success); font-weight: 700; }
.hist-item .amt .minus { color: var(--danger); font-weight: 700; }
.hist-item .amt .text-soft { color: var(--text-soft); font-weight: 600; }

/* ============ PAGINATION ============ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px; }
.pagination .pg-btn { border: 1px solid var(--primary); color: var(--primary); background: #fff; border-radius: 10px; padding: 8px 18px; font-weight: 600; cursor: pointer; font-size: 14px; }
.pagination .pg-btn:disabled { opacity: 0.35; cursor: default; }
.pagination .pg-info { font-size: 13px; color: var(--text-soft); }

/* ============ PROFILE ============ */
.profile-head { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; padding: 26px 18px; }
.profile-avatar { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center; font-size: 28px; margin-bottom: 10px; }
.profile-head .nm { font-size: 18px; font-weight: 800; }
.profile-head .id { font-size: 12px; opacity: 0.85; }

.menu-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin: 0 16px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.menu-item:last-child { border-bottom: none; }
.menu-item .ico { font-size: 18px; }
.menu-item .nm { flex: 1; font-size: 14px; font-weight: 600; }
.menu-item .val { font-size: 13px; color: var(--text-soft); }
.menu-item:active { background: #f8fafc; }

/* ============ DETAIL / CONFIRM ============ */
.detail-hero { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 16px 14px; padding: 18px; text-align: center; }
.detail-hero .ico { width: 56px; height: 56px; border-radius: 14px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 10px; }
.detail-hero .nm { font-size: 16px; font-weight: 700; }
.detail-hero .price { font-size: 22px; font-weight: 800; color: var(--primary); margin-top: 6px; }

.order-status-hero { text-align: center; padding: 30px 20px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 16px 14px; }
.order-status-hero .ico { font-size: 52px; margin-bottom: 10px; }
.order-status-hero .st { font-size: 18px; font-weight: 800; }
.order-status-hero .sub { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  left: 50%; bottom: 90px;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 999;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toast.error { background: rgba(220, 38, 38, 0.95); }
.toast.success { background: rgba(22, 163, 74, 0.95); }

/* ============ BOTTOM NAV ============ */
#bottom-nav {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 7px;
  background: none; border: none; cursor: pointer;
  color: var(--text-soft);
  font-size: 11px;
}
.nav-item .nav-ico { font-size: 20px; }
.nav-item.active { color: var(--primary); font-weight: 700; }

/* ============ LOADING ============ */
.loading { text-align: center; padding: 40px 0; color: var(--text-soft); }
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 36px 16px; color: var(--text-soft); font-size: 14px; }
.empty .ico { font-size: 40px; margin-bottom: 8px; }

/* ============ MODAL ============ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%; max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
}
