:root {
  color-scheme: light;
  --background: #f4f7f2;
  --panel: #ffffff;
  --ink: #183027;
  --muted: #64746d;
  --line: #dbe5df;
  --primary: #236b4b;
  --primary-dark: #185038;
  --accent: #dff3e8;
  --accent-strong: #a9dfbf;
  --danger: #a33a3a;
  --shadow: 0 12px 32px rgba(30, 64, 49, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(150deg, #eef7f0 0%, var(--background) 42%, #f8f3e9 100%);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }

.page-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 52px 24px 24px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: -0.04em; }
h2 { margin: 0 0 5px; font-size: 1.35rem; }
h3 { margin: 28px 0 12px; font-size: 1rem; }
p { line-height: 1.55; }
.subtitle, .step-heading p { margin: 0; color: var(--muted); }

.page-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 24px 80px;
}

.panel {
  margin-top: 18px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(35, 107, 75, 0.12);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.step-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
}

.step-number {
  display: grid;
  flex: 0 0 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 800;
}

.step-number.complete { background: var(--primary); color: white; }

.inline-form, .search-row, .button-row {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.field { display: grid; gap: 7px; min-width: 150px; }
.field.grow { flex: 1 1 320px; }
.field.compact { flex: 0 1 150px; }
.field > span { color: #40554b; font-size: 0.86rem; font-weight: 700; }

input, select, textarea {
  width: 100%;
  border: 1px solid #bfcec6;
  border-radius: 10px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 107, 75, 0.13);
}

textarea { resize: vertical; line-height: 1.5; }

.button {
  min-height: 43px;
  border: 0;
  border-radius: 10px;
  padding: 10px 17px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 100ms ease, background 120ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.6; transform: none; }
.button-primary { background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { background: #e9efeb; color: var(--ink); }
.button-confirm { background: #ccebd8; color: #123d2a; }
.button-danger { padding: 6px 10px; min-height: auto; background: #f7e4e4; color: var(--danger); }

.message {
  position: sticky;
  top: 12px;
  z-index: 10;
  margin-bottom: 12px;
  padding: 12px 15px;
  border-radius: 10px;
  background: #e2f3e9;
  border: 1px solid #b8dcc6;
  color: #174d34;
  box-shadow: var(--shadow);
}

.message.error { background: #fae8e8; border-color: #edbaba; color: #822d2d; }

.search-results {
  margin: 16px 0;
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
}

.search-result {
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 12px;
  background: #f7faf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.search-result:hover { background: var(--accent); }
.search-result strong, .search-result span { display: block; }
.search-result span { margin-top: 3px; color: var(--muted); font-size: 0.84rem; }
.saved-recipe-list { display: grid; gap: 8px; margin: 14px 0 24px; }
.saved-recipe-row { display: flex; align-items: stretch; gap: 8px; }
.saved-recipe-open { flex: 1; }
.saved-recipe-delete { flex: 0 0 auto; padding-inline: 16px; }
.table-actions { display: flex; justify-content: flex-end; gap: 7px; }
.table-actions .button { white-space: nowrap; }
.planner-date-field { max-width: 230px; margin-bottom: 18px; }
.planner-meal-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) minmax(220px, 1.2fr) minmax(140px, 0.5fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}
.planner-single-item-fields {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf8;
}
.planner-single-item-fields .subpanel { margin-bottom: 0; }
.planner-meal-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  gap: 12px;
  min-width: 0;
}
.planner-meal-footer .field { min-width: 0; }
.planner-meal-footer .button { flex: 0 0 auto; }
.helper-text { color: var(--muted); font-size: 0.88rem; }
.goal-profile { margin: 16px 0 4px; font-weight: 750; }
.overview-table { max-width: 760px; }
.overview-table th:first-child, .overview-table td:first-child { position: static; }
.goal-over td:last-child { color: var(--danger); font-weight: 800; }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.week-nav h2 { margin: 0; }
.week-day-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.week-day { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--panel); }
.week-day summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.week-day.not-logged { color: var(--muted); }
.week-day-overview { color: var(--muted); }
.link-button { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 800; cursor: pointer; text-decoration: underline; }
.goal-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.goal-badge { border-radius: 999px; padding: 3px 10px; font-size: 0.85rem; background: #e9efeb; }
.goal-met { background: var(--accent); color: #123d2a; }
.goal-missed { background: #f7e4e4; color: var(--danger); }
hr { margin: 24px 0; border: 0; border-top: 1px solid var(--line); }

.subpanel, .review-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 13px;
  background: #f5f8f6;
  border: 1px solid var(--line);
}

.selected-label { margin-top: 0; }
.review-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; background: #fff8e8; border-color: #ead9aa; }
.review-title { display: block; margin-bottom: 5px; color: #78652c; font-size: 0.78rem; font-weight: 800; text-transform: uppercase; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: right; font-size: 0.88rem; }
th { background: #f2f6f3; color: #52645c; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; }
th:first-child, td:first-child { position: sticky; left: 0; text-align: left; background: white; }
th:first-child { background: #f2f6f3; }
tr:last-child td { border-bottom: 0; }

.current-total {
  margin: 14px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}
.current-total strong { color: var(--ink); text-align: right; }

.results-panel { border-color: var(--accent-strong); }
.macro-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 10px; }
.macro-card { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #f8faf8; }
.macro-card span, .macro-card strong { display: block; }
.macro-card span { color: var(--muted); font-size: 0.78rem; }
.macro-card strong { margin-top: 5px; font-size: 1.25rem; }
.macro-grid.compact { margin-bottom: 18px; }
.macro-grid.compact .macro-card { padding: 12px; }
.macro-grid.compact .macro-card strong { font-size: 1.05rem; }
.macro-grid.featured .macro-card { background: var(--accent); border-color: var(--accent-strong); }
.optional { margin-left: 6px; color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; }
.save-row { display: flex; align-items: center; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
.save-row strong { color: var(--muted); font-size: 0.9rem; }
.recipe-step-list { display: grid; gap: 10px; padding-left: 28px; }
.recipe-step-list li { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8faf8; }
.recipe-step-list p { margin: 0 0 8px; white-space: pre-wrap; }
.recipe-step-list small { display: block; margin-bottom: 10px; color: var(--muted); }
.step-options { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.step-options summary { cursor: pointer; color: var(--primary); font-weight: 700; }
.step-options[open] summary { margin-bottom: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

[hidden] { display: none !important; }

@media (max-width: 650px) {
  .page-header { padding-top: 32px; align-items: flex-start; flex-direction: column; }
  .page-shell { padding-inline: 14px; }
  .panel { border-radius: 14px; }
  .inline-form > .field, .search-row > .field { flex: 1 1 100%; }
  .inline-form > .button, .search-row > .button { width: 100%; }
  .review-card, .current-total { align-items: stretch; flex-direction: column; }
  .button-row .button { flex: 1; }
  .saved-recipe-row { align-items: stretch; }
  .planner-meal-form { grid-template-columns: 1fr; }
  .planner-meal-form .button { width: 100%; }
  .planner-meal-footer { align-items: stretch; flex-direction: column; }
}
