:root {
  --ink: #17352a;
  --muted: #6c7e75;
  --green: #1f6b4f;
  --green-dark: #174d3b;
  --mint: #e3f2e9;
  --cream: #f7f5ee;
  --paper: #fffef9;
  --line: #dde4dd;
  --orange: #ee8656;
  --shadow: 0 18px 48px rgba(30, 65, 50, 0.09);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--cream); }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.app-header {
  position: sticky; top: 0; z-index: 20; height: 78px; padding: 0 max(24px, calc((100vw - 1440px) / 2));
  display: flex; align-items: center; gap: 36px; border-bottom: 1px solid rgba(23, 53, 42, 0.08);
  background: rgba(247, 245, 238, 0.92); backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 230px; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; color: white; background: var(--green); font-family: Georgia, serif; font-size: 20px; font-weight: 700; letter-spacing: -.08em; padding-right: 2px; }
.brand strong { display: block; font-family: Georgia, serif; font-size: 21px; line-height: 1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; letter-spacing: .05em; }
.main-nav { display: flex; align-self: stretch; gap: 6px; }
.nav-item { position: relative; padding: 0 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.nav-item::after { content: ""; position: absolute; height: 3px; left: 14px; right: 14px; bottom: 0; border-radius: 4px 4px 0 0; background: transparent; }
.nav-item:hover, .nav-item.active { color: var(--green); }
.nav-item.active::after { background: var(--green); }
.api-status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.api-status span { width: 8px; height: 8px; border-radius: 50%; background: #49b177; box-shadow: 0 0 0 5px rgba(73,177,119,.12); }

main { width: min(1440px, 100%); margin: 0 auto; padding: 46px 24px 80px; }
.view { display: none; animation: reveal .24s ease both; }
.view.active { display: block; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
.page-heading { margin-bottom: 34px; display: flex; justify-content: space-between; gap: 36px; align-items: flex-end; }
.hero-heading { min-height: 230px; align-items: center; padding: 24px 0 8px; }
.eyebrow { margin: 0 0 9px; color: var(--orange); text-transform: uppercase; letter-spacing: .14em; font-weight: 750; font-size: 11px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 13px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(37px, 5vw, 66px); line-height: 1.02; letter-spacing: -.035em; }
.compact-heading h1 { font-size: clamp(34px, 4vw, 50px); }
h2 { margin-bottom: 0; font-family: Georgia, serif; font-weight: 500; font-size: 27px; }
.lead { margin-bottom: 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.hero-date { align-self: flex-end; padding-bottom: 18px; text-align: right; color: var(--muted); line-height: 1.5; }
.hero-date strong { display: block; color: var(--ink); font-family: Georgia, serif; font-size: 24px; font-weight: 500; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { min-height: 124px; padding: 22px; border-radius: 18px; background: var(--paper); border: 1px solid var(--line); }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin: 13px 0 3px; font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
.stat-card em { color: var(--green); font-style: normal; font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 25px 26px 20px; }
.text-button { padding: 4px 0; border: 0; background: none; color: var(--green); font-size: 13px; cursor: pointer; }
.next-meals { padding: 0 10px 12px; }
.next-meal { display: grid; grid-template-columns: 54px 68px 1fr auto; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); }
.date-badge { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; }
.date-badge strong { display: block; color: var(--ink); font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.meal-thumb { width: 68px; height: 52px; object-fit: cover; border-radius: 11px; background: var(--mint); }
.next-meal h3 { margin: 0 0 5px; font-size: 15px; }
.next-meal p { margin: 0; color: var(--muted); font-size: 12px; }
.pill { padding: 5px 9px; border-radius: 999px; background: var(--mint); color: var(--green); font-size: 11px; white-space: nowrap; }
.shopping-summary-panel { overflow: hidden; }
.shopping-progress { padding: 6px 26px 26px; }
.shopping-total { font-family: Georgia, serif; font-size: 48px; font-weight: 500; }
.shopping-meta { display: flex; justify-content: space-between; margin: 10px 0; color: var(--muted); font-size: 12px; }
.progress-track { height: 9px; overflow: hidden; border-radius: 99px; background: #e8ebe6; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.summary-note { margin: 18px 0 0; padding: 14px; border-radius: 13px; background: var(--cream); color: var(--muted); font-size: 12px; line-height: 1.5; }

.catalog-controls { display: flex; gap: 12px; align-items: center; }
.search-box { width: min(350px, 35vw); display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.search-box span { color: var(--muted); font-size: 20px; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: 13px; background: #e9ece6; }
.segmented button { padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.segmented button.active { color: var(--green-dark); background: var(--paper); box-shadow: 0 2px 8px rgba(30,60,45,.08); }
.recipe-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px; }
.recipe-card { overflow: hidden; border: 1px solid var(--line); border-radius: 19px; background: var(--paper); cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.recipe-card img { width: 100%; aspect-ratio: 1.35; display: block; object-fit: cover; background: var(--mint); }
.recipe-card-body { padding: 17px; }
.recipe-card h3 { min-height: 42px; margin: 5px 0 12px; font-family: Georgia, serif; font-size: 19px; font-weight: 500; line-height: 1.16; }
.recipe-card-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.recipe-card-tag { color: var(--green); }
.empty-state { padding: 80px 20px; text-align: center; color: var(--muted); }
.empty-state span { font-size: 42px; }
.hidden { display: none !important; }

.select-control { min-width: 250px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.select-control select { display: block; width: 100%; margin-top: 7px; padding: 11px 35px 11px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--paper); text-transform: none; letter-spacing: 0; }
.plan-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.plan-legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.week-board { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.day-column { min-width: 210px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,254,249,.68); }
.day-header { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.day-header span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.day-header strong { display: block; margin-top: 3px; font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.meal-slot { min-height: 92px; padding: 12px; border-bottom: 1px solid var(--line); }
.meal-slot:last-child { border-bottom: 0; }
.meal-slot-label { margin-bottom: 7px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.slot-empty { padding: 10px 0; color: #a4aea8; font-size: 12px; }
.slot-recipe { position: relative; min-height: 70px; overflow: hidden; padding: 11px; border-radius: 12px; color: white; background: var(--green-dark); cursor: pointer; isolation: isolate; }
.slot-recipe::before { content: ""; position: absolute; inset: 0; z-index: -2; background: var(--slot-image) center/cover; opacity: .35; }
.slot-recipe::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(16,50,38,.92), rgba(16,50,38,.48)); }
.slot-recipe strong { display: block; font-size: 12px; line-height: 1.35; }
.slot-recipe small { display: block; margin-top: 7px; opacity: .8; font-size: 10px; }

.shopping-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.shopping-list-panel { overflow: hidden; }
.shopping-category h2 { padding: 23px 24px 10px; font-family: inherit; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.shopping-row { display: grid; grid-template-columns: 28px minmax(220px, 1fr) 150px 88px 88px 34px; align-items: center; gap: 12px; padding: 13px 24px; border-top: 1px solid var(--line); font-size: 13px; }
.shopping-row.checked { color: #93a098; }
.shopping-row.checked .product-name { text-decoration: line-through; }
.shopping-check { appearance: none; width: 20px; height: 20px; border: 1.5px solid #9eaaa3; border-radius: 6px; cursor: pointer; }
.shopping-check:checked { border-color: var(--green); background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-width='2' d='m3 8 3 3 7-7'/%3E%3C/svg%3E") center/14px; }
.product-name { font-weight: 650; }
.product-id { margin-top: 3px; color: var(--muted); font-size: 10px; }
.shopping-quantity, .shopping-price { color: var(--muted); }
.mobile-product-details { display: none; }
.shopping-line-total { text-align: right; font-weight: 750; }
.product-link { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--green); background: var(--mint); text-decoration: none; }
.receipt-card { position: sticky; top: 98px; padding: 25px; }
.receipt-card h2 { margin-bottom: 22px; }
.receipt-line { display: flex; justify-content: space-between; padding: 9px 0; color: var(--muted); font-size: 13px; }
.receipt-total { display: flex; justify-content: space-between; margin-top: 13px; padding-top: 18px; border-top: 1px solid var(--line); font-family: Georgia, serif; font-size: 25px; }
.receipt-card .progress-track { margin: 20px 0 8px; }
.receipt-footnote { color: var(--muted); font-size: 11px; line-height: 1.5; }

.recipe-dialog { width: min(980px, calc(100vw - 36px)); max-height: calc(100vh - 36px); padding: 0; overflow: auto; border: 0; border-radius: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 30px 100px rgba(17, 43, 32, .28); }
.recipe-dialog::backdrop { background: rgba(17, 43, 32, .55); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; top: 16px; float: right; z-index: 4; width: 38px; height: 38px; margin: 16px 16px -54px 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); font-size: 25px; cursor: pointer; box-shadow: 0 5px 16px rgba(0,0,0,.12); }
.recipe-detail-hero { min-height: 370px; display: flex; align-items: flex-end; padding: 34px; color: white; background: linear-gradient(0deg, rgba(15,43,32,.9), rgba(15,43,32,.05)), var(--detail-image) center/cover; }
.recipe-detail-hero h2 { max-width: 720px; font-size: 40px; line-height: 1.03; }
.recipe-detail-hero p { margin: 8px 0 0; opacity: .85; }
.recipe-detail-grid { display: grid; grid-template-columns: .85fr 1.3fr; gap: 42px; padding: 34px; }
.recipe-detail-grid h3 { margin-bottom: 17px; font-family: Georgia, serif; font-size: 22px; }
.ingredient-list { margin: 0; padding: 0; list-style: none; }
.ingredient-list li { padding: 10px 0; border-bottom: 1px solid var(--line); line-height: 1.4; }
.instruction-list { margin: 0; padding-left: 23px; }
.instruction-list li { margin-bottom: 16px; padding-left: 7px; line-height: 1.65; }
.original-link { display: inline-flex; margin-top: 20px; padding: 11px 15px; border-radius: 12px; color: white; background: var(--green); text-decoration: none; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 50; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 12px; color: white; background: var(--green-dark); opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); font-size: 13px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1100px) {
  .recipe-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .shopping-layout { grid-template-columns: 1fr; }
  .receipt-card { position: static; }
  .shopping-row { grid-template-columns: 28px 1fr 120px 78px 34px; }
  .shopping-price { display: none; }
}
@media (max-width: 760px) {
  .app-header { height: auto; min-height: 70px; padding: 10px 16px 0; flex-wrap: wrap; gap: 8px; }
  .brand { min-width: 0; flex: 1; }
  .brand small, .api-status { display: none; }
  .main-nav { order: 3; width: 100%; height: 44px; justify-content: space-between; }
  .nav-item { flex: 1; padding: 0 4px; font-size: 12px; }
  .nav-item::after { left: 4px; right: 4px; }
  main { padding: 25px 14px 60px; }
  .page-heading, .hero-heading { display: block; min-height: 0; }
  .hero-date { margin-top: 25px; text-align: left; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 105px; padding: 17px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .next-meal { grid-template-columns: 44px 56px 1fr; }
  .next-meal .pill { display: none; }
  .meal-thumb { width: 56px; height: 48px; }
  .compact-heading .catalog-controls { margin-top: 22px; }
  .catalog-controls { display: block; }
  .search-box { width: 100%; margin-bottom: 10px; }
  .recipe-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .recipe-card h3 { min-height: 38px; font-size: 16px; }
  .recipe-card-body { padding: 13px; }
  .select-control { display: block; margin-top: 22px; min-width: 100%; }
  .week-board { grid-template-columns: repeat(5, 240px); }
  .shopping-row { grid-template-columns: 26px 1fr 74px 30px; padding: 12px 14px; }
  .shopping-quantity { display: none; }
  .mobile-product-details { display: inline; }
  .recipe-detail-hero { min-height: 280px; padding: 24px; }
  .recipe-detail-hero h2 { font-size: 31px; }
  .recipe-detail-grid { grid-template-columns: 1fr; gap: 28px; padding: 24px; }
}
@media (max-width: 440px) {
  .recipe-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card strong { font-size: 25px; }
}
