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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--tg-theme-bg-color, #ffffff);
  color: var(--tg-theme-text-color, #000000);
  margin: 0;
  padding: 0;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--tg-theme-bg-color, #ffffff);
}

.header {
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.header h1 {
  font-size: 24px;
  margin-bottom: 8px;
  font-weight: 600;
}

.welcome {
  font-size: 16px;
  opacity: 0.9;
}

.payment-status {
  padding: 16px 20px;
  margin: 20px 16px;
  border-radius: 12px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: pulse 2s ease-in-out infinite alternate;
}

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


.content {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.subscription-info {
  text-align: center;
  margin-bottom: 40px;
}

.subscription-info h2 {
  font-size: 20px;
  margin-bottom: 12px;
  color: var(--tg-theme-text-color, #000000);
}

.subscription-info p {
  font-size: 16px;
  color: var(--tg-theme-hint-color, #999999);
  line-height: 1.4;
}

/* Система вкладок */
.tabs-container {
  width: 100%;
}

.tabs-header {
  display: flex;
  background: var(--tg-theme-secondary-bg-color, #f8f9fa);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tab-button {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  color: var(--tg-theme-hint-color, #999999);
}

.tab-button.active {
  background: var(--tg-theme-button-color, #3390ec);
  color: white;
  box-shadow: 0 2px 8px rgba(51, 144, 236, 0.3);
}

.tab-button:hover:not(.active) {
  background: rgba(51, 144, 236, 0.1);
  color: var(--tg-theme-button-color, #3390ec);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Привлекательные планы подписки */
.subscription-plans-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.subscription-plan-card {
  position: relative;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 18px 16px;
  color: white;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
}

.subscription-plan-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.subscription-plan-card:hover::before {
  opacity: 1;
}

.subscription-plan-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(102, 126, 234, 0.4);
}

.subscription-plan-card.popular {
  background: linear-gradient(135deg, #FF6B6B 0%, #FF8E8E 50%, #FFB4B4 100%);
  box-shadow: 0 8px 32px rgba(255, 107, 107, 0.4);
  transform: scale(1.05);
}

.subscription-plan-card.popular:hover {
  transform: translateY(-8px) scale(1.07);
  box-shadow: 0 24px 48px rgba(255, 107, 107, 0.5);
}

.subscription-plan-card.best-value {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 50%, #388e3c 100%);
  box-shadow: 0 8px 32px rgba(76, 175, 80, 0.4);
}

.subscription-plan-card.best-value:hover {
  box-shadow: 0 20px 40px rgba(76, 175, 80, 0.5);
}

.plan-badge {
  position: absolute;
  top: -8px;
  right: 20px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.plan-badge.popular {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #fff;
  animation: pulse-badge 2s ease-in-out infinite;
}

.plan-badge.best-value {
  background: linear-gradient(135deg, #00E676, #00C853);
  color: #fff;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.plan-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.plan-main-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 16px;
  width: 100%;
  flex-direction: row !important;
}

.plan-left {
  flex: 1;
  text-align: left;
  order: 1;
}

.plan-right {
  flex-shrink: 0;
  text-align: right;
  min-width: fit-content;
  order: 2;
}

.plan-features-section {
  margin: 8px 0;
}

.plan-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 6px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.plan-subtitle {
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 12px;
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-item {
  display: flex;
  align-items: center;
  font-size: 14px;
  opacity: 0.95;
  padding: 2px 0;
}

.feature-icon {
  font-size: 16px;
  margin-right: 10px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.feature-text {
  flex: 1;
  font-weight: 500;
}

/* Локации с флагами */
.plan-locations {
  margin-top: 12px;
}

.plan-locations-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-icon {
  font-size: 14px;
}

.locations-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.location-flag {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
  cursor: default;
}

.location-flag:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

.plan-pricing {
  text-align: right;
}

.plan-price {
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.plan-currency {
  font-size: 20px;
  vertical-align: top;
  margin-left: 2px;
}

.plan-period {
  font-size: 11px;
  opacity: 0.8;
  margin-bottom: 6px;
}

.plan-original-price {
  font-size: 13px;
  text-decoration: line-through;
  opacity: 0.7;
  margin-bottom: 3px;
}

.plan-savings {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.plan-buy-button {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  color: white;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  align-self: center;
  margin-top: 0;
}

.plan-buy-button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.plan-buy-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Контейнеры */
.no-subscription-container {
  width: 100%;
}

.support-container {
  margin-top: 32px;
  display: flex;
  justify-content: center;
}

.buttons-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 320px;
  margin: 0 auto;
  width: 100%;
}

.main-button {
  padding: 16px 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.buy-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.buy-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.extend-button {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(240, 147, 251, 0.4);
}

.extend-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(240, 147, 251, 0.5);
}

.support-button {
  background: var(--tg-theme-button-color, #3390ec);
  color: var(--tg-theme-button-text-color, #ffffff);
  border: 2px solid var(--tg-theme-button-color, #3390ec);
}

.support-button:hover:not(:disabled) {
  background: transparent;
  color: var(--tg-theme-button-color, #3390ec);
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-content {
  background: var(--tg-theme-bg-color, #ffffff);
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--tg-theme-hint-color, #e0e0e0);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--tg-theme-text-color, #000000);
  margin: 0;
}

.close-button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--tg-theme-hint-color, #999999);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.close-button:hover {
  background-color: var(--tg-theme-hint-color, rgba(0, 0, 0, 0.1));
}

.subscription-plans {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.subscription-plan {
  position: relative;
  border: 2px solid var(--tg-theme-hint-color, #e0e0e0);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--tg-theme-bg-color, #ffffff);
  min-height: 85px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.subscription-plan:hover {
  border-color: var(--tg-theme-button-color, #3390ec);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(51, 144, 236, 0.2);
}

.plan-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.plan-info h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--tg-theme-text-color, #000000);
  margin: 0;
}

.plan-price {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.price {
  font-size: 16px;
  font-weight: 700;
  color: var(--tg-theme-text-color, #000000);
}

.discount {
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
}

.price-per-month {
  font-size: 11px;
  color: var(--tg-theme-hint-color, #999999);
  text-align: center;
}

.popular-badge {
  position: absolute;
  top: -6px;
  right: 8px;
  background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
  color: white;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}

/* Current subscription styles */
.current-subscription {
  margin-bottom: 32px;
}

.current-subscription h2 {
  font-size: 20px;
  margin-bottom: 16px;
  text-align: center;
  color: var(--tg-theme-text-color, #000000);
}

.subscription-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 20px;
  color: white;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
  margin-bottom: 20px;
}

.subscription-details {
  margin-bottom: 20px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.detail-row:last-child {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.detail-row .label {
  font-size: 14px;
  opacity: 0.9;
  font-weight: 500;
}

.detail-row .value {
  font-size: 14px;
  font-weight: 600;
}

.status.active {
  color: #4CAF50;
  font-weight: 600;
}

.status.expired {
  color: #FF6B6B;
  font-weight: 600;
}

.subscription-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.connect-button,
.extend-subscription-button {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.connect-button {
  background: rgba(255, 255, 255, 0.2);
}

.connect-button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.extend-subscription-button {
  background: rgba(240, 147, 251, 0.3);
  border-color: rgba(240, 147, 251, 0.5);
}

.extend-subscription-button:hover {
  background: rgba(240, 147, 251, 0.4);
  border-color: rgba(240, 147, 251, 0.7);
  transform: translateY(-2px);
}

.loading {
  text-align: center;
  padding: 40px 20px;
  font-size: 16px;
  color: var(--tg-theme-hint-color, #999999);
}

@media (max-width: 480px) {
  .header {
    padding: 16px;
  }
  
  .header h1 {
    font-size: 20px;
  }
  
  .content {
    padding: 20px 12px;
  }
  
  .main-button {
    padding: 14px 20px;
    font-size: 15px;
  }

  .modal-overlay {
    padding: 12px;
  }

  .modal-content {
    max-height: 85vh;
  }

  .modal-header {
    padding: 16px 16px 12px;
  }

  .subscription-plans {
    padding: 12px;
    gap: 8px;
  }

  .subscription-plan {
    padding: 10px;
    min-height: 75px;
  }
  
  .plan-info h4 {
    font-size: 13px;
  }
  
  .price {
    font-size: 14px;
  }
  
  .price-per-month {
    font-size: 10px;
  }

  .subscription-card {
    padding: 16px;
  }
  
  .detail-row {
    margin-bottom: 10px;
    padding-bottom: 6px;
  }
  
  .detail-row .label,
  .detail-row .value {
    font-size: 13px;
  }
  
  .connect-button,
  .extend-subscription-button {
    padding: 12px 14px;
    font-size: 14px;
  }
  
  .subscription-buttons {
    gap: 10px;
  }

  /* Вкладки на мобильных */
  .tabs-header {
    margin-bottom: 20px;
  }
  
  .tab-button {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Планы на мобильных */
  .subscription-plans-grid {
    gap: 16px;
    margin-bottom: 20px;
  }

  .subscription-plan-card {
    padding: 16px 14px;
  }

  .subscription-plan-card.popular {
    transform: scale(1.02);
  }

  .subscription-plan-card.popular:hover {
    transform: translateY(-4px) scale(1.04);
  }

  .plan-main-row {
    flex-direction: row !important;
    gap: 12px;
    align-items: center;
  }

  .plan-left {
    text-align: left;
    order: 1;
  }

  .plan-right {
    text-align: right;
    order: 2;
  }

  .plan-pricing {
    text-align: right;
  }

  .feature-item {
    justify-content: center;
    font-size: 13px;
  }

  .plan-title {
    font-size: 20px;
  }

  .plan-price {
    font-size: 28px;
  }

  .plan-currency {
    font-size: 20px;
  }

  .plan-features li {
    font-size: 13px;
    justify-content: center;
  }

  .plan-locations-title {
    text-align: center;
    font-size: 13px;
  }

  .locations-grid {
    justify-content: center;
    gap: 6px;
  }

  .location-flag {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .plan-buy-button {
    padding: 14px 24px;
    font-size: 14px;
    align-self: center;
  }

  .support-container {
    margin-top: 24px;
  }
}