
:root {
  --bg: #f7f5ef;
  --panel: #fffdf8;
  --panel-2: #f2eee4;
  --text: #1f2933;
  --muted: #687385;
  --line: #dfd8ca;
  --brand: #2f5d50;
  --brand-dark: #24493f;
  --good: #1c7c54;
  --bad: #b42318;
  --warning: #a15c00;
  --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  background: var(--brand);
  color: white;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--brand-dark);
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: #e8e2d5;
}

button.danger {
  color: var(--bad);
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 0.65rem 0.75rem;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 3px solid rgba(47, 93, 80, 0.18);
  border-color: var(--brand);
}

code {
  background: var(--panel-2);
  padding: 0.08rem 0.3rem;
  border-radius: 6px;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

h1,
h2,
h3 {
  margin: 0 0 0.45rem;
  line-height: 1.15;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.04em;
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin-top: 0;
}

.muted,
small {
  color: var(--muted);
}

.status {
  min-height: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
}

.status.error {
  color: var(--bad);
  font-weight: 700;
}

.status.success {
  color: var(--good);
  font-weight: 700;
}

.tabs,
.week-tabs,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.tabs {
  margin: 1rem 0;
}

.tab,
.pill {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.tab.active,
.pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.grid,
.shopping-list,
.recipe-grid,
.meal-grid {
  display: grid;
  gap: 1rem;
}

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

.metrics {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.shopping-list,
.recipe-grid {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
}

.meal-grid {
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card.wide {
  margin-bottom: 1rem;
}

.auth-card {
  max-width: 560px;
  margin: 6vh auto;
}

.stack {
  display: grid;
  gap: 0.9rem;
}

.stack label {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
}

.userbox {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.seed-panel {
  border: 2px solid rgba(47, 93, 80, 0.25);
}

.metric-card {
  background: linear-gradient(180deg, #fffdf8, #f7f3ea);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.big-number {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 900;
}

.good {
  color: var(--good);
}

.bad {
  color: var(--bad);
}

.split {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.progress {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.8rem 0;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}

.shop-item,
.inventory-row {
  display: grid;
  gap: 0.6rem;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 0.75rem 0;
}

.shop-item {
  grid-template-columns: 1fr 94px;
}

.shop-item:first-of-type,
.inventory-row:first-of-type {
  border-top: 0;
}

.checkrow {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.checkrow input {
  margin-top: 0.25rem;
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.shop-item small,
.inventory-row small {
  display: block;
  margin-top: 0.2rem;
}

.shop-item.done strong,
.prep-task.done span,
.meal-toggle.done span {
  text-decoration: line-through;
  color: var(--muted);
}

.price-input {
  width: 94px;
}

.meal-card {
  display: grid;
  gap: 0.65rem;
}

.meal-toggle {
  display: grid;
  text-align: left;
  gap: 0.25rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0.75rem;
}

.meal-toggle:hover {
  background: var(--panel-2);
}

.meal-toggle.done {
  background: #edf6f1;
  border-color: rgba(28, 124, 84, 0.2);
}

.prep-note {
  color: var(--warning);
  font-size: 0.92rem;
  margin: 0.2rem 0 0;
}

.recipe-card details {
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
  margin-top: 0.65rem;
}

.recipe-card summary {
  cursor: pointer;
  font-weight: 800;
}

.inventory-form {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 0.8fr) 120px 120px auto;
}

.inventory-row {
  grid-template-columns: 1fr 118px auto;
}

.icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.prep-task {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  border-top: 1px solid var(--line);
  padding: 0.9rem 0;
}

.prep-task:first-child {
  border-top: 0;
}

.prep-task input {
  width: 18px;
  height: 18px;
  margin-top: 0.1rem;
  accent-color: var(--brand);
}

#recipeSearch {
  width: min(100%, 520px);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: white;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  opacity: 0;
  transition: all 160ms ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .topbar {
    display: block;
  }

  .userbox {
    justify-content: flex-start;
  }

  .inventory-form {
    grid-template-columns: 1fr;
  }

  .shop-item {
    grid-template-columns: 1fr;
  }

  .price-input {
    width: 100%;
  }

  .shell {
    padding: 0.8rem;
  }
}
