:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --bg-soft: #121214;
  --bg-card: #1c1c21;
  --bg-card-2: #232329;
  --bg-elevated: #2a2a32;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f4f4f6;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #c4b5fd;
  --accent-2: #ddd6fe;
  --accent-text: #1a1228;
  --accent-soft: rgba(196, 181, 253, 0.14);
  --accent-ring: rgba(196, 181, 253, 0.55);
  --success: #34c759;
  --success-bg: rgba(52, 199, 89, 0.12);
  --danger: #ff453a;
  --danger-bg: rgba(255, 69, 58, 0.12);
  --warn: #ff9f0a;
  --warn-bg: rgba(255, 159, 10, 0.12);
  --radius: 18px;
  --radius-lg: 24px;
  --nav-h: 64px;
  --cta-h: 280px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Manrope", sans-serif;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  background: var(--bg);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
}

body.paywall-mode .screen.active {
  padding-bottom: calc(var(--cta-h) + 24px);
}

body.plans-checkout {
  --cta-h: 132px;
}

body.plans-checkout .screen.active {
  padding-bottom: calc(var(--cta-h) + 16px);
}

body.plans-checkout .paywall-cta {
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: 10px;
}

body.plans-checkout .paywall-cta .legal,
body.plans-checkout .paywall-cta .signed-as {
  display: none;
}

.paywall-end { height: 24px; }

body.paywall-mode .bottom-nav,
.app-header { display: none; }

.app-content,
.paywall-cta,
.bottom-nav,
.sheet {
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
}

#global-loader.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

#global-loader.loader.hidden { display: none !important; }

.screen {
  display: none;
  padding: 20px 20px 12px;
}

.screen.active { display: block; }

.screen.screen-enter { animation: fadeUp 0.28s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.page-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin: 0 0 10px;
  color: var(--text);
}

.page-desc {
  margin: 0 0 22px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text-secondary);
  font-weight: 500;
}

.feature-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 22px;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.feature-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}

.feature-check svg { width: 18px; height: 18px; }

.duration-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.duration-card {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1.5px solid transparent;
  background: var(--bg-card);
  color: var(--text);
  border-radius: 22px;
  padding: 16px 16px 16px 18px;
  font-family: var(--font);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
}

.duration-card.selected {
  border-color: var(--accent-ring);
  background: linear-gradient(180deg, rgba(196, 181, 253, 0.08), rgba(196, 181, 253, 0.03)), var(--bg-card);
  box-shadow: inset 0 0 0 1px rgba(196, 181, 253, 0.12);
}

.duration-main { min-width: 0; }

.duration-name {
  display: block;
  font-size: 17px;
  font-weight: 700;
}

.duration-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #3a3354;
  color: #d6ccff;
  font-size: 11px;
  font-weight: 700;
}

.duration-note {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.duration-price {
  text-align: right;
  white-space: nowrap;
}

.duration-price-now {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.duration-price-was {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: line-through;
}

.radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #5b5b66;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.duration-card.selected .radio,
.pay-row.selected .radio {
  border: none;
  background: var(--accent);
  color: var(--accent-text);
}

.radio svg,
.radio .ico svg { width: 14px; height: 14px; display: none; }
.duration-card.selected .radio svg,
.duration-card.selected .radio .ico svg,
.pay-row.selected .radio svg,
.pay-row.selected .radio .ico svg { display: block; }

.plan-switch {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 12px;
  scrollbar-width: none;
}

.plan-switch::-webkit-scrollbar { display: none; }

.plan-chip {
  appearance: none;
  border: 1px solid transparent;
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.plan-chip.selected {
  color: var(--text);
  border-color: var(--accent-ring);
  background: var(--accent-soft);
}

.pay-block { margin-top: 8px; }

.pay-choose {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.whats-new {
  margin: 0 0 16px;
  padding-left: 18px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 550;
}

.whats-new li { margin: 0 0 8px; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 18px 0 10px 4px;
}

.pay-row,
.action-row {
  appearance: none;
  width: 100%;
  border: none;
  background: var(--bg-card);
  color: var(--text);
  border-radius: 22px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-family: var(--font);
  cursor: pointer;
}

.pay-row { margin-bottom: 12px; scroll-margin-bottom: calc(var(--cta-h) + 24px); }
.pay-row.selected {
  box-shadow: inset 0 0 0 1.5px var(--accent-ring);
}

.pay-logo,
.action-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.pay-logo svg,
.action-ico svg { width: 20px; height: 20px; }

.pay-logo img,
.sbp-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}

.pay-copy { flex: 1; min-width: 0; }

.pay-title,
.action-title {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.pay-hint,
.action-hint {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.pay-row .chevron,
.action-row .chevron {
  color: var(--text-muted);
  margin-left: auto;
}

.paywall-cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  padding: 12px 20px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(11, 11, 13, 0) 0%, var(--bg) 28%);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 16px 18px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active { transform: scale(0.985); opacity: 0.94; }

.btn-primary {
  background: var(--accent-2);
  color: var(--accent-text);
}

.btn-secondary {
  background: var(--bg-card-2);
  color: var(--text);
  margin-top: 10px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-inline {
  width: auto;
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 12px;
}

.legal {
  margin: 14px 8px 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.legal a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.signed-as {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.signed-as button {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.screen-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.icon-btn {
  appearance: none;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn svg { width: 18px; height: 18px; }

.screen-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.platform-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.platform-tabs::-webkit-scrollbar { display: none; }

.platform-tab {
  appearance: none;
  border: none;
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
}

.platform-tab.selected {
  background: #2a2438;
  color: var(--accent-2);
}

.platform-tab svg { width: 14px; height: 14px; }

.steps-card,
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.install-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px 12px;
  margin-bottom: 16px;
}

.install-step:last-child { margin-bottom: 0; }

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #3a3354;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.step-text {
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  font-weight: 550;
}

.step-btn {
  grid-column: 2;
  appearance: none;
  border: none;
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  justify-self: start;
  cursor: pointer;
}

.home-hero {
  text-align: left;
  padding: 4px 0 18px;
}

.brand-mark {
  display: flex;
  align-items: center;
  margin: 2px 0 18px;
}

.brand-mark img {
  height: 42px;
  width: auto;
  max-width: 196px;
  object-fit: contain;
  display: block;
}

.home-status {
  font-size: 13px;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 8px;
}

.home-hero h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.035em;
}

.home-hero p {
  margin: 0 0 18px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.4;
}

.home-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  appearance: none;
  border: none;
  width: 100%;
  color: inherit;
  font-family: var(--font);
  cursor: pointer;
}

.home-hint .pay-copy { flex: 1; }
.home-hint .chevron { color: var(--text-muted); margin-left: auto; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  background: var(--bg-elevated);
  border-radius: 16px;
  padding: 12px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 14px;
  font-weight: 700;
  word-break: break-word;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 12px;
}

.status-active { background: var(--success-bg); color: var(--success); }
.status-expired { background: var(--danger-bg); color: var(--danger); }
.status-limited { background: var(--warn-bg); color: var(--warn); }

.device-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.device-item:last-child { border-bottom: none; }

.device-name { font-size: 14px; font-weight: 650; }
.muted { color: var(--text-secondary); font-size: 12px; }

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.input {
  width: 100%;
  border: none;
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 16px;
  outline: none;
}

.key-box {
  background: var(--bg-elevated);
  border-radius: 14px;
  padding: 12px;
  word-break: break-all;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 10px 0;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 6px 8px var(--safe-bottom);
  background: rgba(11, 11, 13, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 650;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.nav-btn.active { color: var(--accent); }
.nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icon svg { width: 22px; height: 22px; display: block; }

.loader { text-align: center; color: var(--text-secondary); gap: 14px; }
.loader-text { font-size: 13px; font-weight: 600; }

.loader-ring {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-h) + 12px + var(--safe-bottom));
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(6px);
  z-index: 60;
}

body.paywall-mode .toast { bottom: calc(var(--cta-h) + 8px); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { color: #ffb4ae; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 71;
  background: #16161a;
  border-radius: 28px 28px 0 0;
  padding: 10px 18px calc(18px + var(--safe-bottom));
  transform: translateY(110%);
  transition: transform 0.28s ease;
  max-height: min(78vh, 640px);
  overflow-y: auto;
}

.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: #3a3a42;
  margin: 4px auto 14px;
}

.sheet h2 {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 800;
}

.qr-wrap {
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  margin: 8px 0 14px;
  display: flex;
  justify-content: center;
}

.qr-wrap img {
  width: 220px;
  height: 220px;
  display: block;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

.app-version {
  margin: 18px 0 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.55;
}

.hidden { display: none !important; }
.ico { display: inline-flex; line-height: 0; }
.ico svg { display: block; }

.balance-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}
