/* ==========================================
   NutriTrack — Design System & Styles
   ========================================== */

:root {
  --primary: #16a34a;
  --primary-light: #22c55e;
  --primary-dark: #15803d;
  --primary-bg: #f0fdf4;
  --primary-bg2: #dcfce7;
  --bg: #f8f9fb;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --protein-color: #16a34a;
  --carbs-color: #eab308;
  --fats-color: #f97316;
  --fiber-color: #6366f1;
  --red: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ==========================================
   NAVBAR
   ========================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 64px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 40px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text {
  font-weight: 700;
  font-size: 1.2rem;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 8px;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg);
}

.nav-links a.active {
  color: var(--text);
  background: var(--bg);
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.notification-btn {
  position: relative;
}

.notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid var(--card-bg);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-secondary {
  padding: 10px 22px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

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

.btn-outline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: var(--radius-xs);
  font-weight: 500;
  font-size: 0.825rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.btn-link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: var(--transition);
}

.btn-link:hover {
  text-decoration: underline;
  color: #15803d;
  /* darker green hover */
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.avatar-btn:hover {
  box-shadow: 0 0 0 2px var(--primary);
}

/* ==========================================
   MAIN CONTENT
   ========================================== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px 60px;
}

/* ==========================================
   STATS ROW
   ========================================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card--green {
  background: var(--primary-bg);
  border-color: var(--primary-bg2);
}

.stat-card--clickable {
  cursor: pointer;
}

.stat-card--clickable:hover {
  border-color: var(--primary);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-icon--streak {
  background: #fef3c7;
  color: #d97706;
}

.stat-icon--cal {
  background: var(--primary-bg2);
  color: var(--primary);
}

.stat-icon--weight {
  background: #e0e7ff;
  color: #4f46e5;
}

.stat-icon--goals {
  background: var(--primary-bg2);
  color: var(--primary);
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-sub.positive {
  color: var(--primary);
}

.stat-sub.negative {
  color: var(--red);
}

/* ==========================================
   CARD
   ========================================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.set-goal-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 500;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.set-goal-link:hover {
  text-decoration: underline;
}

/* ==========================================
   MIDDLE ROW
   ========================================== */
.middle-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  margin-bottom: 24px;
}

.daily-calories-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.daily-calories-card .card-header {
  width: 100%;
}

.donut-chart-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
}

.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 16;
}

.donut-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 502.65;
  stroke-dashoffset: 502.65;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
  line-height: 1;
}

.donut-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.calorie-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

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

.calorie-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

#remainingNum {
  color: var(--primary);
}

.calorie-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

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

/* Macro Grid */
.macros-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.macro-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.macro-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.macro-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.macro-pct {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.macro-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  margin-bottom: 12px;
  overflow: hidden;
}

.macro-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.protein .macro-bar {
  background: var(--protein-color);
}

.carbs .macro-bar {
  background: var(--carbs-color);
}

.fats .macro-bar {
  background: var(--fats-color);
}

.fiber .macro-bar {
  background: var(--fiber-color);
}

.macro-bottom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.macro-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.macro-val span {
  font-size: 1.5rem;
}

.macro-remaining {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.fiber-fill {
  background: var(--fiber-color);
}

.macro-remaining {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================
   BOTTOM ROW
   ========================================== */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

.bottom-left-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.macro-split-card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.split-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.pie-svg {
  width: 160px;
  height: 160px;
}

.split-legend {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.protein-dot {
  background: var(--protein-color);
}

.carbs-dot {
  background: var(--carbs-color);
}

.fats-dot {
  background: var(--fats-color);
}

.legend-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.legend-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================
   WEIGHT TRACKER CARD
   ========================================== */
.weight-card {}

.weight-card .card-header {
  margin-bottom: 12px;
}

.unit-toggle {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--border);
}

.unit-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-secondary);
  transition: var(--transition);
}

.unit-btn.active {
  background: var(--primary);
  color: #fff;
}

.weight-log-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 16px;
}

.weight-log-input-row input {
  flex: 1;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: var(--card-bg);
  color: var(--text-main);
  transition: all 0.2s;
  height: 36px;
}

.weight-log-input-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.weight-log-input-row button {
  height: 36px;
  padding: 0 16px;
}

.weight-chart-container {
  margin-bottom: 10px;
}

.weight-chart-container canvas {
  width: 100%;
  height: 140px;
  display: block;
}

.weight-history {
  max-height: 100px;
  overflow-y: auto;
}

.weight-history::-webkit-scrollbar {
  width: 3px;
}

.weight-history::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

.weight-entry {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.weight-entry:last-child {
  border-bottom: none;
}

.weight-entry-val {
  font-weight: 600;
  color: var(--text);
}

.weight-entry-change {
  font-size: 0.72rem;
}

.weight-entry-change.up {
  color: var(--red);
}

.weight-entry-change.down {
  color: var(--primary);
}

.unit-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ==========================================
   MEALS LIST
   ========================================== */
.meals-card {
  max-height: 700px;
  display: flex;
  flex-direction: column;
}

.meals-list {
  overflow-y: auto;
  flex: 1;
}

.meals-list::-webkit-scrollbar {
  width: 4px;
}

.meals-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

.meal-group {
  margin-bottom: 8px;
}

.meal-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.meal-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.meal-group-kcal {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.meal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.meal-item:hover {
  background: var(--bg);
  border-left-color: var(--primary);
}

.meal-item-left {
  flex: 1;
}

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

.meal-item-macros {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.meal-item-right {
  text-align: right;
  display: flex;
  align-items: center;
  gap: 12px;
}

.meal-item-cal {
  font-weight: 600;
  font-size: 0.9rem;
}

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

.meal-delete-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.meal-item:hover .meal-delete-btn {
  opacity: 1;
}

.meal-delete-btn:hover {
  color: var(--red);
  background: #fef2f2;
}

.meal-edit-btn {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.meal-item:hover .meal-edit-btn {
  opacity: 1;
}

.meal-edit-btn:hover {
  color: var(--primary);
  background: var(--primary-bg);
}

.empty-meals {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 0;
  color: var(--text-muted);
}

.empty-meals p {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.empty-meals span {
  font-size: 0.82rem;
}

/* ==========================================
   MODALS
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 480px;
  max-width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s ease;
}

.modal-wider {
  width: 540px;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Form */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group label .optional {
  font-weight: 400;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.form-group textarea {
  resize: vertical;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.weight-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.weight-input-row input {
  flex: 1;
}

.weight-unit-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  min-width: 30px;
}

.hidden {
  display: none !important;
}

/* Calculated macros — editable */
.calculated-macros {
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 18px;
}

.calculated-macros h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 12px;
}

.editable-hint {
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.macro-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.macro-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 12px;
  border-radius: var(--radius-xs);
}

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

.mp-input-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}

.mp-input {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
  font-family: inherit;
  color: var(--primary-dark);
  background: #fff;
  transition: var(--transition);
}

.mp-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
}

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

.btn-recalc {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
  transition: var(--transition);
}

.btn-recalc:hover {
  text-decoration: underline;
}

/* Goal mode toggle (lose/gain weight) */
.goal-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  padding: 4px;
}

.goal-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-secondary);
  transition: var(--transition);
}

.goal-mode-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.03);
}

.goal-mode-btn.active[data-mode="lose"] {
  background: var(--primary-bg);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.goal-mode-btn.active[data-mode="gain"] {
  background: #fff7ed;
  color: #c2410c;
  box-shadow: var(--shadow-sm);
}

/* ==========================================
   INPUT METHOD TABS
   ========================================== */
.input-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  padding: 4px;
}

.input-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-secondary);
  transition: var(--transition);
}

.input-tab:hover {
  color: var(--text);
}

.input-tab.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
}

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

/* Estimate button */
.btn-estimate {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 14px;
  background: var(--primary-bg);
  color: var(--primary-dark);
  border: 1px solid var(--primary-bg2);
  border-radius: var(--radius-xs);
  font-weight: 500;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

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

/* Estimated result */
.estimated-result {
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 14px;
}

.estimated-result h4 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.est-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.est-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 4px;
}

.est-item:first-child {
  grid-column: 1 / -1;
}

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

.est-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
}

/* ==========================================
   PHOTO UPLOAD
   ========================================== */
.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

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

.photo-upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.photo-placeholder p {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.photo-placeholder span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.photo-preview {
  width: 100%;
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-xs);
  object-fit: cover;
}

.photo-analyze-btn {
  margin-bottom: 12px;
  width: 100%;
  justify-content: center;
}

/* ==========================================
   SEARCH MODAL
   ========================================== */
.modal-search {
  width: 560px;
  padding: 0;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: transparent;
}

.search-input-wrap kbd {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: inherit;
}

.search-results {
  padding: 16px 20px;
  max-height: 340px;
  overflow-y: auto;
}

.search-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px 0;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
}

.search-result-item:hover {
  background: var(--primary-bg);
}

.search-result-name {
  font-weight: 500;
  font-size: 0.88rem;
}

.search-result-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.search-result-edit {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
  opacity: 0;
  transition: var(--transition);
}

.search-result-item:hover .search-result-edit {
  opacity: 1;
}

/* ==========================================
   USER MENU
   ========================================== */
.user-menu {
  position: fixed;
  top: 60px;
  right: 32px;
  z-index: 150;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  width: 240px;
  overflow: hidden;
  animation: menuFadeIn 0.2s ease;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.user-menu-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-bg2);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.user-menu-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.user-menu-email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.user-menu-item:hover {
  background: var(--bg);
  color: var(--primary);
}

/* ==========================================
   TOASTS
   ========================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 340px;
}

.toast.success {
  background: var(--primary);
}

.toast.error {
  background: var(--red);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1024px) {

  .middle-row,
  .bottom-row {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 768px) {
  .navbar {
    padding: 0 16px;
  }

  .nav-links {
    display: none;
  }

  .main-content {
    padding: 16px;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .macros-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .macros-grid {
    grid-template-columns: 1fr;
  }

  .calorie-summary {
    gap: 16px;
  }
}

/* ==========================================
   LOGIN / AUTH PAGE
   ========================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 50%, #f0fdf4 100%);
  padding: 20px;
}

.login-page.hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 40px 36px 32px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.04);
  animation: cardSlideUp 0.5s ease-out;
}

@keyframes cardSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}

.login-brand h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.login-brand p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Auth Form */
.auth-form-group {
  margin-bottom: 16px;
}

.auth-form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.auth-form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg);
  transition: var(--transition);
  color: var(--text);
}

.auth-form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
  background: #fff;
}

.auth-form-group input::placeholder {
  color: var(--text-muted);
}

/* Auth Buttons */
.btn-auth {
  width: 100%;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

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

.btn-auth.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn-auth-primary {
  background: var(--primary);
  color: #fff;
  margin-top: 8px;
}

.btn-auth-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}

.btn-google {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-google:hover {
  background: var(--bg);
  border-color: #d1d5db;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Forgot password */
.forgot-link {
  display: block;
  text-align: center;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.forgot-link:hover {
  color: var(--primary);
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Footer toggle */
.auth-footer {
  text-align: center;
  margin-top: 22px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Login error message */
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  margin-bottom: 16px;
  text-align: center;
  animation: errorShake 0.4s ease;
}

@keyframes errorShake {

  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-4px);
  }

  40%,
  80% {
    transform: translateX(4px);
  }
}

.login-error.hidden {
  display: none;
}

/* Responsive login */
@media (max-width: 500px) {
  .login-card {
    padding: 28px 22px 24px;
    border-radius: 16px;
  }

  .login-brand h1 {
    font-size: 1.35rem;
  }
}