:root {
  --bg-dark: #090d16;
  --surface-dark: #131b2e;
  --surface-card: rgba(22, 32, 54, 0.75);
  --surface-glass: rgba(255, 255, 255, 0.04);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #10b981;
  
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.3);
  
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-main: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  padding-bottom: 90px;
}

.app-container {
  width: 100%;
  max-width: 500px; /* Perfectly sized for mobile phone like Vivo V60e & centered on desktop */
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #047857);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
}

.brand h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--surface-dark);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  background: var(--surface-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-btn svg {
  width: 16px;
  height: 16px;
}

.tab-btn.active {
  background: var(--primary);
  color: #000;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Tab Content Visibility */
.tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
}

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

/* Snap CTA Button */
.snap-cta-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 468px;
  z-index: 100;
}

.snap-btn {
  width: 100%;
  padding: 16px;
  border-radius: 18px;
  border: none;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
  transition: var(--transition-fast);
}

.snap-btn:active {
  transform: scale(0.98);
}

.snap-btn svg {
  width: 24px;
  height: 24px;
}

/* Date Navigator */
.date-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 14px;
}

.date-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 10px;
}

.current-date-display {
  position: relative;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  cursor: pointer;
}

.current-date-display input[type="date"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Cards */
.card {
  background: var(--surface-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-main);
}

/* Calorie Ring Overview */
.calorie-hero {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-bottom: 20px;
  gap: 10px;
}

.calorie-ring-container {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-fill {
  transition: stroke-dashoffset 0.6s ease-in-out;
}

.calorie-center-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.big-number {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.calorie-center-text .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.calorie-stat-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-divider {
  height: 1px;
  background: var(--border-color);
  width: 100%;
}

/* Macros Grid */
.macros-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.macro-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.macro-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.macro-name {
  color: var(--text-muted);
  font-weight: 600;
}

.macro-val {
  color: var(--text-main);
}

.bar-bg {
  height: 8px;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease-out;
}

.macro-item.protein .bar-fill { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.macro-item.carbs .bar-fill { background: linear-gradient(90deg, #06b6d4, #38bdf8); }
.macro-item.fats .bar-fill { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* Meals List */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.section-title h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.badge {
  background: var(--surface-glass);
  border: 1px solid var(--border-color);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.meals-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-card {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  position: relative;
}

.meal-img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #1e293b;
}

.meal-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.meal-notes {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-time {
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.meal-macros-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.pill {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 6px;
  font-weight: 600;
}

.pill.cal { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.pill.pro { background: rgba(139, 92, 246, 0.15); color: #c084fc; }
.pill.carb { background: rgba(6, 182, 212, 0.15); color: #38bdf8; }
.pill.fat { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }

.delete-meal-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition-fast);
}

.delete-meal-btn:hover {
  color: var(--accent-rose);
}

.empty-state {
  text-align: center;
  padding: 30px 16px;
  background: var(--surface-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.empty-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.empty-state p {
  font-weight: 600;
  color: var(--text-muted);
}

.empty-state small {
  color: var(--text-subtle);
  font-size: 0.78rem;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 440px;
  background: var(--surface-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Image Preview & AI Loading */
.image-preview-box {
  position: relative;
  width: 100%;
  height: 200px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
}

.image-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 16px;
}

.ai-overlay.hidden {
  display: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(16, 185, 129, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Forms */
.meal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-form.hidden {
  display: none;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="url"] {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}

input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

.help-text {
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.form-section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-top: 10px;
}

.modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

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

.btn-secondary {
  background: var(--surface-glass);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

/* Analytics Chart Containers */
.analytics-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analytics-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
}

.chart-container {
  position: relative;
  height: 200px;
  width: 100%;
}

.history-controls input {
  margin-bottom: 12px;
}
