:root {
  --primary: #005fb8;
  --on-primary: #ffffff;
  --background: #fafdfc;
  --on-background: #191c1d;
  --surface-container-lowest: #ffffff;
  --surface-variant: #dce4e3;
  --outline: #6f7978;
  --error: #ba1a1a;
  --success: #22c55e;
  --warning: #f97316;
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--background);
  color: var(--on-background);
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--surface-container-lowest);
  border-bottom: 1px solid var(--surface-variant);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-balance {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  padding: 8px 16px;
  background: #e8f0fe;
  border-radius: 24px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}

.main-content {
  flex: 1;
  padding: 32px;
  padding-bottom: 120px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

.section-subtitle {
  font-size: 15px;
  color: var(--outline);
  margin-bottom: 32px;
}

.page-header {
  margin-bottom: 32px;
}

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

.auth-card {
  background: var(--surface-container-lowest);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--outline);
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--outline);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--on-background);
}

.form-input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--surface-variant);
  border-radius: 14px;
  font-size: 15px;
  font-family: inherit;
  background: white;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  padding: 16px 28px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 95, 184, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-secondary {
  width: 100%;
  padding: 16px 28px;
  background: var(--surface-variant);
  color: var(--on-background);
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #c5ccc9;
}

.btn-small {
  padding: 10px 20px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-small:hover {
  opacity: 0.9;
}

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  color: #dc2626;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dashboard-header {
  margin-bottom: 32px;
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-card.highlight {
  grid-column: span 1;
  background: linear-gradient(135deg, var(--primary), #00c6ff);
  color: var(--on-primary);
}

.stat-card.highlight .stat-label,
.stat-card.highlight .stat-icon {
  color: rgba(255, 255, 255, 0.8);
}

.stat-card.highlight .btn-small {
  margin-left: auto;
  background: white;
  color: var(--primary);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #e8f0fe;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 28px;
  flex-shrink: 0;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--outline);
  text-transform: uppercase;
  font-weight: 500;
}

.quick-actions {
  margin-bottom: 32px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.action-btn {
  background: var(--surface-container-lowest);
  border: none;
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.action-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.action-btn span.material-symbols-outlined {
  font-size: 40px;
  color: var(--primary);
}

.action-btn span:not(.material-symbols-outlined):not(.action-badge) {
  font-size: 14px;
  font-weight: 600;
  color: var(--on-background);
}

.action-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--error);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
}

.recent-activity {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  padding: 24px;
}

.empty-state {
  text-align: center;
  padding: 60px 30px;
  color: var(--outline);
}

.empty-state .material-symbols-outlined {
  font-size: 64px;
  opacity: 0.5;
  display: block;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 15px;
}

.balance-card {
  background: linear-gradient(135deg, var(--primary), #00c6ff);
  border-radius: 24px;
  padding: 48px;
  text-align: center;
  color: white;
  margin-bottom: 32px;
}

.balance-label {
  font-size: 16px;
  opacity: 0.8;
  margin-bottom: 12px;
}

.balance-value {
  font-size: 64px;
  font-weight: 800;
  margin-bottom: 4px;
}

.balance-unit {
  font-size: 16px;
  opacity: 0.8;
}

.points-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.action-btn-large {
  background: var(--surface-container-lowest);
  border: none;
  border-radius: 18px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.action-btn-large:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.action-btn-large span.material-symbols-outlined {
  font-size: 40px;
  color: var(--primary);
  flex-shrink: 0;
}

.action-btn-large .action-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--on-background);
  margin-bottom: 4px;
}

.action-btn-large .action-desc {
  font-size: 13px;
  color: var(--outline);
}

.action-btn-large .action-points {
  margin-left: auto;
  background: #e8f0fe;
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 14px;
  flex-shrink: 0;
}

.history-section {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  padding: 24px;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.plan-card {
  background: var(--surface-container-lowest);
  border-radius: 20px;
  padding: 28px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.plan-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

.plan-card.popular {
  border-color: var(--primary);
  position: relative;
  transform: scale(1.05);
}

.plan-badge {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 16px;
}

.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.plan-name {
  font-size: 20px;
  font-weight: 700;
}

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

.plan-price .amount {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.plan-price .period {
  font-size: 14px;
  color: var(--outline);
}

.plan-desc {
  font-size: 14px;
  color: var(--outline);
  margin-bottom: 24px;
}

.plan-features {
  list-style: none;
  margin-bottom: 24px;
  flex: 1;
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  margin-bottom: 10px;
}

.plan-features li .material-symbols-outlined {
  font-size: 20px;
  color: var(--success);
}

.groupbuy-tabs {
  display: flex;
  background: var(--surface-variant);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 14px;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: var(--outline);
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: white;
  color: var(--on-background);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tab-content {
  display: none;
}

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

.create-form {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  padding: 28px;
}

.form-note {
  font-size: 13px;
  color: var(--warning);
  margin-bottom: 20px;
  padding: 14px;
  background: #fff7ed;
  border-radius: 10px;
}

.invite-reward-card {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  margin-bottom: 32px;
}

.reward-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.reward-item .material-symbols-outlined {
  font-size: 40px;
  color: var(--primary);
}

.reward-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.reward-label {
  font-size: 13px;
  color: var(--outline);
}

.reward-divider {
  width: 1px;
  height: 64px;
  background: var(--surface-variant);
}

.invite-code-section {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  padding: 28px;
  margin-bottom: 20px;
}

.invite-code-label {
  font-size: 15px;
  color: var(--outline);
  margin-bottom: 16px;
}

.invite-code-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e8f0fe;
  border-radius: 14px;
  padding: 20px 24px;
}

.invite-code-display span:first-child {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--primary);
}

.copy-btn {
  background: white;
  border: none;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  color: var(--outline);
  transition: all 0.2s ease;
}

.copy-btn:hover {
  color: var(--primary);
}

.invite-share-section {
  margin-bottom: 32px;
}

.referrals-section {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  padding: 24px;
}

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

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.task-item {
  background: var(--surface-container-lowest);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.task-item .task-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #e8f0fe;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.task-item .task-icon .material-symbols-outlined {
  font-size: 28px;
  color: var(--primary);
}

.task-item .task-info {
  flex: 1;
}

.task-item .task-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.task-item .task-desc {
  font-size: 13px;
  color: var(--outline);
}

.task-item .task-reward {
  background: #e8f0fe;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 12px;
  flex-shrink: 0;
}

.task-item.completed {
  opacity: 0.6;
}

.task-item.completed .task-reward {
  background: var(--success);
  color: white;
}

.profile-card {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  padding: 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.profile-email {
  font-size: 14px;
  color: var(--outline);
}

.profile-menu {
  background: var(--surface-container-lowest);
  border-radius: 18px;
  overflow: hidden;
}

.menu-item {
  width: 100%;
  padding: 20px 28px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--surface-variant);
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-size: 15px;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background: var(--surface-variant);
}

.menu-item span:first-child {
  color: var(--outline);
  font-size: 28px;
}

.menu-item span:not(:first-child):not(.arrow) {
  flex: 1;
  font-weight: 500;
}

.menu-item .arrow {
  color: var(--outline);
  font-size: 24px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 24px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: white;
  box-shadow: 0 -4px 16px -4px rgba(0, 0, 0, 0.12);
  z-index: 100;
}

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: 16px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--outline);
  transition: all 0.2s ease;
  min-width: 70px;
}

.nav-link:hover {
  background: var(--surface-variant);
}

.nav-link.active {
  color: var(--primary);
  background: #e8f0fe;
}

.nav-link span {
  font-size: 28px;
}

.nav-link small {
  font-size: 12px;
  font-weight: 600;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface-variant);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.toast-container {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1f2937;
  color: white;
  padding: 14px 24px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.3s ease;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--error);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

@media (max-width: 992px) {
  .stats-overview {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .points-actions {
    grid-template-columns: 1fr;
  }
  
  .plans-grid {
    grid-template-columns: 1fr;
  }
  
  .plan-card.popular {
    transform: scale(1);
  }
}

@media (max-width: 576px) {
  .main-content {
    padding: 20px;
  }
  
  .section-title {
    font-size: 24px;
  }
  
  .stats-overview {
    grid-template-columns: 1fr;
  }
  
  .action-grid {
    grid-template-columns: 1fr;
  }
  
  .invite-reward-card {
    flex-direction: column;
    gap: 20px;
  }
  
  .reward-divider {
    width: 64px;
    height: 1px;
  }
}
