:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-input: #0f172a;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #cbd5e1;

  --color-primary: #10b981; /* Emerald Green - Safe / Allowance */
  --color-primary-dark: #059669;
  --color-danger: #ef4444;  /* Red - Over Target / Food Intake */
  --color-warning: #f59e0b; /* Amber - Near Limit */
  --color-info: #06b6d4;    /* Cyan - Exercise / Burned */
  --color-accent: #8b5cf6;  /* Purple - Calorie Bank */

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.15);
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-left: 72px; /* Space for Left Navigation Rail */
  padding-bottom: 20px;
}

/* Header Navbar */
.app-header {
  background-color: var(--bg-card);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-info));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(90deg, #34d399, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.date-pill {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* App Container & Tab Views */
.app-container {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* MealPlanr Hero Card - Safe-to-Eat Gauge */
.hero-card {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.hero-subtitle {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.hero-main-stat {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hero-main-stat span.unit {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.on-track {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.over-budget {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Progress Bar */
.progress-bar-container {
  height: 12px;
  background: var(--bg-dark);
  border-radius: 6px;
  overflow: hidden;
  margin: 16px 0 12px 0;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-info));
  border-radius: 6px;
  transition: width 0.4s ease, background-color 0.3s;
}

.progress-bar-fill.over {
  background: linear-gradient(90deg, var(--color-warning), var(--color-danger));
}

.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-box {
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-value.burned {
  color: var(--color-info);
}

.stat-value.intake {
  color: var(--color-danger);
}

.stat-value.accent {
  color: var(--color-accent);
}

/* Calorie Bank Card */
.bank-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bank-info h4 {
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bank-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.bank-balance {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-accent);
}

/* Action Floating Row & Quick Buttons */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.btn {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-block {
  width: 100%;
}

/* Section Titles */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title span {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: normal;
}

/* List Items (Food / Meal / Activity Logs) */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.log-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.log-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.log-item-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.log-item-icon.meal {
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-danger);
}

.log-item-icon.exercise {
  background: rgba(6, 182, 212, 0.12);
  color: var(--color-info);
}

.log-item-details h5 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.log-item-details p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.log-item-cals {
  font-size: 1rem;
  font-weight: 700;
  text-align: right;
}

.log-item-cals.intake {
  color: var(--color-danger);
}

.log-item-cals.burned {
  color: var(--color-info);
}

.delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  margin-left: 8px;
  font-size: 1rem;
  transition: color 0.2s;
}

.delete-btn:hover {
  color: var(--color-danger);
}

/* Calorie Forecast Table & SVG Chart */
.forecast-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
}

.chart-container {
  width: 100%;
  height: 180px;
  margin: 16px 0;
}

.timeline-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.85rem;
}

.timeline-table th,
.timeline-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.timeline-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
}

.timeline-table td.today-row {
  background: rgba(16, 185, 129, 0.08);
  font-weight: bold;
}

.positive-bal {
  color: var(--color-primary);
}

.negative-bal {
  color: var(--color-danger);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--color-primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* 👈 LEFT NAVIGATION RAIL / SIDEBAR */
.left-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 72px;
  background: #111827;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 16px;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.left-nav-brand {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-info));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 20px;
  color: #fff;
  box-shadow: var(--shadow-glow);
  margin-bottom: 12px;
  cursor: pointer;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 10px 4px;
  width: 62px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.nav-item.active {
  color: var(--color-primary);
  background: rgba(16, 185, 129, 0.12);
  font-weight: 700;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

/* Macro Nutrients Pills */
.macro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.macro-box {
  background: var(--bg-dark);
  padding: 10px;
  border-radius: var(--radius-sm);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.macro-box .label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.macro-box .val {
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  opacity: 0.4;
}

/* 📱 RESPONSIVE MEDIA QUERIES FOR PERFECT MOBILE VS DESKTOP CONSISTENCY */
@media (max-width: 600px) {
  body {
    padding-left: 60px; /* Slimmer 60px left sidebar on narrow phones */
    padding-bottom: 16px;
  }

  .left-nav {
    width: 60px;
    padding: 12px 0;
    gap: 10px;
  }

  .left-nav-brand {
    width: 34px;
    height: 34px;
    font-size: 17px;
    margin-bottom: 6px;
  }

  .nav-item {
    width: 52px;
    padding: 8px 2px;
    font-size: 0.62rem;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .app-header {
    padding: 12px 14px;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .app-container {
    padding: 12px 10px;
  }

  .hero-card {
    padding: 16px;
  }

  .hero-main-stat {
    font-size: 2rem;
  }

  .hero-stats-grid {
    gap: 8px;
  }

  .stat-value {
    font-size: 0.98rem;
  }

  .quick-actions {
    gap: 8px;
  }

  .btn {
    padding: 10px 10px;
    font-size: 0.8rem;
  }

  .forecast-card {
    padding: 14px;
  }

  .form-row {
    grid-template-columns: 1fr; /* Single column forms on mobile */
  }

  .timeline-table th,
  .timeline-table td {
    padding: 8px 6px;
    font-size: 0.78rem;
  }
}
