:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #edf3ef;
  --ink: #1d2521;
  --muted: #68736d;
  --line: #d9e0dc;
  --accent: #2e6f56;
  --accent-strong: #1d5b44;
  --warn: #a94232;
  --shadow: 0 18px 45px rgba(32, 45, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(246, 247, 244, 0.18), rgba(246, 247, 244, 0.18)),
    url("ekitchen_background.png") center / cover fixed no-repeat,
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-page {
  min-height: 100vh;
  display: grid;
}

.login-shell {
  width: min(100%, 440px);
  margin: auto;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.login-panel h1 {
  font-size: 2rem;
}

.login-panel .primary {
  width: 100%;
}

.login-error {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid #e7b6ae;
  border-radius: 6px;
  background: #fff1ef;
  color: var(--warn);
  font-weight: 750;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 5vw, 64px) 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 3vw, 2.6rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.2vw, 2rem);
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.tab {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 16px rgba(32, 45, 38, 0.08);
}

.logout-button {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  min-height: 38px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
}

.logout-button:hover,
.logout-button:focus-visible {
  background: var(--accent-strong);
}

main {
  padding: 30px clamp(18px, 5vw, 64px) 54px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.count {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 22px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.form-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

label,
fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  color: #303b35;
  font-size: 0.92rem;
  font-weight: 760;
}

fieldset {
  border: 0;
  padding: 0;
}

legend {
  padding: 0 0 8px;
}

.nutrition-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(46, 111, 86, 0.24);
  border-color: var(--accent);
}

.form-actions,
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-field {
  gap: 10px;
}

.radio-field legend {
  padding-bottom: 0;
}

.radio-group {
  display: flex;
  gap: 18px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--ink);
  font-weight: 700;
}

.radio-group input {
  width: 17px;
  min-height: 17px;
  padding: 0;
}

.table-actions {
  flex-wrap: nowrap;
}

.week-actions {
  display: grid;
  grid-template-columns: repeat(2, 30px);
  gap: 8px;
  justify-content: center;
}

.primary,
.ghost,
.danger,
.icon-button {
  min-height: 38px;
  border-radius: 6px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #fff;
  padding: 0 15px;
}

.primary:hover {
  background: var(--accent-strong);
}

.primary:disabled {
  cursor: not-allowed;
  background: #8ba99c;
}

.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
}

.danger {
  background: #fff1ef;
  color: var(--warn);
  padding: 0 12px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
}

.danger-icon {
  color: var(--warn);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.numeric-cell {
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: 850;
  letter-spacing: inherit;
  text-transform: inherit;
}

.sort-button::after {
  content: "↕";
  color: #9aa49f;
  font-size: 0.72rem;
}

.sort-button[data-direction="asc"]::after {
  content: "↑";
  color: var(--accent-strong);
}

.sort-button[data-direction="desc"]::after {
  content: "↓";
  color: var(--accent-strong);
}

.actions-col {
  width: 118px;
}

.empty {
  display: none;
  margin: 0;
  padding: 18px;
  color: var(--muted);
}

.empty.is-visible {
  display: block;
}

.check-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--ink);
  font-weight: 650;
}

.check-list input {
  width: 17px;
  min-height: 17px;
}

.check-list .recipe-ingredient-option {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) minmax(92px, 128px);
  align-items: center;
}

.recipe-ingredient-quantity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.recipe-ingredient-quantity input {
  width: 100%;
  min-height: 32px;
  padding: 5px 7px;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.recipe-card {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: 190px;
  padding: 16px;
  padding-top: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.recipe-card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
}

.recipe-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  background: var(--surface-soft);
  color: #31453b;
  padding: 5px 9px;
  font-size: 0.82rem;
  font-weight: 750;
}

.week-table {
  min-width: 900px;
}

.week-table th,
.week-table td {
  padding: 8px;
}

.week-table select {
  width: 100%;
  min-width: 104px;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.84rem;
}

.week-dates {
  display: grid;
  gap: 4px;
  min-width: 132px;
}

.week-dates label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.week-dates input {
  min-height: 34px;
  padding: 6px 8px;
}

.week-dates span {
  color: var(--muted);
}

.meal-heading {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  width: 62px;
}

@media (max-width: 920px) {
  .app-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

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

}

@media (max-width: 560px) {
  main {
    padding-top: 22px;
  }

  .ingredient-table th:nth-child(3),
  .ingredient-table td:nth-child(3) {
    display: none;
  }

  .nutrition-fields {
    grid-template-columns: 1fr;
  }
}
