:root {
  --bg: #1a1512;
  --card-bg: #2a221c;
  --card-border: rgba(255, 255, 255, 0.08);
  --accent: #e53935;
  --accent-soft: #c62828;
  --orange: #ff9800;
  --text: #ffffff;
  --text-muted: #b0a090;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
}

.btn-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.topbar-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.topbar-placeholder {
  width: 36px;
}

/* Hero — логотип по центру */
.hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 32px 24px;
}

.hero-rings {
  position: absolute;
  inset: 20%;
  border: 2px solid rgba(229, 57, 53, 0.2);
  border-radius: 50%;
  animation: pulse 3s ease-in-out infinite;
}

.hero-rings::before {
  content: '';
  position: absolute;
  inset: -15%;
  border: 1px solid rgba(229, 57, 53, 0.12);
  border-radius: 50%;
}

.hero-rings::after {
  content: '';
  position: absolute;
  inset: -30%;
  border: 1px solid rgba(229, 57, 53, 0.08);
  border-radius: 50%;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

.hero-logo {
  position: relative;
  z-index: 1;
  max-width: 180px;
  width: 60%;
  height: auto;
  object-fit: contain;
}

/* Экран «Добро пожаловать» — только кнопка Подключить */
.welcome-card {
  margin: 0 16px 24px;
  padding: 24px 20px;
  background: var(--card-bg);
  border-radius: 20px;
  border: 1px solid var(--card-border);
}

.welcome-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.welcome-text {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.btn-connect {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--accent-soft) 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
}

.btn-connect:active:not(.is-loading) {
  opacity: 0.9;
}

.btn-connect.is-loading {
  background: #5d4037;
  color: rgba(255, 255, 255, 0.85);
  cursor: wait;
}

/* Карточка подписки */
.subscription-card {
  margin: 0 16px 24px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: 20px;
  border: 1px solid var(--card-border);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.card-expiry {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.card-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.status-connection {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.status-connection.online {
  color: #4caf50;
}

.status-data {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.status-badge {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 152, 0, 0.25);
  color: var(--orange);
}

.status-badge.active {
  background: rgba(76, 175, 80, 0.25);
  color: #4caf50;
}

.card-users {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Кнопки: Продлить подписку, Подключить устройство */
.btn-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 14px;
  transition: opacity 0.2s;
  margin-bottom: 10px;
}

.btn-action:last-of-type {
  margin-bottom: 0;
}

.btn-action:active {
  opacity: 0.9;
}

.btn-renew {
  background: linear-gradient(135deg, var(--orange) 0%, var(--accent-soft) 100%);
}

.btn-device {
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.9) 0%, rgba(198, 40, 40, 0.9) 100%);
}

.btn-action-icon {
  font-size: 1.25rem;
}

.btn-action-text {
  flex: 1;
}

.btn-action-badge {
  font-size: 0.8125rem;
  font-weight: 600;
  opacity: 0.95;
}

.btn-os-badge {
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Нижняя навигация */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--card-border);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  gap: 8px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
}

.nav-item:active {
  opacity: 0.85;
}

.nav-icon {
  font-size: 1.25rem;
}

/* Экран «Настройка» */
.setup-screen {
  padding: 0 16px 24px;
}

.setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 16px;
}

.btn-back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
}

.setup-header-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.setup-header-menu {
  width: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 1.25rem;
}

.setup-card {
  background: linear-gradient(135deg, var(--card-bg) 0%, #352a22 100%);
  border-radius: 20px;
  padding: 24px 20px;
  border: 1px solid var(--card-border);
}

.setup-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 16px;
}

.setup-id-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  margin: 0 auto 24px;
  max-width: 200px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.btn-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
}

.btn-copy:active {
  color: var(--orange);
}

.setup-graphic {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  margin-bottom: 20px;
}

.setup-rings {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 2px solid rgba(255, 152, 0, 0.4);
  border-radius: 50%;
}

.setup-rings::before {
  content: '';
  position: absolute;
  inset: -12px;
  border: 1px solid rgba(255, 152, 0, 0.25);
  border-radius: 50%;
}

.setup-device-icon {
  position: relative;
  z-index: 1;
  font-size: 3rem;
}

.setup-desc {
  text-align: center;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 24px;
}

.setup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-setup {
  display: block;
  width: 100%;
  text-align: center;
  padding: 16px 20px;
  border-radius: 14px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  transition: opacity 0.2s;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.btn-setup:active {
  opacity: 0.9;
}

.btn-setup-primary {
  background: linear-gradient(135deg, var(--orange) 0%, #e65100 100%);
  color: #fff;
}

.btn-setup-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid var(--card-border);
}

/* Экран «Установка Happ» */
.happ-install-screen {
  padding: 0 16px 24px;
}

.happ-install-card {
  background: linear-gradient(135deg, var(--card-bg) 0%, #352a22 100%);
  border-radius: 20px;
  padding: 24px 20px;
  border: 1px solid var(--card-border);
}

.happ-install-graphic {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  margin-bottom: 16px;
}

.happ-install-ring {
  position: absolute;
  width: 90px;
  height: 90px;
  border: 3px solid rgba(255, 152, 0, 0.5);
  border-radius: 50%;
}

.happ-install-icon {
  position: relative;
  z-index: 1;
  font-size: 2.5rem;
}

.happ-install-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

.happ-install-desc {
  text-align: center;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 20px;
}

.happ-install-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  text-align: center;
}

.happ-install-platforms {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.happ-platform-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.happ-platform-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.happ-install-row {
  display: flex;
  gap: 10px;
}

.happ-install-row a {
  flex: 1;
  display: block;
  text-align: center;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--orange) 0%, #e65100 100%);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 12px;
  transition: opacity 0.2s;
}

.happ-install-row a:active {
  opacity: 0.9;
}

.happ-install-single a {
  display: block;
  text-align: center;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--orange) 0%, #e65100 100%);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 12px;
  transition: opacity 0.2s;
}

.happ-install-single a:active {
  opacity: 0.9;
}

.btn-happ-next {
  display: block;
  width: 100%;
  text-align: center;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--orange) 0%, #e65100 100%);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s;
}

.btn-happ-next:active {
  opacity: 0.9;
}

/* Экран «Подписка» (добавить в Happ) */
.subscription-add-screen {
  padding: 0 16px 24px;
}

.subscription-add-card {
  background: linear-gradient(135deg, var(--card-bg) 0%, #352a22 100%);
  border-radius: 20px;
  padding: 24px 20px;
  border: 1px solid var(--card-border);
}

.subscription-add-graphic {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  margin-bottom: 16px;
}

.subscription-add-ring {
  position: absolute;
  width: 90px;
  height: 90px;
  border: 3px solid rgba(255, 152, 0, 0.5);
  border-radius: 50%;
}

.subscription-add-icon {
  position: relative;
  z-index: 1;
  font-size: 3rem;
}

.subscription-add-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

.subscription-add-desc {
  text-align: center;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 24px;
}

.subscription-add-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-add-primary {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--orange) 0%, #e65100 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
}

.btn-add-primary:active {
  opacity: 0.9;
}

.btn-add-secondary {
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
}

.btn-add-secondary:active,
.btn-add-qr:active {
  opacity: 0.9;
}

.btn-add-qr {
  display: block;
}

/* Модалка «Перейти по ссылке» */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.is-visible {
  display: flex;
}

.modal-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px 20px;
  max-width: 360px;
  width: 100%;
  border: 1px solid var(--card-border);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 12px;
}

.modal-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.modal-url {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
  max-height: 80px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.modal-btn-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.modal-btn-go {
  background: #0a84ff;
  color: #fff;
}
