/* ═══ 色彩 token（全家 FamilyMart：藍＋綠）═══
   品牌層：藍 #0062ad、綠 #009b4c。語意層：元件只引用這一層（--acc、--price、--err…），不要直接用品牌色。
   對比度（WCAG，一般文字要 ≥4.5）：--acc #0062ad 對白 6.2；綠 #009b4c 對白 3.6 → 只當裝飾（logo、圖示、色條）。
   一律白底（同 funbox 後台），不跟系統切深色模式。 */
:root {
  /* 品牌 */
  --brand-blue: #0062ad; --brand-green: #009b4c;
  /* 中性 */
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f1f4f9; --line: #dde2ea; --fg: #1f2328; --mut: #59636e;
  /* 語意 */
  --acc: var(--brand-blue); --acc-fg: #ffffff; --acc-soft: #e6f0f8;
  --price: #c4161c;
  --ok: #1a7f37; --ok-soft: #e6f4ea; --warn: #9a6700; --warn-soft: #fff4d6; --err: #c4161c; --err-soft: #fdecee;
  /* 圖表（溫度圖）：分類色第 1、2 格（藍、橘，dataviz 驗證過色盲可分）；超出範圍用狀態紅＋三角形 */
  --series-a: #2a78d6; --series-b: #eb6834; --crit: #d03b3b;
  --supply: rgba(89, 99, 110, .13); --supply-edge: #8a949e;   /* 溫度圖的巡補底帶與起訖線：中性灰，不跟兩櫃的藍／橘混 */
  /* 形狀與間距 */
  --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/familymart-logo.svg");
  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: 176px; height: 35px; 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: 230px; height: 46px; 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(--err); 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); }
.tag.model { font-weight: 600; vertical-align: 1px; }
.tag.model.tcn { background: var(--warn-soft); color: var(--warn); }
.tag.model.ly { background: var(--acc-soft); color: var(--acc); }
a.tag { text-decoration: none; }
.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 .sm-btn { min-height: 32px; padding: 4px 10px; font-size: .88em; margin-left: 6px; }

.mlist .ml-templink { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--mut); }
.mlist .ml-templink.err { color: var(--err); font-weight: 600; border-bottom-color: var(--err); }

/* 巡補記錄：歷史／日統計／月統計 切換鈕、可點的列、明細欄位 */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; margin-bottom: 10px; }
.seg button { font: inherit; font-size: .92em; border: 0; background: none; color: var(--mut); border-radius: 999px; padding: 6px 16px; min-height: 36px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: var(--shadow); }
.click-rows tbody tr { cursor: pointer; }
.click-rows tbody tr:hover td, .click-rows tbody tr:focus-visible td { background: var(--acc-soft); }
.click-rows .link { color: var(--acc); font-size: .9em; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 6px 0 12px; font-size: .92em; }
.kv dt { color: var(--mut); } .kv dd { margin: 0; }

/* 巡補記錄的清單（桌機一般表格；手機一筆一段：第一行 p 主要欄＋q 件數，換行後 s 次要欄小字，不做卡片） */
.slist-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }
.slist td { vertical-align: middle; }
.slist td.br { display: none; }
.slist td.go { text-align: right; }
.stock-list .exp-t { display: block; }

/* 溫度紀錄 */
.temp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 12px; }
.temp-stat b { font-size: 1.6em; }
.temp-stat > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.temp-stat .swatch { margin-right: 0; }
.cab-A { background: var(--series-a); } .cab-B { background: var(--series-b); }
.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 12px 12px 4px; margin-bottom: 6px; }
#temp-chart { width: 100%; height: 300px; }
.sec-h { font-size: 1em; margin: 20px 0 8px; }
/* 溫度頁區間檢視：目前看的時段＋「看整段」、圖下方「只看最近」快捷 */
.t-win { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 0 0 10px; min-height: 36px; }
.t-quick { align-items: center; margin: 2px 0 6px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* 表格 */
.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; }
/* 表頭排序：可點的欄名、目前排序的箭頭；手機版表頭藏起來，改用表格上方的 .sortbar */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--acc); }
th.sortable::after { content: "↕"; margin-left: 4px; color: var(--line); font-weight: 400; }
th[aria-sort="ascending"]::after { content: "▲"; color: var(--acc); }
th[aria-sort="descending"]::after { content: "▼"; color: var(--acc); }
.sortbar { display: none; }
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); }
.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; } }

/* ═══ 手機 ═══ */
@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" "today stock" "temp act" "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-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-temp { grid-area: temp; color: var(--mut); align-self: end; }
  .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; }

  .slist-wrap { overflow: visible; }
  .sortbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 0 0 8px; font-size: .88em; color: var(--mut); }
  .sortbar select { min-height: 32px; padding: 4px 8px; font-size: 1em; }
  .sortbar .sm-btn { min-height: 32px; padding: 4px 10px; }
  .slist, .slist tbody { display: block; }
  .slist thead { display: none; }
  .slist tr { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
  .slist tr:last-child { border-bottom: 0; }
  .slist td { display: block; padding: 0; border: 0; text-align: left; }
  .slist td.p { order: 1; font-weight: 600; min-width: 0; }
  .slist td.p.goods { font-weight: 400; flex: 1 1 0; }
  .slist td.q { order: 2; margin-left: auto; font-weight: 600; white-space: nowrap; }
  .slist td.br { display: block; order: 3; flex-basis: 100%; height: 0; }
  .slist td.s { order: 5; font-size: .84em; color: var(--mut); }
  .slist td.s.first { order: 4; }
  .slist td.s:has(~ td.s)::after { content: "・"; margin-left: 8px; color: var(--line); }
  .slist td.s[data-l]::before { content: attr(data-l); }
  .slist td.go { display: none; }
  #sheet .slist-wrap { border: 0; box-shadow: none; }
  /* 庫存：第一行 貨道＋商品＋剩餘，第二行 售價・到期日・狀態 */
  .cab .slist-wrap { border: 0; box-shadow: none; border-radius: 0; }
  .stock-list .exp-t { display: inline; margin-left: 4px; }
  .stock-list td.q { min-width: 70px; text-align: right; }
  .stock-list td.q .meter { margin-top: 3px; }
  .stock-list tr.empty td:first-child { box-shadow: none; }
  .stock-list tr.empty { box-shadow: inset 4px 0 var(--err); }

  #temp-chart { height: 260px; }
  .temp-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .temp-stat { padding: 8px 10px; }
  .temp-stat b { font-size: 1.3em; }
  .temp-stat .sm { font-size: .8em; }

  /* 表格 → 一筆一張卡片：每格前面帶欄名（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; }
}
.form label.row { flex-direction: row; align-items: center; gap: 8px; }
.form .row { display: flex; gap: 8px; }

/* ═══ 庫存：左櫃／右櫃區塊（Mozo 2026-10-28：左右櫃要區分明顯）═══
   左櫃＝品牌藍、右櫃＝品牌綠：色帶與底色只當裝飾，櫃名字色用對白 ≥4.5 的深色（藍 #0062ad 6.2、綠 #00703c 6.0）。
   寬螢幕左右並排（同機台實體位置），窄螢幕上下排。 */
.cabs { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-bottom: 16px; }
@media (min-width: 1100px) { .cabs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.cab { --cab: var(--brand-blue); --cab-soft: #e6f0f8; --cab-fg: #0062ad;
  border: 1px solid var(--line); border-top: 6px solid var(--cab); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.cab-B { --cab: var(--brand-green); --cab-soft: #e5f5ec; --cab-fg: #00703c; }
.cab-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 10px 14px; background: var(--cab-soft); border-bottom: 1px solid var(--line); }
.cab-name { font-size: 1.2em; font-weight: 700; color: var(--cab-fg); }
.cab-code { font-size: .85em; color: var(--cab-fg); border: 1px solid var(--cab); border-radius: 999px; padding: 0 8px; }
.cab-meta { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-size: .9em; color: var(--mut); }
.cab-meta b { color: var(--fg); }
.cab-temp { font-weight: 700; color: var(--cab-fg); }
.cab .tw { border: 0; border-radius: 0; box-shadow: none; }
.cab-track { display: inline-block; font-weight: 700; color: var(--cab-fg); }
.cab tr td:first-child { box-shadow: inset 4px 0 var(--cab); }
.cab tr.empty td:first-child { box-shadow: inset 4px 0 var(--err); }
/* 窄螢幕：表格變卡片，色條改在整張卡片左側（不壓到欄名） */
@media (max-width: 760px) {
  .cab .tw { padding: 8px; }
  .cab tr td:first-child, .cab tr.empty td:first-child { box-shadow: none; }
  .cab .tw tr { box-shadow: inset 5px 0 var(--cab), var(--shadow); padding-left: 16px; }
  .cab .tw tr.empty { box-shadow: inset 5px 0 var(--err), var(--shadow); }
}
a.tag { text-decoration: none; }

/* ═══ 登入頁：申請帳號 ═══ */
.apply-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.apply-form { text-align: left; margin: 12px 0 0; box-shadow: none; position: relative; }
.form .field { display: flex; flex-direction: column; gap: 3px; font-size: .9em; }
.store-picker { position: relative; display: grid; gap: 6px; }
.store-picker .picked { display: flex; flex-wrap: wrap; gap: 6px; }
.store-picker .picked:empty { display: none; }
.pick-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--acc-soft); color: var(--fg); border-radius: 999px; padding: 2px 2px 2px 12px; font-size: .95em; max-width: 100%; }
.pick-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-chip button { border: 0; background: none; color: var(--mut); font: inherit; font-size: 1.15em; line-height: 1; min-width: 32px; min-height: 32px; border-radius: 999px; cursor: pointer; }
.pick-chip button:hover, .pick-chip button:focus-visible { background: var(--surface); color: var(--err); }
.store-picker .store-list { margin: 0; }
.store-list { list-style: none; margin: -8px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; }
.store-list li { padding: 2px 0; }
.store-list li.mut { padding: 8px; }
.store-list button { width: 100%; text-align: left; min-height: var(--tap); padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none; font: inherit; color: var(--fg); cursor: pointer; }
.store-list button:hover, .store-list button:focus { background: var(--acc-soft); outline: none; }
.store-list button[aria-selected="true"] { color: var(--mut); }
.store-list button[aria-selected="true"]::after { content: '　✓ 已選'; color: var(--ok); }
#apply-msg { margin: 10px 0 0; }

/* ═══ 登入頁：申請審核中 ═══ */
.pending-box { text-align: left; background: var(--acc-soft); border-radius: var(--r-md); padding: 14px 16px; margin: 6px 0 4px; }
.pending-box h2 { margin: 0 0 6px; font-size: 1.1em; color: var(--acc); }
.pending-box p { margin: 0 0 8px; }
.pending-box dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 12px; font-size: .92em; }
.pending-box dt { color: var(--mut); }
.pending-box dd { margin: 0; overflow-wrap: anywhere; }

/* 機台登記：待處理提示（設定檔與 SCO 不一致） */
.warn-box { background: var(--warn-soft); color: var(--fg); border-radius: var(--r-sm); padding: 10px 12px; }
.warn-box b { color: var(--warn); }

/* 清單全文搜尋（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; }

/* 頁面上方過濾器（販售／巡補／庫存／溫度）：桌機收成一張卡片——
   第一行期間（巡補：模式＋期間；庫存／溫度：機台＋篩選）、第二行機台與日期、下載 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; }
}
