:root {
  --bg: #F1F7FF;
  --surface: #FFFFFF;
  --surface-2: #E5EFFF;
  --text: #101B3C;
  --text-dim: #536681;
  --border: #D5E3F5;
  --blue: #1558EF;
  --blue-2: #007CAA;
  --success: #13734E;
  --danger: #B3261E;
  --btn-grad: linear-gradient(90deg, #006CE8, #3543ED);
  --hero-grad: linear-gradient(135deg, #E2F4FF, #EFF1FF);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */

.topbar {
  padding: 14px 18px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-badge { width: 30px; height: 30px; object-fit: contain; }
.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.1px;
}
.brand-name b { color: var(--blue); font-weight: 800; }

.balance-pill {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.balance-pill .icon { width: 16px; height: 16px; color: var(--blue-2); }

/* ---------- Layout ---------- */

.tab-content {
  padding: 10px 18px 18px;
  flex: 1;
}

.screen-title {
  font-size: 26px;
  font-weight: 800;
  margin: 10px 0 4px;
  letter-spacing: -0.2px;
}
.screen-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 18px;
  line-height: 1.5;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 14px;
}

.card-title { font-size: 16px; font-weight: 700; }
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.title-icon { color: var(--blue-2); width: 18px; height: 18px; }
.card-desc { color: var(--text-dim); font-size: 13px; line-height: 1.5; margin-bottom: 14px; }

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
}

/* ---------- Hero (Home) ---------- */

.hero-card {
  position: relative;
  background: var(--hero-grad);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px 20px 22px;
  margin-bottom: 14px;
  overflow: hidden;
}
.hero-shield {
  position: absolute;
  top: 8px;
  right: 4px;
  width: 96px;
  height: 96px;
  object-fit: contain;
  opacity: 0.92;
}
.hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--blue-2);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.hero-title {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 800;
  margin: 0 0 14px;
  max-width: 72%;
  color: var(--text);
  letter-spacing: -0.3px;
}
.hero-title .accent { color: var(--blue); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.status-pill::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}
.status-pill.status-active { color: var(--success); }
.status-pill.status-active::before { background: var(--success); }
.status-pill.status-trial { color: var(--blue-2); }
.status-pill.status-trial::before { background: var(--blue-2); }
.status-pill.status-expired { color: var(--danger); }
.status-pill.status-expired::before { background: var(--danger); }
.status-pill.status-new { color: var(--text-dim); }
.status-pill.status-loading { color: var(--text-dim); }
.status-pill.status-error { color: var(--danger); }
.status-pill.status-error::before { background: var(--danger); }

/* ---------- Subscription details card ---------- */

.sub-card { min-height: 96px; }

.skeleton {
  height: 74px;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--surface-2) 25%, #F6FAFF 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.sub-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.sub-plan-name { font-size: 16px; font-weight: 700; }
.sub-plan-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.sub-bolt {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sub-bolt .icon { color: var(--blue); width: 18px; height: 18px; }

.sub-empty { color: var(--text-dim); font-size: 14px; line-height: 1.5; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-box { min-width: 0; }
.stat-val { font-size: 15px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.stat-divider { width: 1px; background: var(--border); margin: 0 4px; }
.sub-stats-row { display: flex; align-items: flex-start; }
.sub-stats-row .stat-box { flex: 1; }

/* ---------- Buttons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid transparent;
  margin-bottom: 12px;
  cursor: pointer;
  text-align: center;
}
.btn .icon { width: 18px; height: 18px; }
.btn-primary {
  background: var(--btn-grad);
  color: #fff;
}
.btn-primary:disabled { opacity: 0.6; }
.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:disabled { opacity: 0.55; }

.btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.btn-row .btn { margin-bottom: 0; flex: 1; }
.btn-outline-compact { font-size: 14px; }
.btn-outline-compact .icon { width: 16px; height: 16px; color: var(--blue-2); }

.btn-pill-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--blue);
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-pill-action .icon { width: 15px; height: 15px; }

/* ---------- Hint card ---------- */

.hint-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
}
.hint-icon {
  color: var(--blue);
  width: 20px; height: 20px;
  flex-shrink: 0;
}
.hint-text { flex: 1; min-width: 0; }
.hint-title { font-size: 14px; font-weight: 700; }
.hint-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.chevron { color: var(--text-dim); width: 18px; height: 18px; flex-shrink: 0; }
.support-hint { cursor: default; }

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 7px 2px;
  border-radius: 12px;
  cursor: pointer;
  min-height: 44px;
}
.nav-item .icon { width: 21px; height: 21px; }
.nav-item.active { color: var(--blue); background: var(--surface-2); }

/* ---------- Setup tab ---------- */

.select-wrap { position: relative; margin-bottom: 16px; }
.device-select {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 0 42px 0 16px;
  appearance: none;
  -webkit-appearance: none;
}
.select-chevron {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.step-card { padding: 18px; }
.step-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.step-title { font-size: 15px; font-weight: 700; }
.step-sub { color: var(--text-dim); font-size: 13px; line-height: 1.5; margin: 0 0 14px 34px; }
.step-links { display: flex; flex-direction: column; gap: 8px; margin: 0 0 4px 34px; }
.step-btn { margin-top: 4px; }

#oneclick-list { display: flex; flex-direction: column; }
#oneclick-list .btn { margin-bottom: 10px; }
#oneclick-list .btn:last-child { margin-bottom: 4px; }

.link-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn .icon { width: 16px; height: 16px; color: var(--blue-2); }

.link-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--blue-2);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 0;
  margin: 0 0 0 34px;
  cursor: pointer;
}
.link-toggle .chevron { width: 16px; height: 16px; transition: transform 0.2s ease; }
.link-toggle.open .chevron { transform: rotate(180deg); }

.manual-block { margin: 10px 0 0 34px; }

.key-fallback {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 4px 0 12px;
}
.key-fallback-hint { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.key-fallback-text {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  user-select: all;
  color: var(--text);
}

/* ---------- Profile ---------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px 16px;
}
.avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--blue);
  font-size: 18px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile-name { font-size: 16px; font-weight: 700; }
.profile-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

.balance-card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.balance-value { font-size: 24px; font-weight: 800; margin-top: 2px; }

.stat-box .stat-val { font-size: 17px; }

.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.hist-row:last-child { border-bottom: none; }
.hist-label { font-weight: 700; color: var(--text); }
.hist-date { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.hist-plus { color: var(--success); font-weight: 700; white-space: nowrap; }
.hist-minus { color: var(--text); font-weight: 700; white-space: nowrap; }

.link-all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 12px;
  color: var(--blue-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.link-all-btn .icon { width: 15px; height: 15px; }

.history-pager { display: flex; gap: 8px; margin-top: 10px; }
.history-pager .link-btn { text-align: center; justify-content: center; }

/* ---------- Help / FAQ ---------- */

.faq-card { padding: 4px 18px; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-question {
  width: 100%;
  background: none;
  border: none;
  padding: 15px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.faq-question .chevron { transition: transform 0.2s ease; }
.faq-question.open .chevron { transform: rotate(180deg); color: var(--blue); }
.faq-answer { padding: 0 0 15px; }
.faq-answer p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

.footer-caption {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 27, 60, 0.35);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}
.modal-sheet {
  width: 100%;
  max-height: 82vh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close {
  background: var(--surface-2);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}
.modal-body {
  padding: 14px 20px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.insufficient-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 4px 0 16px;
}
.insufficient-banner .icon { color: var(--blue); width: 20px; height: 20px; flex-shrink: 0; }
.insufficient-text { flex: 1; min-width: 160px; }
.insufficient-title { font-size: 14px; font-weight: 700; color: var(--text); }
.insufficient-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }
.insufficient-btn { width: 100%; height: 44px; font-size: 14px; margin-bottom: 0; margin-top: 2px; }

.tariff-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin: 16px 0 8px;
}
.tariff-group-title:first-child { margin-top: 4px; }

.tariff-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.tariff-info { flex: 1; min-width: 0; }
.tariff-name { font-size: 13px; font-weight: 700; }
.tariff-price { font-size: 13px; font-weight: 800; white-space: nowrap; color: var(--text); }
.tariff-buy-btn {
  background: var(--btn-grad);
  border: none;
  border-radius: 10px;
  padding: 9px 15px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.tariff-buy-btn:disabled { opacity: 0.6; }

.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.amount-btn {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 4px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.amount-btn.active {
  border-color: var(--blue);
  background: var(--surface);
  color: var(--blue);
}

.custom-amount-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 16px;
}
.custom-amount-input::placeholder { color: var(--text-dim); }

.support-textarea {
  resize: vertical;
  min-height: 90px;
  font-family: inherit;
  line-height: 1.4;
}

.waiting-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  margin: 8px auto 18px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.waiting-title { font-weight: 700; text-align: center; margin-bottom: 8px; }
.waiting-sub { color: var(--text-dim); font-size: 13px; text-align: center; margin-bottom: 18px; line-height: 1.5; }

/* ---------- Small width safety ---------- */
@media (max-width: 340px) {
  .hero-title { font-size: 24px; max-width: 68%; }
  .hero-shield { width: 78px; height: 78px; }
}

.payout-btn { margin-top: 10px; }
.payout-hint { margin: 12px 0 0; }


/* ---------- Web cabinet: login screen + desktop column ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--hero-grad); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 28px 22px; text-align: center; box-shadow: 0 10px 40px rgba(21, 88, 239, 0.08); }
.login-logo { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 10px; }
.login-brand { font-weight: 800; letter-spacing: 0.3px; color: var(--text); }
.login-brand b { color: var(--blue); }
.login-title { font-size: 24px; margin: 14px 0 6px; color: var(--text); }
.login-sub { color: var(--text-dim); font-size: 14.5px; line-height: 1.5; margin: 0 0 20px; }
.login-code-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); }
.login-code { font-size: 44px; font-weight: 800; letter-spacing: 10px; color: var(--blue); background: var(--surface-2); border-radius: 16px; padding: 14px 0 14px 10px; margin: 6px 0 16px; }
.login-steps { text-align: left; color: var(--text-dim); font-size: 13.5px; line-height: 1.55; padding-left: 20px; margin: 0 0 14px; }
.login-wait { color: var(--text-dim); font-size: 14px; margin-bottom: 12px; }
.login-note { color: var(--danger); font-size: 13.5px; margin-top: 10px; }
.login-foot { margin-top: 18px; font-size: 12.5px; color: var(--text-dim); }
.login-foot a { color: var(--blue); text-decoration: none; }
a.btn { text-decoration: none; }
.login-label { display: block; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); margin: 0 0 6px 2px; }
.login-key { width: 100%; margin-bottom: 12px; text-align: left; }
.login-hint { color: var(--text-dim); font-size: 13px; line-height: 1.5; text-align: left; margin: -2px 0 6px; }
.login-code.cred { font-size: 22px; letter-spacing: 1px; padding: 12px 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; user-select: all; word-break: break-all; }
.cred-text { text-align: center; margin: 4px 0 14px; }
.cred-check { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; color: var(--text); margin: 0 0 14px; cursor: pointer; }
.cred-check input { width: 18px; height: 18px; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 12.5px; margin: 14px 0; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
@media (min-width: 700px) {
  body { background: #E9F1FC; }
  .app { max-width: 520px; margin: 0 auto; background: var(--bg); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .bottom-nav { max-width: 520px; width: 100%; left: 50%; right: auto; transform: translateX(-50%); }
}
