:root {
  --bg:     #f4f6f8;
  --card:   #ffffff;
  --line:   #e2e7ec;
  --text:   #1c2530;
  --sub:    #6b7683;
  --ok:     #2e7d5b;
  --warn:   #b8860b;
  --bad:    #d1524a;
  --loss:   #a3231b;
}
* { box-sizing: border-box; }

body {
  margin: 0; padding: 24px 16px 64px;
  background: var(--bg); color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-size: 15px; line-height: 1.6;
}
main { max-width: 860px; margin: 0 auto; }

header { margin-bottom: 28px; }
h1 { font-size: 24px; margin: 0 0 6px; }
.lead { margin: 0; color: var(--sub); font-size: 14px; }

section {
  background: var(--card); border-radius: 14px;
  padding: 20px 18px; margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.sec-head {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px;
}
h2 { font-size: 17px; margin: 0; flex: 1 1 auto; }
.hint { margin: 0 0 12px; font-size: 13px; color: var(--sub); }

.target { font-size: 13px; color: var(--sub); }
.target input { width: 60px; }

/* ---- 表 ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 460px; }
th, td {
  padding: 9px 8px; text-align: right;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
th { font-size: 12px; color: var(--sub); font-weight: 600; }
.l { text-align: left; }
tfoot td { font-weight: 700; border-bottom: none; }

#summary .rate { font-weight: 700; }
#summary tr.lv-warn .rate { color: var(--warn); }
#summary tr.lv-bad  { background: #fdf0ef; }
#summary tr.lv-bad  .rate { color: var(--bad); }
#summary tr.lv-loss { background: #fbe3e1; }
#summary tr.lv-loss .rate,
#summary td.minus   { color: var(--loss); font-weight: 700; }

/* ---- 警告 ---- */
.alert {
  margin: 0 0 8px; padding: 10px 12px; border-radius: 8px;
  background: #fdf0ef; color: var(--loss); font-size: 14px;
  border-left: 3px solid var(--bad);
}
.alert.ok { background: #eef7f2; color: var(--ok); border-left-color: var(--ok); }

/* ---- 入力 ---- */
input, select {
  font: inherit; font-size: 16px;   /* 16px未満だとiPhoneで勝手に拡大する */
  padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: inherit;
}
input.n { width: 88px; text-align: right; }
input.t { width: 100%; min-width: 130px; }
input.u { width: 70px; }
input.big { font-weight: 700; }
td.calc { color: var(--sub); font-variant-numeric: tabular-nums; }

/* ---- レシピカード ---- */
.recipe {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-bottom: 12px;
}
.recipe-head {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 10px;
}
.recipe-head .t { flex: 1 1 160px; }
.price { font-size: 13px; color: var(--sub); white-space: nowrap; }
.cost-badge {
  font-size: 13px; font-weight: 700; color: var(--sub);
  background: var(--bg); padding: 5px 10px; border-radius: 999px;
}
.line { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.line select { flex: 1 1 auto; min-width: 0; }
.unit { font-size: 13px; color: var(--sub); width: 44px; }

/* ---- ボタン ---- */
button { font: inherit; cursor: pointer; }
.ghost {
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font-size: 14px; color: var(--text);
}
.ghost:hover { background: var(--bg); }
.ghost.sm { font-size: 13px; padding: 5px 10px; }
.ghost.danger { color: var(--bad); border-color: #f0cdca; }
.x {
  background: none; border: none; color: var(--sub);
  font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.x:hover { background: #fdf0ef; color: var(--bad); }

footer { text-align: center; margin-top: 28px; }
.note { font-size: 12px; color: var(--sub); margin-top: 12px; }

@media (max-width: 560px) {
  .recipe-head .t { flex: 1 1 100%; }
}
