:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #eef3ee;
  --ink: #1d2520;
  --muted: #657069;
  --line: #d9e0d9;
  --accent: #19715d;
  --accent-strong: #105244;
  --warn: #b55d1c;
  --danger: #b73535;
  --good: #187240;
  --shadow: 0 14px 40px rgba(24, 42, 34, 0.08);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  align-items: center;
  background: #183a34;
  color: #fff;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  min-height: 104px;
  padding: 22px clamp(18px, 4vw, 48px);
}

.eyebrow {
  color: #bfe0d6;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.1;
  margin-bottom: 0;
}

h2 {
  font-size: 1rem;
  margin-bottom: 0;
}

main {
  display: grid;
  gap: 22px;
  padding: 22px clamp(14px, 4vw, 48px) 42px;
}

.top-actions,
.panel-title,
.ingredients-head,
.ingredient-row,
.actions,
.search-field,
.inline-stat {
  align-items: center;
  display: flex;
}

.top-actions {
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.summary-strip {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.summary-strip div {
  background: var(--surface);
  min-width: 0;
  padding: 16px;
}

.summary-strip span,
.muted {
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-strip strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 6px;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.input-panel {
  padding: 18px;
}

.table-panel {
  overflow: hidden;
}

.panel-title {
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.table-tools {
  flex-wrap: wrap;
  padding: 18px 18px 0;
}

.stacked-form {
  display: grid;
  gap: 14px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.86rem;
  gap: 6px;
}

input,
select {
  background: #fff;
  border: 1px solid #cdd6cf;
  border-radius: 7px;
  color: var(--ink);
  min-height: 42px;
  min-width: 0;
  padding: 9px 11px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25, 113, 93, 0.15);
  outline: none;
}

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

.primary,
.ghost,
.icon-button {
  align-items: center;
  border: 0;
  border-radius: 7px;
  display: inline-flex;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
}

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

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

.ghost {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: inherit;
  padding: 9px 12px;
}

.panel .ghost {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--ink);
}

.compact {
  min-height: 34px;
  padding: 7px 10px;
}

.icon-button {
  aspect-ratio: 1;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink);
  flex: 0 0 38px;
  padding: 0;
}

.icon-button:hover,
.ghost:hover {
  filter: brightness(0.97);
}

svg {
  height: 17px;
  width: 17px;
}

.file-action input {
  display: none;
}

.search-field {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  max-width: 320px;
  padding-left: 10px;
  width: 100%;
}

.search-field input {
  border: 0;
  box-shadow: none;
  min-height: 38px;
  padding-left: 0;
}

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

table {
  border-collapse: collapse;
  min-width: 840px;
  width: 100%;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8faf8;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td strong {
  display: block;
}

.category {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  margin-top: 3px;
}

.actions {
  flex-wrap: wrap;
  gap: 7px;
}

.stock-move {
  min-width: 38px;
}

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

.warning {
  color: var(--warn);
}

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

.ingredients-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.ingredients-head {
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ingredients-head span {
  font-weight: 800;
}

.ingredients-list {
  display: grid;
  gap: 9px;
}

.ingredient-row {
  gap: 8px;
  min-width: 0;
}

.ingredient-product {
  flex: 1 1 44%;
}

.ingredient-qty {
  flex: 1 1 26%;
}

.ingredient-unit {
  flex: 1 1 20%;
}

.recipe-grid {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  background: var(--line);
  border-top: 1px solid var(--line);
}

.recipe-card {
  background: var(--surface);
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
}

.recipe-card h3 {
  font-size: 1.05rem;
  margin: 0;
}

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

.recipe-stats div {
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

.recipe-stats span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.recipe-stats strong {
  font-size: 1rem;
}

.recipe-ingredients {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0;
}

.empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.app-unavailable .panel,
.app-unavailable .summary-strip {
  opacity: 0.72;
}

.app-unavailable .empty {
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 980px) {
  .workspace,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .form-grid,
  .recipe-stats {
    grid-template-columns: 1fr;
  }

  .ingredient-row {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .ingredient-row .remove-ingredient {
    grid-column: 2;
    justify-self: end;
  }

  .top-actions .ghost {
    width: 100%;
  }
}
