* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
  min-height: 100vh;
  padding: 20px;
  color: #fff;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 50%, rgba(255, 140, 0, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 165, 0, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app-container {
  max-width: 1000px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.container {
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 140, 0, 0.1);
  width: 100%;
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.header {
  background: linear-gradient(135deg, #ff8c00 0%, #ff6b00 100%);
  padding: 24px 32px;
  border-bottom: 3px solid #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-icon {
  width: 48px;
  height: 48px;
  background: #000;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.header-text h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.header-text p {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.nav-buttons {
  display: flex;
  gap: 12px;
}

.nav-btn {
  background: rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-btn:hover {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.nav-btn.active {
  background: #000;
  border-color: #fff;
}

.page {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.page.active {
  display: flex;
}

/* INPUT PAGE STYLES */
.input-page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-page-content::-webkit-scrollbar {
  width: 8px;
}

.input-page-content::-webkit-scrollbar-track {
  background: #f0f0f0;
}

.input-page-content::-webkit-scrollbar-thumb {
  background: #ff8c00;
  border-radius: 4px;
}

.upload-section {
  background: #fff;
  border: 3px dashed #ff8c00;
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-section:hover {
  border-color: #ff6b00;
  background: #fffaf0;
}

.upload-section.dragover {
  border-color: #ff6b00;
  background: #fff5e6;
  transform: scale(1.02);
}

.upload-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.upload-text {
  font-size: 1.1rem;
  color: #333;
  font-weight: 600;
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 0.9rem;
  color: #666;
}

#imageInput {
  display: none;
}

.preview-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  margin: 20px auto;
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.or-divider {
  text-align: center;
  color: #999;
  font-weight: 600;
  margin: 10px 0;
  position: relative;
}

.or-divider::before,
.or-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 2px;
  background: #e0e0e0;
}

.or-divider::before {
  left: 0;
}

.or-divider::after {
  right: 0;
}

.text-input-section {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  border: 2px solid #e0e0e0;
}

.input-label {
  display: block;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  font-size: 1rem;
}

.text-input-wrapper {
  display: flex;
  gap: 12px;
}

input[type="text"] {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: #fafafa;
  color: #333;
}

input[type="text"]:focus {
  outline: none;
  border-color: #ff8c00;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.1);
}

.analyze-btn {
  padding: 14px 32px;
  background: linear-gradient(135deg, #ff8c00 0%, #ff6b00 100%);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.3);
  white-space: nowrap;
}

.analyze-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 140, 0, 0.4);
}

.analyze-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.result-card {
  background: #000;
  color: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-top: 20px;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.result-icon {
  font-size: 32px;
}

.result-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.nutrition-item {
  background: rgba(255, 140, 0, 0.1);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 140, 0, 0.2);
}

.nutrition-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
  font-weight: 500;
}

.nutrition-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff8c00;
}

.nutrition-unit {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
  margin-left: 4px;
}

.brand-info {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid rgba(255, 255, 255, 0.1);
  font-size: 1rem;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 140, 0, 0.2);
  border-top-color: #ff8c00;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* STATISTICS PAGE STYLES */
.stats-page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #fafafa;
}

.stats-page-content::-webkit-scrollbar {
  width: 8px;
}

.stats-page-content::-webkit-scrollbar-track {
  background: #f0f0f0;
}

.stats-page-content::-webkit-scrollbar-thumb {
  background: #ff8c00;
  border-radius: 4px;
}

.stats-header {
  background: #000;
  color: #fff;
  padding: 24px;
  border-radius: 16px;
  margin-bottom: 24px;
}

.stats-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.stats-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 2px solid #e0e0e0;
}

.summary-label {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 8px;
  font-weight: 500;
}

.summary-value {
  font-size: 2rem;
  font-weight: 700;
  color: #ff8c00;
}

.day-section {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 2px solid #e0e0e0;
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f0f0f0;
}

.day-date {
  font-size: 1.3rem;
  font-weight: 700;
  color: #333;
}

.day-total {
  font-size: 1.1rem;
  color: #ff8c00;
  font-weight: 600;
}

.food-item {
  background: #fafafa;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border-left: 4px solid #ff8c00;
  position: relative;
  transition: all 0.3s ease;
}

.food-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.food-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.food-brand {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 12px;
}

.food-nutrition {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.food-nutrition span {
  font-size: 0.9rem;
  color: #666;
}

.food-nutrition strong {
  color: #ff8c00;
  font-weight: 600;
}

.delete-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #f5576c;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s ease;
  opacity: 0.7;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.delete-btn:hover {
  opacity: 1;
  background: #e63946;
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(245, 87, 108, 0.3);
}

.delete-btn:active {
  transform: scale(0.95);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-text {
  font-size: 1.1rem;
  color: #666;
}

.nutrition-table {
  width: 100%;
  margin-top: 20px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  overflow: hidden;
}

.nutrition-table thead {
  background: rgba(255, 140, 0, 0.2);
}

.nutrition-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #ff8c00;
  font-size: 0.9rem;
  border-bottom: 2px solid rgba(255, 140, 0, 0.3);
}

.nutrition-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

.nutrition-table tbody tr:last-child td {
  border-bottom: none;
}

.nutrition-table tbody tr:hover {
  background: rgba(255, 140, 0, 0.1);
}

.table-item-name {
  font-weight: 600;
  color: #fff;
}

.table-item-brand {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 4px;
}

.items-count {
  background: rgba(255, 140, 0, 0.2);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  display: inline-block;
}

.profile-section {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 2px solid #e0e0e0;
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f0f0f0;
}

.profile-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.profile-input-group {
  display: flex;
  flex-direction: column;
}

.profile-input-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #666;
  margin-bottom: 8px;
}

.profile-input-group input,
.profile-input-group select {
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  background: #fafafa;
  color: #333;
}

.profile-input-group input:focus,
.profile-input-group select:focus {
  outline: none;
  border-color: #ff8c00;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.1);
}

.save-profile-btn {
  padding: 12px 24px;
  background: linear-gradient(135deg, #ff8c00 0%, #ff6b00 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.3);
}

.save-profile-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 140, 0, 0.4);
}

.calorie-goal-card {
  background: linear-gradient(135deg, #ff8c00 0%, #ff6b00 100%);
  color: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.3);
}

.calorie-goal-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.calorie-goal-value {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.calorie-goal-label {
  font-size: 0.9rem;
  opacity: 0.9;
}

.calorie-progress {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 16px;
}

.calorie-progress-bar {
  width: 100%;
  height: 24px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 12px;
  position: relative;
}

.calorie-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 12px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: #ff8c00;
}

.calorie-status {
  margin-top: 12px;
  font-size: 1rem;
  font-weight: 600;
}

.calorie-status.under {
  color: #4caf50;
}

.calorie-status.over {
  color: #f5576c;
}

.calorie-status.good {
  color: #fff;
}

@media (max-width: 600px) {
  .container {
    border-radius: 0;
    min-height: 100vh;
  }

  .header {
    padding: 20px;
    flex-wrap: wrap;
  }

  .nav-buttons {
    width: 100%;
    margin-top: 12px;
  }

  .nav-btn {
    flex: 1;
    text-align: center;
  }

  .upload-section {
    padding: 24px;
  }

  .text-input-wrapper {
    flex-direction: column;
  }

  .nutrition-grid {
    grid-template-columns: 1fr;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .result-card {
    overflow-x: auto;
  }

  .nutrition-table {
    font-size: 0.75rem;
    min-width: 600px;
  }

  .nutrition-table th,
  .nutrition-table td {
    padding: 8px 6px;
  }

  .delete-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
    top: 8px;
    right: 8px;
  }
}