:root {
  color-scheme: dark;
  --bg: #151c23;
  --panel: #1f2a33;
  --panel-strong: #23313d;
  --field-bg: #263543;
  --text: #f7f9fb;
  --muted: #9aa6b2;
  --line: rgba(7, 13, 18, 0.44);
  --link: #4cb3ff;
  --button: #2d95df;
  --button-text: #ffffff;
  --secondary-button: #33424f;
  --capsule: #2b3640;
  --capsule-text: #ffffff;
  --danger: #e8665e;
  --avatar: #ffb65f;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f0f1f7;
  --panel-strong: #ffffff;
  --field-bg: #ffffff;
  --text: #0f1115;
  --muted: #8f8f98;
  --line: rgba(60, 60, 67, 0.16);
  --link: #0088ff;
  --button: #0a8ff5;
  --button-text: #ffffff;
  --secondary-button: #e4e7ee;
  --capsule: #edf0f5;
  --capsule-text: #0f1115;
  --danger: #d74b44;
  --avatar: #ffb65f;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html.modal-open,
body.modal-open {
  overflow: hidden;
  height: 100%;
}

body.modal-open {
  position: fixed;
  width: 100%;
  left: 0;
  right: 0;
}

.app {
  width: min(720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px 10px 56px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-brand-name {
  font-size: 22px;
  font-weight: 780;
  letter-spacing: -0.02em;
}

.info-btn {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  color: var(--muted);
  cursor: pointer;
}

.info-btn:active {
  transform: scale(0.96);
  color: var(--link);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 4px;
}

.card-head__title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: clamp(20px, 5.2vw, 24px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: left;
}

.card-head__actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
}

.card-head__main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.card-head__main .card-head__title {
  flex: 1 1 auto;
}

.card-head__emoji {
  font-size: 30px;
  line-height: 1;
  flex-shrink: 0;
}

.device-connected-meta {
  margin: 4px 0 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.2;
  text-align: left;
}

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

.device-empty-block {
  padding-top: 10px;
  text-align: center;
}

.device-empty-block .hub-icon {
  margin-top: 0;
}

.device-row {
  gap: 8px;
}

.device-status-dot-wrap {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 10px;
}

.device-status-dot-wrap .status-dot {
  width: 8px;
  height: 8px;
}

.devices-list-in-card .list-row {
  padding: 8px 0;
  min-height: 54px;
  gap: 10px;
}

.devices-list-in-card .platform-icon {
  width: 36px;
  height: 36px;
  font-size: 17px;
}

.device-row-text .device-row-title {
  font-size: 15px;
  font-weight: 680;
  line-height: 1.2;
}

.device-row-text .device-row-platform {
  margin-top: 1px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.2;
  color: var(--muted);
}

.section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.info-modal-card {
  width: min(380px, 100%);
  max-height: min(78vh, 640px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.info-modal-body {
  overflow-y: auto;
  padding-right: 2px;
  text-align: left;
}

.info-block {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.info-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.info-block h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.info-block p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.info-block p:last-child {
  margin-bottom: 0;
}

.info-block p strong {
  color: var(--text);
  font-weight: 650;
}

.info-block--important h3 {
  color: var(--text);
}

.info-block--important p {
  color: var(--text);
}

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

.header-balance-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.header-balance-amount {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.balance-tools {
  margin-bottom: 18px;
}

.balance-tools .balance-duration {
  margin: 0 0 12px;
  text-align: center;
}

.balance-tools .balance-actions {
  margin-top: 0;
}

.balance-section {
  padding: 8px 4px 24px;
  text-align: center;
}

.balance-label {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 600;
}

.balance-amount {
  margin: 6px 0 0;
  font-size: clamp(42px, 11vw, 54px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.balance-duration {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 550;
}

.balance-alert {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  text-align: left;
}

.balance-alert strong {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
}

.balance-alert p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.balance-alert--low {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.balance-alert--depleted {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.balance-alert-action {
  margin-top: 12px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.balance-section--low .balance-amount {
  color: #f59e0b;
}

.balance-section--depleted .balance-amount {
  color: #ef4444;
}

.device-row--warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
}

.device-row--suspended {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.28);
  opacity: 0.92;
}

.device-row--warning .row-text strong,
.device-row--suspended .row-text strong {
  color: var(--text);
}

.balance-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--panel);
}

.balance-action {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 88px;
  padding: 14px 12px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--link);
  font-size: 16px;
  font-weight: 700;
}

.balance-action:last-child {
  border-right: 0;
}

.balance-action-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 24px;
  line-height: 1;
}

.devices-section {
  margin-top: 0;
}

.channel-gate-section {
  margin: 0 0 18px;
}

.channel-gate-card .hub-lead strong {
  font-weight: 700;
}

.home-content.hidden {
  display: none;
}

.referral-attributions-list {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.referral-attributions-list:empty {
  display: none;
}

.referral-links-list {
  margin-top: 14px;
  text-align: left;
}

.referral-links-list:empty {
  display: none;
}

.referral-link-card {
  padding: 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--secondary-button) 72%, transparent);
}

.referral-link-label {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.referral-link-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.referral-link-value {
  display: block;
  width: 100%;
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--link) 28%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  color: var(--link);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 6%, transparent);
}

.referral-link-value:active {
  transform: scale(0.995);
  background: color-mix(in srgb, var(--link) 8%, var(--panel));
}

.referral-link-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.referral-action-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

.referral-action-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  line-height: 0;
}

.referral-action-btn-primary {
  background: var(--button);
  color: var(--button-text);
}

.referral-action-btn-secondary {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

.referral-attributions-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.referral-attributions-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.referral-attributions-list.is-collapsed .referral-attributions-toggle {
  margin-bottom: 0;
}

.referral-attributions-chevron {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.referral-attributions-chevron.is-open {
  transform: rotate(180deg);
}

.referral-attributions-list.is-collapsed .referral-attributions-scroll {
  display: none;
}

.referral-attributions-scroll {
  --referral-attribution-row-size: 78px;
  max-height: calc(var(--referral-attribution-row-size) * 3);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.referral-attribution-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: var(--referral-attribution-row-size, 78px);
  padding: 12px 0;
  border-top: 1px solid var(--line);
  box-sizing: border-box;
}

.referral-attribution-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.referral-user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.referral-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--secondary-button);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.referral-user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 650;
}

.referral-status strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.referral-status small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.referrals-section {
  margin-top: 16px;
}

.home-content > .balance-section + .devices-section,
.home-content > .devices-section + .referrals-section {
  margin-top: 16px;
}

.hub-card {
  overflow: hidden;
  border-radius: 16px;
  background: var(--panel);
}

.hub-panel {
  padding: 22px 16px 20px;
  text-align: center;
}

.hub-panel--stack {
  padding: 16px;
  text-align: left;
}

.hub-panel--stack .hub-lead,
.hub-panel--stack .hub-footnote,
.hub-panel--stack .referral-links-list,
.hub-panel--stack .referral-attributions-list {
  text-align: left;
}

.hub-panel--stack .hub-lead {
  margin-top: 8px;
}

.hub-panel--stack .device-list-body .hub-primary-btn {
  width: 100%;
  margin: 14px 0 0;
}

.hub-icon {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 12px;
}

.hub-title {
  margin: 0;
  font-size: clamp(22px, 5.5vw, 26px);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hub-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 550;
}

.hub-lead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.hub-footnote {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.hub-tariff {
  margin: 10px 4px 0;
  color: var(--muted);
  text-align: left;
  font-size: 14px;
  font-weight: 550;
}

.hub-primary-btn,
.hub-secondary-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  margin-top: 18px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.hub-primary-btn {
  width: 100%;
  background: var(--button);
  color: var(--button-text);
}

.hub-primary-btn-compact,
.hub-secondary-btn.hub-primary-btn-compact {
  width: 100%;
  margin: 14px 0 0;
}

.hub-secondary-btn {
  width: 100%;
  background: var(--secondary-button);
  color: var(--text);
}

.hub-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.hub-action-row .hub-primary-btn,
.hub-action-row .hub-secondary-btn {
  margin-top: 0;
  min-height: 48px;
  font-size: 16px;
}

.hub-btn-icon {
  font-size: 18px;
  line-height: 1;
}

.hub-list-head {
  text-align: left;
  margin-bottom: 4px;
}

.devices-list-in-card .list-row {
  border-top: 1px solid var(--line);
}

.devices-list-in-card .list-row:first-child {
  border-top: 0;
}

.referral-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.referral-hub-card .hub-secondary-btn.hub-primary-btn-compact {
  color: var(--link);
}

.referral-hub-card .hub-primary-btn {
  margin-top: 18px;
}

.referral-link-main {
  min-width: 0;
}

.referral-link-main strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.referral-link-main small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.referral-icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.referral-icon-btn-share {
  background: var(--button);
  color: var(--button-text);
}

.referral-icon-btn-copy {
  background: var(--secondary-button);
  color: var(--text);
}

.referral-used-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-height: 64px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.referral-used-row:first-child {
  border-top: 0;
}

.referral-used-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--secondary-button);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.referral-used-status-paid {
  color: #3ecf8e;
}

.referral-used-status-pending {
  color: #f5c451;
}

.referral-used-status-skipped {
  color: var(--muted);
}

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

.happ-logo {
  display: block;
  width: 96px;
  height: 96px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.happ-download-card {
  padding: 12px;
}

.happ-download-grid {
  display: grid;
  gap: 10px;
}

.happ-store-btn {
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  text-align: center;
  cursor: pointer;
}

.happ-already-section {
  margin-top: -8px;
  padding-top: 0;
}

.happ-already-btn {
  appearance: none;
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--secondary-button);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.happ-already-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.referral-links-panel {
  margin-top: 16px;
  text-align: left;
}

.referral-links-panel:empty {
  display: none;
}

.referral-links-panel .list-row {
  border-top: 1px solid var(--line);
  min-height: 64px;
  padding-inline: 4px;
}

.referral-links-panel .list-row:first-child {
  border-top: 0;
}

.referral-links-empty {
  margin: 0;
  padding-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.devices-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.devices-head h2 {
  font-size: clamp(24px, 6vw, 28px);
}

.devices-connected {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 550;
}

.pill-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(10, 143, 245, 0.12);
  color: var(--link);
  font-size: 15px;
  font-weight: 700;
}

:root[data-theme="dark"] .pill-button {
  background: rgba(76, 179, 255, 0.14);
}

.devices-card {
  margin-top: 0;
}

.tariff-note {
  margin: 0;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  font-weight: 550;
}

.platform-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
}

.platform-icon.image {
  background: transparent;
  padding: 0;
}

.platform-icon-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 10px;
}

.platform-icon.ios {
  background: #2f7cf6;
  font-family: "SF Pro Display", "Apple Color Emoji", system-ui, sans-serif;
  font-size: 20px;
}

.platform-icon.default {
  background: var(--secondary-button);
  color: var(--text);
}

.topup-wheel-wrap {
  position: relative;
  height: 220px;
  margin: 8px 0 18px;
  overflow: hidden;
  touch-action: none;
}

.topup-wheel-wrap::before,
.topup-wheel-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 72px;
  z-index: 1;
  pointer-events: none;
}

.topup-wheel-wrap::before {
  top: 0;
  background: linear-gradient(to bottom, var(--panel), transparent);
}

.topup-wheel-wrap::after {
  bottom: 0;
  background: linear-gradient(to top, var(--panel), transparent);
}

.topup-wheel-highlight {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  z-index: 1;
  height: 44px;
  transform: translateY(-50%);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
  pointer-events: none;
}

.topup-wheel {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y proximity;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
  contain: layout style paint;
}

.topup-wheel-spacer {
  height: 88px;
  flex-shrink: 0;
}

.topup-wheel::-webkit-scrollbar {
  display: none;
}

.topup-wheel-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  scroll-snap-align: center;
  user-select: none;
  -webkit-user-select: none;
}

.topup-confirm-btn {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--button);
  color: var(--button-text);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.topup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.topup-grid button {
  min-height: 52px;
  font-size: 17px;
}

.topup-grid button.secondary {
  background: var(--secondary-button);
  color: var(--text);
}

.modal-hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
}

.sheet-card {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
}

.history-list {
  display: grid;
  gap: 0;
}

.history-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.history-list > :first-child {
  border-top: 0;
  padding-top: 0;
}

.history-row strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.history-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.history-amount {
  flex: 0 0 auto;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
}

.history-amount.credit {
  color: #1f9d55;
}

.history-amount.debit {
  color: var(--danger);
}

.history-empty {
  padding: 24px 0 8px;
  color: var(--muted);
  text-align: center;
  font-size: 15px;
}

.view {
  animation: view-in 140ms ease-out;
}

.hero {
  display: grid;
  justify-items: center;
  padding: 18px 18px 28px;
  text-align: center;
}

.compact-hero {
  padding-top: 20px;
  padding-bottom: 28px;
}

.device-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 4px 14px;
}

.device-head-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 14px;
  font-size: 24px;
}

.device-head-text {
  min-width: 0;
  flex: 1;
  text-align: left;
}

.device-head-text h1 {
  margin-top: 0;
  font-size: clamp(22px, 5.5vw, 28px);
  line-height: 1.15;
}

.device-head-text .handle {
  margin-top: 4px;
  text-align: left;
  font-size: 15px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 16px;
  font-size: clamp(30px, 7.2vw, 38px);
  font-weight: 780;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(24px, 6vw, 30px);
  font-weight: 780;
  line-height: 1.12;
  letter-spacing: 0;
}

.lead {
  max-width: 540px;
  margin-top: 12px;
  color: var(--muted);
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 520;
}

.handle {
  margin-top: 10px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--avatar), #ffc06f);
  color: #ffffff;
  font-weight: 760;
  letter-spacing: 0;
}

.avatar-xl {
  width: 96px;
  height: 96px;
  font-size: 42px;
}

.logo-avatar {
  position: relative;
  overflow: visible;
  background: transparent;
}

.logo-avatar::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 58%;
  width: 84%;
  height: 34%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  filter: blur(13px);
  z-index: 0;
  pointer-events: none;
}

.logo-avatar img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-sm {
  width: 56px;
  height: 56px;
  font-size: 23px;
}

.muted-avatar {
  background: var(--secondary-button);
  color: var(--muted);
}

.section,
.settings-section {
  margin-top: 22px;
}

.settings-section h2 {
  margin: 0 22px 14px;
}

.list-card,
.settings-card,
.access-card,
.notice,
.token-card {
  overflow: hidden;
  border-radius: 12px;
  background: var(--panel);
}

.list-row,
.settings-row {
  appearance: none;
  width: 100%;
  min-height: 74px;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 12px 22px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.list-card > :first-child,
.settings-card > :first-child {
  border-top: 0;
}

.add-row {
  min-height: 72px;
  color: var(--link);
  font-size: 20px;
  font-weight: 650;
}

.plus-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 3px solid var(--link);
  border-radius: 50%;
  color: transparent;
  font-size: 0;
  line-height: 0;
}

.plus-icon::before,
.plus-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 19px;
  height: 3px;
  border-radius: 999px;
  background: var(--link);
  transform: translate(-50%, -50%);
}

.plus-icon::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.row-text {
  min-width: 0;
  flex: 1 1 auto;
}

.row-text strong,
.static-row strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 20px;
  font-weight: 730;
  line-height: 1.2;
}

.row-text small,
.static-row small {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 16px;
  font-weight: 550;
  line-height: 1.22;
}

.inventory-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.inventory-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--capsule);
  color: var(--capsule-text);
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
}

.inventory-chip.green { background: #d8f8df; color: #166534; }
.inventory-chip.blue { background: #dceeff; color: #075985; }
.inventory-chip.amber { background: #fff1c7; color: #8a5800; }
.inventory-chip.rose { background: #ffdce2; color: #b4233a; }
.inventory-chip.slate { background: var(--secondary-button); color: var(--capsule-text); }

.chevron {
  margin-left: auto;
  color: #70808d;
  font-size: 36px;
  line-height: 1;
}

.empty-row {
  cursor: default;
  opacity: 1;
}

.static-row {
  cursor: default;
}

.row-icon--dot {
  display: inline-grid;
  place-items: center;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.status-dot--green {
  background: #34c759;
}

.status-dot--yellow {
  background: #ffcc00;
}

.status-dot--red {
  background: #ff3b30;
}

.app-activity {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
}

.app-activity.hidden {
  display: none;
}

.app-activity--overlay {
  inset: 0;
  left: 0;
  bottom: auto;
  transform: none;
  width: 100%;
  max-width: none;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  border-radius: 0;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(6px);
}

.app-activity--overlay .app-activity-spinner {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.app-activity--overlay .app-activity-text {
  max-width: 18rem;
  white-space: normal;
  text-align: center;
  font-size: 16px;
  line-height: 1.35;
}

.boot-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 46vh;
  padding: 24px 16px;
  text-align: center;
}

.boot-state.hidden {
  display: none;
}

.boot-state-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid color-mix(in srgb, var(--muted) 28%, transparent);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: app-activity-spin 0.75s linear infinite;
}

.boot-state-text {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.boot-state--error .boot-state-spinner {
  display: none;
}

.boot-state--error .boot-state-text {
  color: var(--text);
}

.boot-retry-btn {
  margin-top: 4px;
}

.boot-retry-btn.hidden {
  display: none;
}

.app-activity-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--muted) 28%, transparent);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: app-activity-spin 0.75s linear infinite;
}

.app-activity-text {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

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

.row-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-width: 36px;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.notice,
.access-card,
.token-card {
  margin-top: 16px;
  padding: 20px 24px;
}

.notice {
  display: grid;
  gap: 6px;
}

.notice strong,
.access-card h2 {
  font-size: 20px;
  font-weight: 740;
}

.notice span,
.access-card p {
  color: var(--muted);
  font-size: 16px;
}

.field-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
}

input {
  min-height: 50px;
  padding: 0 14px;
  font-size: 17px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 14px;
  font: 14px/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font: inherit;
  font-weight: 730;
  letter-spacing: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

.field-row button {
  min-width: 112px;
  min-height: 50px;
}

.device-action-grid {
  padding: 0 12px 4px;
}

.device-info-panel {
  display: grid;
  gap: 14px;
  padding: 14px 16px 16px;
}

.device-info-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) auto;
  gap: 12px;
  align-items: center;
}

.device-info-side {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.device-info-side--left {
  justify-items: start;
}

.device-info-side--center {
  text-align: center;
  justify-items: center;
}

.device-info-platform {
  width: 42px;
  height: 42px;
  font-size: 18px;
}

.device-info-side strong {
  font-size: 15px;
  line-height: 1.2;
}

.device-info-side small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.device-info-kicker {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.device-info-traffic {
  font-size: 18px;
  line-height: 1.15;
}

.device-info-traffic-detail {
  display: block;
  margin-top: 2px;
  opacity: 0.82;
}

.device-info-cabinet {
  appearance: none;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(41, 182, 246, 0.12);
  color: #29b6f6;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.device-info-cabinet-icon {
  display: grid;
  place-items: center;
}

.device-info-balance {
  border-radius: 12px;
  padding: 12px 14px;
}

.device-info-balance strong {
  display: block;
  margin-bottom: 4px;
}

.device-info-balance p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
}

.device-info-balance--low {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.device-info-balance--low strong {
  color: #f59e0b;
}

.device-info-balance--depleted {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.32);
}

.device-info-balance--depleted strong {
  color: #f43f5e;
}

.device-info-hints {
  display: grid;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.device-info-hint {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.device-info-hint strong {
  color: var(--text);
}

.device-info-hint-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--panel-soft);
}

.happ-refresh-hint-icon {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.device-instruction-wrap {
  border-top: 1px solid var(--line);
}

.instruction-toggle {
  appearance: none;
  width: 100%;
  min-height: 58px;
  padding: 12px 18px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.instruction-chevron {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.instruction-toggle.is-open .instruction-chevron {
  transform: rotate(90deg);
}

.instruction-body {
  padding: 0 18px 16px 52px;
}

.instruction-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.instruction-list li + li {
  margin-top: 10px;
}

.instruction-sublist {
  margin: 8px 0 0;
  padding-left: 18px;
  list-style: disc;
}

.instruction-sublist li {
  margin-top: 6px;
}

.instruction-sublist li:first-child {
  margin-top: 0;
}

.instruction-list strong {
  color: var(--text);
  font-weight: 700;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.button-grid button {
  min-height: 68px;
  font-size: 20px;
}

.button-grid .happ-open {
  grid-column: 1 / -1;
}

.button-grid button.secondary {
  background: var(--secondary-button);
  color: var(--text);
}

.compact-grid {
  padding: 0 22px 18px;
}

.compact-grid button {
  min-height: 48px;
  font-size: 16px;
}

.choice .checkmark {
  display: none;
  margin-left: auto;
  color: var(--link);
  font-size: 24px;
  font-weight: 800;
}

.choice.selected .checkmark {
  display: block;
}

.form-card {
  padding: 22px;
}

.rename-panel {
  display: grid;
  gap: 10px;
  padding: 18px 22px 20px;
}

.rename-panel label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.rename-field {
  position: relative;
}

.rename-field input {
  min-height: 52px;
  padding-right: 18px;
  border-radius: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, padding-right 0.18s ease;
}

.rename-field.is-actions-visible input {
  border-color: color-mix(in srgb, var(--button) 58%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--button) 22%, transparent);
}

.rename-field.is-actions-visible:not(.has-existing-name) input {
  padding-right: 50px;
}

.rename-field.is-actions-visible.has-existing-name input {
  padding-right: 88px;
}

.rename-actions {
  position: absolute;
  top: 50%;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translateY(-50%);
  pointer-events: none;
}

.rename-actions:not(.hidden) {
  pointer-events: auto;
}

.rename-icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: transparent;
  cursor: pointer;
  box-shadow: none;
}

.rename-icon-btn img {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  pointer-events: none;
}

.rename-icon-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.rename-icon-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.back-button {
  min-height: 44px;
  margin-bottom: 16px;
  padding: 0 16px;
  border-radius: 24px;
  background: var(--capsule);
  color: var(--capsule-text);
  font-size: 18px;
  font-weight: 720;
}

.token-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-bg);
}

.token-key-icon {
  flex: 0 0 auto;
  font-size: 22px;
  line-height: 1;
}

.token-field-body {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 32px;
}

.token-field textarea {
  width: 100%;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  resize: none;
  line-height: 1.35;
  word-break: break-all;
}

.token-field textarea.is-masked {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  pointer-events: none;
}

.token-field.is-key-masked .token-field-body {
  min-height: 32px;
}

.config-link-mask {
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}

.token-field-body.is-masked {
  cursor: pointer;
}

.config-link-mask canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.config-link-mask.hidden {
  display: none;
}

.danger-row {
  color: var(--danger);
}

.danger-row .row-icon,
.danger-row .chevron {
  color: var(--danger);
}

.danger-row.is-disabled,
.danger-row:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  overscroll-behavior: none;
  touch-action: none;
}

.modal-card {
  position: relative;
  width: min(340px, 100%);
  padding: 16px;
  border-radius: 16px;
  background: var(--panel);
  touch-action: manipulation;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 19px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--capsule);
  color: var(--capsule-text);
  font-size: 24px;
  line-height: 1;
}

.qr-code {
  padding: 10px;
  border-radius: 12px;
  background: #ffffff;
}

.qr-code svg {
  display: block;
  width: 100%;
  height: auto;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 18px;
  z-index: 30;
  width: min(520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.96);
  color: #ffffff;
  text-align: center;
  font-size: 15px;
}

.hidden {
  display: none !important;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

@media (max-width: 520px) {
  .app {
    padding: 22px 16px 56px;
  }

  .hero {
    padding: 14px 12px 24px;
  }

  .avatar-xl {
    width: 84px;
    height: 84px;
    font-size: 36px;
  }

  .avatar-sm {
    width: 50px;
    height: 50px;
    font-size: 21px;
  }

  h1 {
    font-size: 31px;
  }

  h2 {
    font-size: 25px;
  }

  .lead {
    font-size: 17px;
  }

  .list-row,
  .settings-row {
    min-height: 68px;
    padding: 11px 16px;
    gap: 13px;
  }

  .row-text strong,
  .static-row strong {
    font-size: 18px;
  }

  .row-text small,
  .static-row small {
    font-size: 15px;
  }

  .add-row {
    font-size: 18px;
  }

  .plus-icon {
    width: 36px;
    height: 36px;
    border-width: 3px;
  }

  .plus-icon::before,
  .plus-icon::after {
    width: 17px;
    height: 3px;
  }

  .chevron {
    font-size: 34px;
  }

  .settings-section h2 {
    margin-inline: 16px;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    display: grid;
  }

  .field-row button {
    width: 100%;
  }

  .rename-field.is-actions-visible:not(.has-existing-name) input {
    padding-right: 50px;
  }

  .rename-field.is-actions-visible.has-existing-name input {
    padding-right: 88px;
  }

  .rename-icon-btn {
    width: 32px;
    height: 32px;
  }
}

.notification-preferences-section {
  margin: 28px 0 34px;
}

.ios-settings-card {
  overflow: hidden;
  border-radius: 14px;
  background: var(--panel);
}

.ios-toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.ios-toggle-row:first-child {
  border-top: 0;
}

.ios-toggle-copy {
  display: grid;
  gap: 4px;
}

.ios-toggle-copy strong {
  font-size: 16px;
  line-height: 1.25;
}

.ios-toggle-copy small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.ios-switch {
  position: relative;
  display: inline-flex;
  width: 51px;
  height: 31px;
  flex: 0 0 auto;
}

.ios-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.ios-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.32);
  transition: background 0.2s ease;
}

.ios-switch-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.2s ease;
}

.ios-switch input:checked + .ios-switch-slider {
  background: #34c759;
}

.ios-switch input:checked + .ios-switch-slider::after {
  transform: translateX(20px);
}

.ios-switch input:focus-visible + .ios-switch-slider {
  outline: 2px solid rgba(52, 199, 89, 0.45);
  outline-offset: 2px;
}
