/* ============================================================
   TikTok Followers — Global reset + design tokens
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; margin: 0; padding: 0; }

:root {
  --tt-red:    #fe2c55;
  --tt-red-h:  #f01d49;
  --tt-red-a:  #e21545;
  --tt-black:  #161823;
  --tt-grey:   #f1f1f2;
  --tt-border: #e5e5e8;
  --tt-muted:  rgba(22,24,35,.5);
  --mpesa-green: #00a550;
  --mpesa-red:   #e3001b;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

body {
  font-family: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #fafafa;
  color: var(--tt-black);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   TIKTOK LOADER
   ============================================================ */
.tiktok-loader {
  width: 44px; height: 22px;
  position: relative; display: inline-block; flex-shrink: 0;
}
.tiktok-loader::before, .tiktok-loader::after {
  position: absolute; content: "";
  top: 3px; background-color: #ff3e9e;
  width: 16px; height: 16px;
  border-radius: 50%; mix-blend-mode: multiply;
  animation: tiktok-anim 1s linear infinite;
}
.tiktok-loader::after { background-color: #4de8f4; animation-delay: .5s; }
@keyframes tiktok-anim {
  0%,100% { top:3px; left:0;  width:16px; height:16px; z-index:0; }
  25%     { top:0;  left:11px; width:22px; height:22px; z-index:1; }
  50%     { top:3px; left:26px; width:16px; height:16px; }
  75%     { top:4px; left:14px; width:16px; height:16px; }
}

/* Startup splash */
.tiktok-splash {
  position: fixed; inset: 0; background: #fff;
  z-index: 100000; display: flex;
  align-items: center; justify-content: center;
  transition: opacity .4s ease, visibility .4s ease;
}
.tiktok-splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }

/* ============================================================
   HEADER
   ============================================================ */
header {
  position: fixed; top: 0; left: 0; right: 0;
  background: #fff;
  border-bottom: 1px solid var(--tt-border);
  z-index: 100;
  padding-top: env(safe-area-inset-top, 0px);
}
.hdr-inner {
  display: flex; align-items: center; gap: 14px;
  max-width: 600px; margin: 0 auto;
  padding: 10px 16px;
}
.logo img { height: 32px; display: block; }
.hdr-title {
  font-size: 16px; font-weight: 800; color: var(--tt-black);
  letter-spacing: -.3px;
}

/* ============================================================
   MAIN
   ============================================================ */
.main-container {
  max-width: 600px; margin: 0 auto;
  padding: 80px 16px 40px;
}

.page-title {
  font-size: 28px; font-weight: 900; color: var(--tt-black);
  margin: 0 0 6px; text-align: center; letter-spacing: -.5px;
}
.page-sub {
  font-size: 14px; color: var(--tt-muted);
  text-align: center; margin: 0 0 24px;
}

/* ============================================================
   STEP CARDS
   ============================================================ */
.step-card {
  background: #fff;
  border: 1px solid var(--tt-border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.step-label {
  font-size: 15px; font-weight: 800;
  color: var(--tt-black); margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.step-num {
  width: 26px; height: 26px;
  background: var(--tt-red); color: #fff;
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  font-size: 13px; font-weight: 900; flex-shrink: 0;
}

/* ============================================================
   USERNAME INPUT
   ============================================================ */
.input-row {
  display: flex; gap: 10px; align-items: flex-start;
}
.input-wrap {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  border: 1.5px solid var(--tt-border);
  border-radius: var(--radius-sm);
  padding: 0 14px; background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.input-wrap:focus-within {
  border-color: var(--tt-red);
  box-shadow: 0 0 0 3px rgba(254,44,85,.1);
}
.at-sign { color: var(--tt-muted); font-size: 16px; font-weight: 700; flex-shrink: 0; }
.username-input {
  flex: 1; border: none; outline: none;
  padding: 14px 8px; font-size: 16px;
  font-family: inherit; background: transparent;
  color: var(--tt-black); min-width: 0;
}
.verify-btn {
  height: 52px; padding: 0 20px; flex-shrink: 0;
  background: var(--tt-red); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 800;
  font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.verify-btn:hover { background: var(--tt-red-h); }
.verify-btn:active { background: var(--tt-red-a); }
.verify-btn:disabled { background: rgba(254,44,85,.45); cursor: not-allowed; }

/* ============================================================
   PROFILE CARD
   ============================================================ */
.profile-card {
  background: #fff; border: 1px solid var(--tt-border);
  border-radius: var(--radius-lg); padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.profile-card-inner {
  display: flex; gap: 14px; align-items: center;
}
.profile-avatar-wrap { flex-shrink: 0; }
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  object-fit: cover; background: var(--tt-grey);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.profile-info { flex: 1; min-width: 0; }
.profile-name {
  font-size: 17px; font-weight: 800;
  color: var(--tt-black); line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-handle {
  font-size: 13px; color: var(--tt-muted);
  margin-bottom: 8px;
}
.profile-stats { display: flex; gap: 14px; }
.profile-stat {
  display: flex; flex-direction: column; align-items: center;
}
.stat-num { font-size: 15px; font-weight: 800; color: var(--tt-black); }
.stat-lbl { font-size: 11px; color: var(--tt-muted); }
.verify-loader {
  display: flex; justify-content: center;
  padding: 14px 0 4px;
}

/* ============================================================
   PACKAGES GRID
   ============================================================ */
.packages-section { }
.packages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.pkg-card {
  background: var(--tt-grey); border: 1.5px solid transparent;
  border-radius: var(--radius-sm); padding: 14px 12px;
  cursor: pointer; transition: all .15s; text-align: left;
  position: relative;
}
.pkg-card:hover { background: #e8e8ea; }
.pkg-card.selected {
  background: #fff5f7; border-color: var(--tt-red);
}
.pkg-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--tt-red); color: #fff;
  font-size: 10px; font-weight: 800;
  padding: 2px 6px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .5px;
}
.pkg-followers {
  font-size: 22px; font-weight: 900;
  color: var(--tt-black); letter-spacing: -.5px;
  margin-bottom: 2px;
}
.pkg-followers-label {
  font-size: 12px; font-weight: 600;
  color: var(--tt-muted); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .5px;
}
.pkg-price {
  font-size: 18px; font-weight: 800;
  color: var(--mpesa-green);
}
.pkg-price-sub {
  font-size: 11px; color: var(--tt-muted);
}

/* ============================================================
   MPESA PAYMENT
   ============================================================ */
.mpesa-form { }
.mpesa-logo-row {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: #f8fff8;
  border: 1px solid #c8e8c8;
  border-radius: var(--radius-sm);
}
.mpesa-logo { display: flex; align-items: center; }
.mpesa-logo-img { height: 36px; width: auto; display: block; }
/* legacy spans kept for fallback */
.mpesa-m { color: var(--mpesa-red); }
.mpesa-pesa { color: var(--mpesa-green); }
.pay-summary {
  text-align: right; font-size: 13px;
}
.pay-summary .summary-pkg {
  font-weight: 800; font-size: 15px; color: var(--tt-black);
}
.pay-summary .summary-price {
  color: var(--mpesa-green); font-weight: 700; font-size: 14px;
}

.field-label {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--tt-muted); margin-bottom: 6px;
}

/* Plain full-width phone input — no prefix */
.phone-input-plain {
  width: 100%; height: 56px;
  padding: 0 16px;
  border: 1.5px solid var(--tt-border);
  border-radius: var(--radius-sm);
  font-size: 17px; font-weight: 600;
  font-family: inherit; letter-spacing: .5px;
  color: var(--tt-black); background: #fff;
  outline: none; margin-bottom: 6px;
  box-sizing: border-box;
  transition: border-color .2s, box-shadow .2s;
}
.phone-input-plain::placeholder {
  font-size: 14px; font-weight: 500;
  color: #bbb; letter-spacing: 0;
}
.phone-input-plain:focus {
  border-color: var(--mpesa-green);
  box-shadow: 0 0 0 3px rgba(0,165,80,.1);
}
.phone-hint {
  font-size: 12px; color: var(--tt-muted);
  margin: 0 0 18px;
}
.pay-btn {
  width: 100%; height: 56px;
  background: var(--mpesa-green); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 17px; font-weight: 800;
  font-family: inherit; cursor: pointer;
  transition: background .15s, opacity .15s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.pay-btn:hover:not(:disabled) { background: #008a44; }
.pay-btn:disabled { opacity: .45; cursor: not-allowed; }
.pay-btn .btn-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   PROCESSING OVERLAY
   ============================================================ */
.processing-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.95);
  z-index: 10005;
  display: flex; align-items: center; justify-content: center;
}
.processing-overlay[hidden] { display: none !important; }
.processing-overlay.show { display: flex !important; }
.processing-box {
  text-align: center; padding: 40px 24px;
  max-width: 320px; width: 100%;
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
}
.processing-title {
  font-size: 18px; font-weight: 800; color: var(--tt-black);
  margin: 0;
}
.processing-sub {
  font-size: 14px; color: var(--tt-muted);
  margin: 0; line-height: 1.5;
}

/* ============================================================
   SUCCESS SCREEN
   ============================================================ */
.success-screen {
  position: fixed; inset: 0; background: #fff;
  z-index: 10006;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;
  padding: 40px 16px calc(40px + env(safe-area-inset-bottom,0px));
  padding-top: calc(40px + env(safe-area-inset-top,0px));
}
.success-screen[hidden] { display: none !important; }
.success-screen.show { display: flex !important; }
.success-box {
  max-width: 400px; width: 100%;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
}
.success-check { animation: pop .35s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-title {
  font-size: 26px; font-weight: 900; color: var(--tt-black);
  margin: 0; letter-spacing: -.5px;
}
.success-followers {
  font-size: 16px; color: var(--tt-muted); margin: 0;
}
.success-timer-box {
  width: 100%; background: linear-gradient(135deg,#f0fff4,#e8f8f0);
  border: 1px solid #c3e8d0; border-radius: var(--radius-md);
  padding: 18px 16px;
  display: flex; align-items: flex-start; gap: 14px;
  text-align: left;
}
.timer-icon { font-size: 28px; flex-shrink: 0; }
.timer-text {
  display: flex; flex-direction: column; gap: 4px;
}
.timer-text strong { font-size: 16px; font-weight: 800; color: var(--tt-black); }
.timer-text span { font-size: 13px; color: var(--tt-muted); line-height: 1.4; }
.success-info {
  width: 100%; text-align: left;
  padding: 14px 16px; background: var(--tt-grey);
  border-radius: var(--radius-sm);
}
.success-info p {
  font-size: 13px; color: #444;
  margin: 0 0 6px; line-height: 1.5;
}
.success-info p:last-child { margin: 0; }
.back-btn {
  width: 100%; height: 54px;
  background: var(--tt-red); color: #fff;
  border: none; border-radius: 27px;
  font-size: 16px; font-weight: 800;
  font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.back-btn:hover { background: var(--tt-red-h); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #161823; color: #fff;
  padding: 12px 20px; border-radius: 24px;
  font-size: 14px; font-weight: 600;
  z-index: 99999; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: toast-in .25s ease;
}
.toast[hidden] { display: none !important; }
.toast.show { display: block !important; }
@keyframes toast-in { from { opacity:0; transform:translateX(-50%) translateY(12px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  .main-container { padding: 74px 12px 32px; }
  .page-title { font-size: 24px; }
  .packages-grid { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .pkg-followers { font-size: 20px; }
  .pkg-price { font-size: 16px; }
  .verify-btn { padding: 0 14px; font-size: 14px; }
}
@media (max-width: 360px) {
  .packages-grid { grid-template-columns: repeat(2,1fr); gap: 6px; }
  .pkg-card { padding: 10px 8px; }
  .pkg-followers { font-size: 18px; }
}

/* ============================================================
   RESULT SCREENS (cancelled + loading followers)
   ============================================================ */
.result-screen {
  position: fixed; inset: 0; background: #fff;
  z-index: 10006; overflow-y: auto;
  display: flex; align-items: flex-start; justify-content: center;
  padding: calc(30px + env(safe-area-inset-top,0px)) 16px
           calc(40px + env(safe-area-inset-bottom,0px));
}
.result-screen[hidden] { display: none !important; }
.result-screen.show    { display: flex !important; }

.result-box {
  max-width: 420px; width: 100%;
  display: flex; flex-direction: column;
  align-items: center; gap: 16px; text-align: center;
}

/* Cancelled */
.cancelled-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fef3f2; color: #e53e3e;
  font-size: 32px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.result-title {
  font-size: 24px; font-weight: 900;
  color: var(--tt-black); margin: 0; letter-spacing: -.5px;
}
.result-sub { font-size: 15px; color: var(--tt-muted); margin: 0; }

/* Loading followers box */
.loading-box { gap: 20px; }
.loading-pkg  { font-size: 15px; color: var(--tt-muted); margin: 0; }

/* ── Progress section ── */
.loading-section {
  width: 100%; background: #f8f9ff;
  border: 1px solid #e0e4ff; border-radius: 14px;
  padding: 16px 16px 14px;
}
.loading-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 10px; gap: 8px;
}
.loading-label {
  font-size: 14px; font-weight: 700; color: var(--tt-black);
  display: flex; align-items: center; gap: 10px;
}
.loading-pct {
  font-size: 14px; font-weight: 800;
  color: #5a5fe0; flex-shrink: 0;
}
.progress-track {
  width: 100%; height: 8px; background: #e8e9f5;
  border-radius: 100px; overflow: hidden; margin-bottom: 10px;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #5a5fe0, #8b5cf6);
  border-radius: 100px;
  transition: width 2s ease-out;
}
.loading-meta {
  display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
}
.loading-status {
  font-size: 12px; color: #5a5fe0; font-weight: 600;
}
.loading-eta {
  font-size: 12px; color: var(--tt-muted);
}

/* ── Info cards ── */
.loading-cards {
  width: 100%; display: flex; flex-direction: column; gap: 10px;
}
.loading-card {
  background: var(--tt-grey); border-radius: var(--radius-sm);
  padding: 12px 14px; display: flex; align-items: flex-start; gap: 12px;
  text-align: left;
}
.loading-card-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-card-icon svg {
  width: 40px;
  height: 40px;
  display: block;
}
.loading-card-text {
  display: flex; flex-direction: column; gap: 2px;
}
.loading-card-text strong {
  font-size: 14px; font-weight: 700; color: var(--tt-black);
}
.loading-card-text span  { font-size: 12px; color: var(--tt-muted); }

.secondary-btn {
  background: var(--tt-black) !important;
}
.secondary-btn:hover { background: #2d2f3a !important; }

/* ── Processing hint text ── */
.processing-hint {
  font-size: 12px; color: var(--tt-muted); margin: 0;
  max-width: 280px; text-align: center; line-height: 1.5;
}

/* ── Small TikTok loader inline ── */
.tiktok-loader.small {
  width: 28px; height: 14px; display: inline-block; vertical-align: middle;
}
.tiktok-loader.small::before,
.tiktok-loader.small::after {
  width: 10px; height: 10px; top: 2px;
  animation-name: tiktok-anim-sm;
}
@keyframes tiktok-anim-sm {
  0%,100% { top:2px; left:0;  width:10px; height:10px; z-index:0; }
  25%     { top:0;  left:7px; width:14px; height:14px; z-index:1; }
  50%     { top:2px; left:16px; width:10px; height:10px; }
  75%     { top:3px; left:8px;  width:10px; height:10px; }
}


/* ============================================================
   PWA INSTALL BANNER
   ============================================================ */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--tt-border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 9999;
  box-shadow: 0 -4px 20px rgba(0,0,0,.1);
}
.install-banner[hidden] { display: none !important; }
.install-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}
.install-banner-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}
.install-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.install-banner-text strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--tt-black);
}
.install-banner-text span {
  font-size: 12px;
  color: var(--tt-muted);
}
.install-banner-btn {
  background: var(--tt-red);
  color: #fff; border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 14px; font-weight: 700;
  font-family: inherit; cursor: pointer;
  flex-shrink: 0;
}
.install-banner-btn:hover { background: var(--tt-red-h); }
.install-banner-dismiss {
  background: none; border: none;
  color: var(--tt-muted);
  font-size: 18px; cursor: pointer;
  padding: 4px 6px; flex-shrink: 0;
}
