* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-dark: #0f172a;
  --bg-darker: #020617;
  --bg-light: #f8fafc;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --card-bg: #ffffff;
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-light);
  color: var(--text-primary);
}

/* Loading Screen */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--gradient-primary);
  color: white;
  font-size: 20px;
}

/* Auth Container */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  padding: 20px;
}

.auth-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-header h1 {
  font-size: 32px;
  margin-bottom: 10px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.form-group input,
.form-group textarea {
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
  background: var(--bg-light);
  color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-auth {
  padding: 12px 24px;
  background: var(--gradient-primary);
  color: white;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.3s;
  margin-top: 10px;
  cursor: pointer;
  border: none;
}

.btn-auth:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-auth:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Header */
.header {
  background: var(--gradient-primary);
  color: white;
  padding: 16px 0;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo h1 {
  font-size: 24px;
  margin: 0;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  text-align: right;
}

.user-name {
  font-weight: 600;
  margin: 0;
  font-size: 14px;
}

.user-email {
  font-size: 12px;
  opacity: 0.9;
  margin: 4px 0 0 0;
}

.btn-logout {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Main App */
.app-main {
  min-height: calc(100vh - 80px);
  background: var(--bg-light);
  padding: 20px 0;
}

.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  gap: 20px;
  flex-wrap: wrap;
}

.dashboard-header h1 {
  font-size: 28px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.btn-shopping {
  padding: 12px 24px;
  background: var(--gradient-success);
  color: white;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.3s;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  border: none;
}

.btn-shopping:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Balance Card */
.balance-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.balance-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: 100%;
}

.balance-main {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.balance-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.balance-header h1 {
  font-size: 36px;
  font-weight: 700;
  margin: 8px 0 4px 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.balance-label {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
  font-weight: 500;
}

.balance-info {
  font-size: 12px;
  opacity: 0.8;
  margin: 0;
}

.balance-daily {
  text-align: right;
}

.daily-badge {
  background: rgba(255, 255, 255, 0.25);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.daily-text {
  font-size: 11px;
  opacity: 0.8;
  margin: 8px 0 0 0;
}

.balance-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.balance-stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 12px;
  opacity: 0.8;
  margin: 0;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
}

.stat-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ffed4e);
  transition: width 0.3s ease;
}

.stat-percent {
  font-size: 11px;
  opacity: 0.7;
  margin: 0;
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-top: 20px;
}

.grid-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.grid-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.card h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 600;
}

/* Chart Card */
.chart-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-container {
  min-height: 200px;
  padding: 20px;
  background: linear-gradient(135deg, #f0f4ff 0%, #f9f3ff 100%);
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
}

.simple-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  width: 100%;
  height: 120px;
}

.simple-chart .bar {
  width: 100%;
  background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px 4px 0 0;
  transition: all 0.3s ease;
  opacity: 0.8;
}

.simple-chart .bar:hover {
  opacity: 1;
  transform: scaleY(1.05);
}

.chart-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
}

/* Pie Chart Card */
.pie-card {
  text-align: center;
}

.pie-chart-container {
  padding: 20px;
  background: linear-gradient(135deg, #f0f4ff 0%, #f9f3ff 100%);
  border-radius: 8px;
  margin: 16px 0;
}

.pie-chart {
  max-width: 150px;
  margin: 0 auto;
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  justify-content: flex-start;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-item span:nth-child(2) {
  flex: 1;
}

.legend-item strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* Notification Card */
.notification-card p {
  margin: 8px 0;
  font-size: 14px;
  color: var(--text-primary);
}

.stat-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s;
  border: 1px solid var(--border-color);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  font-size: 32px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  border-radius: 12px;
  color: white;
  flex-shrink: 0;
}

.stat-content h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 8px 0;
  font-weight: 500;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

/* Dashboard Content */
.dashboard-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

/* Transaction Feed */
.transaction-feed {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-color);
}

.feed-header h2 {
  margin: 0;
  font-size: 18px;
  color: var(--text-primary);
}

.feed-badge {
  background: var(--success);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.transactions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 600px;
  overflow-y: auto;
}

.empty-feed {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.transaction-item {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--bg-light);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: all 0.3s;
  animation: slideInLeft 0.4s ease-out;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.transaction-item:hover {
  background: var(--card-bg);
  box-shadow: var(--shadow-md);
}

.transaction-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
  font-size: 18px;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.transaction-content {
  flex: 1;
  min-width: 0;
}

.transaction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  gap: 8px;
}

.transaction-username {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.transaction-time {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.transaction-item-name {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  margin: 4px 0;
  word-break: break-word;
}

.transaction-reason {
  color: var(--text-secondary);
  font-size: 12px;
  margin: 4px 0 8px 0;
  font-style: italic;
}

.transaction-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.transaction-price {
  color: var(--success);
  font-weight: 600;
  font-size: 14px;
}

.transaction-photo-badge {
  font-size: 14px;
}

/* Leaderboard */
.leaderboard {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.leaderboard-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
}

.leaderboard-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text-primary);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-light);
  border-radius: 8px;
  transition: all 0.3s;
  border: 1px solid transparent;
}

.leaderboard-item.rank-1 {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
}

.leaderboard-item.rank-2 {
  background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
  color: white;
}

.leaderboard-item.rank-3 {
  background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
  color: #78350f;
}

.leaderboard-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.rank-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.3);
}

.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.3);
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.user-details {
  min-width: 0;
}

.user-name {
  font-weight: 600;
  margin: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-stats {
  font-size: 11px;
  opacity: 0.8;
  margin: 2px 0 0 0;
}

.user-amount {
  text-align: right;
  flex-shrink: 0;
}

.user-amount p {
  font-weight: 700;
  font-size: 12px;
  margin: 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}

.shopping-modal {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-width: 540px;
  width: 100%;
  animation: modalOpen 0.3s ease-out;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalOpen {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--card-bg);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  color: var(--text-primary);
  font-size: 18px;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

.modal-close:hover {
  background: var(--border-color);
}

.shopping-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.username-display {
  padding: 12px 16px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-weight: 500;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.total-price-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--gradient-success);
  border-radius: 8px;
  color: white;
  font-weight: 600;
}

.total-price-display strong {
  font-size: 18px;
}

/* Photo Upload */
.photo-upload {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--bg-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  position: relative;
}

.photo-upload:hover {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(236, 72, 153, 0.05) 100%);
}

.photo-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 10px;
}

.photo-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.photo-text {
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

.photo-hint {
  color: var(--text-secondary);
  font-size: 12px;
  margin: 0;
}

.btn-submit {
  padding: 14px 24px;
  background: var(--gradient-success);
  color: white;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.3s;
  margin-top: 8px;
  cursor: pointer;
  border: none;
}

.btn-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.purchase-limit-notice {
  padding: 12px;
  background: #fef08a;
  color: #78350f;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  font-weight: 500;
  border: 1px solid #fcd34d;
}

/* Notification */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 24px;
  border-radius: 8px;
  background: var(--success);
  color: white;
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
  max-width: 300px;
  box-shadow: var(--shadow-lg);
}

.notification.show {
  opacity: 1;
}

.notification-error {
  background: var(--danger);
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-section {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-content {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .grid-right {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-header h1 {
    font-size: 24px;
  }

  .btn-shopping {
    width: 100%;
  }

  .stats-section {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .grid-right {
    grid-template-columns: 1fr !important;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .balance-footer {
    grid-template-columns: 1fr;
  }

  .modal-header {
    padding: 16px;
  }

  .shopping-form {
    padding: 16px;
  }

  .header-container {
    flex-direction: column;
    gap: 12px;
  }

  .header-user {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-card {
    padding: 24px;
  }

  .balance-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .dashboard {
    padding: 12px;
  }

  .balance-card {
    padding: 16px;
  }

  .balance-amount {
    font-size: 28px;
  }

  .stat-card {
    padding: 16px;
  }

  .notification {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
