/* ── Reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #f4f4ef;
  --surface:       #ffffff;
  --border:        #ddd;
  --text:          #1a1a1a;
  --text-muted:    #777;
  --primary:       #2c7a4b;
  --primary-dark:  #245f3c;
  --primary-light: #e8f5ee;
  --danger:        #c0392b;
  --danger-dark:   #a93226;
  --radius:        8px;
  --shadow:        0 2px 10px rgba(0,0,0,0.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────────────── */
header {
  background: var(--primary);
  color: white;
  padding: 14px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

nav { display: flex; gap: 4px; }

.nav-link {
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  padding: 7px 15px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.13s, color 0.13s;
}
.nav-link:hover  { color: white; background: rgba(255,255,255,0.12); }
.nav-link.active { color: white; background: rgba(255,255,255,0.22); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 20px;
  padding-left: 20px;
  border-left: 1px solid rgba(255,255,255,0.25);
}
.nav-username {
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 500;
  padding: 7px 10px;
  white-space: nowrap;
}
.nav-logout { color: rgba(255,255,255,0.65) !important; }

/* ── Login page ─────────────────────────────────────────────────────── */
.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 48px;
  width: 100%;
  max-width: 420px;
}
.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}
.login-error {
  background: #fdf0ef;
  border: 1px solid #f5c6c3;
  color: var(--danger);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}
.login-success {
  background: var(--primary-light);
  border: 1px solid #b8dfc9;
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
}
.login-btn { width: 100%; margin-top: 8px; }

/* ── Main layout ────────────────────────────────────────────────────── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Card ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.section-header h2 {
  font-size: 19px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-badge {
  background: #eee;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 12px;
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.13s, box-shadow 0.13s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

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

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #f0f0f0; }

.btn-sm { padding: 7px 14px; font-size: 14px; }

.btn-edit { background: #f0f0ec; color: var(--text); }
.btn-edit:hover { background: #e4e4df; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-dark); }

.btn-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-close:hover { background: #f0f0f0; color: var(--text); }

/* ── Filters ────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: #fafaf8;
  flex-wrap: wrap;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filters select {
  font-size: 16px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  min-width: 160px;
  color: var(--text);
}

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  background: #fafaf8;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #efefef;
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f7fdf9; }

tbody td {
  padding: 13px 16px;
  vertical-align: middle;
}

.col-center { text-align: center; }
.col-actions { text-align: right; }
td.col-actions { text-align: right; }

.action-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.empty-state {
  text-align: center;
  padding: 48px 16px !important;
  color: var(--text-muted);
  font-style: italic;
  font-size: 16px;
}

/* ── Meal type badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-Breakfast { background: #fff3cd; color: #7a5c00; }
.badge-Lunch     { background: #d1ecf1; color: #0a4f58; }
.badge-Dinner    { background: #d4edda; color: #155724; }
.badge-Snack     { background: #fde8d8; color: #7a3000; }

/* ── Print indicator ────────────────────────────────────────────────── */
.print-yes { color: var(--primary); font-size: 18px; font-weight: 700; }
.print-no  { color: #ccc; font-size: 18px; }

/* ── Day muted / dash ───────────────────────────────────────────────── */
.no-value { color: #ccc; }

/* ── Modal overlay ──────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; 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 h3 { font-size: 19px; font-weight: 600; }

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  font-size: 17px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  width: 100%;
  color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23777' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.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(44,122,75,0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-check label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 400;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.required { color: var(--danger); }
.optional  { font-weight: 400; color: var(--text-muted); font-size: 13px; }

.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(192,57,43,0.12) !important;
}

.error-msg {
  color: var(--danger);
  font-size: 14px;
  padding: 8px 12px;
  background: #fdf0ee;
  border-radius: 6px;
  border: 1px solid #f5c6c2;
}

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 13px 22px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: white;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: opacity 0.3s, transform 0.3s;
}

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

/* ── Utilities ──────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Dashboard stat cards ───────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}

.stat-value {
  font-size: 52px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 10px;
}

.quick-actions {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  padding: 22px 28px;
  background: var(--primary-light);
  border: 1.5px solid #b3d9c0;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: background 0.13s, border-color 0.13s;
  flex: 1;
}

.quick-action-btn:hover {
  background: #d4eddb;
  border-color: var(--primary);
}

.qa-btn-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}

.qa-btn-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Bulk selection checkbox (meals table) ──────────────────────── */
.col-cb {
  width: 44px;
  text-align: center;
  padding-left: 12px !important;
}

.col-cb input[type="checkbox"],
#meals-select-all {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
  vertical-align: middle;
}

/* ── Bulk actions bar ───────────────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--primary-light);
  border-bottom: 1px solid #c0dfc9;
  flex-wrap: wrap;
}

.bulk-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  margin-right: 4px;
}

.bulk-type-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}

.bulk-type-wrap select {
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

/* ── Data quality warning ───────────────────────────────────────── */
.data-warning {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  background: #fff8e1;
  border-bottom: 1px solid #ffe082;
  font-size: 14px;
  color: #6d4c00;
  font-weight: 500;
}

tr.row-warning { background: #fff8e1 !important; }
tr.row-warning:hover { background: #fff3cc !important; }

/* ── Quick Add form ─────────────────────────────────────────────── */
.quick-add-body {
  padding: 20px 24px 24px;
  border-top: 1px solid var(--border);
  background: #fafaf8;
}

.qa-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.qa-row:last-child { margin-bottom: 0; }

.qa-row .form-group         { flex: 1; }
.qa-row .form-group.qa-wide { flex: 2; }
.qa-row .form-group.qa-narrow { flex: 0 0 90px; }
.qa-row .form-group.qa-auto   { flex: 0 0 auto; }

.form-check-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  padding: 10px 0;
}

.form-check-inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ── CSV import modal ───────────────────────────────────────────── */
.csv-help {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 12px 16px;
  background: #f7f7f5;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.csv-preview-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.csv-preview-table {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.csv-preview-table table { font-size: 14px; }
.csv-preview-table thead th { font-size: 11px; padding: 8px 12px; }
.csv-preview-table tbody td { padding: 7px 12px; }

/* ── File input override ────────────────────────────────────────── */
.form-group input[type="file"] {
  font-size: 15px;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

/* ── Client profile: show-inactive toggle ───────────────────────── */
.show-inactive-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.show-inactive-toggle input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ── Client table: allergy cell (red emphasis) ──────────────────── */
.allergy-cell {
  color: var(--danger);
  font-weight: 600;
  font-size: 15px;
}

/* ── Client status badges ───────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.status-active   { background: #d4edda; color: #155724; }
.status-inactive { background: #e9ecef; color: #666; }

/* ── Inactive client row (muted) ────────────────────────────────── */
tr.row-inactive td { color: var(--text-muted); }
tr.row-inactive strong { font-weight: 500; color: var(--text-muted); }

/* ── Client modal: allergy field emphasis ───────────────────────── */
.allergy-field-label {
  color: var(--danger) !important;
}

.allergy-field-input {
  border-color: #e8a09a !important;
}

.allergy-field-input:focus {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(192,57,43,0.12) !important;
}

/* ── Allergy warning banner (meal modal) ────────────────────────── */
.allergy-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  background: #fff3cd;
  border: 1.5px solid #ffc107;
  border-radius: 7px;
  font-size: 15px;
  color: #7a5c00;
  line-height: 1.5;
}
