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

:root {
  --bg: #08090f;
  --card: #12131c;
  --card-2: #171826;
  --border: rgba(255,255,255,0.07);
  --text: #f3f4f8;
  --text-dim: #8b8d9c;
  --text-dim2: #5c5e6c;
  --cyan: #22d3ee;
  --blue: #6d7bff;
  --purple: #a78bfa;
  --green: #34d399;
  --red: #f87171;
  --grad: linear-gradient(135deg, var(--cyan), var(--blue) 55%, var(--purple));
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(86px + var(--safe-bottom));
  position: relative;
}

/* ---------------- TOPBAR ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 6px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; color: #04060c;
}
.brand-name { font-size: 19px; font-weight: 700; }
.brand-name span { color: var(--text-dim); font-weight: 500; }
.bell-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}

/* ---------------- SCREENS ---------------- */
.screens { padding: 14px 16px 4px; }
.screen { display: none; animation: fadein .18s ease; }
.screen.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title { font-size: 22px; font-weight: 700; margin: 10px 2px 12px; }
.section-subtitle { font-size: 14px; font-weight: 600; color: var(--text-dim); margin-bottom: 10px; }
.kicker { font-size: 12px; letter-spacing: .08em; color: var(--text-dim2); margin: 4px 2px 0; font-weight: 700; }

/* ---------------- CARD ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}

/* ---------------- RING ---------------- */
.ring-card { display: flex; flex-direction: column; align-items: center; padding: 26px 20px 22px; }
.ring-wrap { position: relative; width: 210px; height: 210px; }
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); filter: drop-shadow(0 0 18px rgba(109,123,255,.25)); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.06); stroke-width: 10; }
.ring-fg {
  fill: none; stroke: url(#none); stroke: var(--cyan); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 597; stroke-dashoffset: 597;
  transition: stroke-dashoffset .7s cubic-bezier(.4,0,.2,1);
}
.ring-dot { fill: #eafcff; filter: drop-shadow(0 0 6px #22d3ee); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-value { font-size: 46px; font-weight: 800; line-height: 1; }
.ring-label { color: var(--text-dim); font-size: 14px; margin-top: 6px; }

.status-pill {
  margin-top: 18px; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(52,211,153,.12); color: var(--green);
  padding: 7px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.off { background: rgba(248,113,113,.12); color: var(--red); }
.status-pill.muted { background: rgba(255,255,255,.06); color: var(--text-dim); }

.plan-line { margin-top: 12px; color: var(--text-dim); font-size: 14px; text-align: center; }
.plan-line b { color: var(--text); font-weight: 600; }

.traffic-block { width: 100%; margin-top: 18px; }
.traffic-row { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-dim); margin-bottom: 8px; }
.progress-track { height: 8px; border-radius: 6px; background: rgba(255,255,255,.07); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; background: var(--grad); width: 0%; transition: width .5s ease; }

.btn-row { display: flex; gap: 10px; width: 100%; margin-top: 20px; }

.btn {
  flex: 1; border: none; border-radius: 14px; padding: 14px 10px;
  font-size: 15px; font-weight: 700; cursor: pointer; text-align: center;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.97); opacity: .9; }
.btn-grad { background: var(--grad); color: #04060c; }
.btn-ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.btn-small { flex: none; padding: 10px 14px; font-size: 13px; border-radius: 10px; background: var(--card-2); color: var(--cyan); border: 1px solid var(--border); }
.btn-full { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.mini-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 18px 14px; text-align: left; cursor: pointer;
}
.mini-emoji { font-size: 22px; margin-bottom: 22px; }
.mini-text { font-size: 14.5px; font-weight: 600; line-height: 1.3; }

/* ---------------- PLANS ---------------- */
.plans-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.plan-card {
  position: relative; background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px; cursor: pointer;
}
.plan-card.popular { border-color: rgba(109,123,255,.5); }
.plan-badge {
  position: absolute; top: -10px; right: 16px; background: var(--grad);
  color: #04060c; font-size: 11px; font-weight: 800; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 999px;
}
.plan-top { display: flex; justify-content: space-between; align-items: flex-start; }
.plan-name { font-size: 18px; font-weight: 700; }
.plan-desc { color: var(--text-dim); font-size: 13.5px; margin-top: 3px; }
.plan-price { text-align: right; font-size: 20px; font-weight: 800; white-space: nowrap; }
.plan-price small { display: block; font-weight: 500; font-size: 12px; color: var(--text-dim); }
.plan-meta { display: flex; gap: 16px; margin-top: 14px; }
.plan-meta span { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-dim); }

.servers-card { padding: 6px 18px; }
.server-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.server-row:last-child { border-bottom: none; }
.server-name { font-size: 15px; font-weight: 500; }
.server-ping { font-size: 13px; font-weight: 700; color: var(--green); background: rgba(52,211,153,.12); padding: 4px 10px; border-radius: 999px; }
.server-ping.slow { color: #fbbf24; background: rgba(251,191,36,.12); }
.server-ping.off { color: var(--text-dim); background: rgba(255,255,255,.06); }

/* ---------------- SUBSCRIPTIONS ---------------- */
.subs-list { display: flex; flex-direction: column; gap: 12px; }
.sub-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 18px; }
.sub-top { display: flex; justify-content: space-between; align-items: flex-start; }
.sub-name { font-size: 16.5px; font-weight: 700; }
.sub-badge { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.sub-badge.active { background: rgba(52,211,153,.14); color: var(--green); }
.sub-badge.expired { background: rgba(248,113,113,.14); color: var(--red); }
.sub-meta { color: var(--text-dim); font-size: 13.5px; margin-top: 5px; }
.sub-linkbox {
  display: flex; align-items: center; gap: 8px; background: var(--card-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-top: 14px;
}
.sub-linkbox input { flex: 1; background: none; border: none; outline: none; font-size: 12.5px; color: var(--text-dim); }
.sub-linkbox button { flex: none; background: none; border: none; color: var(--cyan); font-weight: 700; font-size: 13px; cursor: pointer; }
.sub-actions { display: flex; gap: 10px; margin-top: 10px; }
.autorenew-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.autorenew-label { font-size: 13.5px; color: var(--text-dim); }
.switch { width: 44px; height: 26px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border); position: relative; cursor: pointer; flex: none; }
.switch.on { background: var(--grad); }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .18s ease; }
.switch.on .knob { transform: translateX(18px); }

/* ---------------- PROFILE ---------------- */
.user-card { display: flex; align-items: center; gap: 14px; }
.user-avatar {
  width: 48px; height: 48px; border-radius: 50%; background: var(--grad);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 19px; color: #04060c; flex: none;
}
.user-name { font-size: 16px; font-weight: 700; }
.user-id { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.wallet-card { text-align: center; }
.wallet-label { color: var(--text-dim); font-size: 13.5px; }
.wallet-balance { font-size: 38px; font-weight: 800; margin-top: 6px; }

.ref-card {}
.ref-title { font-weight: 700; font-size: 16px; }
.ref-desc { color: var(--text-dim); font-size: 13.5px; margin-top: 8px; line-height: 1.4; }
.ref-link-row { display: flex; gap: 8px; margin-top: 14px; }
.ref-link-row input {
  flex: 1; background: var(--card-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; color: var(--text-dim); outline: none;
}
.ref-stats { display: flex; gap: 24px; margin-top: 16px; }
.ref-stats div { display: flex; flex-direction: column; }
.ref-stats span { font-size: 20px; font-weight: 800; }
.ref-stats small { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; }
.history-desc { color: var(--text-dim); max-width: 68%; }
.history-date { color: var(--text-dim2); font-size: 11.5px; margin-top: 2px; }
.history-amount { font-weight: 700; white-space: nowrap; }
.history-amount.pos { color: var(--green); }
.history-amount.neg { color: var(--red); }
.empty-hint { color: var(--text-dim2); font-size: 13.5px; text-align: center; padding: 10px 0; }

.links-card { display: flex; flex-direction: column; gap: 2px; padding: 6px 18px; }
.link-row { padding: 14px 0; font-size: 14.5px; font-weight: 500; border-bottom: 1px solid var(--border); }
.link-row:last-child { border-bottom: none; }

/* ---------------- SKELETONS ---------------- */
.skeleton { height: 90px; border-radius: 18px; background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 37%, var(--card) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; margin-bottom: 12px; }
.skeleton.small { height: 46px; margin-bottom: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------------- TABBAR ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  background: rgba(10,11,18,.92); backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex; padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 40;
}
.tab {
  flex: 1; background: none; border: none; display: flex; flex-direction: column;
  align-items: center; gap: 4px; padding: 6px 0; color: var(--text-dim2); cursor: pointer;
}
.tab span { font-size: 11px; font-weight: 600; }
.tab.active { color: var(--cyan); }

/* ---------------- TOAST ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: #1c1d2b; border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100; max-width: 86%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- BOTTOM SHEET ---------------- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 90;
}
.sheet-overlay.show { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 480px; background: var(--card);
  border-radius: 22px 22px 0 0; padding: 10px 20px calc(24px + var(--safe-bottom));
  transform: translateY(100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
  max-height: 82vh; overflow-y: auto;
}
.sheet-overlay.show .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 6px auto 16px; }
.sheet h3 { font-size: 18px; margin-bottom: 4px; }
.sheet p { color: var(--text-dim); font-size: 13.5px; margin-bottom: 16px; line-height: 1.4; }

.stepper { display: flex; align-items: center; justify-content: center; gap: 20px; margin: 18px 0; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--border); font-size: 20px; color: var(--text); cursor: pointer; }
.stepper-value { font-size: 24px; font-weight: 800; min-width: 44px; text-align: center; }

.sheet-input {
  width: 100%; background: var(--card-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; font-size: 16px; color: var(--text); outline: none; margin-bottom: 14px; text-align: center;
}

.price-line { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 16px; font-size: 15px; }
.price-line b { font-size: 19px; }

.pay-options { display: flex; flex-direction: column; gap: 10px; }
.pay-option {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; font-size: 14.5px; font-weight: 600;
}
.pay-option[disabled] { opacity: .4; pointer-events: none; }
.pay-option .arrow { color: var(--text-dim2); }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.25); border-top-color: #04060c; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
