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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #22c55e;
  --success-light: #dcfce7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

/* Layout */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-200);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.875rem;
}

.btn-icon {
  padding: 8px;
  background: transparent;
  color: var(--gray-600);
}

.btn-icon:hover {
  background: var(--gray-100);
}

.btn-full {
  width: 100%;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
}

.card-body {
  padding: 16px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--gray-700);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* Login page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  padding: 32px 16px 24px;
}

.login-header h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--gray-500);
}

/* Meals list */
.meals-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
}

.meal-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.meal-item:active {
  transform: scale(0.98);
}

.meal-item.checked {
  background: var(--success-light);
}

.meal-checkbox {
  width: 28px;
  height: 28px;
  border: 2px solid var(--gray-300);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.meal-item.checked .meal-checkbox {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.meal-checkbox svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.15s;
}

.meal-item.checked .meal-checkbox svg {
  opacity: 1;
}

.meal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meal-name {
  font-size: 1.1rem;
  font-weight: 500;
}

.meal-checked-by {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 400;
}

.bug-report {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-weight: 400;
  text-align: center;
  margin-top: 24px;
  padding-bottom: 16px;
}

.bug-report a {
  color: var(--gray-500);
  text-decoration: underline;
}

.meal-number {
  color: var(--gray-400);
  font-size: 0.875rem;
}

/* Progress */
.progress-container {
  padding: 16px;
  text-align: center;
}

.progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-fill.complete {
  background: var(--success);
}

.progress-text {
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* Reward modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

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

.modal-content {
  background: white;
  border-radius: var(--radius);
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.25rem;
}

.modal-body {
  padding: 16px;
}

.modal-close {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--gray-500);
  border-radius: 8px;
}

.modal-close:hover {
  background: var(--gray-100);
}

.reward-image {
  width: 100%;
  border-radius: var(--radius);
}

.reward-message {
  text-align: center;
  padding: 16px 0;
}

.reward-message h3 {
  color: var(--success);
  margin-bottom: 8px;
}

/* Confetti animation */
@keyframes confetti-fall {
  0% { transform: translateY(-100vh) rotate(0deg); }
  100% { transform: translateY(100vh) rotate(720deg); }
}

.confetti {
  position: fixed;
  top: 0;
  width: 10px;
  height: 10px;
  pointer-events: none;
  z-index: 999;
  animation: confetti-fall 3s linear forwards;
}

/* Admin tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  background: white;
}

.tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab:hover:not(.active) {
  color: var(--gray-700);
  background: var(--gray-50);
}

.tab-content {
  display: none;
}

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

/* User list */
.user-list {
  display: flex;
  flex-direction: column;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
}

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

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

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta {
  font-size: 0.875rem;
  color: var(--gray-500);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-admin {
  background: var(--primary);
  color: white;
}

.badge-upload {
  background: var(--success-light);
  color: var(--success);
}

/* Photo grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 16px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-order {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.photo-item:hover .photo-delete {
  opacity: 1;
}

/* Upload area */
.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  margin: 16px;
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--gray-50);
}

.upload-area.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--gray-400);
}

/* History */
.history-day {
  background: white;
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.history-day-header {
  padding: 12px 16px;
  background: var(--gray-50);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-day-header.complete {
  background: var(--success-light);
  color: var(--success);
}

.history-meals {
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-meal {
  padding: 4px 12px;
  background: var(--gray-100);
  border-radius: 9999px;
  font-size: 0.875rem;
}

.history-meal.checked {
  background: var(--success-light);
  color: var(--success);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--gray-500);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  color: var(--gray-300);
}

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
}

/* Change password prompt */
.password-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
}

.password-prompt .modal-content {
  transform: none;
}

/* Navigation */
.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  display: flex;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.15s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

/* Add padding for bottom nav */
.main-content {
  padding-bottom: 80px;
}

/* Responsive */
@media (min-width: 768px) {
  .container {
    max-width: 600px;
  }

  .photo-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Hidden */
.hidden {
  display: none !important;
}
