:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #1c2330;
  --border:    rgba(255,255,255,0.08);
  --teal:      #00c9a7;
  --teal-dim:  rgba(0,201,167,0.15);
  --blue:      #3ab0f0;
  --green:     #6cd63f;
  --red:       #f05a5a;
  --yellow:    #f0c040;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --radius:    14px;
  --radius-sm: 8px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── Layout ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100svh;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
}

.page {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 80px;
  display: none;
}
.page.active { display: block; }

/* ── Bottom Nav ── */
.bottom-nav {
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  transition: color .2s;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--teal); }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card--teal { border-color: rgba(0,201,167,0.35); }
.card--blue { border-color: rgba(58,176,240,0.35); }

/* ── Balance Hero ── */
.balance-hero {
  background: linear-gradient(135deg, rgba(0,201,167,0.12) 0%, rgba(58,176,240,0.08) 100%);
  border: 1px solid rgba(0,201,167,0.25);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 16px;
}
.balance-hero__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.balance-hero__amount { font-size: 42px; font-weight: 700; color: var(--teal); line-height: 1; }
.balance-hero__sub { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.stat-card__num { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-card__label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  width: 100%;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary { background: var(--teal); color: #000; }
.btn-secondary { background: var(--bg3); border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: rgba(240,90,90,0.15); border: 1px solid rgba(240,90,90,0.35); color: var(--red); }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ── Section Header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h2 { font-size: 16px; font-weight: 600; }

/* ── Device Card ── */
.device-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .2s;
}
.device-card:active { border-color: var(--teal); }
.device-card__top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.device-card__icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.device-card__icon--pc { background: rgba(58,176,240,0.15); }
.device-card__icon--android { background: rgba(108,214,63,0.15); }
.device-card__icon--ios { background: rgba(0,201,167,0.15); }
.device-card__name { font-weight: 600; font-size: 14px; }
.device-card__type { font-size: 12px; color: var(--muted); }
.device-card__status { margin-left: auto; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.status--active { background: rgba(108,214,63,0.15); color: var(--green); }
.status--inactive { background: rgba(240,90,90,0.12); color: var(--red); }

/* ── Traffic Bar ── */
.traffic-wrap { margin-top: 4px; }
.traffic-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.traffic-bar { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.traffic-bar__fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--blue)); border-radius: 3px; transition: width .4s; }
.traffic-bar__fill--warn { background: linear-gradient(90deg, var(--yellow), var(--red)); }
.traffic-none { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }

/* ── Traffic Tiers ── */
.tiers-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.tier-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--bg3);
}
.tier-card:hover, .tier-card.selected { border-color: var(--teal); background: var(--teal-dim); }
.tier-card__price { font-size: 20px; font-weight: 700; color: var(--teal); }
.tier-card__gb { font-size: 14px; font-weight: 600; margin: 2px 0; }
.tier-card__per { font-size: 11px; color: var(--muted); }

/* ── Topup Packages ── */
.packages-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.pkg-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: border-color .15s;
}
.pkg-btn.selected { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); }

/* ── Referral ── */
.ref-code-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: monospace;
  font-size: 15px;
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  word-break: break-all;
}
.ref-code-box svg { flex-shrink: 0; }

.ref-stat { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ref-stat:last-child { border-bottom: none; }
.ref-stat__label { color: var(--muted); font-size: 13px; }
.ref-stat__val { font-weight: 600; font-size: 13px; }

/* ── URL Box ── */
.url-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: monospace;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
  cursor: pointer;
  position: relative;
}

/* ── Toast ── */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Page Title ── */
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 16px; }
.page-title span { color: var(--teal); }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state__icon { font-size: 48px; margin-bottom: 12px; }
.empty-state__text { font-size: 14px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 16px 32px;
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.34,1.2,.64,1);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal__title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal__close { float: right; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }

/* ── Input ── */
.input-wrap { margin-bottom: 12px; }
.input-wrap label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; }
.input-wrap input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .15s;
}
.input-wrap input:focus { border-color: var(--teal); }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100svh; flex-direction: column; gap: 12px; color: var(--muted);
}

/* ── Accent text ── */
.accent { color: var(--teal); }
.accent2 { color: var(--blue); }
.muted { color: var(--muted); font-size: 13px; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 12px 0; }
