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

:root {
  /* HMI Brand — Forest green + teal, matching logo */
  --green:        #1A5C38;   /* dark forest green — "healthy" wordmark */
  --green-mid:    #2D7A4F;   /* mid green */
  --green-light:  #5BAD3A;   /* apple green */
  --green-50:     #E8F5EE;   /* lightest green tint */
  --green-100:    #B8DFC8;   /* light green */
  --teal:         #1BC4B4;   /* teal — "MEALS|inc" wordmark */
  --teal-dark:    #0E8A7E;   /* deeper teal for text on light */
  --teal-50:      #E0F7F5;   /* lightest teal tint */
  --bg:           #F4F8F6;   /* very slight green tint on white */
  --surface:      #FFFFFF;
  --border:       rgba(0,0,0,0.08);
  --text:         #1A2B22;   /* near-black with green undertone */
  --text-muted:   #5A7266;
  --radius:       14px;
  --radius-sm:    9px;
  font-size: 18px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Screen System ─────────────────────────────── */
.screen { display: none; flex-direction: column; min-height: 100vh; max-width: 480px; margin: 0 auto; }
.screen.active { display: flex; }
.scroll-content { flex: 1; overflow-y: auto; padding: 0 16px 32px; }

/* ── Auth Screens ──────────────────────────────── */
.auth-hero {
  background: #B8D96E;
  padding: 36px 16px 24px;
  text-align: center;
  border-bottom: 3px solid #8B6914;
}
.auth-logo {
  width: 95%;
  max-width: 380px;
  height: auto;
  display: block;
  margin: 0 auto 12px;
  border-radius: 6px;
}
.brand-tagline {
  font-size: 22px;
  color: #2D5A0E;
  font-weight: 500;
  font-style: italic;
  opacity: 1;
  margin-top: 6px;
  letter-spacing: 0.01em;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px;
  flex: 1;
  margin-top: -1px;
}

/* ── Topbar ────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--green);
  color: var(--green-100);
  padding: 52px 16px 14px;
  font-size: 17px; font-weight: 500;
  position: sticky; top: 0; z-index: 10;
}
.back-btn {
  background: none; border: none;
  color: var(--green-100); font-size: 26px;
  cursor: pointer; line-height: 1;
  padding: 0 8px 0 0;
}

/* ── Home Header ───────────────────────────────── */
.home-header {
  background: #B8D96E;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 3px solid #4A8C1C;
  flex-direction: column;
  padding: 44px 12px 16px;
  position: relative;
}
.greeting { font-size: 16px; color: #1A5C38; opacity: 1; font-weight: 600; }
.greeting-name {
  font-family: 'DM Serif Display', serif;
  font-size: 24px; color: var(--text);
  margin-top: 2px;
}
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--green); color: #fff;
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
}

/* ── Metrics Grid ──────────────────────────────── */
.metrics-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; padding: 16px 0 4px;
}
.metric-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
}
.metric-label { font-size: 15px; color: var(--text-muted); margin-bottom: 4px; }
.metric-value { font-size: 24px; font-weight: 500; }

/* ── Section Label ─────────────────────────────── */
.section-label {
  font-size: 15px; font-weight: 500;
  color: var(--teal-dark); text-transform: uppercase;
  letter-spacing: 0.06em; margin: 20px 0 10px;
}

/* ── Action Grid ───────────────────────────────── */
.action-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.action-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px 16px;
  text-align: center; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.action-card:hover { background: var(--teal-50); }
.action-card:active { transform: scale(0.97); }
.action-icon { font-size: 26px; line-height: 1; }
.action-label { font-size: 16px; font-weight: 500; line-height: 1.4; color: var(--text); }

/* ── Wellness Card ─────────────────────────────── */
.wellness-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
}
.wellness-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.wellness-title { font-size: 17px; font-weight: 500; }
.chip {
  background: var(--teal-50); color: var(--teal-dark);
  font-size: 14px; font-weight: 500;
  padding: 4px 10px; border-radius: 20px;
}

/* ── Form Styles ───────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-top: 16px;
}
.form-card-title {
  font-size: 17px; font-weight: 500;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 0.5px solid var(--border);
}
.field-group { margin-bottom: 14px; }
label {
  display: block;
  font-size: 15px; color: var(--text-muted);
  margin-bottom: 5px;
}
.opt { font-size: 13px; color: var(--text-muted); opacity: 0.65; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="tel"],
select, textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  touch-action: manipulation;
  min-height: 44px;
  box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-light);
  background: var(--surface);
}
textarea { resize: vertical; min-height: 100px; line-height: 1.5; }

/* ── Mood & Emoji ──────────────────────────────── */
.mood-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.mood-chip {
  padding: 8px 15px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 15px; cursor: pointer;
  background: var(--surface);
  transition: all 0.15s;
  user-select: none;
}
.mood-chip.selected {
  background: var(--green-50);
  border-color: var(--green-100);
  color: var(--green);
}

.emoji-row { display: flex; gap: 14px; margin-top: 6px; }
.emoji-opt {
  font-size: 28px; cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.15s, transform 0.15s;
  user-select: none;
}
.emoji-opt.selected { opacity: 1; transform: scale(1.2); }

/* ── Buttons ───────────────────────────────────── */
.btn-primary {
  display: block; width: 100%; padding: 14px;
  background: #7DB63A; color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: background 0.15s;
  margin-top: 6px;
  border-bottom: 2px solid #4A8C1C;
}
.btn-primary:hover { background: #5C430C; }
.btn-primary:active { background: #5C9A2A; }

.btn-ghost {
  display: block; width: 100%; padding: 13px;
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  min-height: 48px; touch-action: manipulation;
  font-size: 16px; font-family: 'DM Sans', sans-serif;
  cursor: pointer; margin-top: 10px; transition: background 0.15s;
}
.btn-ghost:hover { background: var(--green-50); }

.btn-link {
  display: block; width: 100%; padding: 10px;
  background: none; border: none;
  font-size: 16px; color: var(--text-muted);
  cursor: pointer; text-align: center;
  font-family: 'DM Sans', sans-serif;
  margin-top: 4px;
}

/* ── Messages ──────────────────────────────────── */
.error-msg {
  font-size: 16px; color: #A32D2D;
  background: #FCEBEB; border-radius: var(--radius-sm);
  padding: 10px 13px; margin-bottom: 10px;
}
.success-msg {
  font-size: 16px; color: var(--green);
  background: var(--green-50); border-radius: var(--radius-sm);
  padding: 10px 13px; margin-bottom: 10px;
}
.hidden { display: none !important; }

.helper-text { font-size: 17px; color: var(--text-muted); line-height: 1.6; margin-bottom: 16px; }

/* ── Success Screen ────────────────────────────── */
.success-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  flex: 1; padding: 60px 32px 40px;
}
.success-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--teal-50); color: var(--teal-dark);
  font-size: 34px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.success-title {
  font-family: 'DM Serif Display', serif;
  font-size: 32px; margin-bottom: 10px;
}
.success-body { font-size: 18px; color: var(--text-muted); line-height: 1.6; margin-bottom: 28px; }

/* ── Log History ───────────────────────────────── */
.log-entry {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 10px;
  display: flex; align-items: center; gap: 12px;
}
.log-date { font-size: 15px; color: var(--text-muted); min-width: 64px; }
.log-detail { font-size: 17px; flex: 1; }

/* ── Loading Spinner ───────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Admin ─────────────────────────────────────── */
.admin-nav-btn {
  background: var(--teal);
  color: #fff;
  border: 2px solid #fff;
  border-radius: var(--radius-sm);
  padding: 7px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.02em;
}
.admin-nav-btn:hover { background: var(--teal-dark); }

.blast-preview {
  background: var(--green-50);
  border: 1px solid var(--green-100);
  border-radius: var(--radius-sm);
  padding: 14px; font-size: 13px; line-height: 1.6;
  margin-top: 10px; white-space: pre-wrap;
}

.client-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 14px;
}
.client-row:last-child { border-bottom: none; }
.client-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green-50); color: var(--green);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.client-name { font-weight: 500; }
.client-email { font-size: 12px; color: var(--text-muted); }

/* ── Onboarding Wizard ──────────────────────────── */
.ob-step { animation: obFadeIn 0.25s ease; }
.ob-step.hidden { display: none !important; }
@keyframes obFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.ob-choice {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.ob-choice:hover { border-color: var(--teal); background: var(--teal-50); }
.ob-choice.selected {
  border-color: var(--green);
  background: var(--green-50);
}
.ob-choice-icon { font-size: 24px; margin-bottom: 6px; line-height: 1; }
.ob-choice-label { font-size: 13px; font-weight: 500; color: var(--text); }
.ob-choice.selected .ob-choice-label { color: var(--green); }

.ob-choice-wide {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 14px 16px;
}
.ob-choice-wide .ob-choice-icon { font-size: 22px; margin-bottom: 0; flex-shrink: 0; }
.ob-choice-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.ob-choice-wide.selected .ob-choice-sub { color: var(--green-mid); }

/* ── Home Menu ──────────────────────────────────── */
.home-menu { padding: 4px 0 20px; }

.home-tile {
  width: 100%; background: var(--surface);
  border: 0.5px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  margin-bottom: 10px; font-family: 'DM Sans', sans-serif;
}
.home-tile:hover { background: var(--green-50); }
.home-tile:active { transform: scale(0.98); }

.home-tile-wide {
  display: flex; align-items: center;
  gap: 14px; padding: 14px 16px; text-align: left;
}
.home-tile-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.home-tile-text { flex: 1; }
.home-tile-label { font-size: 17px; font-weight: 500; color: var(--text); }
.home-tile-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; }
.home-tile-arrow { font-size: 20px; color: var(--text-muted); }

.home-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.home-tile-sm {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 16px 8px; text-align: center;
  border: 0.5px solid var(--border);
}
.home-tile-icon-sm { font-size: 26px; margin-bottom: 8px; line-height: 1; }
.home-tile-label-sm { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.4; }

/* ── Sign Out & Footer ──────────────────────────── */
.signout-fab {
  position: fixed;
  bottom: 70px;
  right: 16px;
  background: var(--green);
  color: #C0DD97;
  border: none;
  border-radius: 20px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: none;
}
.signout-fab.visible { display: block; }

.app-footer {
  text-align: center;
  padding: 10px 16px 24px;
  font-size: 16px;
  color: var(--text-muted);
  opacity: 0.9;
  letter-spacing: 0.02em;
  font-style: italic;
}

/* ── Date picker overrides ──────────────────────── */
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}

/* Style today's date in lime green, override browser's blue min-date highlight */
input[type="date"] {
  color-scheme: light;
}

/* Override the browser's default blue highlight on min date */
input[type="date"]::-webkit-datetime-edit-day-field:focus,
input[type="date"]::-webkit-datetime-edit-month-field:focus,
input[type="date"]::-webkit-datetime-edit-year-field:focus {
  background: var(--green-50);
  color: var(--green);
}
