/* ==========================================================================
   "Fresh" — alternate visual theme for the Nutrition Dashboard.
   A modern wellness palette: oat canvas, forest + garden greens, mint tints,
   citrus and coral accents. Built mobile-first; class names match the
   original stylesheet so no template or script changes are required.
   ========================================================================== */

:root {
  /* Neutrals */
  --ink: #14241d;
  --muted: #5c6f66;
  --faint: #8a9a92;
  --canvas: #f4f7f2;
  --surface: #ffffff;
  --wash: #eef4ee;
  --line: #dfe7e0;

  /* Brand greens */
  --forest: #0e3d2c;
  --green: #127a52;
  --green-dark: #0d6242;
  --garden: #4caf6d;
  --mint: #d8f0e2;
  --mint-deep: #a9dcc0;

  /* Accents */
  --lime: #8ec63f;
  --citrus: #f2a33c;
  --coral: #ef6b53;
  --sky: #2f9fb8;

  /* Effects */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(20, 36, 29, 0.05), 0 6px 18px -10px rgba(20, 36, 29, 0.25);
  --shadow-lift: 0 2px 6px rgba(20, 36, 29, 0.07), 0 18px 40px -18px rgba(20, 36, 29, 0.35);
  --ring: 0 0 0 3px rgba(18, 122, 82, 0.18);

  --display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;

  /* Chart series colours, read by progress.js. */
  --chart-1: #127a52;
  --chart-2: #2f9fb8;
  --chart-3: #8ec63f;
  --chart-4: #f2a33c;
  --chart-5: #7a5ea8;
  --chart-alert: #ef6b53;
  --chart-ink: #14241d;
  --chart-grid: rgba(20, 36, 29, 0.10);
  --chart-font: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 88% -8%, rgba(142, 198, 63, 0.16), transparent 62%),
    radial-gradient(900px 460px at 4% 0%, rgba(47, 159, 184, 0.12), transparent 60%),
    var(--canvas);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); }

h1, h2, h3, h4, legend {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.12; margin: 0 0 1rem; }
h2 { font-size: clamp(1.15rem, 3.2vw, 1.4rem); line-height: 1.2; margin: 0 0 0.6rem; }
h3 { font-size: 1.05rem; line-height: 1.3; margin: 0 0 0.5rem; }
h4 { font-size: 0.98rem; line-height: 1.35; margin: 0 0 0.25rem; }

/* Page title: a short lime rule instead of a full-width underline. */
main > h1 { position: relative; padding-bottom: 0.7rem; margin-bottom: 1.4rem; }
main > h1::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 52px; height: 4px; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--green), var(--lime));
}

/* --- Utility bar --------------------------------------------------------- */
.utilitybar {
  background: var(--forest);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}
.utilitybar-inner {
  max-width: 1320px; margin: 0 auto; padding: 0.4rem 1rem;
  display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap;
}
.utility-right { margin-left: auto; opacity: 0.72; }

/* --- Header -------------------------------------------------------------- */
.topnav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(1.5) blur(12px);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topnav-inner {
  max-width: 1320px; margin: 0 auto; padding: 0.6rem 1rem;
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none;
  min-width: 0; order: 1; margin-right: auto;
}
.brand-mark {
  width: 34px; height: 34px; flex: none; display: block;
  padding: 4px; border-radius: 11px;
  background: linear-gradient(150deg, var(--mint), #ffffff);
  box-shadow: inset 0 0 0 1px var(--mint-deep);
}
.brand-text {
  font-family: var(--display); font-weight: 600; font-size: 1.1rem;
  letter-spacing: -0.02em; color: var(--forest); white-space: nowrap;
}
.brand-text em { font-style: normal; color: var(--garden); margin: 0 0.12em; }

.navlinks { display: flex; align-items: center; gap: 0.25rem; order: 2; }
.navlinks a {
  font-weight: 500; font-size: 0.9rem; text-decoration: none; color: var(--muted);
  padding: 0.45rem 0.85rem; border-radius: var(--radius-pill);
  transition: background 0.15s ease, color 0.15s ease;
}
.navlinks a:hover { color: var(--ink); background: var(--wash); }
.navlinks a.is-active { color: var(--forest); background: var(--mint); font-weight: 600; }

/* Nav toggle — shown only on small screens. */
.nav-toggle {
  display: none; border: 1px solid var(--line); background: var(--surface);
  width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
  align-items: center; justify-content: center; color: var(--ink); flex: none;
  order: 4;
}
.nav-toggle svg { width: 20px; height: 20px; }
.nav-toggle:hover { background: var(--wash); }

.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem; order: 3;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: var(--radius-pill); padding: 0.4rem 0.85rem;
  font: inherit; font-size: 0.82rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.theme-toggle:hover { background: var(--wash); color: var(--ink); }
.theme-toggle .dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--lime), var(--green));
}

.content { max-width: 1320px; width: 100%; margin: 0 auto; padding: 1.6rem 1rem 3rem; flex: 1; }
.hidden { display: none !important; }
.loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty-state {
  padding: 2.5rem 1.2rem; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}

/* --- Footer -------------------------------------------------------------- */
.quote-band {
  background: linear-gradient(115deg, var(--forest), var(--green) 55%, #1d9a63);
  color: #fff; text-align: center; padding: 2rem 1.2rem;
}
.quote-band p {
  margin: 0 auto; max-width: 720px;
  font-family: var(--display); font-weight: 500;
  font-size: clamp(1rem, 2.6vw, 1.3rem); letter-spacing: -0.01em; line-height: 1.4;
  text-transform: none;
}
.sitefooter {
  background: var(--surface); text-align: center;
  padding: 1.6rem 1.2rem; border-top: 1px solid var(--line);
}
.footer-name { font-family: var(--display); font-weight: 600; margin: 0 0 0.2rem; }
.footer-cred { margin: 0; font-size: 0.85rem; color: var(--muted); }
.footer-notice { max-width: 46rem; margin: 0.6rem auto 0; font-size: 0.75rem; line-height: 1.5; color: var(--muted); }
.footer-notice a { color: inherit; }
.data-notice { font-size: 0.8rem; }
.org-create { margin-bottom: 1.2rem; }
.org-temp-password code { font-size: 1rem; padding: 0.1rem 0.4rem; user-select: all; }

/* --- Landing ------------------------------------------------------------- */
.landing {
  text-align: center; padding: 2rem 0 1rem;
  display: flex; flex-direction: column; justify-content: center;
  min-height: min(62vh, 560px);
}
.landing h1 {
  font-size: clamp(2rem, 8vw, 3.4rem); font-weight: 600; margin: 0 0 0.6rem; padding: 0;
}
.landing h1::after { display: none; }
.landing > p {
  font-size: clamp(1rem, 3vw, 1.15rem); color: var(--muted);
  max-width: 560px; margin: 0 auto;
}
.landing-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 1rem; max-width: 780px; margin: 2.4rem auto 0; text-align: left;
}
.landing-card {
  position: relative; overflow: hidden; width: auto;
  padding: 1.6rem 1.5rem 1.5rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); text-decoration: none; color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.landing-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--green), var(--lime));
}
.landing-card:nth-child(2)::before { background: linear-gradient(90deg, var(--sky), var(--mint-deep)); }
.landing-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: var(--mint-deep); }
.landing-card h2 { margin: 0 0 0.4rem; }
.landing-card p { color: var(--muted); margin: 0; font-size: 0.94rem; }

/* --- Controls & form elements -------------------------------------------- */
.controls {
  margin: 1rem 0; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  font-size: 0.92rem;
}
.controls label { color: var(--muted); }
/* Recipe search — sits beside the meal-type filter above the suggestion list. */
.recipe-search { flex: 1 1 16rem; min-width: 0; max-width: 22rem; }
.suggestion-empty {
  list-style: none; padding: 1rem 0.2rem; color: var(--muted);
  font-size: 0.92rem; font-style: italic;
}


select, input[type="text"], input[type="search"], input[type="number"], input[type="email"], input[type="date"],
textarea {
  padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 0.95rem; font-family: inherit; color: inherit; background: var(--surface);
  max-width: 100%;
}
textarea { width: 100%; }
input[type="number"] { width: 8rem; }
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--green); box-shadow: var(--ring);
}

button.primary {
  background: var(--green); color: #fff; border: none; border-radius: var(--radius-pill);
  padding: 0.55rem 1.15rem; cursor: pointer; font-size: 0.92rem; font-family: inherit;
  font-weight: 600; transition: background 0.15s ease, transform 0.1s ease;
}
button.primary:hover { background: var(--green-dark); }
button.primary:active { transform: translateY(1px); }
button.secondary {
  background: var(--surface); color: var(--green); border: 1px solid var(--mint-deep);
  border-radius: var(--radius-pill); padding: 0.42rem 0.9rem; cursor: pointer;
  font-size: 0.88rem; font-family: inherit; font-weight: 500;
}
button.secondary:hover { background: var(--mint); }
button.secondary.danger { color: var(--coral); border-color: #f4c4bb; }
button.secondary.danger:hover { background: #fdeeea; }

.status-text { color: var(--green); font-size: 0.88rem; font-weight: 500; }
.status-text.error { color: var(--coral); }
.hint { color: var(--faint); font-size: 0.85rem; }

/* --- Panels -------------------------------------------------------------- */
.suggestions-panel, .planner-panel, .recipe-list-panel, .recipe-editor-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}

/* --- Recipes page (list + editor) ---------------------------------------- */
.recipes-layout {
  display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 1rem; align-items: start;
}
.recipe-list-panel .controls { margin-bottom: 0.6rem; }
.recipe-list-panel .controls input[type="search"] { flex: 1 1 10rem; }
.recipe-list-panel > .hint { margin-top: 0.8rem; }
.add-recipe-form { margin-top: 0.5rem; }
.add-recipe-form .form-row {
  display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.8rem;
}
.add-recipe-form .form-row label { color: var(--muted); font-size: 0.88rem; }
.add-recipe-form textarea { flex: 1 1 100%; }
.add-recipe-form fieldset {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 1rem; margin: 0 0 0.9rem;
  /* A fieldset defaults to min-width: min-content; keep it from blowing
     past the panel on narrow screens. */
  min-width: 0;
}
.add-recipe-form legend {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--green); padding: 0 0.4rem;
}
.my-recipes { margin: 0.8rem 0 0; max-height: 70vh; overflow-y: auto; }
.my-recipe-row {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  padding: 0.55rem 0.75rem; margin-bottom: 0.4rem; background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--lime);
  border-radius: var(--radius-sm);
}
.my-recipe-row.is-editing { border-left-color: var(--green); background: var(--wash); }
.my-recipe-row .mr-name { font-weight: 600; flex: 1 1 100%; }
.my-recipe-row .mr-meta {
  color: var(--green-dark); background: var(--mint); border-radius: var(--radius-pill);
  padding: 0.1rem 0.55rem; font-size: 0.74rem; font-weight: 600;
  text-transform: capitalize;
}
.my-recipe-row .mr-usage { color: var(--faint); font-size: 0.74rem; }
.my-recipe-row .mr-actions { margin-left: auto; display: inline-flex; gap: 0.4rem; }

/* --- Compliance tiles ---------------------------------------------------- */
.tile-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem; margin-bottom: 1.4rem;
}
.tile {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1rem 1rem; box-shadow: var(--shadow); border-top: none;
}
.tile::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--line);
}
.tile.good::before { background: linear-gradient(90deg, var(--green), var(--lime)); }
.tile.warn::before { background: linear-gradient(90deg, var(--citrus), #ffd08a); }
.tile.bad::before  { background: linear-gradient(90deg, var(--coral), #ff9d86); }
.tile .tile-value {
  font-family: var(--display); font-size: clamp(1.6rem, 5vw, 2rem);
  font-weight: 600; line-height: 1.1; letter-spacing: -0.03em;
}
.tile.good .tile-value { color: var(--green); }
.tile.warn .tile-value { color: #b9750d; }
.tile.bad  .tile-value { color: var(--coral); }
.tile .tile-label { font-size: 0.85rem; font-weight: 500; margin-top: 0.15rem; color: var(--ink); }
.tile .tile-target { font-size: 0.74rem; color: var(--faint); margin-top: 0.2rem; }

/* --- Recommendations ----------------------------------------------------- */
.rec-section { margin-bottom: 1.6rem; }
.rec-section h2 { margin-bottom: 0.7rem; }
.rec-card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.95rem 1.1rem 0.95rem 1.35rem;
  margin-bottom: 0.55rem; box-shadow: var(--shadow); overflow: hidden;
}
.rec-card::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--line);
}
.rec-card.concern::before { background: var(--coral); }
.rec-card.success::before { background: var(--green); }
.rec-card.insight::before { background: var(--sky); }
.rec-card h4 { margin: 0 0 0.25rem; }
.rec-card p { margin: 0; font-size: 0.92rem; color: var(--muted); }

/* --- Charts -------------------------------------------------------------- */
.chart-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 1rem;
}
.chart-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.2rem; box-shadow: var(--shadow); min-width: 0;
}
.chart-card h3 {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin: 0 0 0.9rem; font-size: 1rem; border-bottom: none; padding-bottom: 0;
}
.chart-card canvas { max-width: 100%; }

/* --- Patient layout ------------------------------------------------------ */
.planner-layout {
  display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 1rem; align-items: start;
}

/* --- Suggestions --------------------------------------------------------- */
.suggestion-list {
  list-style: none; margin: 0; padding: 0; max-height: 620px; overflow-y: auto;
  scrollbar-width: thin;
}
.suggestion-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0.7rem 0.8rem; margin-bottom: 0.5rem;
  cursor: grab; transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.suggestion-card:hover {
  border-color: var(--mint-deep); box-shadow: var(--shadow); transform: translateY(-1px);
}
.suggestion-card .s-name { font-weight: 600; }
/* Gold star after a shared-library recipe's name (cards, planner entries, modal). */
.shared-badge { color: var(--citrus); margin-left: 0.3em; font-size: 0.95em; line-height: 1; }
.suggestion-card .s-meta { font-size: 0.76rem; color: var(--muted); margin-top: 0.2rem; }
.suggestion-card .s-reasons { font-size: 0.74rem; color: var(--green); margin-top: 0.15rem; }
.suggestion-card .s-type {
  display: inline-block; font-size: 0.66rem; background: var(--mint); color: var(--green-dark);
  border-radius: var(--radius-pill); padding: 0.1rem 0.5rem; margin-right: 0.4rem;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; vertical-align: 1px;
}

/* --- Planner grid -------------------------------------------------------- */
/* Scrolls horizontally when narrow; the slot-label column stays pinned. */
.planner-panel { overflow: hidden; }
.planner-grid {
  display: grid; grid-template-columns: 84px repeat(7, minmax(96px, 1fr)); gap: 5px;
  overflow-x: auto; padding-bottom: 0.4rem;
  scrollbar-width: thin; overscroll-behavior-x: contain;
}
.planner-grid .grid-head {
  font-weight: 600; text-align: center; padding: 0.4rem 0.25rem;
  background: var(--forest); color: #fff; border-radius: var(--radius-sm);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
}
.planner-grid .grid-head:first-child {
  background: transparent; position: sticky; left: 0; z-index: 4;
}
.planner-grid .slot-label {
  position: sticky; left: 0; z-index: 3;
  display: flex; align-items: center;
  font-weight: 600; font-size: 0.75rem; color: var(--muted);
  padding: 0.4rem 0.5rem 0.4rem 0.35rem; text-transform: capitalize;
  background: var(--surface); box-shadow: 6px 0 6px -6px rgba(20, 36, 29, 0.18);
}
.planner-cell {
  min-height: 68px; background: var(--wash); border: 1px dashed var(--mint-deep);
  border-radius: var(--radius-sm); padding: 4px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.planner-cell.drag-over { background: var(--mint); border-color: var(--garden); }
.plan-entry {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--garden); border-radius: 8px;
  padding: 0.35rem 0.45rem; margin-bottom: 4px; font-size: 0.76rem;
  cursor: grab; box-shadow: 0 1px 2px rgba(20, 36, 29, 0.06);
}
.plan-entry .e-name { font-weight: 600; }
.plan-entry .e-remove {
  float: right; border: none; background: none; color: var(--faint);
  cursor: pointer; font-size: 0.85rem; padding: 0 0 0 4px; line-height: 1.2;
}
.plan-entry .e-remove:hover { color: var(--coral); }
.totals-row {
  font-size: 0.7rem; padding: 0.45rem; background: var(--mint);
  border-radius: var(--radius-sm); line-height: 1.55; color: var(--forest);
}
.totals-row .t-ok { color: var(--green); }
.totals-row .t-bad { color: #b1341c; font-weight: 600; }
.day-warnings { margin-top: 4px; }
.warning-badge {
  display: block; font-size: 0.66rem; background: #fdeeea; color: #a63c28;
  border: 1px solid #f6cfc6; border-radius: 8px; padding: 3px 5px; margin-top: 3px;
}
.warning-badge .w-suggest { color: #8a5a05; }

/* --- Modal --------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; background: rgba(14, 61, 44, 0.5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 1rem;
}
.modal-content {
  background: var(--surface); border: none; border-top: 4px solid var(--green);
  border-radius: 20px;
  padding: 1.6rem; max-width: 640px; width: 100%; max-height: 88vh;
  overflow-y: auto; position: relative; box-shadow: var(--shadow-lift);
}
.modal-content h2 { padding-right: 2rem; }
.modal-close {
  position: absolute; top: 0.9rem; right: 1rem; border: none; background: var(--wash);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 1.2rem; cursor: pointer; color: var(--muted); line-height: 1;
}
.modal-close:hover { background: var(--mint); color: var(--ink); }
.modal-nutrition {
  display: flex; gap: 0.45rem; flex-wrap: wrap; font-size: 0.8rem; margin-bottom: 0.8rem;
}
.modal-nutrition span {
  background: var(--wash); border-radius: var(--radius-pill);
  padding: 0.2rem 0.7rem; color: var(--muted);
}
.instructions {
  white-space: pre-wrap; font-family: inherit; background: var(--wash);
  padding: 1rem; border-radius: var(--radius-sm); font-size: 0.9rem; line-height: 1.6;
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 1000px) {
  .planner-layout, .recipes-layout { grid-template-columns: 1fr; }
  .suggestion-list { max-height: 340px; }
  .my-recipes { max-height: 340px; }
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .topnav-inner { flex-wrap: wrap; row-gap: 0.5rem; }
  .navlinks {
    order: 5; flex-basis: 100%; flex-direction: column; align-items: stretch;
    gap: 0.15rem; padding-bottom: 0.4rem;
  }
  .navlinks:not(.is-open) { display: none; }
  .navlinks a { padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); font-size: 0.95rem; }
  .theme-toggle { order: 2; padding: 0.55rem 0.7rem; }
  .theme-toggle .label { display: none; }

  .utilitybar-inner { justify-content: center; font-size: 0.7rem; }
  .utility-right { margin-left: 0; }

  .content { padding: 1.2rem 0.9rem 2.4rem; }

  /* Comfortable tap targets; 16px inputs stop iOS Safari zooming on focus. */
  button.primary, button.secondary { padding: 0.65rem 1.15rem; font-size: 0.95rem; }
  select, input[type="text"], input[type="search"], input[type="number"], input[type="email"], input[type="date"],
textarea { font-size: 16px; }

  .suggestions-panel, .planner-panel, .recipe-list-panel, .recipe-editor-panel {
    padding: 1rem;
  }
  .tile-row { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 0.6rem; }
  .tile { padding: 0.85rem 0.8rem; }
  .chart-card { padding: 0.9rem; }
  .quote-band { padding: 1.6rem 1rem; }
  .modal-content { padding: 1.2rem; border-radius: 16px; }
}

@media (max-width: 560px) {
  .planner-grid { grid-template-columns: 66px repeat(7, minmax(104px, 1fr)); }
  .planner-grid .slot-label { font-size: 0.68rem; }
  .add-recipe-form .form-row { flex-direction: column; align-items: stretch; }
  .add-recipe-form .form-row > input,
  .add-recipe-form .form-row > select { width: 100%; }
  .add-recipe-form .form-row > button { align-self: flex-start; }
  /* In a column flex container a flex-basis would size the height, not the
     width — reset it so the text field stays a single-line input. */
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Label kept for screen readers where the placeholder carries the visible cue. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Accounts & plan templates ------------------------------------------- */
.nav-user {
  font-size: 0.85rem; font-weight: 600; color: var(--forest);
  padding: 0.45rem 0.4rem 0.45rem 0.85rem; white-space: nowrap;
}
.nav-logout { display: inline-flex; margin: 0; }
.nav-logout button {
  font: inherit; font-weight: 500; font-size: 0.9rem; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 0.4rem 0.85rem; cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.nav-logout button:hover { color: var(--ink); background: var(--wash); }

.auth-panel {
  max-width: 440px; margin: 2rem auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem 1.8rem;
  box-shadow: var(--shadow);
}
.auth-panel h1 { margin-top: 0; }
.auth-form .form-row { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.auth-form .form-row label { color: var(--muted); font-size: 0.88rem; }
.auth-form input[type="password"] {
  padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 0.95rem; font-family: inherit; color: inherit; background: var(--surface);
}
.auth-form input[type="password"]:focus { outline: none; border-color: var(--green); box-shadow: var(--ring); }
.auth-form .form-row:last-child { flex-direction: row; align-items: center; gap: 0.8rem; }

.planner-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin: 0.6rem 0 0.8rem; font-size: 0.9rem;
}
.planner-toolbar label { color: var(--muted); }
.planner-toolbar select { max-width: 100%; }

.plan-entry .e-servings-label {
  display: inline-flex; align-items: center; gap: 2px; margin-top: 4px;
  font-size: 0.7rem; color: var(--muted); cursor: default;
}
.plan-entry .e-servings {
  width: 3.4rem; padding: 1px 4px; font-size: 0.72rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--wash);
}
.plan-entry.readonly { cursor: default; }
.plan-entry .e-servings-note { display: block; font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
.modal-content.modal-wide { max-width: 1100px; }
.planner-grid-readonly .planner-cell { min-height: 56px; }

.save-template-form .form-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.7rem; }
.save-template-form .form-row label { color: var(--muted); font-size: 0.88rem; min-width: 9rem; }
.save-template-form input[type="text"] { flex: 1 1 12rem; }

@media (max-width: 760px) {
  .nav-user { padding: 0.5rem 0.9rem; }
  .nav-logout button { width: 100%; text-align: left; border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; }
  .auth-panel { margin: 1rem auto; padding: 1.2rem; }
}

/* --- Ingredients (recipe form) ------------------------------------------ */
.ingredients-fieldset .hint { margin: 0 0 0.6rem; }
.ingredient-rows { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.6rem; }
.ingredient-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 6rem minmax(10rem, 15rem) auto;
  gap: 0.5rem; align-items: center;
}
.ingredient-search { position: relative; min-width: 0; }
.ingredient-search input { width: 100%; }
.ingredient-query.is-picked { border-color: var(--green); }
.ingredient-results {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 0.25rem; list-style: none; max-height: 16rem; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
}
.ingredient-results li { padding: 0.4rem 0.55rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.ingredient-results li:hover { background: var(--wash); }
.ingredient-results .ingredient-category { display: block; color: var(--faint); font-size: 0.76rem; }
.ingredient-results .ingredient-no-result { color: var(--faint); cursor: default; }
.ingredient-remove { padding: 0.35rem 0.6rem; }
.nutrition-preview { margin-top: 0.6rem; font-size: 0.88rem; color: var(--muted); }
.modal-ingredients { margin: 0 0 0.8rem; padding-left: 1.2rem; }
.modal-ingredients li { margin-bottom: 0.2rem; }

/* --- Grocery list ------------------------------------------------------- */
.planner-footer { margin-top: 0.9rem; align-items: center; }
.grocery-category { margin: 1rem 0 0.35rem; font-size: 0.95rem; color: var(--green); }
.grocery-items { list-style: none; margin: 0; padding: 0; }
.grocery-item {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 0.15rem 0.8rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line);
}
.grocery-item .g-name { font-weight: 600; }
.grocery-item .g-amount { text-align: right; }
.grocery-item .g-amount em { font-style: normal; color: var(--faint); font-size: 0.82rem; }
.grocery-item .g-recipes { grid-column: 1 / -1; color: var(--faint); font-size: 0.78rem; }
.grocery-empty { margin: 0.5rem 0; }

@media (max-width: 700px) {
  .ingredient-row { grid-template-columns: 1fr 1fr; }
  .ingredient-search { grid-column: 1 / -1; }
  .grocery-item { grid-template-columns: 1fr; }
  .grocery-item .g-amount { text-align: left; }
}

/* --- Roles: nutritionist client picker + Org Management ------------------ */
.nav-client { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0 0.3rem; font-size: 0.85rem; }
.nav-client label { color: var(--muted); }
.nav-client select { padding: 0.3rem 0.5rem; font-size: 0.85rem; max-width: 12rem; }
.org-layout { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.org-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.org-panel .controls { margin: 0.4rem 0 0.6rem; }
.org-panel .controls input[type="search"] { flex: 1 1 10rem; }
.org-list { max-height: 60vh; overflow-y: auto; }
.org-row {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding: 0.55rem 0.75rem;
  margin-bottom: 0.4rem; background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--lime); border-radius: var(--radius-sm); cursor: default;
}
.org-row.is-selectable { cursor: pointer; }
.org-row.is-selectable:hover, .org-row.is-selected { background: var(--wash); border-left-color: var(--green); }
.org-row .org-name { font-weight: 600; }
.org-row .org-email { color: var(--faint); font-size: 0.82rem; flex: 1 1 100%; }
.org-row .org-count, .org-row .org-tag {
  color: var(--green-dark); background: var(--mint); border-radius: var(--radius-pill);
  padding: 0.1rem 0.55rem; font-size: 0.74rem; font-weight: 600;
}
.org-row .org-tag.is-none { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.org-row .org-actions { margin-left: auto; display: inline-flex; gap: 0.4rem; }
.org-more { margin-top: 0.4rem; }
@media (max-width: 1000px) { .org-layout { grid-template-columns: 1fr; } }

/* --- Recipe Import review ------------------------------------------------ */
.review-summary-text { font-weight: 600; margin: 0 0 0.3rem; }
.review-filters { flex-wrap: wrap; gap: 0.4rem; }
.review-row.is-unmatched { border-left-color: var(--coral); }
.review-lines { flex: 1 1 100%; margin: 0.15rem 0 0; padding-left: 1.1rem; font-size: 0.84rem; color: var(--muted); }
.review-lines li { margin: 0.1rem 0; }
.review-grams { color: var(--green-dark); font-weight: 600; }
.review-problem { color: var(--coral); }
.review-status { flex: 1 1 100%; }
.review-status:empty { display: none; }
.review-editor { flex: 1 1 100%; border-top: 1px solid var(--line); padding-top: 0.6rem; margin-top: 0.3rem; }
.review-food-search { max-width: 32rem; }
.review-candidates { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.review-candidates:empty { display: none; }
.review-unit-map { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.4rem 0; font-size: 0.88rem; }
@media (max-width: 760px) { .nav-client { padding: 0.5rem 0.9rem; } .nav-client select { max-width: 100%; } }

/* --- Recipe ratings, proposals and Recipe Feedback ----------------------- */
.suggestion-card .s-rating { color: #d4a017; font-weight: 600; }
.rating-block {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem;
  margin: 0.6rem 0 0.2rem; padding: 0.5rem 0.6rem;
  background: var(--wash); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.rating-block .rating-label { color: var(--muted); font-weight: 600; }
.rating-stars { display: inline-flex; gap: 0.1rem; }
.rating-star {
  background: none; border: none; padding: 0 0.1rem; cursor: pointer; line-height: 1;
  font-size: 1.25rem; color: var(--faint); transition: color 0.12s ease, transform 0.12s ease;
}
.rating-star:hover { color: #d4a017; transform: scale(1.12); }
.rating-star.is-filled { color: #d4a017; }
.rating-block .rating-summary { color: var(--muted); }
.rating-block .rating-clear {
  background: none; border: none; padding: 0; color: var(--green); font-size: 0.8rem;
  text-decoration: underline; cursor: pointer;
}
.rating-block .rating-error:empty { display: none; }
.modal-actions { display: flex; gap: 0.5rem; margin: 0.6rem 0 0.2rem; }
.modal-actions:empty { display: none; }
.rating-average { color: #d4a017; font-weight: 600; }

.my-recipe-row .mr-proposal {
  font-size: 0.72rem; font-weight: 600; border-radius: var(--radius-pill);
  padding: 0.1rem 0.55rem; background: var(--mint); color: var(--green-dark);
}
.my-recipe-row .mr-proposal.is-denied { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.my-recipe-row .mr-proposal.is-approved { background: var(--lime); color: var(--green-dark); }

.feedback-table-wrap { overflow-x: auto; }
.feedback-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.feedback-table th, .feedback-table td {
  text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line);
}
.feedback-table th { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
.feedback-table .num { text-align: right; }
.feedback-table .fb-name { font-weight: 600; }
.feedback-row { cursor: pointer; }
.feedback-row:hover, .feedback-row.is-selected { background: var(--wash); }
.usage-history { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.usage-history h3 { margin: 0 0 0.2rem; font-size: 0.95rem; }
.usage-chart-wrap { position: relative; height: 220px; }

.proposal-list { display: flex; flex-direction: column; gap: 0.6rem; }
.proposal-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--lime);
  border-radius: var(--radius-sm); padding: 0.7rem 0.8rem;
}
.proposal-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.proposal-name { font-weight: 600; }
.proposal-status {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  border-radius: var(--radius-pill); padding: 0.1rem 0.5rem; background: var(--mint); color: var(--green-dark);
}
.proposal-status.is-denied { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.proposal-meta, .proposal-nutrition { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.proposal-details { margin-top: 0.4rem; font-size: 0.8rem; color: var(--muted); }
.proposal-details summary { cursor: pointer; color: var(--green); }
.proposal-details ul { margin: 0.4rem 0; padding-left: 1.1rem; }
.proposal-actions { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
/* The feedback table needs more room than the proposal cards, so this page
   flips the Org layout's narrow-left proportions. */
.feedback-layout { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
@media (max-width: 900px) { .feedback-layout { grid-template-columns: minmax(0, 1fr); } }

/* --- Patient Progress uploads (layout only; colours come from .chart-card,
   .hint and .status-text) ------------------------------------------------- */
.upload-panel { margin-bottom: 1rem; }
.upload-panel > .hint { margin: 0 0 0.8rem; }
.upload-rows { display: flex; flex-direction: column; gap: 0.6rem; }
.upload-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.upload-label { flex: 0 1 17rem; font-weight: 600; }
.upload-label .hint { display: block; font-weight: 400; }
.upload-panel .controls { margin-bottom: 0; }

/* --- Audit Log ----------------------------------------------------------- */
.audit-filters { flex-wrap: wrap; gap: 0.4rem; }
.audit-filters input[type="search"] { flex: 1 1 9rem; }
.audit-table td { vertical-align: top; }
.audit-table .audit-action { font-weight: 600; white-space: nowrap; }
.audit-table .audit-sub { display: block; color: var(--faint); font-size: 0.76rem; }
.audit-table .audit-request { font-size: 0.8rem; color: var(--muted); }
.audit-role { color: var(--muted); font-size: 0.74rem; }
.audit-outcome {
  border-radius: var(--radius-pill); padding: 0.1rem 0.55rem; font-size: 0.74rem; font-weight: 600;
  color: var(--green-dark); background: var(--mint);
}
.audit-outcome.is-denied, .audit-outcome.is-failure { color: var(--coral); background: transparent; border: 1px solid var(--coral); }

/* --- Shared recipe photos ------------------------------------------------ */
.suggestion-card { display: flow-root; }
.suggestion-card .s-thumb {
  float: right; width: 52px; height: 52px; object-fit: cover;
  border-radius: 6px; margin: 0 0 0.25rem 0.5rem; border: 1px solid var(--line);
}
.modal-photo {
  display: block; width: 100%; max-height: 320px; object-fit: cover;
  border-radius: 12px; margin: 0.25rem 0 0.75rem;
}
.my-recipe-row .mr-thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 4px; flex: 0 0 40px;
}
.my-recipe-row .mr-thumb + .mr-name { flex-basis: calc(100% - 3.5rem); }
.recipe-photo-editor { display: flex; gap: 0.75rem; align-items: flex-start; flex-wrap: wrap; }
.recipe-photo-preview {
  width: 220px; max-width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line);
}
.recipe-photo-controls { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }
