/* ===== Theme tokens ===== */
:root {
  --bg-1: #eef1fb;
  --bg-2: #e7ecfb;
  --bg-3: #f4f0fb;
  --surface: #ffffff;
  --surface-2: #f5f7fc;
  --text: #10152b;
  --text-dim: #6b7391;
  --text-mut: #9aa1bd;
  --border: #eceef6;
  --shadow: 0 10px 30px rgba(45, 55, 120, .08);
  --shadow-sm: 0 4px 14px rgba(45, 55, 120, .07);
  --primary: #6c5ce7;
  --primary-2: #8b7cf0;
  --grad: linear-gradient(135deg, #6c5ce7 0%, #7d6cf0 55%, #9b6cf0 100%);
  --grad-soft: linear-gradient(135deg, #eef0ff 0%, #f6efff 100%);
  --green: #10b981;
  --blue: #3b96f5;
  --teal: #14b8a6;
  --orange: #f59e0b;
  --pink: #ec4899;
  --red: #ef4444;
  --radius: 20px;
  --radius-sm: 14px;
  --nav-h: 64px;
}
:root[data-theme="dark"] {
  --bg-1: #0b0d1a;
  --bg-2: #0e1020;
  --bg-3: #12132a;
  --surface: #171a2e;
  --surface-2: #1e2138;
  --text: #eef0fb;
  --text-dim: #9aa1c4;
  --text-mut: #6a7096;
  --border: #262a45;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .3);
  --grad-soft: linear-gradient(135deg, #1b1e38 0%, #22203c 100%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-3) 55%, var(--bg-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--primary); text-decoration: none; }

.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg-1) 75%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--grad); box-shadow: 0 6px 16px rgba(108, 92, 231, .4);
}
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.2px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface); color: var(--text-dim); box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
}
.icon-btn:active { transform: scale(.92); }

/* ===== View ===== */
.view { flex: 1; padding: 8px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin: 10px 2px 14px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-mut); text-transform: uppercase; letter-spacing: .6px; margin: 22px 4px 10px; }

/* ===== Cards ===== */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.card.tight { padding: 14px; }

/* Hero subscription card */
.hero {
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(16,185,129,.18), transparent 70%); border-radius: 50%;
}
.hero-row { display: flex; align-items: center; gap: 14px; }
.hero-icon {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; flex: none;
  color: #fff;
}
.hero-title { font-size: 17px; font-weight: 800; }
.hero-sub { font-size: 13.5px; color: var(--text-dim); margin-top: 2px; }

.greeting { font-size: 27px; font-weight: 800; letter-spacing: -.6px; margin: 6px 2px 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px; margin-bottom: 14px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.off { background: #ffe9ee; color: #e11d48; }
.badge.off .dot { background: #e11d48; }
.badge.on { background: #e6f9f1; color: #059669; }
.badge.on .dot { background: #10b981; }
:root[data-theme="dark"] .badge.off { background: rgba(225,29,72,.15); }
:root[data-theme="dark"] .badge.on { background: rgba(16,185,129,.15); }

/* Primary button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px 18px; border-radius: 16px; font-weight: 800; font-size: 15.5px;
  transition: transform .12s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 10px 24px rgba(108,92,231,.35); }
.btn.ghost { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); border: 1.5px solid color-mix(in srgb, var(--primary) 30%, transparent); }
.btn.soft { background: var(--surface-2); color: var(--text); }
.btn.sm { width: auto; padding: 11px 16px; font-size: 14px; border-radius: 13px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* Quick actions grid */
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 4px 0 6px; }
.quick.four { grid-template-columns: repeat(4, 1fr); }
.qa { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 6px 2px; border-radius: 14px; transition: transform .12s ease; }
.qa:active { transform: scale(.94); }
.qa .qa-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm); }
.qa .qa-lb { font-size: 11.5px; font-weight: 600; color: var(--text-dim); text-align: center; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.stat { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-sm); padding: 14px 10px; text-align: center; }
.stat .st-ic { width: 30px; height: 30px; border-radius: 9px; margin: 0 auto 8px; display: grid; place-items: center; color: #fff; }
.stat .st-v { font-size: 17px; font-weight: 800; letter-spacing: -.3px; }
.stat .st-l { font-size: 11.5px; color: var(--text-mut); margin-top: 2px; }
.stat.wide { grid-column: span 1; }

/* Banner row */
.banner { display: flex; align-items: center; gap: 14px; background: var(--grad-soft); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.banner .bn-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); color: #fff; flex: none; }
.banner .bn-t { font-weight: 800; font-size: 15px; }
.banner .bn-s { font-size: 12.5px; color: var(--text-dim); }
.banner .chev { margin-left: auto; color: var(--text-mut); }

/* List rows (profile) */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 14px; background: var(--surface);
  border-radius: 18px; box-shadow: var(--shadow-sm); padding: 15px 16px; transition: transform .12s ease;
}
.row:active { transform: scale(.99); }
.row .row-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.row .row-t { font-weight: 700; font-size: 15px; }
.row .row-s { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }
.row .chev { margin-left: auto; color: var(--text-mut); }

/* Profile head */
.phead { display: flex; align-items: center; gap: 14px; }
.avatar { width: 58px; height: 58px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 22px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* 2x2 grid tiles (subscription page) */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px 16px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; transition: transform .12s ease; }
.tile:active { transform: scale(.97); }
.tile .tl-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; }
.tile .tl-t { font-weight: 700; font-size: 15px; }

/* Platform selector */
.plats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.plat { background: var(--surface-2); border: 1.5px solid transparent; border-radius: 14px; padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.plat.active { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border-color: var(--primary); color: var(--primary); }
.plat svg { width: 22px; height: 22px; }

/* Tariff card */
.tcard { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 12px; border: 1.5px solid var(--border); }
.tcard.best { border-color: var(--primary); box-shadow: 0 10px 26px rgba(108,92,231,.18); }
.tcard-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.tcard-name { font-weight: 800; font-size: 17px; }
.tcard-tag { font-size: 11px; font-weight: 800; color: #fff; background: var(--grad); padding: 4px 9px; border-radius: 999px; }
.tcard-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.tmeta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tmeta .chip { font-size: 12px; font-weight: 600; color: var(--text-dim); background: var(--surface-2); padding: 6px 10px; border-radius: 10px; display: inline-flex; align-items: center; gap: 5px; }
.periods { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.period { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 13px; background: var(--surface-2); border: 1.5px solid transparent; transition: .12s; }
.period.sel { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.period .p-l { font-weight: 700; font-size: 14px; }
.period .p-sub { font-size: 11.5px; color: var(--text-mut); }
.period .p-r { text-align: right; }
.period .p-price { font-weight: 800; font-size: 15px; }
.period .p-old { font-size: 11.5px; color: var(--text-mut); text-decoration: line-through; }
.period .p-disc { font-size: 11px; font-weight: 800; color: var(--green); }

/* App list (install) */
.applist { display: flex; flex-direction: column; gap: 10px; }
.approw { display: flex; align-items: center; gap: 13px; background: var(--surface-2); border-radius: 16px; padding: 13px 14px; transition: transform .12s ease; }
.approw:active { transform: scale(.98); }
.app-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; flex: none; box-shadow: var(--shadow-sm); }
.app-meta { min-width: 0; flex: 1; }
.app-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.app-badge { font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); white-space: nowrap; }
.app-badge.alt { background: var(--surface); color: var(--text-mut); box-shadow: var(--shadow-sm); }
.app-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-dl { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--primary); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }

/* Callout */
.callout { display: flex; gap: 12px; align-items: flex-start; background: var(--grad-soft); border-radius: 16px; padding: 14px; }
.callout .co-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; flex: none; }
.callout .co-t { font-weight: 700; font-size: 13.5px; }
.callout .co-d { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

/* Info / country rows */
.crow { display: flex; align-items: center; gap: 12px; padding: 13px 6px; border-bottom: 1px solid var(--border); }
.crow:last-child { border-bottom: none; }
.flag { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 17px; flex: none; }
.crow .c-n { font-weight: 700; font-size: 14.5px; }
.crow .c-s { font-size: 12px; color: var(--text-mut); }
.pill { margin-left: auto; font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 999px; }
.pill.ok { background: #e6f9f1; color: #059669; }
:root[data-theme="dark"] .pill.ok { background: rgba(16,185,129,.16); }

/* Link box */
.linkbox { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 13px; padding: 12px 14px; }
.linkbox code { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.qr { background: #fff; padding: 14px; border-radius: 16px; display: grid; place-items: center; box-shadow: var(--shadow-sm); margin: 0 auto 14px; width: fit-content; }
.qr img, .qr canvas { display: block; border-radius: 6px; }

/* Progress */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; background: var(--grad); border-radius: 999px; }

/* Steps */
.step { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; }
.step .num { width: 26px; height: 26px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; flex: none; }
.step .s-t { font-weight: 700; font-size: 14px; }
.step .s-d { font-size: 12.5px; color: var(--text-dim); }

/* Empty / muted */
.muted { color: var(--text-dim); font-size: 13.5px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.stack > * + * { margin-top: 10px; }

/* Skeleton */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 12px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); animation: sh 1.2s infinite; }
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
@keyframes sh { 100% { transform: translateX(100%); } }
.skel.h48 { height: 48px; } .skel.h80 { height: 80px; } .skel.h140 { height: 140px; }

/* Tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--text-mut); font-size: 11px; font-weight: 600; border-radius: 12px; transition: color .15s; }
.tab.active { color: var(--primary); }
.tab.active svg { filter: drop-shadow(0 4px 8px rgba(108,92,231,.4)); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 20px); z-index: 60; opacity: 0; pointer-events: none;
  background: #1a1d33; color: #fff; padding: 12px 18px; border-radius: 13px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0,0,0,.3); transition: opacity .22s, transform .22s; max-width: 86%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* Bottom sheet */
.sheet-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(10,12,30,.5); opacity: 0; pointer-events: none; transition: opacity .25s; display: flex; align-items: flex-end; }
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet { width: 100%; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 22px); transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1); max-height: 86vh; overflow-y: auto; }
.sheet-overlay.open .sheet { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--border); margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }

/* Full-screen gate */
.gate { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 14px; }
.gate .g-ic { width: 76px; height: 76px; border-radius: 22px; background: var(--grad); display: grid; place-items: center; color: #fff; box-shadow: 0 14px 34px rgba(108,92,231,.4); }
.gate h2 { margin: 0; font-size: 21px; font-weight: 800; }
.gate p { margin: 0; color: var(--text-dim); font-size: 14px; max-width: 300px; }

.footer-note { text-align: center; font-size: 11.5px; color: var(--text-mut); padding: 16px 0 4px; }
