:root {
  --bg: #f4f1ec;
  --card: #fffdf9;
  --ink: #3b3a36;
  --sub: #85807a;
  --line: #e4ddd2;
  --sage: #6f8f72;
  --sage-d: #4f6b53;
  --sage-l: #e7efe5;
  --lav: #8a76b0;
  --lav-l: #efeaf7;
  --amber: #b5793a;
  --red: #b4513f;
  --zoom: 1;
}
* { box-sizing: border-box; }
html { font-size: calc(16px * var(--zoom)); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Microsoft JhengHei UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
input[type=number]::-webkit-inner-spin-button { opacity: .5; }

/* 頁首 */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: .6rem 1.2rem; background: var(--sage-d); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.logo { font-size: 1.9rem; }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: .05em; }
.brand-sub { font-size: .78rem; opacity: .8; }
.tabs { display: flex; gap: .3rem; flex: 1; flex-wrap: wrap; }
.tab {
  border: 0; background: transparent; color: #fff; opacity: .78;
  padding: .45rem .9rem; border-radius: 999px; cursor: pointer; font-size: 1rem; white-space: nowrap;
}
@media (max-width: 1100px) {
  .top { gap: .7rem; }
  .brand-sub { display: none; }
  .tab { padding: .45rem .6rem; }
}
.tab:hover { opacity: 1; background: rgba(255,255,255,.12); }
.tab.on { opacity: 1; background: #fff; color: var(--sage-d); font-weight: 700; }
.badge { font-size: .75rem; background: var(--lav); color: #fff; border-radius: 999px; padding: 0 .45rem; margin-left: .2rem; }
.badge:empty { display: none; }
.zoom #toBottom { margin-left: .3rem; }
.btns .m-top { margin-left: auto; }
.zoom button {
  border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff;
  border-radius: 6px; padding: .2rem .55rem; cursor: pointer;
}
.zoom button:hover { background: rgba(255,255,255,.15); }

main { max-width: 1280px; margin: 0 auto; padding: 1rem 1.2rem 2rem; }
.page { display: none; }
.page.on { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem 1.2rem; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(80,60,30,.05);
}
.card h2 { margin: 0; font-size: 1.15rem; color: var(--sage-d); }
.step { display: flex; align-items: center; gap: .55rem; font-size: 1.15rem; font-weight: 700; margin-bottom: .8rem; color: var(--sage-d); }
.step small { font-weight: 400; color: var(--sub); font-size: .8rem; letter-spacing: .05em; }
.step .step-btn { margin-left: auto; font-weight: 700; color: var(--sage-d); }
.rc-box { border: 2px solid var(--sage); border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; background: var(--bg); }
.rc-box[hidden] { display: none; }
/* 濃度換算（按摩油／調和油），樣式跟比例計算器一樣 */
.step .step-btn + .step-btn { margin-left: .4rem; }
.step .step-btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(1); }
.dc-box { border: 2px solid var(--lav, #9b7fc9); border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; background: var(--bg); }
.dc-box[hidden] { display: none; }
.dc-box .chips { margin: .2rem 0 .6rem; }
.rc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .8rem; margin-bottom: .5rem; color: var(--sage-d); }
.rc-head .sub { font-size: .82rem; color: var(--sub); }
.num {
  display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--sage); color: #fff; font-size: .95rem;
}

.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
.col-side { position: sticky; top: 5.2rem; }
@media (max-width: 960px) {
  .calc-grid { grid-template-columns: 1fr; }
  .col-side { position: static; }
}

.row2 { display: grid; grid-template-columns: 1fr 200px; gap: .8rem; }
@media (max-width: 600px) { .row2 { grid-template-columns: 1fr; } }
.fld { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .5rem; }
.fld > span { font-size: .85rem; color: var(--sub); }
.fld.inline { flex-direction: row; align-items: center; gap: .8rem; }
.fld.inline .unit { width: 130px; }
input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: .45rem .6rem; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-l); }
textarea { resize: vertical; }
.unit { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.unit:focus-within { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-l); }
.unit input { border: 0 !important; box-shadow: none !important; text-align: right; }
.unit em { font-style: normal; color: var(--sub); padding: 0 .7rem 0 .2rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; cursor: pointer;
  padding: .3rem .8rem; font-size: .9rem;
}
.chip:hover { border-color: var(--sage); }
.chip.on { background: var(--sage); border-color: var(--sage); color: #fff; }
.chip small { opacity: .75; margin-left: .3rem; }

.pct-line { display: flex; align-items: center; gap: 1rem; }
.pct-line input[type=range] { flex: 1; accent-color: var(--sage); height: 1.6rem; }
.pct-box { width: 120px; }
.pct-box input { font-size: 1.2rem; font-weight: 700; }

.target {
  margin-top: .9rem; padding: .8rem 1rem; border-radius: 12px; background: var(--sage-l);
  display: grid; grid-template-columns: auto 1fr; column-gap: 1.2rem; align-items: center;
}
.target-lbl { font-size: .85rem; color: var(--sage-d); grid-column: 1; }
.target-num { grid-column: 1; grid-row: 2; font-size: 1.1rem; color: var(--sage-d); }
.target-num b { font-size: 2.4rem; line-height: 1.1; }
.target-f { grid-column: 2; grid-row: 1 / 3; color: var(--sage-d); font-size: .95rem; }
.target-hint { grid-column: 1 / 3; font-size: .85rem; color: var(--amber); margin-top: .3rem; }
.target-hint:empty { display: none; }

/* 精油列 */
table.eo { width: 100%; border-collapse: separate; border-spacing: 0 .35rem; }
table.eo th { text-align: left; font-size: .8rem; color: var(--sub); font-weight: 400; padding: 0 .3rem; }
table.eo td { padding: 0 .3rem; vertical-align: middle; }
.c-ratio { width: 90px; } .c-drops { width: 120px; } .c-cost { width: 130px; } .c-x { width: 36px; }
td.cost-cell { font-size: .85rem; color: var(--sub); line-height: 1.3; }
td.cost-cell b { color: var(--ink); font-size: .95rem; }
td.cost-cell .nop { color: #c0b8ab; }
.drops-wrap { position: relative; }
.drops-wrap input { padding-right: 1.6rem; }
.drops-wrap.manual input { border-color: var(--lav); background: var(--lav-l); font-weight: 700; }
.drops-wrap .unman {
  position: absolute; right: .25rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer; color: var(--lav); font-size: .9rem; display: none;
}
.drops-wrap.manual .unman { display: block; }
.xbtn { border: 0; background: transparent; cursor: pointer; color: #bbb; font-size: 1.2rem; }
.xbtn:hover { color: var(--red); }
.eo-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.tag-manual { display: inline-block; background: var(--lav-l); color: var(--lav); border: 1px solid var(--lav); border-radius: 4px; font-size: .75rem; padding: 0 .3rem; margin: 0 .2rem; }
.tip { font-size: .85rem; color: var(--sub); margin: .7rem 0 0; }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer;
  padding: .45rem .9rem;
}
.btn:hover { border-color: var(--sage); }
.btn.primary { background: var(--sage); border-color: var(--sage); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--sage-d); }
.btn.ghost { background: transparent; border-style: dashed; color: var(--sage-d); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.wide { width: 100%; margin-top: .6rem; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }

/* 總覽 */
.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.kpi { background: var(--bg); border-radius: 10px; padding: .5rem .7rem; }
.kpi span { display: block; font-size: .78rem; color: var(--sub); }
.kpi b { font-size: 1.6rem; color: var(--sage-d); }
.sum-grid.g4 { grid-template-columns: repeat(4, 1fr); }
.sum-grid.g3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .sum-grid.g4, .sum-grid.g3 { grid-template-columns: 1fr 1fr; } }
.kpi b small { font-size: .95rem; color: var(--sub); font-weight: 400; }
.mode .card.sum .cost-line span:last-child { text-align: right; }
.mode .card.sum .cost { max-width: 720px; }
.kpi i { font-style: normal; color: var(--sub); margin-left: .2rem; font-size: .9rem; }
.warn { margin-top: .6rem; background: #fdf3e6; color: var(--amber); border-radius: 8px; padding: .45rem .7rem; font-size: .85rem; }
.cost { margin-top: .8rem; border-top: 1px dashed var(--line); padding-top: .7rem; }
.cost-total { display: flex; justify-content: space-between; align-items: baseline; }
.cost-total b { font-size: 1.7rem; color: var(--lav); }
.cost-line { display: flex; justify-content: space-between; font-size: .9rem; color: var(--sub); }
.missing { font-size: .8rem; color: var(--amber); margin-top: .3rem; }
.bt-line { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; align-items: end; margin-top: .7rem; }
.bt-info { font-size: .85rem; color: var(--sage-d); padding-bottom: .8rem; }
.bt-info.bad { color: var(--amber); }
@media (max-width: 600px) { .bt-line { grid-template-columns: 1fr; } }
.cost-line small { margin-left: .2rem; font-size: .8rem; }
.sell { margin-top: .8rem; border-top: 1px dashed var(--line); padding-top: .7rem; display: grid; gap: .45rem; }
.sell-row { display: grid; grid-template-columns: 6.5rem 1fr; align-items: center; gap: .5rem; font-size: .95rem; }
.sell-row .unit input { font-size: 1.15rem; font-weight: 700; color: var(--sage-d); }
.unit em.pre { padding: 0 0 0 .7rem; }
.sell-row.neg .unit input { color: var(--red); }
.sell-ref { font-size: .82rem; color: var(--sub); }
.disc-info { font-size: .82rem; color: var(--lav); margin: -.2rem 0 0 7rem; }
.disc-info:empty { display: none; }
/* 蝦皮價：勾選才顯示（body.fee-on） */
.fee-info { font-size: .9rem; color: var(--ink); background: #fff4ec; border-radius: 8px; padding: .45rem .7rem; line-height: 1.8; }
.fee-info b { color: #d4511e; }
.fee-info .sub { font-size: .8rem; color: var(--sub); }
.fee-info:empty { display: none; }
.fee-box { margin-top: .7rem; border-top: 1px dashed var(--line); padding-top: .6rem; display: grid; gap: .4rem; }
table.zt .c-fee { display: none; color: #d4511e; font-weight: 700; }
body.fee-on table.zt .c-fee { display: table-cell; }
table.zt .c-dp, .fee-info b.dp { color: #2f7d5b; }
table.zt .c-dp.neg, .fee-info .neg { color: var(--red); }
table.zt th.c-dp small { display: block; font-weight: 400; font-size: .75rem; }
.fee-only { display: none; }
body.fee-on .fee-only { display: flex; }
.fee-disc { align-items: center; gap: .4rem; font-size: .92rem; flex-wrap: wrap; }
.fee-disc .unit { width: 7rem; }
.sell-ref:empty { display: none; }
.sell-ref button { margin-left: .4rem; }
table.pt td.per small, table.pt td.gp small { display: block; color: var(--sub); font-weight: 400; }
table.pt td.gp { white-space: nowrap; color: var(--sage-d); font-weight: 700; }
table.pt td.gp.neg { color: var(--red); }
table.pt td.n input { width: 90px; }
table.pt td:first-child input { min-width: 9rem; }
table.pt th { white-space: nowrap; }
.card:has(table.pt) { overflow-x: auto; }
.save-box { margin-top: .8rem; border-top: 1px dashed var(--line); padding-top: .8rem; }
.btns { display: flex; gap: .5rem; margin-top: .5rem; }
.btns .btn { flex: 1; }
.chk { display: flex; gap: .4rem; align-items: flex-start; font-size: .82rem; color: var(--sub); margin-top: .6rem; cursor: pointer; }
.chk input { margin-top: .25rem; accent-color: var(--sage); }
.editing { font-size: .82rem; background: var(--lav-l); color: var(--lav); border-radius: 8px; padding: .35rem .6rem; }

/* 價目表：上層總搜尋＋三個子分頁 */
.psearch { position: relative; }
.psearch input { padding: .65rem .9rem .65rem 2.4rem; font-size: 1.05rem; border-radius: 12px; }
.psearch-ico { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); opacity: .6; }
.ptabs { display: flex; gap: .3rem; margin-top: .9rem; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.ptab {
  border: 0; background: transparent; cursor: pointer; padding: .5rem 1.1rem; font-size: 1rem;
  border-radius: 10px 10px 0 0; color: var(--sub); margin-bottom: -2px; border-bottom: 3px solid transparent;
}
.ptab:hover { color: var(--sage-d); background: var(--sage-l); }
.ptab.on { color: var(--sage-d); font-weight: 700; border-bottom-color: var(--sage); }
.ptab.zero { opacity: .45; }
.pcount { font-size: .78rem; background: var(--bg); border-radius: 999px; padding: 0 .5rem; margin-left: .2rem; font-weight: 400; }
.ptab.on .pcount { background: var(--sage); color: #fff; }
.search-sum { font-size: .85rem; color: var(--sub); margin-top: .5rem; }
.search-sum:empty { display: none; }
.ppanel { display: none; padding-top: .9rem; }
.ppanel.on { display: block; }
.nohit { text-align: center; color: var(--sub); padding: 1.5rem; }
/* 計算器主頁：兩種計算器各佔一半 */
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.modebtn {
  display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: center; text-align: left;
  border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: .7rem .9rem; cursor: pointer;
  box-shadow: 0 1px 3px rgba(80,60,30,.05);
}
.modebtn:hover { border-color: var(--sage); }
.modebtn .mi { grid-row: 1 / 3; font-size: 1.7rem; }
.modebtn .mt { font-weight: 700; color: var(--sage-d); font-size: 1.05rem; }
.modebtn .md { font-size: .78rem; color: var(--sub); line-height: 1.35; }
.modebtn.on { background: var(--sage); border-color: var(--sage); }
.modebtn.on .mt, .modebtn.on .md { color: #fff; }
.mode { display: none; }
.mode.on { display: block; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.row2.even { grid-template-columns: 1fr 1fr; }
.row2.even.c-row3 { grid-template-columns: 1fr 1fr 1.6fr; }
@media (max-width: 760px) { .row2.even.c-row3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .row3, .row2.even { grid-template-columns: 1fr; } }
.unit.sm { display: inline-flex; width: 7rem; }
.unit.sm input { padding: .25rem .4rem; }
.unit.w140 { width: 140px; }
/* 套裝：每一項各自選瓶子、各自算成本（2026-11-12） */
table.eo.st-tab { min-width: 860px; }
table.eo.st-tab { table-layout: fixed; }
table.eo.st-tab .c-name { width: 25%; } table.eo.st-tab .c-bt { width: 15%; }
table.eo.st-tab .c-ex { width: 10%; line-height: 1.2; } table.eo.st-tab .c-qty { width: 8%; }
table.eo.st-tab .c-num { width: 9%; text-align: right; line-height: 1.2; } table.eo.st-tab .c-x { width: 6%; }
table.eo.st-tab td.cost-cell { text-align: right; white-space: nowrap; }
table.eo.st-tab .unit.sm { width: 100%; }
table.eo.st-tab select { width: 100%; }
table.eo.st-tab tfoot td { border-top: 1px dashed var(--line); padding-top: .45rem; font-size: .9rem; }
table.eo.st-tab .t-ftl { text-align: right; color: var(--sub); }
/* 商品：勾「含稅計算」才顯示營業稅那一列 */
#mode-product:not(.tax-on) .tax-only { display: none; }
/* 非蝦皮價固定自動算：售價、毛利率兩格只顯示不能改 */
table.ch-tab .unit:has(input[readonly]) { background: var(--sage-l); border-color: transparent; }
table.ch-tab input[readonly] { cursor: default; color: var(--sage-d); }
/* 商品：列印／複製選項 */
.p-print { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; align-items: center; margin-top: .7rem; padding: .55rem .8rem; border: 1px dashed var(--line); border-radius: 10px; }
.p-print .sub { color: var(--sub); font-size: .85rem; }
.p-cheap { margin-left: auto; color: var(--sage-d); }
/* 商品：合併計算（從我的配方加入的配方、復方） */
.t-addRec { width: auto; max-width: 280px; padding: .45rem .6rem; border: 1px dashed var(--sage); border-radius: 10px; color: var(--sage-d); background: transparent; cursor: pointer; }
table.eo.st-tab .i-src { display: block; width: 100%; text-align: left; font: inherit; border: 0; cursor: pointer; padding: .5rem .6rem; border-radius: 8px; background: #efe9f6; color: #5b4a7a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.eo.st-tab .i-src:hover { background: #e3d9f0; text-decoration: underline; }
/* 從合併計算跳到我的配方時，那一筆閃一下 */
@keyframes recFlash { 0%, 60% { box-shadow: 0 0 0 3px #9b7fc9; background: #f4effa; } 100% { box-shadow: none; } }
.rec.flash { animation: recFlash 2.5s ease-out; }
/* 沒有成本價的提示：點了跳到價目表那一列並閃爍 */
/* 復方比例合計：還剩多少／超過 */
.pct-ok { color: var(--sage-d); font-weight: 700; }
.pct-left { color: var(--amber); font-weight: 700; }
.pct-over { color: var(--red); font-weight: 700; }
.info-line.c-info.pct-bad { background: #fff4e5; border-color: #f0c98a; }
a.miss-link { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
a.miss-link:hover { color: #b0451c; }
@keyframes priceFlash { 0%, 100% { background-color: transparent; box-shadow: none; } 50% { background-color: #ffe27a; box-shadow: 0 0 0 3px #f0a020; } }
tbody tr.flash td, tbody tr.flash input, tbody tr.flash select { animation: priceFlash .5s ease-in-out 6; }
table.eo.st-tab .i-btfix { font-size: .9rem; line-height: 1.3; }
table.eo.st-tab .i-btfix small { display: block; color: var(--sub); }
/* 商品：三通路定價表 */
table.ch-tab { width: 100%; min-width: 560px; border-collapse: collapse; table-layout: fixed; }
table.ch-tab th, table.ch-tab td { padding: .4rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.ch-tab thead th { text-align: right; font-size: 1rem; white-space: nowrap; }
table.ch-tab thead th small { display: block; font-weight: normal; color: var(--sub); font-size: .78rem; }
table.ch-tab tbody th { text-align: left; color: var(--sub); font-weight: normal; white-space: nowrap; width: 5em; }
table.ch-tab td.n { text-align: right; white-space: nowrap; }
table.ch-tab .unit { margin-left: auto; max-width: 150px; }
table.ch-tab .unit.sm { display: flex; width: 110px; } table.ch-tab .unit input { min-width: 0; }
table.ch-tab thead th:first-child { width: 4.5em; }
table.ch-tab .r-price input { font-weight: bold; font-size: 1.05rem; }
table.ch-tab .r-pf td { font-size: 1.05rem; }
table.ch-tab td small { color: var(--sub); }
table.ch-tab .neg, table.ch-tab .neg b { color: #c0392b; }
.p-autobox { margin-top: .2rem; min-height: 1.4em; }
.p-autobox .sub { color: var(--sub); font-size: .8rem; }
.p-opts { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; align-items: center; margin-top: .7rem; font-size: .92rem; color: var(--sub); }
.p-opts .unit.sm { display: inline-flex; width: 110px; vertical-align: middle; }
.p-set { margin-top: .6rem; }
.cost-line.total { color: var(--ink); border-top: 1px solid var(--line); margin-top: .2rem; padding-top: .3rem; }
/* 包材金額＋「從其它加入」 */
.packrow { display: flex; gap: .4rem; align-items: center; }
.packrow .unit { flex: 1 1 auto; min-width: 6rem; }
.packrow .unit.w140 { flex: 0 0 140px; }
.packrow .m-packAdd { flex: 0 1 auto; width: auto; max-width: 13rem; font-size: .88rem; color: var(--sub); }
.btns.wrap { flex-wrap: wrap; }
.btns.wrap .btn { flex: 0 1 auto; }
.chk.inl { margin-top: 0; align-items: center; }
.chk.inl input { margin-top: 0; }
.info-line { margin-top: .6rem; padding: .55rem .8rem; background: var(--sage-l); border-radius: 10px; color: var(--sage-d); font-size: .92rem; }
.info-line .sub { color: var(--sub); margin-left: .4rem; font-size: .85rem; }
.ztools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .9rem; margin-bottom: .6rem; }
.ztools select { width: auto; padding: .3rem .4rem; }
.zwrap { overflow-x: auto; }
table.zt { width: 100%; border-collapse: separate; border-spacing: 0; }
table.zt th { text-align: left; font-size: .8rem; color: var(--sub); font-weight: 400; padding: .3rem .4rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.zt td { padding: .3rem .4rem; border-bottom: 1px solid #f0ebe3; white-space: nowrap; }
table.zt th.n, table.zt td.n { text-align: right; }
table.zt td.z-name small { display: block; color: var(--sub); font-size: .75rem; }
table.zt th.z-exh { line-height: 1.25; white-space: normal; }
table.zt .unit.sm.z-exw { width: 5.6rem; }
table.zt td.z-pf { color: var(--sage-d); font-weight: 700; }
/* 復方規格表（每列自己新增）：裝量、防揮發、瓶子、做幾瓶 */
table.zt .unit.sm.z-mlw { width: 7rem; }
table.zt .unit.sm.z-mlw input { min-width: 0; flex: 1; }
table.zt td.z-all small { display: block; color: var(--sub); font-size: .75rem; }
table.zt input.z-qty { width: 4.2rem; text-align: right; }
table.zt td.z-btw select { min-width: 8.5rem; }
table.zt td.z-btw small { display: block; font-size: .75rem; }
#mode-compound .ztools { margin-top: .5rem; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
#mode-compound .ztools .z-info { flex: 1; min-width: 16rem; margin: 0; }
#mode-compound .z-foot { margin-top: .8rem; }
table.zt td.z-pf.neg { color: var(--red); }
table.zt td.z-disc { color: var(--lav); font-weight: 700; }
table.zt tr.off td { opacity: .45; }
table.zt tr.off td:first-child { opacity: 1; }
table.zt input[type=checkbox] { accent-color: var(--sage); width: 1.1rem; height: 1.1rem; }
.zwarn:empty { display: none; }
.c-use { width: 110px; }
.rtag { display: inline-block; font-size: .75rem; background: var(--lav-l); color: var(--lav); border-radius: 999px; padding: 0 .5rem; margin-right: .4rem; vertical-align: middle; font-weight: 400; }
/* 使用說明 */
.help .card { max-width: 900px; }
.help h2 { margin-bottom: .6rem; }
.help ol, .help ul { margin: 0; padding-left: 1.4rem; display: grid; gap: .5rem; line-height: 1.7; }
.help .eg { display: inline-block; margin-top: .2rem; font-size: .88rem; color: var(--lav); background: var(--lav-l); border-radius: 6px; padding: .1rem .5rem; }
.htable { width: 100%; border-collapse: separate; border-spacing: 0; }
.htable th, .htable td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.6; }
.htable th { font-size: .85rem; color: var(--sub); font-weight: 400; }
.htable td:first-child { white-space: nowrap; font-weight: 700; color: var(--sage-d); }
.htable td:nth-child(2) { white-space: nowrap; color: var(--sub); }
@media (max-width: 700px) { .htable td:nth-child(2) { white-space: normal; } }
.help dl { margin: 0; }
.help dt { font-weight: 700; color: var(--sage-d); margin-top: .7rem; }
.help dt:first-child { margin-top: 0; }
.help dd { margin: .2rem 0 0 0; line-height: 1.7; }
/* 精油子分類 */
.catbar { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.catbtn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; cursor: pointer;
  padding: .3rem .85rem; font-size: .92rem;
}
.catbtn:hover { border-color: var(--lav); }
.catbtn.on { background: var(--lav); border-color: var(--lav); color: #fff; font-weight: 700; }
.catbtn small { opacity: .75; margin-left: .25rem; }
.catbtn.zero { opacity: .45; }
.catbtn.mgr { border-style: dashed; color: var(--lav); background: transparent; }
.catmgr { margin-top: .7rem; background: var(--lav-l); border-radius: 12px; padding: .8rem 1rem; }
.catmgr-head { display: flex; gap: .8rem; align-items: baseline; flex-wrap: wrap; }
.catmgr-head .tip { margin: 0; }
.cat-list { display: grid; gap: .35rem; margin: .6rem 0; }
.cat-row { display: flex; gap: .4rem; align-items: center; }
.cat-row input { max-width: 16rem; }
.cat-row .n { font-size: .82rem; color: var(--sub); min-width: 3.5rem; }
.cat-row button { border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; padding: .15rem .5rem; }
.cat-row button:disabled { opacity: .3; cursor: default; }
.cat-row button.del:hover { color: var(--red); border-color: var(--red); }
.cat-add { display: flex; gap: .4rem; flex-wrap: wrap; }
.cat-add input { max-width: 16rem; }
table.pt td select { padding: .3rem .4rem; min-width: 7rem; }
/* 價目表 */
.price-head { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.price-head h2 { margin-right: auto; }
.price-head input { width: 220px; }
table.pt { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: .6rem; }
table.pt th { text-align: left; font-size: .8rem; color: var(--sub); font-weight: 400; padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
table.pt th.n, table.pt td.n { text-align: right; }
table.pt td { padding: .25rem .4rem; border-bottom: 1px solid #f0ebe3; }
table.pt td input { padding: .3rem .5rem; }
table.pt td.n input { text-align: right; width: 100px; }
table.pt td.per { color: var(--lav); font-weight: 700; white-space: nowrap; }
table.pt tr.hide { display: none; }
.data-loc { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-top: .8rem; font-size: .85rem; color: var(--sub); }
code { background: var(--bg); padding: .1rem .4rem; border-radius: 4px; }

/* 我的配方 */
.rec-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; margin-top: .8rem; }
.rec {
  border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; background: #fff;
  display: flex; flex-direction: column; gap: .3rem;
}
.rec h3 { margin: 0; font-size: 1.05rem; color: var(--sage-d); }
.rec .meta { font-size: .8rem; color: var(--sub); }
.rec .oils { font-size: .9rem; }
.rec .note { font-size: .82rem; color: var(--sub); white-space: pre-wrap; }
.rec .acts { display: flex; gap: .4rem; margin-top: .3rem; }
.empty { color: var(--sub); text-align: center; padding: 2rem; grid-column: 1 / -1; }

.foot { max-width: 1280px; margin: 0 auto; padding: 0 1.2rem 1.5rem; font-size: .8rem; color: var(--sub); }
.foot #ver { margin-left: .8rem; opacity: .7; }

.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%) translateY(150%);
  background: var(--ink); color: #fff; padding: .6rem 1.2rem; border-radius: 999px;
  transition: transform .25s, opacity .25s, visibility .25s; z-index: 50; pointer-events: none;
  opacity: 0; visibility: hidden;   /* 收起來時完全看不到（只往下移會露出一截黑色） */
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }

/* 商店資料（設定頁＋列印抬頭／頁尾，預覽和列印共用同一組樣式） */
.shop-grid { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: end; max-width: 640px; }
.shop-grid .chk { padding-bottom: .55rem; white-space: nowrap; }
.shop-preview { margin-top: 1rem; }
.paper { margin-top: .4rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #000; padding: .8rem 1rem; max-width: 640px; font-size: .95rem; }
.paper .pbody { color: #999; padding: .8rem 0; border-top: 1px dashed #ccc; border-bottom: 1px dashed #ccc; text-align: center; }
.pshop { font-size: 1.15em; font-weight: 700; letter-spacing: .1em; text-align: center; padding-bottom: .3em; margin-bottom: .6em; border-bottom: 2px solid #000; }
.pfoot { display: flex; flex-wrap: wrap; justify-content: center; gap: .3em 1.6em; font-size: .9em; color: #333; margin-top: .8em; padding-top: .4em; border-top: 1px solid #999; }
.pfoot:empty, .pshop:empty { display: none; }

/* 列印 */
.print-area { display: none; }
@media print {
  body { background: #fff; }
  .top, main, .foot, .toast { display: none !important; }
  .print-area { display: block; font-size: 12pt; color: #000; padding: 0 4mm; }
  .print-area h1 { font-size: 18pt; margin: 0 0 4pt; }
  .print-area .pm { color: #444; margin-bottom: 10pt; }
  .print-area table { width: 100%; border-spacing: 0; margin: 6pt 0 10pt; }
  .print-area th, .print-area td { text-align: left; padding: 4pt 6pt; border-bottom: 1px solid #999; }
  .print-area td.n, .print-area th.n { text-align: right; }
  .print-area .pnote { white-space: pre-wrap; border: 1px solid #999; padding: 6pt; margin-top: 8pt; }
  .print-area .pwarn { font-size: 9pt; color: #555; margin-top: 14pt; }
}

/* 計算器大按鈕說明裡的連結（例：商品計價說明裡的「配方調配」） */
.modebtn .mode-link { text-decoration: underline; font-weight: 700; cursor: pointer; }
.modebtn .mode-link:hover { opacity: .8; }

/* 說明裡的連結點過去：目的地計算器按鈕外框閃幾秒 */
@keyframes modeFlash { 0%, 100% { box-shadow: 0 0 0 0 rgba(240,160,32,0); } 50% { box-shadow: 0 0 0 4px #f0a020, 0 0 14px 4px rgba(255,210,90,.9); } }
/* 提示閃爍：hint-flash＝閃 3 次、hint-quick＝快閃 3 次、hint-slow＝閃 5 次 */
.hint-flash { animation: modeFlash .5s ease-in-out 3; }
.hint-quick { animation: modeFlash .25s ease-in-out 3; }
.hint-slow { animation: modeFlash .5s ease-in-out 5; }

/* 程式自己畫的確認視窗（uiConfirm）：取代瀏覽器 confirm() */
.ui-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(40,35,25,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.ui-dlg { background: var(--card); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.28); width: min(30rem, 100%); padding: 1.1rem 1.3rem 1rem; }
.ui-head { display: flex; align-items: center; gap: .7rem; font-size: 1.15rem; color: var(--sage-d); margin-bottom: .6rem; }
.ui-head svg { flex: none; }
.ui-msg { white-space: pre-line; line-height: 1.6; margin: 0 0 1rem 3.1rem; }
.ui-btns { display: flex; justify-content: flex-end; gap: .6rem; }

.hint-loop { animation: modeFlash .6s ease-in-out infinite; }

/* 2026-11-14 商品計價：一次插入好幾個瓶子／規格、各項定價表 */
.add-panel { border: 2px solid var(--sage); border-radius: 12px; padding: .8rem 1rem; margin: .6rem 0 1rem; background: var(--bg); }
.add-panel[hidden] { display: none; }
.add-panel .a-row { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: flex-end; margin: .4rem 0; }
.add-panel .a-namef { flex: 1 1 16rem; }
.add-panel .a-namef input { width: 100%; }
.add-panel .chips { margin: .4rem 0 .7rem; }
.chip.a-chk { cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; }
.chip.a-chk input { margin: 0; }
.chip.a-chk:has(input:checked) { background: var(--sage); border-color: var(--sage); color: #fff; }
.chip.a-chk.off { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.chip.a-chk.off small { text-decoration: none; }
table.q-tab { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.q-tab th, table.q-tab td { padding: .35rem .4rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.q-tab thead th { font-size: .8rem; color: var(--sub); font-weight: 400; white-space: nowrap; }
table.q-tab th.n, table.q-tab td.n { text-align: right; }
table.q-tab td small, table.q-tab th small { display: block; font-size: .75rem; color: var(--sub); font-weight: 400; }
table.q-tab .unit { width: 7.2rem; margin-left: auto; }
table.q-tab .unit.sm { display: flex; width: 5.6rem; margin-left: auto; }
table.q-tab .unit input { min-width: 0; }
table.q-tab .neg, table.q-tab .neg b { color: #c0392b; }
table.q-tab .q-autobox { min-height: 1.2em; }
table.q-tab .q-autobox .sub { font-size: .75rem; color: var(--sub); }
table.q-tab tbody.q-sum tr.q-total { background: rgba(127,160,120,.12); }
table.q-tab tbody.q-sum tr.q-total th, table.q-tab tbody.q-sum tr.q-total td { border-top: 2px solid var(--sage); }
table.q-tab tbody.q-sum tr.q-custom { background: rgba(230,180,80,.10); }
table.q-tab tbody.q-sum tr.q-ratio td { font-size: .9rem; }
table.q-tab tbody.q-sum th { text-align: left; white-space: nowrap; }

/* 「⬆ 跳到[…]」：捲回頁首後目標閃 10 次 */
.hint-ten { animation: modeFlash .5s ease-in-out 10; }

/* 存檔鈕正下方一行：回頁首＋跳到[…]，靠左排 */
.btns.m-navs { margin-top: .5rem; }
.btns.m-navs .m-top { margin-left: 0; }

/* 列印範本列 */
.tpl-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin: .8rem 0 .2rem; }
.tpl-row .tpl-btn.on { background: var(--sage); border-color: var(--sage); color: #fff; }
.tpl-row select { width: auto; }
.tpl-row .sub { font-size: .8rem; }
/* 設定頁：備份與匯出 */
.bk-box { margin-top: 1rem; padding-top: .8rem; border-top: 1px dashed var(--line); }
.bk-box .btns { margin: .4rem 0; }

/* 毛利警戒線 */
table.q-tab td.low { background: rgba(180,81,63,.12); }
table.q-tab td.low b, table.q-tab td.low small { color: var(--red); }
.rec.low { box-shadow: 0 0 0 2px rgba(180,81,63,.45); }
.rec .lowline { color: var(--red); font-size: .85rem; margin: .2rem 0; font-weight: bold; }
/* 第一次開的提示列 */
.first-run { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; border: 2px solid var(--sage); margin-bottom: 1rem; }
.first-run > span:not(.btns) { flex: 1 1 20rem; }
.first-run .btns { display: flex; gap: .5rem; }
/* 看範例導覽 */
#tourBox { position: fixed; z-index: 9999; background: var(--card); color: var(--ink); border: 2px solid #f0a020; border-radius: 12px;
  padding: .8rem 1rem; box-shadow: 0 8px 28px rgba(0,0,0,.25); line-height: 1.6; }
#tourBox .tour-txt > b:first-child { display: block; margin-bottom: .2rem; font-size: 1.05em; }
#tourBox .tour-btns { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; margin-top: .6rem; }
#tourBox .tour-btns .sub { margin-right: auto; color: var(--sub); }
.tour-hi { outline: 3px solid #f0a020; outline-offset: 3px; border-radius: 8px; animation: modeFlash .8s ease-in-out 3; }

/* 說明頁計算器表：怎麼用另起一行 */
.htable tr:has(+ .how-row) td { border-bottom: 0; padding-bottom: .2rem; }
.htable td.how { white-space: normal; font-weight: 400; color: var(--ink); padding-top: 0; padding-bottom: 1rem; }
.htable td.how .how-h { font-size: .85rem; color: var(--sub); margin-bottom: .2rem; }
