@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Nunito:wght@700;800&display=swap");

:root {
  --bg: #e7ecf4;
  --bg-deep: #eff3f8;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.72);
  --surface-tint: rgba(0, 122, 255, 0.07);
  --line: rgba(0, 0, 0, 0.06);
  --line-strong: rgba(0, 122, 255, 0.14);
  --text: #0b1220;
  --muted: #707579;
  --extra: #7885a2;
  --accent: #007aff;
  --accent-strong: #0062d6;
  --danger: #ff3b30;
  --success: #34c759;
  --shadow: 0 10px 24px rgba(36, 52, 86, 0.08);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --app-width: 414px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --shell-padding-top: max(8px, var(--safe-top));
  --shell-padding-right: max(8px, var(--safe-right));
  --shell-padding-bottom: calc(18px + var(--safe-bottom));
  --shell-padding-left: max(8px, var(--safe-left));
  --tg-viewport-height: 100dvh;
}

body.is-dark-theme {
  --bg: #000509;
  --bg-deep: #0c1016;
  --surface: #171a21;
  --surface-soft: rgba(23, 26, 33, 0.92);
  --surface-tint: rgba(41, 144, 255, 0.14);
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(41, 144, 255, 0.24);
  --text: #fcfcfc;
  --muted: #a2acb0;
  --extra: #969dae;
  --accent: #2990ff;
  --accent-strong: #0f7af0;
  --danger: #ff4d73;
  --success: #34c759;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.26);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.4), transparent 32%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 100%);
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: var(--tg-viewport-height);
  padding: var(--shell-padding-top) var(--shell-padding-right) var(--shell-padding-bottom)
    var(--shell-padding-left);
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(100%, var(--app-width));
  min-height: calc(var(--tg-viewport-height) - var(--shell-padding-top) - var(--shell-padding-bottom));
  margin: 0 auto;
  position: relative;
}

.topbar,
.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 14px;
}

.topbar {
  min-height: 72px;
  border-bottom: 1px solid var(--line);
}

body.is-dark-theme .topbar {
  border-bottom-color: var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #192033;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  flex: 0 0 auto;
}

body.is-dark-theme .brand-mark {
  background: #ffffff;
  color: #111;
}

body[data-brand="hitvpn"] .brand {
  gap: 8px;
}

body[data-brand="hitvpn"] .brand-mark {
  width: auto;
  height: auto;
  min-width: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.8rem;
  line-height: 1;
  padding: 0;
}

.brand-name {
  min-width: 0;
  font-size: clamp(1.65rem, 6vw, 2.15rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.icon-button,
.modal-close {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(0, 122, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--accent);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  backdrop-filter: blur(8px);
}

.icon-button svg,
.action-icon svg,
.menu-item-icon svg,
.referral-mark svg,
.modal-mark svg,
.icon-symbol svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-button svg circle {
  fill: currentColor;
  stroke: none;
}

.page {
  display: grid;
  gap: 12px;
  padding: 0;
}

.overlay-view {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: var(--app-width);
  margin: 0 auto;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.34), transparent 28%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 100%);
  overflow: auto;
  z-index: 40;
  padding: var(--shell-padding-top) var(--shell-padding-right) var(--shell-padding-bottom)
    var(--shell-padding-left);
}

.overlay-content {
  display: grid;
  gap: 12px;
  padding: 0 4px;
}

.overlay-content h1 {
  margin: 0;
  font-size: clamp(1.75rem, 7vw, 2.2rem);
  line-height: 1.02;
  letter-spacing: -0.06em;
}

.overlay-note,
.section-note,
.hero-subtitle,
.tariff-note,
.topup-disclaimer,
.device-subtitle,
.history-item-time,
.overlay-balance-caption,
.device-detail-meta {
  color: var(--muted);
}

.status-banner,
.hero-card,
.action-card,
.promise-card,
.devices-card,
.referral-card,
.videos-card,
.amount-card,
.history-list,
.modal-card,
.dropdown-menu {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.status-banner,
.hero-card,
.promise-card,
.devices-card,
.referral-card,
.videos-card,
.amount-card,
.history-list,
.modal-card {
  background: var(--surface);
}

.status-banner {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
}

.status-banner a,
.device-detail-list a {
  color: var(--accent);
}

.hero-card {
  padding: 20px 12px 8px;
  border-radius: 0;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
}

.hero-caption,
.video-title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-transform: none;
}

.hero-balance-line {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
}

.hero-balance {
  font-family: "Nunito", "Inter", sans-serif;
  font-size: clamp(3.5rem, 16vw, 4.8rem);
  line-height: 0.9;
  letter-spacing: -0.07em;
  font-weight: 800;
}

.hero-currency {
  font-family: "Nunito", "Inter", sans-serif;
  font-size: clamp(2rem, 8vw, 2.8rem);
  line-height: 1;
  color: rgba(11, 18, 32, 0.38);
  font-weight: 700;
}

.hero-subtitle {
  margin: 10px auto 0;
  max-width: 320px;
  font-size: 0.98rem;
  line-height: 1.35;
}

.action-grid {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "topup topup"
    "promise history";
  gap: 10px;
}

.action-card,
.soft-button,
.pay-button,
.pill-button,
.back-button,
.menu-item,
.device-row,
.video-row,
.amount-button,
.platform-button,
.device-detail-button {
  border: none;
  cursor: pointer;
}

.action-card {
  min-height: 84px;
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
}

.action-card--topup {
  grid-area: topup;
  min-height: 76px;
}

#quickPromiseButton {
  grid-area: promise;
}

#openHistoryButton {
  grid-area: history;
}

.action-card--primary,
.soft-button,
.pay-button,
.device-detail-button--primary {
  background: linear-gradient(180deg, #0f86ff 0%, #0070f2 100%);
  color: #fff;
  border-color: transparent;
}

.action-card:active,
.soft-button:active,
.pay-button:active,
.pill-button:active,
.device-row:active,
.video-row:active,
.menu-item:active,
.amount-button:active,
.platform-button:active,
.device-detail-button:active {
  transform: scale(0.985);
}

.action-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(0, 122, 255, 0.1);
}

.action-card--primary .action-icon {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.action-card--secondary {
  background: var(--surface);
  border: 1px solid var(--line);
}

.action-card.is-disabled,
.soft-button.is-disabled,
.device-detail-button.is-disabled {
  opacity: 0.72;
}

.promise-card,
.devices-card,
.referral-card,
.videos-card,
.amount-card {
  border-radius: var(--radius-xl);
  padding: 16px;
}

body.is-dark-theme .promise-card,
body.is-dark-theme .devices-card,
body.is-dark-theme .referral-card,
body.is-dark-theme .videos-card,
body.is-dark-theme .amount-card,
body.is-dark-theme .hero-card,
body.is-dark-theme .history-list,
body.is-dark-theme .modal-card,
body.is-dark-theme .status-banner {
  background: var(--surface);
}

.promise-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-title,
.devices-card h2,
.referral-card h2 {
  margin: 0;
  font-size: clamp(1.35rem, 6vw, 1.75rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.soft-button,
.pill-button,
.pay-button,
.back-button {
  min-height: 48px;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 700;
}

.soft-button {
  width: 100%;
}

.section-head {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pill-button,
.pay-button--secondary,
.device-detail-button--ghost {
  background: var(--surface-tint);
  color: var(--accent);
}

.pill-button {
  min-height: 44px;
  padding: 0 18px;
  white-space: nowrap;
}

.device-list,
.video-list,
.referral-actions,
.payment-methods,
.device-detail-actions {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.devices-card {
  padding: 0;
  overflow: hidden;
}

.devices-card .section-head {
  padding: 16px;
}

.devices-card .section-note {
  margin-top: 4px;
}

.device-row,
.video-row {
  width: 100%;
  background: transparent;
  border-radius: 0;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  text-align: left;
}

body.is-dark-theme .device-row,
body.is-dark-theme .video-row {
  background: transparent;
}

.device-row + .device-row,
.video-row + .video-row {
  border-top: 1px solid var(--line);
}

.device-list {
  margin-top: 0;
  gap: 0;
}

.device-icon,
.video-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(180deg, #0f86ff 0%, #0070f2 100%);
}

.video-icon {
  background: rgba(0, 122, 255, 0.09);
  color: var(--accent);
}

.device-icon .icon-symbol svg,
.video-icon .icon-symbol svg {
  width: 24px;
  height: 24px;
}

.device-title,
.video-label {
  min-width: 0;
  font-size: 1rem;
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.device-subtitle {
  margin-top: 4px;
  font-size: 0.82rem;
  line-height: 1.3;
}

.device-title,
.device-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-date,
.device-arrow,
.video-arrow {
  color: var(--extra);
  font-size: 0.82rem;
  white-space: nowrap;
}

.tariff-note {
  margin: 4px 4px 4px;
  text-align: center;
  font-size: 0.92rem;
}

.referral-card {
  text-align: center;
  padding-top: 20px;
}

body.is-dark-theme .referral-card {
  background: #1a222e;
}

.referral-mark,
.modal-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  background: rgba(0, 122, 255, 0.08);
  color: var(--accent);
}

.referral-mark svg,
.modal-mark svg {
  width: 24px;
  height: 24px;
}

.referral-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.referral-button {
  min-height: 62px;
}

.history-list {
  border-radius: var(--radius-xl);
  padding: 8px 14px;
}

.history-group + .history-group {
  margin-top: 16px;
}

.history-date {
  margin: 0 0 10px;
  color: var(--extra);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.history-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
}

.history-item + .history-item {
  border-top: 1px solid var(--line);
}

.history-item-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(0, 122, 255, 0.08);
  color: var(--text);
}

body.is-dark-theme .history-item-icon {
  background: rgba(255, 255, 255, 0.06);
}

.history-item-icon .icon-symbol svg {
  width: 20px;
  height: 20px;
}

.history-item-title {
  font-size: 0.98rem;
  line-height: 1.2;
  font-weight: 700;
}

.history-item-time {
  margin-top: 4px;
  font-size: 0.82rem;
}

.history-item-amount {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}

.amount-card {
  text-align: center;
}

.amount-card-total {
  font-family: "Nunito", "Inter", sans-serif;
  font-size: clamp(2.7rem, 14vw, 3.6rem);
  line-height: 0.95;
  font-weight: 800;
  color: rgba(11, 18, 32, 0.42);
  letter-spacing: -0.06em;
}

.amount-grid,
.platform-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.amount-button,
.platform-button {
  min-height: 56px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
}

body.is-dark-theme .amount-button,
body.is-dark-theme .platform-button {
  background: rgba(255, 255, 255, 0.03);
}

.amount-button.is-selected,
.platform-button.is-selected {
  border-color: var(--line-strong);
  background: rgba(0, 122, 255, 0.08);
  color: var(--accent);
}

.topup-disclaimer {
  margin: 2px 4px 0;
  text-align: center;
  font-size: 0.9rem;
}

.payment-methods {
  grid-template-columns: 1fr;
}

.pay-button {
  min-height: 52px;
  font-size: 0.98rem;
}

.back-button {
  background: transparent;
  color: var(--accent);
  padding: 0;
  min-height: auto;
  justify-content: flex-start;
}

.overlay-balance {
  text-align: right;
}

.overlay-balance-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(17, 24, 39, 0.28);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.modal-card {
  width: min(100%, 420px);
  position: relative;
  border-radius: 24px;
  padding: 18px 16px 16px;
}

.modal-card--wide {
  width: min(100%, 420px);
}

.modal-card h3,
.device-detail-heading {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.dropdown-menu {
  position: absolute;
  top: 62px;
  right: 0;
  width: min(280px, calc(100vw - 32px));
  padding: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  z-index: 45;
  backdrop-filter: blur(14px);
}

body.is-dark-theme .dropdown-menu {
  background: rgba(23, 26, 33, 0.96);
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: transparent;
  text-align: left;
  border-radius: 12px;
  font-size: 0.96rem;
}

.menu-item + .menu-item {
  border-top: 1px solid var(--line);
}

.menu-item-label {
  font-weight: 700;
}

.menu-item-icon {
  color: currentColor;
}

.menu-item--danger {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 360px);
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(11, 18, 32, 0.94);
  color: #fff;
  text-align: center;
  font-size: 0.9rem;
  box-shadow: 0 12px 30px rgba(11, 18, 32, 0.24);
  z-index: 60;
}

.device-detail-meta {
  margin-top: 8px;
  font-size: 0.9rem;
}

.device-detail-list {
  margin: 14px 0 0;
  padding-left: 18px;
  font-size: 0.92rem;
  line-height: 1.55;
}

.device-config {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(0, 122, 255, 0.08);
  color: #1d3557;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  word-break: break-all;
}

body.is-dark-theme .device-config {
  background: rgba(41, 144, 255, 0.12);
  color: #d5e6ff;
}

.device-detail-actions {
  grid-template-columns: 1fr;
}

.device-detail-button {
  min-height: 52px;
  border-radius: 12px;
  font-weight: 700;
}

.device-detail-button--danger {
  background: rgba(255, 59, 48, 0.1);
  color: var(--danger);
}

.icon-symbol {
  display: grid;
  place-items: center;
}

.empty-state {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
  font-weight: 600;
}

.soft-button.is-disabled {
  background: rgba(0, 122, 255, 0.1);
  color: var(--accent);
  cursor: default;
}

.hero-card.is-balance-ok .hero-balance,
.hero-card.is-balance-ok .hero-currency {
  color: var(--accent);
}

.hero-card.is-balance-critical .hero-balance,
.hero-card.is-balance-critical .hero-currency {
  color: #ff4d73;
}

.hero-card.is-balance-warning .hero-balance,
.hero-card.is-balance-warning .hero-currency {
  color: #ff9f0a;
}

body.is-dark-theme .hero-card.is-balance-warning .hero-balance,
body.is-dark-theme .hero-card.is-balance-warning .hero-currency {
  color: #ffb340;
}

@media (prefers-color-scheme: dark) {
  body:not(.is-light-theme) {
    --bg: #000509;
    --bg-deep: #0c1016;
    --surface: #171a21;
    --surface-soft: rgba(23, 26, 33, 0.92);
    --surface-tint: rgba(41, 144, 255, 0.14);
    --line: rgba(255, 255, 255, 0.06);
    --line-strong: rgba(41, 144, 255, 0.24);
    --text: #fcfcfc;
    --muted: #a2acb0;
    --extra: #969dae;
    --accent: #2990ff;
    --accent-strong: #0f7af0;
    --danger: #ff4d73;
    --success: #34c759;
    --shadow: 0 10px 26px rgba(0, 0, 0, 0.26);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page > section,
.page > p {
  animation: rise 220ms ease both;
}

@media (min-width: 721px) {
  body {
    padding: 18px;
  }

  .overlay-view {
    top: 18px;
    bottom: 18px;
    left: 50%;
    right: auto;
    width: min(calc(100vw - 36px), var(--app-width));
    max-width: var(--app-width);
    margin: 0;
    transform: translateX(-50%);
    border-radius: 22px;
    padding: 18px 14px 20px;
    box-shadow: var(--shadow);
  }

  .modal-card--wide {
    width: min(100%, 640px);
  }

  .device-detail-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 360px) {
  .brand-name {
    font-size: 1.5rem;
  }

  .action-grid,
  .referral-actions,
  .amount-grid,
  .platform-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topup"
      "promise"
      "history";
  }

  .device-row,
  .video-row,
  .history-item {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .device-date,
  .video-arrow,
  .history-item-amount {
    grid-column: 2;
    justify-self: start;
  }

  .section-head {
    flex-wrap: wrap;
  }
}
