:root {
  color-scheme: light;
  --bg: #f7f4ed;
  --ink: #24211c;
  --muted: #70685f;
  --line: #ded7ca;
  --panel: #fffdf8;
  --green: #126343;
  --green-soft: #e4f1e8;
  --red: #b51f2a;
  --gold: #c78b2d;
  --shadow: 0 18px 50px rgba(36, 33, 28, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 5vw, 56px) 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.05rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
  padding: 0 clamp(18px, 5vw, 56px) 40px;
}

.panel {
  min-height: 72vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.promo-strip {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fbf7ef;
}

.store-picker {
  display: grid;
  grid-template-columns: minmax(96px, 0.55fr) minmax(150px, 0.85fr) minmax(220px, 1.6fr);
  gap: 10px;
}

.store-field,
.provider-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.store-field span,
.provider-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.store-field select,
.provider-field select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.promo-strip p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.promo-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.promo-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.promo-card.active {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 2px var(--green);
}

.promo-image {
  width: 54px;
  height: 66px;
  border-radius: 6px;
  background: #f1eee6;
  object-fit: cover;
}

.promo-content {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
}

.promo-name {
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.18;
}

.promo-period {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.promo-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 850;
}

.promo-facts span {
  border-radius: 999px;
  background: #f1eee6;
  padding: 4px 7px;
}

.panel-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-heading input {
  width: min(230px, 48%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
}

.product-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: min(430px, 58%);
}

.product-actions input {
  width: min(230px, 100%);
}

.recipe-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.provider-field {
  width: 170px;
}

.products-panel .panel-heading {
  align-items: stretch;
  flex-direction: column;
}

.products-panel .product-actions {
  justify-content: stretch;
  width: 100%;
}

.products-panel .product-actions input {
  flex: 1 1 180px;
  min-width: 0;
  width: auto;
}

.products-panel .product-actions .text-button {
  flex: 0 0 auto;
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
}

.text-button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 12px;
  max-height: calc(100vh - 190px);
  padding: 14px;
  overflow: auto;
}

.category-list {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.category-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 11px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.category-pill span {
  color: var(--muted);
  font-weight: 700;
}

.category-pill.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.product-card {
  display: grid;
  grid-template-rows: 112px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}

.product-card.selected {
  border-color: var(--green);
  box-shadow: inset 0 0 0 2px var(--green);
}

.product-card img {
  width: 100%;
  height: 112px;
  object-fit: contain;
  padding: 10px;
  background: #fafafa;
}

.product-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.product-title {
  min-height: 42px;
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.25;
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.price {
  color: var(--red);
  font-weight: 900;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 86px;
  min-height: 46px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  overflow: auto;
}

.chip {
  border: 1px solid #b8d4bf;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  padding: 6px 9px;
  font-size: 0.82rem;
  font-weight: 800;
}

.recipe-results {
  display: grid;
}

.recipes-grid {
  display: grid;
  gap: 8px;
}

.recipe-group {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
}

.recipe-group + .recipe-group {
  border-top: 1px solid var(--line);
}

.recipe-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recipe-group-heading h3 {
  margin: 0;
  font-size: 0.98rem;
}

.recipe-group-heading span {
  border-radius: 999px;
  background: #f1eee6;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.recipe-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.recipe-card img {
  width: 100%;
  height: 100%;
  min-height: 96px;
  object-fit: cover;
  background: #e9e3d8;
}

.recipe-body {
  display: grid;
  align-content: center;
  gap: 7px;
  min-width: 0;
  padding: 10px 12px;
}

.recipe-title {
  font-size: 0.94rem;
  font-weight: 850;
  line-height: 1.25;
}

.recipe-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.recipe-provider {
  color: var(--ink);
}

.fact {
  border-radius: 999px;
  background: #f1eee6;
  padding: 5px 8px;
}

.recipe-match {
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
}

.recipe-link {
  justify-self: start;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 850;
}

.empty {
  grid-column: 1 / -1;
  padding: 36px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty.compact {
  padding: 18px;
}

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

  .store-picker {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .products-grid {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-heading input {
    width: 100%;
  }

  .product-actions,
  .recipe-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .provider-field {
    width: 100%;
  }
}
