:root {
  --green-dark: #0f4c2b;
  --green: #15693a;
  --green-light: #1f8a4d;
  --gold: #c99a2e;
  --gold-light: #e6b93d;
  --text-dark: #1a2420;
  --text-muted: #5b6b62;
  --bg-light: #f7f9f6;
  --border: #e4e9e2;
  --white: #ffffff;
  --pass: #1f8a4d;
  --pass-bg: #e6f4ea;
  --check: #b3441e;
  --check-bg: #fbeee6;
  --input-bg: #fffaf0;
  --shadow: 0 4px 20px rgba(15, 76, 43, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-dark);
  background: var(--bg-light);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

.container { max-width: 1320px; margin: 0 auto; padding: 0 20px; }

.crumbbar {
  background: var(--green-dark);
  color: #dcefe1;
  font-size: 0.82rem;
  padding: 10px 0;
}
.crumbbar .container { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.crumbbar a { color: #dcefe1; opacity: 0.9; }
.crumbbar a:hover { opacity: 1; text-decoration: underline; }
.crumbbar span.sep { opacity: 0.5; }

.fm-header {
  background: linear-gradient(120deg, var(--green-dark), var(--green));
  color: #fff;
  padding: 34px 0 28px;
}
.fm-header .container { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.fm-header h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: 6px; letter-spacing: -0.02em; }
.fm-header p { color: #d9ecdf; max-width: 620px; font-size: 0.98rem; }
.fm-badge {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: #eafbf0;
  white-space: nowrap;
}

.disclaimer {
  background: #fff4dc;
  color: #7a4a10;
  font-size: 0.85rem;
  padding: 12px 0;
  border-bottom: 1px solid #f0dcaa;
}

.fm-shell { padding: 28px 0 70px; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 22px;
}
.card h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green-dark);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--bg-light);
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.field label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  font-size: 0.95rem;
  color: var(--text-dark);
}
.field input:focus, .field select:focus { outline: 2px solid var(--green-light); outline-offset: 1px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--green-dark); }
.btn-outline:hover { border-color: var(--green); }
.btn-gold { background: var(--gold); color: #382b04; }
.btn-gold:hover { background: var(--gold-light); }
.btn-danger-outline { background: #fff; border-color: #e2c3b3; color: var(--check); }

.fm-main-grid { display: grid; grid-template-columns: 2.1fr 1fr; gap: 22px; align-items: start; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  background: var(--green);
  color: #fff;
  text-align: left;
  padding: 10px 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
tbody td { padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:hover { background: #f5faf6; }

.line-kg, .ing-field { width: 84px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg); }
.line-ing { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg); max-width: 160px; }
.line-remove, .ing-remove {
  border: none; background: #fbeee6; color: var(--check); width: 26px; height: 26px; border-radius: 50%; font-size: 1rem; line-height: 1;
}
.line-remove:hover, .ing-remove:hover { background: #f4d7c8; }

.status-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; }
.status-badge.pass { background: var(--pass-bg); color: var(--pass); }
.status-badge.check { background: var(--check-bg); color: var(--check); }

#checksPassed { font-size: 0.82rem; color: var(--text-muted); margin-top: 10px; }

.summary-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.9rem; }
.summary-row strong { color: var(--green-dark); }
.summary-row.warn strong { color: var(--check); }
#summaryBox hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

.saved-row { display: flex; gap: 8px; flex-wrap: wrap; }
.saved-row select { flex: 1; min-width: 140px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); }

.status-msg {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--pass-bg);
  color: var(--pass);
  font-size: 0.85rem;
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: opacity 0.2s ease;
}
.status-msg.show { opacity: 1; height: auto; padding: 10px 14px; margin-top: 12px; }

.ingredients-section summary { cursor: pointer; font-weight: 700; color: var(--green-dark); padding: 4px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.ingredients-section summary::-webkit-details-marker { display: none; }
.ingredients-section summary::before { content: "▸"; transition: transform 0.15s ease; }
.ingredients-section[open] summary::before { transform: rotate(90deg); }
.ingredients-section p.hint { color: var(--text-muted); font-size: 0.85rem; margin: 10px 0 14px; }

.fm-footer { background: var(--green-dark); color: #cfe6d7; padding: 26px 0; font-size: 0.85rem; margin-top: 40px; }
.fm-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.fm-footer a { color: #eafbf0; }

@media (max-width: 980px) {
  .fm-main-grid { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .setup-grid { grid-template-columns: 1fr; }
  .fm-header .container { flex-direction: column; align-items: flex-start; }

  /* responsive table -> stacked cards */
  table.responsive-stack thead { display: none; }
  table.responsive-stack, table.responsive-stack tbody, table.responsive-stack tr, table.responsive-stack td { display: block; width: 100%; }
  table.responsive-stack tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; padding: 8px 10px; }
  table.responsive-stack td {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    border-bottom: 1px dashed var(--border); padding: 7px 2px; white-space: normal;
  }
  table.responsive-stack td:last-child { border-bottom: none; }
  table.responsive-stack td::before { content: attr(data-label); font-weight: 700; color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; }
  table.responsive-stack td[data-label=""]::before { content: ""; }
  table.responsive-stack .line-ing, table.responsive-stack .line-kg, table.responsive-stack .ing-field { width: auto; max-width: 60%; }
}
