/* Unfat Modern Responsive Stylesheet */
:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: #d1fae5;
  --primary-dark: #065f46;
  --secondary: #6366f1;
  --secondary-hover: #4f46e5;
  --accent: #f59e0b;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #10b981;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--secondary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Responsive Navbar */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.navbar-header {
  grid-column: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary-dark);
  text-decoration: none !important;
}

.brand-icon {
  background: var(--primary);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.nav-toggle-checkbox {
  position: absolute;
  top: -9999px;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  flex-direction: column;
  justify-content: space-between;
  width: 38px;
  height: 34px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-toggle:focus {
  outline: none;
  border-color: var(--primary);
}

.hamburger-bar {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--text-main);
  border-radius: 2px;
  transition: all 0.25s ease-in-out;
}

/* Hamburger to X animation on checkbox checked or .open class */
.nav-toggle-checkbox:checked ~ .navbar-header .nav-toggle .hamburger-bar:nth-child(1),
.nav-toggle.open .hamburger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle-checkbox:checked ~ .navbar-header .nav-toggle .hamburger-bar:nth-child(2),
.nav-toggle.open .hamburger-bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle-checkbox:checked ~ .navbar-header .nav-toggle .hamburger-bar:nth-child(3),
.nav-toggle.open .hamburger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-menu {
  display: contents;
}

.nav-links {
  grid-column: 2;
  display: flex;
  gap: 1.25rem;
  align-items: center;
  justify-self: center;
  list-style: none;
}

.nav-link {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  display: block;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background: #f1f5f9;
  text-decoration: none;
}

.user-menu {
  grid-column: 3;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-self: end;
}

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

.auth-links {
  grid-column: 3;
  display: flex;
  gap: 0.5rem;
  justify-self: end;
}

/* Mobile & Tablet Navbar Breakpoint (<= 860px) */
@media (max-width: 860px) {
  .navbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem 1rem;
  }

  .navbar-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .nav-toggle {
    display: flex;
    margin-left: auto;
  }

  .nav-menu {
    display: none;
    flex-direction: column;
    align-items: stretch;
    margin-left: 0;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    gap: 0.5rem;
    animation: fadeInMenu 0.2s ease-in-out;
  }

  .nav-toggle-checkbox:checked ~ .nav-menu,
  .nav-menu.open {
    display: flex;
  }

  .nav-links {
    grid-column: auto;
    justify-self: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    width: 100%;
  }

  .nav-link {
    padding: 0.7rem 0.85rem;
    font-size: 1rem;
    border-radius: var(--radius-sm);
  }

  .user-menu {
    grid-column: auto;
    justify-self: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px dashed var(--border);
  }

  .user-name {
    padding: 0 0.5rem;
    font-size: 0.85rem;
  }

  .logout-btn {
    width: 100%;
    text-align: center;
    padding: 0.6rem;
  }

  .auth-links {
    grid-column: auto;
    justify-self: auto;
  }
}

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

/* Layout container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
  flex: 1;
}

/* Alerts / Flash Messages */
.flash-container {
  margin-bottom: 1.5rem;
}
.alert {
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.alert-notice {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #a7f3d0;
}
.alert-alert {
  background-color: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Cards & Grid */
.grid {
  display: grid;
  gap: 1.25rem;
}
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}
.stat-number {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Progress bar */
.progress-bar-container {
  background: #e2e8f0;
  height: 10px;
  border-radius: 9999px;
  overflow: hidden;
  margin: 0.75rem 0;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 9999px;
  transition: width 0.4s ease;
}
.progress-bar.over-budget {
  background: var(--danger);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-breakfast { background: #fef3c7; color: #92400e; }
.badge-lunch     { background: #e0e7ff; color: #3730a3; }
.badge-dinner    { background: #fce7f3; color: #9d174d; }
.badge-snack     { background: #e0f2fe; color: #075985; }
.badge-drink     { background: #f3e8ff; color: #6b21a8; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none !important;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: #e2e8f0;
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
}
.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}
.btn-block {
  width: 100%;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}
.form-control {
  width: 100%;
  padding: 0.55rem 0.8rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  transition: border-color 0.15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Quick add pills */
.quick-add-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.quick-pill {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s ease;
}
.quick-pill:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.table th {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.table tr:hover td {
  background: #fbfcfe;
}

/* Week Day Bar Chart (Pure CSS) */
.week-chart {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 140px;
  padding-top: 1.5rem;
  gap: 0.5rem;
}
.day-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.day-bar-wrapper {
  width: 100%;
  max-width: 32px;
  height: 90px;
  background: #f1f5f9;
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.day-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  transition: height 0.4s ease;
}
.day-bar.over {
  background: var(--danger);
}
.day-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.4rem;
}
.day-label.today {
  color: var(--primary-dark);
  font-weight: 800;
}
.day-val {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

/* Auth Cards */
.auth-wrapper {
  max-width: 440px;
  margin: 3rem auto;
}
