:root {
  --bg: #f6f1e8;
  --surface: #fffaf2;
  --surface-strong: #ffffff;
  --ink: #19312b;
  --muted: #6f7a73;
  --line: #e4dacb;
  --primary: #0f7a5b;
  --primary-dark: #095840;
  --accent: #f28c38;
  --accent-soft: #fff0d7;
  --danger: #b42318;
  --shadow: 0 18px 60px rgba(62, 48, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #fff7ea 0, var(--bg) 22rem);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

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

h1 {
  margin-bottom: 0.5rem;
  font-size: 2.35rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 0.9rem;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 250, 242, 0.94);
  border-bottom: 1px solid rgba(25, 49, 43, 0.1);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(1440px, calc(100% - 40px));
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
}

.brand-logo {
  width: 44px;
  height: 44px;
  display: block;
}

.brand-text {
  font-size: 1.22rem;
  letter-spacing: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-right a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 700;
}

.topbar-right a:hover {
  background: #f0eadf;
}

.topbar-user {
  max-width: 360px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.topbar-toggle span {
  width: 20px;
  height: 2px;
  display: block;
  margin: 4px auto;
  border-radius: 2px;
  background: var(--ink);
}

.page {
  width: min(1440px, calc(100% - 40px));
  margin: 36px auto;
}

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

.page-hero p:not(.eyebrow) {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel,
.card {
  background: rgba(255, 250, 242, 0.94);
  border: 1px solid rgba(25, 49, 43, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel,
.card {
  padding: 24px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(360px, 0.72fr);
  gap: 22px;
  align-items: start;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #30423c;
  font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 122, 91, 0.13);
}

button,
.btn-primary,
.btn-outline,
.btn-soft {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button,
.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

button:hover,
.btn-primary:hover {
  background: var(--primary-dark);
  color: #ffffff;
}

.btn-outline {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--ink);
}

.btn-outline:hover {
  background: #f0eadf;
  color: var(--ink);
}

.btn-soft {
  background: var(--accent-soft);
  color: #7c3e0e;
}

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

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.input-with-unit input {
  border: 0;
  border-radius: 0;
}

.input-with-unit span {
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
}

.toggle-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-self: end;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.ingredient-editor {
  margin: 22px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.ingredient-head,
.ingredient-row {
  display: grid;
  grid-template-columns: 96px 110px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.ingredient-head {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.ingredient-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.icon-button {
  min-width: 44px;
  width: 44px;
  padding: 0;
  background: #f7e2dc;
  color: var(--danger);
  font-size: 1.25rem;
}

.icon-button:hover {
  background: #f4ccc2;
  color: var(--danger);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.recipe-list {
  display: grid;
  gap: 12px;
}

.recipe-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.recipe-item p {
  margin-bottom: 10px;
  color: var(--muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf5ef;
  color: #27644d;
  font-size: 0.78rem;
  font-weight: 800;
}

.tag.accent {
  background: var(--accent-soft);
  color: #8a4a12;
}

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  font-weight: 800;
}

.danger-link {
  color: var(--danger);
}

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

.week-nav {
  display: grid;
  grid-template-columns: 140px 110px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
}

table.list,
table.week-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

table.list th,
table.list td,
table.week-grid th,
table.week-grid td {
  border-bottom: 1px solid var(--line);
  padding: 14px;
  vertical-align: top;
}

table.week-grid th {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: left;
  text-transform: uppercase;
}

.week-grid {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.week-grid .cell {
  display: grid;
  gap: 10px;
}

.day-cell {
  min-width: 210px;
}

.day-cell strong,
.day-cell span {
  display: block;
}

.day-cell strong {
  margin-bottom: 4px;
}

.day-cell .tag {
  width: fit-content;
  margin-top: 10px;
}

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

.slot-grid label {
  gap: 5px;
  font-size: 0.8rem;
}

.slot-empty {
  color: var(--muted);
  font-style: italic;
}

.slot-max {
  color: var(--primary);
  font-weight: 800;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 20px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.open-slots {
  padding-left: 20px;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .split-layout,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .recipe-list-panel {
    order: -1;
  }
}

@media (max-width: 780px) {
  .topbar-inner,
  .page {
    width: min(100% - 24px, 1440px);
  }

  .topbar-inner {
    min-height: 66px;
  }

  .topbar-right {
    position: absolute;
    top: 66px;
    left: 12px;
    right: 12px;
    display: none;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-right.open {
    display: flex;
  }

  .topbar-toggle {
    display: block;
  }

  .topbar-user {
    max-width: none;
    padding: 8px 12px;
    white-space: normal;
  }

  .page {
    margin-top: 20px;
  }

  .page-hero {
    display: grid;
    align-items: start;
  }

  h1 {
    font-size: 1.9rem;
  }

  .panel,
  .card {
    padding: 16px;
  }

  .form-grid.two,
  .week-nav,
  .slot-grid {
    grid-template-columns: 1fr;
  }

  .ingredient-head {
    display: none;
  }

  .ingredient-row {
    grid-template-columns: 1fr 1fr 44px;
  }

  .ingredient-row input[name="ingredient_name[]"] {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .ingredient-row .icon-button {
    grid-column: 3;
    grid-row: 1 / 3;
    height: 100%;
  }

  .week-grid,
  .week-grid tbody,
  .week-grid tr,
  .week-grid th,
  .week-grid td {
    display: block;
  }

  .week-grid tr:first-child {
    display: none;
  }

  .week-grid td {
    border-bottom: 0;
  }

  .week-grid tr {
    border-bottom: 1px solid var(--line);
  }

  .recipe-item {
    display: grid;
  }

  .item-actions {
    flex-direction: row;
    align-items: center;
  }
}
