:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #f1f7f4;
  --text: #0e1828;
  --muted: #657082;
  --border: #d9e0e5;
  --green: #08734c;
  --green-dark: #064631;
  --blue: #315fa9;
  --amber: #d99012;
  --coral: #d85f3f;
  --shadow: 0 20px 45px rgba(8, 30, 45, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(circle at top right, rgba(8, 115, 76, 0.07), transparent 34%), var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 750;
  color: var(--green-dark);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: 0.82rem;
}

nav {
  display: flex;
  align-items: center;
  gap: 28px;
  color: #26334a;
  font-size: 0.95rem;
}

nav a:hover,
.resource-card:hover strong,
.site-footer a:hover {
  color: var(--green);
}

.top-cta,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 720;
  font-size: 0.95rem;
  cursor: pointer;
}

.top-cta,
.button.primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 28px rgba(8, 115, 76, 0.22);
}

.button.secondary,
.icon-button {
  background: #fff;
  border-color: var(--border);
  color: #172237;
}

main {
  padding: 30px clamp(16px, 3vw, 32px) 24px;
}

.workspace,
.resources {
  max-width: 1480px;
  margin: 0 auto;
}

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 850px;
  color: var(--green-dark);
  font-size: clamp(2rem, 4vw, 3.05rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.lead {
  margin-top: 12px;
  color: #66708a;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 600;
}

.page-title p:last-child {
  max-width: 820px;
  margin-top: 8px;
  color: #4e5d73;
  font-size: 1rem;
  line-height: 1.6;
}

.date-control {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.date-control span {
  color: var(--blue);
  font-weight: 760;
}

.planner-grid {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(420px, 1.25fr) minmax(340px, 0.95fr);
  gap: 22px;
  align-items: stretch;
}

.side-panel,
.planner-panel,
.output-panel,
.resources {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.side-panel,
.planner-panel,
.output-panel {
  padding: 22px;
}

.meal-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.setting-group + .setting-group {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.setting-group h2,
.planner-panel h2,
.output-panel h2,
.resources h2 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  line-height: 1.2;
}

.setting-group label:not(.field) {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: #202b3e;
  font-weight: 630;
}

.setting-group label:not(.field) span {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 540;
}

input[type="checkbox"] {
  accent-color: var(--green);
  width: 17px;
  height: 17px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 15px;
}

.field.compact {
  margin-bottom: 12px;
}

.field span,
.portion-grid span {
  font-size: 0.9rem;
  font-weight: 760;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
  line-height: 1.4;
}

input[type="number"] {
  appearance: textfield;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(49, 95, 169, 0.28);
  outline-offset: 2px;
}

.meal-table {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) minmax(125px, 0.75fr) minmax(118px, 0.55fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.table-row:first-child {
  border-top: 0;
}

.table-head {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.split-heading {
  margin-top: 22px;
}

.portion-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.portion-grid label {
  display: grid;
  gap: 8px;
}

.portion-grid small {
  color: var(--muted);
  font-weight: 700;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.output-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 12px;
  font-weight: 680;
  cursor: pointer;
}

.note-output {
  display: grid;
  gap: 14px;
  min-height: 430px;
}

.note-block {
  padding: 0 0 14px;
  border-bottom: 1px solid var(--border);
}

.note-block:last-child {
  border-bottom: 0;
}

.note-block strong {
  display: block;
  margin-bottom: 7px;
  color: var(--green-dark);
}

.note-block ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.55;
}

.totals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.totals-table th,
.totals-table td {
  padding: 7px 5px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.totals-table td:last-child,
.totals-table th:last-child {
  text-align: right;
}

.boundary-note {
  margin-top: 18px;
  padding: 12px 14px;
  border-left: 4px solid var(--coral);
  background: #fff7f4;
  color: #624437;
  font-size: 0.92rem;
  line-height: 1.45;
}

.resources {
  margin-top: 22px;
  padding: 22px;
}

.section-title {
  margin-bottom: 14px;
}

.section-title a {
  color: var(--blue);
  font-weight: 720;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.resource-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, var(--surface-soft));
}

.resource-card strong {
  color: #12213a;
}

.resource-card span {
  color: var(--muted);
  line-height: 1.45;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  padding: 26px 18px 34px;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer span {
  color: var(--green-dark);
  font-weight: 760;
}

@media (max-width: 1180px) {
  .planner-grid {
    grid-template-columns: 1fr 1fr;
  }

  .side-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(240px, 0.9fr) 1fr 1fr;
    gap: 18px;
  }

  .meal-image {
    margin-bottom: 0;
  }

  .setting-group + .setting-group {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 820px) {
  .site-header,
  .page-title,
  .output-head,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header {
    position: static;
  }

  nav {
    width: 100%;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .top-cta {
    width: 100%;
  }

  main {
    padding: 22px 12px;
  }

  .planner-grid,
  .side-panel,
  .resource-grid {
    grid-template-columns: 1fr;
  }

  .planner-panel {
    order: 1;
  }

  .output-panel {
    order: 2;
  }

  .side-panel {
    order: 3;
  }

  .side-panel,
  .planner-panel,
  .output-panel,
  .resources {
    padding: 17px;
  }

  .table-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .table-head {
    display: none;
  }

  .portion-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .button,
  .icon-button {
    width: 100%;
  }

  .note-output {
    min-height: 0;
  }

  h1 {
    font-size: clamp(1.8rem, 10vw, 2.45rem);
  }
}
