/* ═══ 色彩 token（依麗嬰 funbox Toys 官網 shop.funbox.com.tw）═══
   品牌層：logo 紅 #d50c1c、官網導覽列寶藍 #3156b0、方塊標誌粉 #ff91a4／灰 #858585。
   語意層：元件只引用這一層（--acc、--price、--err…），不要直接用品牌色。
   對比度（WCAG，一般文字要 ≥4.5）：
     --acc #3156b0 對白 6.8（按鈕白字放在上面也是 6.8）；未選分頁用 --mut #59636e 對白 6.1
     --price #d50c1c 對白 5.4（營收、售價強調，同官網促銷價用法）
     logo 灰 #858585 對白只有 3.7、粉 #ff91a4 只有 2.1 → 只當裝飾（logo、圖示、色條），不能當字色。
   一律白底（Mozo 2026-10-27：白底比較好），不跟系統切深色模式。
   選中分頁的指示條用 --acc 藍（非文字 UI 元件要 ≥3:1；粉 #ff91a4 對白只有 2.1，不能拿來當指示條）。 */
:root {
  /* 品牌 */
  --brand-red: #d50c1c; --brand-blue: #3156b0; --brand-pink: #ff91a4; --brand-gray: #858585;
  /* 中性 */
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f1f4f9; --line: #dde2ea; --fg: #1f2328; --mut: #59636e;
  /* 語意 */
  --acc: var(--brand-blue); --acc-fg: #ffffff; --acc-soft: #e8eefa;
  --price: var(--brand-red);
  --ok: #1a7f37; --ok-soft: #e6f4ea; --warn: #9a6700; --warn-soft: #fff4d6; --err: #c4161c; --err-soft: #fdecee;
  /* 形狀與間距 */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --tap: 44px; --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --logo: url("/brand/funbox-logo.png");
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.6 "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
a { color: var(--acc); }
.mut { color: var(--mut); } .err { color: var(--err); } .ok { color: var(--ok); } .warn { color: var(--warn); } .price { color: var(--price); }
.sm { font-size: .88em; }
.logo { display: block; width: 136px; height: 32px; background: var(--logo) left center / contain no-repeat; }

/* ═══ 登入 ═══ */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 380px); justify-content: center; align-content: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 30px 24px 24px; text-align: center; }
.login-card .logo { width: 180px; height: 42px; margin: 0 auto 10px; background-position: center; }
.login-card h1 { font-size: 1.15em; margin: 0 0 .2em; font-weight: 600; }
#gbtn { display: flex; justify-content: center; margin: 18px 0 8px; min-height: 44px; }
.inapp { display: flex; flex-direction: column; gap: 10px; width: 100%; text-align: left; }
.inapp p { margin: 0; }
.inapp .btn { display: block; text-align: center; text-decoration: none; }
.inapp .url { display: block; font-size: .85em; background: var(--surface-2); padding: 6px 8px; border-radius: 6px; overflow-wrap: anywhere; user-select: all; }

/* ═══ 頂端：白底 logo 列＋白底分頁列 ═══ */
.top { position: sticky; top: 0; z-index: 3; background: var(--surface); box-shadow: var(--shadow); padding-top: var(--safe-t); }
.top-row { display: flex; align-items: center; gap: 10px; max-width: 1200px; margin: 0 auto; padding: 8px 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--mut); white-space: nowrap; }
.brand-sub { font-size: .85em; border-left: 1px solid var(--line); padding-left: 10px; }
.me { display: flex; align-items: center; gap: 4px; margin-left: auto; font-size: .92em; }
.me-name { color: var(--mut); margin-right: 4px; }
.badge { display: inline-block; background: var(--acc-soft); color: var(--acc); border-radius: 999px; padding: 1px 9px; font-size: .82em; font-weight: 600; white-space: nowrap; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: var(--tap); height: var(--tap); padding: 0 8px;
  background: none; border: 0; border-radius: var(--r-sm); color: var(--fg); font: inherit; font-size: .9em; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:focus-visible, .btn:focus-visible, .chip:focus-visible, #tabs button:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#install { color: var(--acc); font-weight: 600; }
#reload.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.navbar { background: var(--surface); border-top: 1px solid var(--line); }
#tabs { display: flex; gap: 2px; max-width: 1200px; margin: 0 auto; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
#tabs button { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 10px 14px; color: var(--mut);
  font: inherit; cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; }
#tabs button:hover { color: var(--fg); }
#tabs button.on { color: var(--acc); font-weight: 600; border-bottom-color: var(--acc); }
#tabs .count { background: var(--brand-red); color: #fff; border-radius: 999px; font-size: .72em; padding: 0 6px; font-weight: 700; }

/* ═══ 內容 ═══ */
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
h2 { font-size: 1.2em; margin: 0; }
h3 { font-size: 1.05em; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.bar label { display: flex; flex-direction: column; font-size: .85em; color: var(--mut); gap: 2px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; min-height: var(--tap); }
input:focus, select:focus { outline: 2px solid var(--acc); outline-offset: 0; border-color: var(--acc); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  border-radius: var(--r-sm); padding: 8px 14px; min-height: var(--tap); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); font-weight: 600; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: default; }

/* 機台多選 */
.picker-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 220px; text-align: left;
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; min-height: var(--tap); cursor: pointer; }
.picker-btn::after { content: ""; width: 8px; height: 8px; border: solid var(--mut); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); flex: none; }
.picker-btn b { font-weight: 600; }
.pick-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pick-head h3 { margin: 0; }
.pick-tools { display: flex; gap: 6px; }
.pick-list { display: grid; gap: 2px; max-height: 55vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.pick-list label { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 4px 6px; border-radius: var(--r-sm); cursor: pointer; }
.pick-list label:hover { background: var(--surface-2); }
.pick-list input { width: 20px; height: 20px; min-height: 0; accent-color: var(--acc); flex: none; }
.pick-list .sub { color: var(--mut); font-size: .85em; }
.pick-foot { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
details.mgroup { margin-bottom: 14px; }
details.mgroup > summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; min-height: var(--tap); font-weight: 600; }
details.mgroup > summary::-webkit-details-marker { display: none; }
details.mgroup > summary::before { content: "▸"; color: var(--mut); margin-right: 6px; }
details.mgroup[open] > summary::before { content: "▾"; }
details.mgroup > summary .tags { margin-left: auto; font-weight: 400; }
details.mgroup > div { padding-top: 8px; }

/* 快速篩選膠囊（日期區間、庫存狀態） */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font: inherit; font-size: .9em; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 6px 14px; min-height: 36px; cursor: pointer; }
.chip.on { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); font-weight: 600; }
.chip .n { opacity: .8; margin-left: 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 10px 14px; }
.stat span { font-size: .85em; color: var(--mut); }
.stat b { display: block; font-size: 1.45em; line-height: 1.3; }

/* 機台卡 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.mcard { position: relative; display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow); padding: 14px 14px 12px 18px; overflow: hidden; }
.mcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--ok); }
.mcard.lag::before { background: var(--warn); }
.mcard.off::before { background: var(--mut); }
.mcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mcard-name { font-weight: 700; font-size: 1.05em; }
.mcard-loc { color: var(--mut); font-size: .88em; }
.mcard-today { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.mcard-today > span:first-child { white-space: nowrap; }
.mcard-today b { font-size: 1.35em; color: var(--price); }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--acc); border-radius: 4px; }
.meter.low i { background: var(--warn); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .8em; border-radius: 999px; padding: 1px 8px; background: var(--surface-2); color: var(--mut); white-space: nowrap; }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.mcard-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 2px; }
.mcard-actions .btn { min-height: 40px; font-size: .92em; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; background: var(--mut); }
.dot.on { background: var(--ok); } .dot.lag { background: var(--warn); }

/* 機台清單（同全家後台：一台一列；手機改成精簡三行，不做卡片） */
.mlist-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }
.mlist td { vertical-align: middle; }
.mlist tr.on td:first-child { box-shadow: inset 4px 0 var(--ok); }
.mlist tr.lag td:first-child { box-shadow: inset 4px 0 var(--warn); }
.mlist tr.off td:first-child { box-shadow: inset 4px 0 var(--mut); }
.mlist .ml-title { font-weight: 600; }
.mlist .ml-k { display: none; }
.mlist .ml-stock { min-width: 120px; }
.mlist .ml-act { text-align: right; }
.mlist .ml-ver .v-i { display: block; }
.mlist .ml-ver .v-sep { display: none; }
.mlist .sm-btn { min-height: 32px; padding: 4px 10px; font-size: .88em; margin-left: 6px; }

/* 表格 */
.tw { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: .9em; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { background: var(--surface-2); white-space: nowrap; font-weight: 600; font-size: .92em; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nw { white-space: nowrap; }
tr.empty td:first-child { box-shadow: inset 4px 0 var(--err); }
.bar-cell { min-width: 110px; }
.bar-cell .meter { margin-top: 4px; }

/* 表單 */
.form { display: grid; gap: 12px; max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: .9em; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 14px; }
.checks label { flex-direction: row; align-items: center; gap: 8px; min-height: 40px; }
.checks input { min-height: 0; width: 20px; height: 20px; accent-color: var(--acc); }
.chip { text-decoration: none; }
pre.csv { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8em; margin: 0; max-width: 520px; }
.note { font-size: .88em; color: var(--mut); margin: 6px 0 12px; }
.empty-state { text-align: center; color: var(--mut); padding: 32px 12px; }
.loading { color: var(--mut); padding: 24px 0; text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: var(--r-sm); max-width: calc(100% - 32px); z-index: 9; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); }

/* 底部說明面板（iOS 安裝教學） */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 8; }
.sheet-card { background: var(--surface); color: var(--fg); width: 100%; max-width: 480px; border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 20px 18px calc(18px + var(--safe-b)); display: grid; gap: 12px; }
.sheet-card h3 { margin: 0; }
.sheet-card ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
@media (min-width: 761px) { .sheet { align-items: center; } .sheet-card { border-radius: var(--r-lg); max-width: 520px; } }


/* ═══ 商品 ═══ */
/* 發佈列：目前機台版本＋未發佈修改＋發佈鈕 */
.pubbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 12px; border-left: 5px solid var(--ok); }
.pubbar.dirty { border-left-color: var(--warn); }
.pubbar-info { display: grid; gap: 4px; }
.tag.link { border: 0; font: inherit; font-size: .8em; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.gtools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.search { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }   /* min-width:0：不然輸入框的預設寬度會把整列撐出畫面 */
.search > svg.i { position: absolute; left: 10px; color: var(--mut); pointer-events: none; }
.search input { flex: 1; padding-left: 36px; min-width: 0; }
.search .icon-btn { position: absolute; right: 2px; }
.search:has(.icon-btn) input { padding-right: 46px; }
.gtools-btns { display: flex; gap: 8px; }

.glist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); overflow: hidden; }
.ghead, .gitem { display: grid; grid-template-columns: 52px minmax(0, 1fr) 130px 150px 80px 120px; grid-template-areas: "img name pid bar price state";
  align-items: center; gap: 4px 14px; padding: 8px 14px; }
.ghead { background: var(--surface-2); font-weight: 600; font-size: .85em; border-bottom: 1px solid var(--line); }
.ghead .num, .gprice { text-align: right; }
.gitem { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; font-size: .92em; }
.gitem:last-child { border-bottom: 0; }
.gitem:hover { background: var(--surface-2); }
.gitem:focus-visible { outline: 3px solid var(--acc); outline-offset: -3px; }
.gitem.off .gname b, .gitem.off .gprice { color: var(--mut); }
.gitem.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--acc-soft); } to { background: none; } }
.gthumb { grid-area: img; width: 52px; height: 52px; object-fit: contain; border-radius: var(--r-sm); background: var(--surface); }
.gthumb.none { background: var(--surface-2); }
.gthumb.none { display: flex; align-items: center; justify-content: center; text-align: center; font-size: .7em; color: var(--mut); line-height: 1.2; padding: 2px; }
.gthumb.big { width: 100%; height: 220px; }
.gname { grid-area: name; display: grid; min-width: 0; }
.gname b { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gpid { grid-area: pid; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.gbar { grid-area: bar; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.gprice { grid-area: price; font-weight: 600; white-space: nowrap; }
.gstate { grid-area: state; display: flex; gap: 4px; flex-wrap: wrap; }
.gmeta { grid-area: meta; display: none; }
.more { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 0; flex-wrap: wrap; }
.fab { display: none; }

/* 編輯面板：電腦版右側（清單看得到）、手機版全螢幕 */
.drawer { position: fixed; inset: 0; z-index: 7; background: rgba(0, 0, 0, .35); display: flex; justify-content: flex-end; }
.drawer-card { width: min(480px, 100%); height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: -4px 0 24px rgba(0, 0, 0, .18); }
#drawer-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.dhead { display: flex; align-items: center; gap: 6px; padding: calc(6px + var(--safe-t)) 12px 6px 6px; border-bottom: 1px solid var(--line); }
.dhead h3 { margin: 0; flex: 1; }
.dform { flex: 1; overflow-y: auto; display: grid; gap: 12px; align-content: start; padding: 14px 16px 20px; overscroll-behavior: contain; }
.dform label { display: flex; flex-direction: column; gap: 3px; font-size: .9em; }
.dform input, .dform textarea { width: 100%; }
.dform input[readonly] { background: var(--surface-2); color: var(--mut); }
.dfoot { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface); }
.gimg { display: grid; gap: 8px; }
.gimg-box { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.gimg-box .gthumb.big { border-radius: 0; }
.gimg-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.gimg-btns .btn, label.btn, .dform label.btn { flex-direction: row; align-items: center; font-size: 1em; cursor: pointer; }
#sheet-body > button.btn { width: 100%; margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline { display: flex; gap: 6px; }
.inline input { flex: 1; min-width: 0; }
label.switch { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: var(--tap); }
label.switch input { width: 22px; height: 22px; min-height: 0; accent-color: var(--acc); flex: none; }
label.switch > span:not(.mut) { font-weight: 600; }
label.switch .mut { flex-basis: 100%; padding-left: 32px; }
details.extra > summary { cursor: pointer; color: var(--mut); font-size: .9em; min-height: var(--tap); display: flex; align-items: center; }
details.extra[open] { display: grid; gap: 12px; }
body.noscroll { overflow: hidden; }
textarea { resize: vertical; }

/* 掃條碼 */
.scan { position: relative; border-radius: var(--r-md); overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scan video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: var(--brand-red); box-shadow: 0 0 8px var(--brand-red); }
ul.plain { margin: 0; padding-left: 1.2em; display: grid; gap: 2px; }
label.btn.file { justify-self: start; }
.pick-list label.mrow { align-items: flex-start; }
.mrow .grow { flex: 1; min-width: 0; }
.mrow .right { text-align: right; }
.sheet-card { max-height: 92vh; max-height: 92dvh; overflow-y: auto; }

/* ═══ 手機 ═══ */
@media (max-width: 760px) {
  .top-row { padding: 6px 8px 6px 12px; gap: 6px; }
  .logo { width: 112px; height: 26px; }
  .brand-sub, .me-name { display: none; }
  .icon-btn span { display: none; }
  #install span { display: inline; }

  /* 分頁改成底部導覽列（拇指點得到）；寶藍分頁列收起來 */
  .navbar { background: none; border: 0; }
  #tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; max-width: none; justify-content: space-around; gap: 0; overflow: visible;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + var(--safe-b)); box-shadow: 0 -1px 3px rgba(16, 24, 40, .06); }
  #tabs button { position: relative; flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 2px 4px; border-radius: var(--r-sm);
    border-bottom: 0; color: var(--mut); font-size: .72em; line-height: 1.2; }
  #tabs button svg.i { width: 23px; height: 23px; }
  #tabs button.on { color: var(--acc); background: var(--acc-soft); }
  #tabs button span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #tabs .count { position: absolute; top: 2px; left: 55%; font-size: .9em; }
  main { padding: 12px 12px calc(var(--nav-h) + 24px + var(--safe-b)); }
  .toast { bottom: calc(var(--nav-h) + 16px + var(--safe-b)); }

  .bar { display: grid; grid-template-columns: 1fr 1fr; }
  .bar label.full, .bar > span { grid-column: 1 / -1; }
  .bar select, .bar input { width: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 10px; padding: 0 12px; scrollbar-width: none; }
  .chip { flex: none; }

  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 8px 10px; }
  .stat b { font-size: 1.12em; }
  .cards { grid-template-columns: 1fr; }

  /* 機台清單：一台一段、分隔線隔開。第 1 行店名＋同步，第 2 行今日／庫存，第 3 行狀態＋按鈕 */
  .mlist-wrap { overflow: visible; }
  .mlist, .mlist tbody { display: block; }
  .mlist thead { display: none; }
  .mlist tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name sync" "name ver" "today stock" "tags act";
    gap: 2px 10px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); }
  .mlist tr:last-child { border-bottom: 0; }
  .mlist td { display: block; padding: 0; border: 0; box-shadow: none !important; }
  .mlist tr.on { box-shadow: inset 4px 0 var(--ok); } .mlist tr.lag { box-shadow: inset 4px 0 var(--warn); } .mlist tr.off { box-shadow: inset 4px 0 var(--mut); }
  .mlist .ml-name { grid-area: name; min-width: 0; }
  .mlist .ml-sync { grid-area: sync; text-align: right; font-size: .85em; color: var(--mut); }
  .mlist .ml-ver { grid-area: ver; text-align: right; font-size: .8em; color: var(--mut); }
  .mlist .ml-ver .v-i { display: inline; }
  .mlist .ml-ver .v-sep { display: inline; }
  .mlist .ml-today { grid-area: today; text-align: left; }
  .mlist .ml-stock { grid-area: stock; min-width: 110px; text-align: right; }
  .mlist .ml-last { display: none; }
  .mlist .ml-tags { grid-area: tags; align-self: center; }
  .mlist .ml-act { grid-area: act; align-self: center; }
  .mlist .ml-stock .meter { height: 6px; margin-top: 2px; }
  .mlist .ml-title { font-size: 1em; }
  .mlist .ml-k { display: inline; }

  /* 表格 → 一筆一張卡片：每格前面帶欄名（app.js labelTables 自動補 data-label） */
  .tw { background: none; border: 0; box-shadow: none; overflow: visible; }
  .tw table, .tw tbody, .tw tr, .tw td { display: block; width: 100%; }
  .tw thead { display: none; }
  .tw tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 8px 12px; margin-bottom: 10px; }
  .tw td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 4px 0; border: 0; text-align: right; white-space: normal; }
  .tw td::before { content: attr(data-label); color: var(--mut); text-align: left; flex: none; font-size: .9em; }
  .tw td:first-child { font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 4px; }
  .tw td.num, .tw td.nw { white-space: normal; }
  .tw td > .cell { min-width: 0; overflow-wrap: anywhere; }
  .tw td > .cell .mut { display: block; }
  .tw td:empty { display: none; }
  .tw td[colspan] { justify-content: center; }
  .tw td[colspan]::before { content: none; }
  .tw tr.empty { box-shadow: inset 4px 0 var(--err), var(--shadow); }
  .tw tr.empty td:first-child { box-shadow: none; }
  .bar-cell { min-width: 0; }
  .bar-cell .meter { width: 110px; margin-left: auto; }

  /* 商品：卡片（圖｜名稱＋價格｜代號｜條碼＋狀態）、右下角新增鈕、編輯全螢幕 */
  .pubbar { padding: 10px 12px; }
  .pubbar .btn { width: 100%; }
  .gtools { gap: 6px; }
  .gtools-btns { gap: 6px; flex: none; }
  .gtools-btns .btn span { display: none; }
  .gtools-btns .btn { width: var(--tap); padding: 0; }
  .gtools-btns [data-new] { display: none; }
  .glist { background: none; border: 0; box-shadow: none; overflow: visible; display: grid; gap: 8px; }
  .ghead { display: none; }
  .gpid, .gbar { display: none; }
  .gmeta { display: block; font-size: .85em; color: var(--mut); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .gitem { grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "img name price" "img meta state";
    gap: 2px 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }
  .gitem:last-child { border-bottom: 1px solid var(--line); }
  .gthumb { width: 56px; height: 56px; align-self: start; }
  .gstate { justify-content: flex-end; }
  .fab { display: flex; align-items: center; justify-content: center; position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + var(--safe-b)); z-index: 4;
    width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--acc); color: var(--acc-fg); box-shadow: 0 4px 14px rgba(16, 24, 40, .3); cursor: pointer; }
  .fab svg.i { width: 26px; height: 26px; }
  .more { padding-bottom: 72px; }
  .drawer { background: none; }
  .drawer-card { width: 100%; box-shadow: none; }
  .gthumb.big { height: 240px; }
  .dform input, .dform textarea, .dform select { font-size: 16px; }   /* iOS 小於 16px 會自動放大畫面 */
  .search input { font-size: 16px; }
}

/* 清單全文搜尋（app.js applySearch）：分頁標題下方，桌機與手機都是整列 */
.tsearch { display: flex; align-items: center; gap: 10px; margin: -4px 0 12px; }
.tsearch-f { position: relative; flex: 1; min-width: 0; max-width: 520px; display: block; }
.tsearch-f .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--mut); pointer-events: none; }
.tsearch-f input { width: 100%; padding-left: 36px; }
.tsearch .n { white-space: nowrap; }
.pick-search { width: 100%; margin: 10px 0 8px; }

/* 頁面上方過濾器（販售／庫存／商品，同全家後台 2c78e15）：桌機收成一張卡片——
   第一行期間（庫存：機台＋篩選）、第二行機台與日期、下載 CSV 靠右，搜尋框在最下面用分隔線隔開；
   控制項一律 40px 高才對得齊。手機照舊一行一項，搜尋框排回標題下方。 */
.filters { display: flex; flex-direction: column; }
.filters .seg { align-self: flex-start; }
@media (min-width: 761px) {
  .filters { gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 16px; }
  .filters > *, .filters .f-row > * { margin: 0; }
  .filters .f-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 20px; }
  .filters .bar { gap: 8px 12px; }
  .filters .f-end { margin-left: auto; }
  .filters input, .filters select, .filters .picker-btn, .filters .btn, .filters .chip { min-height: 40px; }
  .filters .picker-btn, .filters .btn { padding-top: 6px; padding-bottom: 6px; }
  .filters .seg button { min-height: 34px; }
  .filters .tsearch { padding-top: 12px; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .filters .f-row { display: contents; }
  .filters > .tsearch { order: -1; }
}

/* 卡機已扣款、販賣機沒有交易紀錄（販售記錄頁上方）*/
.gapbox { border: 1px solid var(--err); border-left-width: 4px; border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 14px; background: var(--surface); }
.gapbox > details.mgroup { margin: 0; }
.gapbox > details.mgroup > summary { font-size: 1.05em; }
/* 販售清單裡混排的那幾列（同樣是交易失敗、要人工刷退）*/
tr.gaprow > td { background: color-mix(in srgb, var(--err) 7%, transparent); }
.gapbox > p { margin: 0 0 10px; }
.gapbox .tw { box-shadow: none; }
.gapbox details.mgroup { margin: 10px 0 0; }
.gapbox td .btn { min-height: 36px; padding: 4px 12px; white-space: nowrap; }
label.gap-note { display: grid; gap: 4px; }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; }
.gapbox .retry { margin-top: 4px; color: var(--acc); }

/* 通報紀錄（只有 NOTIFY_VIEWERS 看得到）：一則一張卡，訊息原文照 Telegram 換行 */
.nlog { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.nlog li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 10px 14px; min-width: 0; }
.nlog .nmeta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: .88em; }
.nlog .ntext { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .92em; color: var(--fg); }
.nlog .nerr { color: var(--err); font-size: .85em; margin-top: 4px; overflow-wrap: anywhere; }
