/* ========== 基础重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* 手机版基准：1rem = 屏宽的 13.333%（375px 时恰为 50px）；电脑宽屏时锁定 50px，页面按手机比例居中 */
html { font-size: min(13.333333vw, 50px); -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif; background: #f4f1ea; color: #2c3e2d; line-height: 1.5; min-height: 100vh; overflow-x: hidden; }
:root {
  --primary: #4a7c4e;
  --primary-light: #6ba06f;
  --primary-dark: #2d5a3d;
  --accent: #e8a847;
  --accent-light: #f4c373;
  --bg-card: #ffffff;
  --bg-soft: #f9f6ef;
  --text-main: #2c3e2d;
  --text-sub: #6b7c6d;
  --text-muted: #9aa89c;
  --border: #e6e0d3;
  --shadow: 0 2px 12px rgba(74, 124, 78, 0.08);
  --shadow-lg: 0 4px 20px rgba(74, 124, 78, 0.12);
}

/* ========== 整体容器 ========== */
.app { max-width: 750px; margin: 0 auto; background: var(--bg-soft); min-height: 100vh; position: relative; padding-bottom: 1.4rem; }

/* ========== 顶部 Banner ========== */
.hero {
  position: relative;
  padding: 0.6rem 0.4rem 1.2rem;
  background: linear-gradient(160deg, #4a7c4e 0%, #6ba06f 60%, #8bb88f 100%);
  color: #fff;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; top: -2rem; right: -2rem;
  width: 8rem; height: 8rem;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%);
  border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute; bottom: -3rem; left: -1rem;
  width: 6rem; height: 6rem;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
  border-radius: 50%;
}
.hero-decor {
  position: absolute; top: 0.3rem; right: 0.3rem; font-size: 0.7rem; opacity: 0.18;
  letter-spacing: 0.1rem;
}
.hero-title {
  position: relative; z-index: 2;
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.04rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  margin-bottom: 0.16rem;
}
.hero-subtitle {
  position: relative; z-index: 2;
  font-size: 0.24rem; opacity: 0.95; font-weight: 300;
  margin-bottom: 0.4rem;
}

/* ========== 通用内容区 ========== */
.section { padding: 0.32rem 0.3rem 0; }
.section-title {
  display: flex; align-items: center; gap: 0.16rem;
  font-size: 0.34rem; font-weight: 700; color: var(--text-main);
  margin-bottom: 0.24rem; padding: 0 0.04rem;
}
.section-title::before {
  content: ''; width: 0.08rem; height: 0.32rem;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 0.04rem;
}
/* ========== 卡片 ========== */
.card {
  background: var(--bg-card); border-radius: 0.28rem;
  padding: 0.32rem 0.28rem; margin-bottom: 0.24rem;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.card-title {
  font-size: 0.3rem; font-weight: 700; color: var(--text-main);
  margin-bottom: 0.2rem; display: flex; align-items: center; justify-content: space-between;
}
.card-title .tag {
  font-size: 0.2rem; padding: 0.04rem 0.16rem;
  background: rgba(74,124,78,0.1); color: var(--primary);
  border-radius: 0.2rem; font-weight: 500;
}

/* ========== 总计卡 ========== */
.total-card {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 70%, var(--primary-light) 100%);
  color: #fff; border-radius: 0.28rem; padding: 0.32rem 0.32rem 0.28rem;
  margin-bottom: 0.24rem; box-shadow: 0 0.12rem 0.3rem rgba(45,90,61,0.28);
}
.total-label { font-size: 0.22rem; opacity: 0.88; letter-spacing: 0.02rem; }
.total-row { display: flex; align-items: baseline; gap: 0.16rem; flex-wrap: wrap; margin-top: 0.08rem; }
.total-kg { font-size: 0.68rem; font-weight: 800; line-height: 1.1; }
.total-unit { font-size: 0.26rem; opacity: 0.92; }
.total-jin { font-size: 0.26rem; font-weight: 600; opacity: 0.95; }
.total-eq { font-size: 0.22rem; opacity: 0.9; margin-top: 0.16rem; }
.total-month { font-size: 0.22rem; opacity: 0.9; margin-top: 0.06rem; }
/* 配比不满 100% 时的说明（浅色胶囊，不抢主数字） */
.total-gap {
  display: inline-block; margin-top: 0.14rem;
  background: rgba(255,255,255,0.18); border-radius: 0.14rem;
  padding: 0.08rem 0.16rem; font-size: 0.2rem; line-height: 1.5;
}

/* 清单 */
.list-note { font-size: 0.2rem; color: var(--text-muted); margin-bottom: 0.08rem; }
.list-total {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 2px solid var(--border); margin-top: 0.1rem; padding-top: 0.18rem;
  font-size: 0.26rem; font-weight: 800; color: var(--primary-dark);
}
.list-total small { font-weight: 400; font-size: 0.2rem; color: var(--text-sub); }

/* ========== 营养浓度 ========== */
.nutrition-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.16rem; }
.nutrition-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.18rem 0.22rem; background: var(--bg-soft);
  border-radius: 0.16rem; font-size: 0.24rem;
}
.nutrition-item .name { color: var(--text-sub); }
.nutrition-item .value { color: var(--primary-dark); font-weight: 700; }
.nutrition-item .value small { font-size: 0.18rem; color: var(--text-muted); font-weight: 400; margin-left: 0.04rem; }

/* ========== 标准对照表 ========== */
.standards-table { width: 100%; border-collapse: collapse; font-size: 0.22rem; }
.standards-table th, .standards-table td {
  padding: 0.14rem 0.08rem; text-align: center; border: 1px solid var(--border);
}
.standards-table th { background: var(--primary); color: #fff; font-weight: 600; font-size: 0.2rem; }
.standards-table td { background: #fff; }
.standards-table tr.highlight td { background: rgba(232,168,71,0.1); font-weight: 700; color: var(--accent); }
.standards-table td:first-child { text-align: left; font-weight: 600; color: var(--text-main); }
.standards-table .stage-tag { font-size: 0.18rem; padding: 0.02rem 0.1rem; background: var(--bg-soft); color: var(--text-sub); border-radius: 0.1rem; }

/* ========== 原料库 ========== */

/* ========== 通用工具 ========== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(0.1rem); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s ease; }

/* ========== 底部信息 ========== */
.footer {
  text-align: center; padding: 0.4rem 0.2rem 0.2rem;
  font-size: 0.2rem; color: var(--text-muted);
}
.footer .brand { color: var(--primary); font-weight: 600; }

/* ========== 浮动操作 ========== */
.fab {
  position: fixed; right: 0.3rem; bottom: 0.6rem;
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 0.4rem; box-shadow: 0 4px 16px rgba(232,168,71,0.5);
  z-index: 100; border: none;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(232,168,71,0.5); }
  50% { box-shadow: 0 4px 24px rgba(232,168,71,0.8); }
}
.fab:active { transform: scale(0.92); }

/* ========== 弹窗 ========== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; display: none; align-items: flex-end; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--bg-soft); width: 100%; max-width: 750px;
  border-radius: 0.32rem 0.32rem 0 0; padding: 0.4rem 0.3rem 0.5rem;
  max-height: 80vh; overflow-y: auto; animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 0.8rem; height: 0.08rem; background: var(--border); border-radius: 0.04rem; margin: 0 auto 0.24rem; }
.modal-title { font-size: 0.34rem; font-weight: 700; text-align: center; margin-bottom: 0.24rem; }

/* ========== 阶段选择器 ========== */
.stage-picker {
  display: flex; flex-wrap: wrap; gap: 0.16rem; margin-bottom: 0.2rem;
}
.stage-chip {
  flex: 1 1 calc(33% - 0.16rem); min-width: calc(33% - 0.16rem);
  background: #fff; border: 1px solid var(--border); border-radius: 0.2rem;
  padding: 0.2rem 0.12rem; text-align: center; transition: all 0.2s;
}
.stage-chip:active { transform: scale(0.96); }
.stage-chip.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-color: var(--primary); box-shadow: var(--shadow-lg);
}
.stage-chip .stage-name { display: block; font-size: 0.26rem; font-weight: 700; color: var(--text-main); }
.stage-chip .stage-sub { display: block; font-size: 0.18rem; color: var(--text-muted); margin-top: 0.04rem; }
.stage-chip.active .stage-name { color: #fff; }
.stage-chip.active .stage-sub { color: rgba(255,255,255,0.85); }

/* ========== 提示条 ========== */
.hint-bar {
  background: rgba(74,124,78,0.08); border: 1px dashed rgba(74,124,78,0.35);
  border-radius: 0.16rem; padding: 0.18rem 0.22rem;
  font-size: 0.22rem; color: var(--primary-dark); line-height: 1.7;
}
.hint-bar b { color: var(--primary-dark); }
.hint-bar.small { margin-bottom: 0.2rem; font-size: 0.2rem; color: var(--text-sub); }

/* ========== 要点列表 ========== */
.tips-list {
  list-style: none; font-size: 0.24rem; color: var(--text-main); line-height: 1.7;
}
.tips-list li { position: relative; padding: 0.08rem 0 0.08rem 0.36rem; }
.tips-list li::before {
  content: '✅'; position: absolute; left: 0; top: 0.08rem; font-size: 0.22rem;
}
.tips-list li:nth-child(even)::before { content: '🌿'; }
.tips-list li b { color: var(--primary-dark); }
ol.tips-list { counter-reset: tip; }
ol.tips-list li::before {
  content: counter(tip); counter-increment: tip;
  width: 0.26rem; height: 0.26rem; background: var(--primary); color: #fff;
  border-radius: 50%; font-size: 0.18rem; display: flex; align-items: center; justify-content: center;
  top: 0.14rem;
}

.card-note {
  margin-top: 0.16rem; font-size: 0.2rem; color: var(--text-muted); line-height: 1.7;
}
.card-note b { color: var(--text-sub); }

/* ========== 原料库 ========== */
.ing-left { display: flex; align-items: center; gap: 0.16rem; }
.ing-dot { width: 0.14rem; height: 0.14rem; border-radius: 50%; flex-shrink: 0; }
.ing-dot.rough { background: var(--primary); }
.ing-dot.conc { background: var(--accent); }
.ing-dot.premix { background: #8b7bb8; }

/* ========== 结果分组明细 ========== */
.detail-group {
  background: var(--bg-soft); border-radius: 0.16rem; padding: 0.18rem 0.2rem; margin-bottom: 0.16rem;
}
.detail-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.24rem; font-weight: 700; color: var(--primary-dark);
  padding-bottom: 0.1rem; margin-bottom: 0.06rem;
  border-bottom: 1px dashed var(--border);
}
.detail-head span:first-child { display: inline-flex; align-items: center; gap: 0.1rem; }

/* ========== 简化版单页 ========== */
.hero.slim { padding: 0.44rem 0.4rem 0.5rem; }
.hero.slim .hero-title { font-size: 0.44rem; margin-bottom: 0.1rem; }
.hero.slim .hero-subtitle { font-size: 0.24rem; margin-bottom: 0; }
.title-note { font-size: 0.2rem; font-weight: 400; color: var(--text-muted); margin-left: 0.08rem; }

/* 输入 */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem; margin-bottom: 0.2rem; }
.field label { display: block; font-size: 0.22rem; color: var(--text-sub); margin-bottom: 0.08rem; }
.field-box {
  display: flex; align-items: center; gap: 0.12rem;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 0.16rem; padding: 0.14rem 0.2rem;
}
.field-box input {
  flex: 1; min-width: 0; border: none; background: transparent; outline: none;
  font-size: 0.3rem; font-weight: 700; color: var(--primary-dark);
}
.field-box .unit { font-size: 0.22rem; color: var(--text-muted); flex-shrink: 0; }
/* 单位换算提示 */
.unit-hint {
  font-size: 0.2rem; color: var(--primary-dark); font-weight: 600;
  background: rgba(74,124,78,0.08); border-radius: 0.12rem;
  padding: 0.1rem 0.18rem; margin: -0.06rem 0 0.18rem;
}
.dmi-edit { margin-top: 0.16rem; }
.intake-line {
  display: flex; align-items: center; gap: 0.16rem;
  background: rgba(74,124,78,0.06); border-radius: 0.16rem;
  padding: 0.16rem 0.2rem; font-size: 0.24rem; color: var(--text-main);
}
.intake-line .intake-val { font-weight: 800; color: var(--primary-dark); font-size: 0.28rem; }
.intake-line span:first-child { flex: 1; }

.mini-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text-sub);
  border-radius: 0.4rem; padding: 0.1rem 0.24rem; font-size: 0.22rem;
  transition: all 0.15s; white-space: nowrap;
}
.mini-btn:active { transform: scale(0.95); }
.mini-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-row { display: flex; align-items: center; gap: 0.16rem; margin-bottom: 0.24rem; }
.pick-count { font-size: 0.22rem; color: var(--text-muted); margin-left: auto; }

/* 选料处的即时提醒 */
.pick-hint { font-size: 0.21rem; line-height: 1.6; color: var(--text-muted); margin-bottom: 0.14rem; }
.pick-hint:empty { display: none; }
.pick-hint.warn {
  color: #9a6b1f; background: rgba(232,168,71,0.12);
  border-radius: 0.12rem; padding: 0.1rem 0.16rem;
}

/* 原料选择（折叠下拉） */
.picker-group {
  background: #fff; border: 1px solid var(--border); border-radius: 0.2rem;
  margin-bottom: 0.14rem; overflow: hidden;
}
.picker-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 0.12rem; background: transparent; border: none;
  padding: 0.24rem 0.24rem; font-size: 0.26rem; font-weight: 700; color: var(--text-main);
  text-align: left;
}
.picker-head:active { background: var(--bg-soft); }
.ph-left { display: flex; flex-direction: column; gap: 0.04rem; min-width: 0; }
.ph-name { font-size: 0.26rem; font-weight: 700; color: var(--text-main); }
.ph-desc { font-size: 0.18rem; font-weight: 400; color: var(--text-muted); }
.ph-total { font-size: 0.2rem; }
.ph-right { display: inline-flex; align-items: center; gap: 0.12rem; font-size: 0.2rem; font-weight: 400; color: var(--text-muted); white-space: nowrap; }
.ph-picked { color: var(--primary-dark); font-weight: 700; background: rgba(74,124,78,0.12); border-radius: 0.2rem; padding: 0.03rem 0.14rem; }
.chev { display: inline-block; transition: transform 0.2s; color: var(--text-muted); }
.picker-group.open .chev { transform: rotate(180deg); }
.picker-body { display: none; padding: 0 0.2rem 0.2rem; }
.picker-group.open .picker-body { display: block; }
.picker-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.12rem; }
.pick-item {
  background: #fff; border: 1.5px solid var(--border); border-radius: 0.18rem;
  padding: 0.16rem 0.18rem; text-align: left; transition: all 0.15s;
}
.pick-item:active { transform: scale(0.97); }
.pick-item .pick-name { display: block; font-size: 0.24rem; font-weight: 600; color: var(--text-main); }
.pick-item .pick-unused { display: block; font-size: 0.18rem; color: var(--text-muted); margin-top: 0.04rem; }
.pick-item.on { border-color: var(--primary); background: rgba(74,124,78,0.07); }
.pick-item.on .pick-name::after { content: ' ✓'; color: var(--primary); font-weight: 800; }
.pick-item.off .pick-name, .pick-item.off .pick-unused { color: var(--text-muted); }

/* ========== 确定按钮 ========== */
.confirm-wrap { padding: 0.2rem 0.3rem 0.1rem; }
.confirm-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.16rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff; border: none; border-radius: 0.24rem;
  padding: 0.28rem 0.32rem; box-shadow: 0 0.1rem 0.24rem rgba(74,124,78,0.26);
  transition: transform 0.15s, box-shadow 0.2s;
}
.confirm-btn:active { transform: scale(0.98); }
.confirm-btn .confirm-main { font-size: 0.3rem; font-weight: 800; white-space: nowrap; }
.confirm-btn .confirm-sub { font-size: 0.22rem; opacity: 0.92; }
.confirm-btn.dirty { animation: btnPulse 1.8s ease-in-out infinite; }
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0.1rem 0.24rem rgba(74,124,78,0.26); }
  50% { box-shadow: 0 0.1rem 0.4rem rgba(74,124,78,0.55); }
}
.confirm-tip {
  max-height: 0; overflow: hidden; opacity: 0;
  font-size: 0.22rem; color: #9a6b1f; line-height: 1.7;
  background: rgba(232,168,71,0.16); border-radius: 0.16rem;
  margin-top: 0; transition: all 0.2s;
}
.confirm-tip.show { max-height: 3rem; opacity: 1; padding: 0.16rem 0.2rem; margin-top: 0.16rem; }

/* 结果区 */
.result-section { scroll-margin-top: 0.2rem; }
.dirty-bar {
  background: rgba(232,168,71,0.16); border: 1px dashed rgba(232,168,71,0.6);
  color: #9a6b1f; font-size: 0.22rem; text-align: center;
  border-radius: 0.16rem; padding: 0.16rem 0.2rem; margin-bottom: 0.22rem;
}

/* 警告 */
.warn-box {
  background: rgba(232,168,71,0.12); border: 1px dashed rgba(232,168,71,0.5);
  border-radius: 0.16rem; padding: 0.18rem 0.22rem; margin-bottom: 0.24rem;
  font-size: 0.22rem; color: #9a6b1f; line-height: 1.8;
}

/* 模式切换 */
.mode-row { display: flex; align-items: center; gap: 0.16rem; margin-bottom: 0.2rem; }
.mode-label { font-size: 0.24rem; color: var(--text-sub); }
.mode-tabs { display: flex; background: var(--bg-soft); border-radius: 0.3rem; padding: 0.05rem; }
.mode-tab {
  border: none; background: transparent; padding: 0.1rem 0.24rem;
  font-size: 0.22rem; color: var(--text-sub); border-radius: 0.3rem;
}
.mode-tab.active { background: var(--primary); color: #fff; font-weight: 600; }
.sum-badge {
  margin-left: auto; font-size: 0.22rem; font-weight: 700; color: var(--primary-dark);
  background: rgba(74,124,78,0.1); border-radius: 0.3rem; padding: 0.08rem 0.2rem;
}
.sum-badge.bad { color: #b3560f; background: rgba(232,168,71,0.2); }

/* 结果明细 */
.mix-item {
  display: flex; justify-content: space-between; align-items: center; gap: 0.16rem;
  padding: 0.14rem 0; border-bottom: 1px dashed var(--border);
}
.mix-item:last-child { border-bottom: none; }
.mix-left { flex: 1; min-width: 0; }
.mix-name { font-size: 0.24rem; font-weight: 600; color: var(--text-main); }
.mix-range { font-size: 0.18rem; color: var(--text-muted); margin: 0.02rem 0 0.06rem; }
.mix-right { text-align: right; flex-shrink: 0; }
.mix-pct { display: inline-block; font-size: 0.2rem; font-weight: 700; color: var(--primary-dark); background: rgba(74,124,78,0.1); border-radius: 0.16rem; padding: 0.02rem 0.12rem; }
.mix-kg { display: block; font-size: 0.26rem; color: var(--text-main); font-weight: 800; margin-top: 0.04rem; }
.mix-jin { display: block; font-size: 0.2rem; color: var(--accent); font-weight: 600; margin-top: 0.02rem; }
.mix-per { font-size: 0.18rem; color: var(--text-muted); margin-top: 0.02rem; }
.zero { color: var(--text-muted); font-size: 0.2rem; font-weight: 400; }
.mix-edit input {
  width: 1.3rem; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 0.12rem; padding: 0.08rem 0.12rem; font-size: 0.24rem;
  text-align: right; color: var(--text-main); outline: none;
}
.mix-edit.err input { border-color: #d9822b; background: rgba(232,168,71,0.12); color: #9a6b1f; }
.mix-edit.err::after { content: ' 超出建议区间'; font-size: 0.18rem; color: #9a6b1f; }

/* 参考折叠 */
.ref-details { padding-bottom: 0.4rem; }
.ref-details summary {
  font-size: 0.26rem; font-weight: 600; color: var(--primary);
  padding: 0.2rem 0.3rem; cursor: pointer; list-style: none;
}
.ref-details summary::before { content: '▸ '; }
.ref-details[open] summary::before { content: '▾ '; }
.ref-details .card { margin: 0 0.3rem 0.24rem; }
