/* 設定畫面的共用元件(public/settings-kit.js)。平台管理每一區與負責人的「方案與帳單」都用這一份;各模組不另寫自己的卡片、欄位、存檔列樣式。
 * 商米舊 WebView(Chrome 56)守則:不靠 flex gap(用 margin);不用 grid、:has()、:is()、min()、clamp()、inset。觸控區一律 >= 44px。 */

/* ---------- 共用色票、字級、間距(員工區、叫貨區、設定頁同一套;設計說明在共用筆記「設計語言-員工與叫貨共用.md」) ----------
 * 底色 / 字色(--bg、--panel、--ink、--line、--accent、--radius)只在 app.css 定義一次;主色在 brand-color.css;灰色說明字 --muted 與綠色 --ok-fg 在這裡(收銀機與員工手機都載入這一份);
 * 這裡只補新的:狀態色一律「底 + 字 + 邊」成對用(綠 = 好了、橘 = 要你處理、紅 = 擋下 / 不能、藍 = 說明 / 例子、灰 = 休假 / 停用 / 不送)。
 * 加了這段不會改到現有畫面(現有樣式沒有讀這些名字)。 */
:root {
  --muted: #5c6474;   /* 灰色說明字:淺灰底上也要 4.5:1 以上(全系統唯一一處) */
  --ok-bg: #ebfbee; --ok-fg: #237032; --ok-bd: #b2f2bb;   /* 綠字 / 綠底白字(全系統唯一一處;淡綠底上 5.7:1) */
  --warn-bg: #fff4e6; --warn-fg: #b35c00; --warn-bd: #ffd8a8;
  --bad-bg: #fff5f5; --bad-fg: #c92a2a; --bad-bd: #ffc9c9;
  --info-bg: #e7f5ff; --info-fg: #1864ab; --info-bd: #a5d8ff;
  --mute-bg: #f1f3f5; --mute-fg: #495057; --soft: #f8f9fb;
  --primary-bg: #fff0e6; --primary-bd: #ffc9a3;          /* 可點改的值、選中的那一列 */
  --note-bg: #fffaf0; --note-fg: #8a5a00; --note-bd: #f0b429;   /* 叫貨提醒區的黃色 */
  --fs-s: 13px; --fs-b: 15px; --fs-h3: 17px; --fs-h2: 20px; --fs-num: 30px;
  --sp1: 4px; --sp2: 8px; --sp3: 12px; --sp4: 16px; --sp5: 24px; --sp6: 32px;
  --shadow1: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow2: 0 4px 16px rgba(15, 23, 42, .12);
}

/* ---------- 頁首:標題 + 一句話 + 最常用的動作 ---------- */
.ks-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin: 0 0 12px; }
.ks-head-t { flex: 1 1 320px; min-width: 0; margin: 0 12px 0 0; }
.ks-head h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.3; }
.ks-lead { font-size: 13.5px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }
.ks-head-a { flex: none; padding-top: 2px; }
.ks-head-a .ks-hbtn { min-height: 44px; margin: 0 0 6px 8px; }

/* ---------- 摘要卡 ---------- */
.ks-card { display: block; margin: 0 0 10px; border: 1px solid var(--line); border-radius: var(--radius, 12px); background: var(--panel, #fff); box-sizing: border-box; }
.ks-card[hidden] { display: none !important; }
.ks-card-h { display: flex; align-items: center; min-height: 56px; padding: 10px 12px 10px 16px; box-sizing: border-box; border-radius: var(--radius, 12px); }
.ks-card.ks-open > .ks-card-h { border-bottom: 1px solid var(--line); border-radius: var(--radius, 12px) var(--radius, 12px) 0 0; }
.ks-card-h[data-row-act]:hover { box-shadow: none; }
.ks-card-t { flex: 1; min-width: 0; }
.ks-title { font-size: 15.5px; font-weight: 800; margin-right: 6px; }
.ks-sum { margin-top: 2px; font-size: 13.5px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.ks-sum:empty { display: none; }
.ks-card-h .ks-edit { flex: none; min-width: 72px; min-height: 44px; margin-left: 10px; }
.ks-card.ks-is-dirty > .ks-card-h .ks-title::after { content: '●'; margin-left: 6px; color: var(--amber, #f08c00); font-size: 12px; vertical-align: middle; }
.ks-card-b { padding: 12px 16px 14px; }
.ks-card-b[hidden] { display: none !important; }
.ks-fixed > .ks-card-h { min-height: 48px; }
/* 包進摘要卡的舊卡片(SettingsKit.wrap):本來的 .set-card 外距與標題交給摘要卡 */
.ks-card.set-card { padding: 0; }
.ks-card-b > .set-card, .ks-card-b > div > .set-card { margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
.ks-card-b > .set-card > h3, .ks-card-b > div > .set-card > h3 { display: none; }

.ks-pill { display: inline-block; vertical-align: middle; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.6; white-space: nowrap; background: #eef1f5; color: #4b5563; }
.ks-pill.ok { background: #e6f4ea; color: #1e7b34; }
.ks-pill.warn { background: #fff4e0; color: #9a5b00; }
.ks-pill.err { background: #fdecea; color: #b42318; }
.ks-pill.info { background: #e7f1fb; color: #1864ab; }

/* ---------- 欄位:桌面標籤在左、輸入在右;手機上下排 ---------- */
.ks-f { display: flex; align-items: flex-start; padding: 8px 0; border-top: 1px solid #f0f2f5; }
.ks-f:first-child, .ks-grp-t + .ks-f { border-top: 0; }
.ks-f-l { flex: none; width: 34%; max-width: 260px; padding: 10px 12px 0 0; box-sizing: border-box; font-size: 14px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.ks-f-l label, .ks-f-l span { font: inherit; color: inherit; }
.ks-f-c { flex: 1; min-width: 0; }
.ks-f-c input[type="text"], .ks-f-c input[type="email"], .ks-f-c input[type="url"], .ks-f-c input[type="date"], .ks-f-c input[type="tel"], .ks-f-c input[type="password"], .ks-f-c input:not([type]), .ks-f-c select, .ks-f-c textarea {
  width: 100%; max-width: 420px; min-height: 44px; box-sizing: border-box; margin: 0; font-size: 15px; }
/* 欄位裡的輸入框、下拉、多行字:同一個外觀(1px 淺灰框、圓角 8、內距 10),跟設定頁 .set-card 裡的一樣;不寫的話瀏覽器預設是直角黑色內凹框 */
.ks-f-c input[type="text"], .ks-f-c input[type="email"], .ks-f-c input[type="url"], .ks-f-c input[type="date"], .ks-f-c input[type="tel"], .ks-f-c input[type="password"], .ks-f-c input[type="number"], .ks-f-c input:not([type]), .ks-f-c select, .ks-f-c textarea { padding-left: 10px; padding-right: 10px; border: 1px solid var(--line, #e3e6ec); border-radius: 8px; background: var(--panel, #fff); color: inherit; font-family: inherit; }
.ks-f-c textarea { padding-top: 9px; padding-bottom: 9px; }
.ks-f-c textarea { max-width: 560px; min-height: 66px; }
.ks-f-c input[type="number"] { width: 140px; min-height: 44px; box-sizing: border-box; margin: 0; font-size: 15px; }
.ks-unit { display: inline-block; margin-left: 8px; color: var(--muted); font-size: 14px; }
.ks-hint { margin-top: 4px; font-size: 12.5px; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.ks-hint:empty { display: none; }
/* 「?」:看起來是一個 22px 的小圓,可以按的範圍是 44 × 44(負邊距抵掉,不撐高那一行) */
.ks-q { position: relative; display: inline-block; width: 44px; height: 44px; min-height: 44px; margin: -11px -11px -11px -5px; padding: 0; border: 0; background: transparent; color: var(--accent, #1971c2); font-size: 12.5px; font-weight: 800; line-height: 44px; text-align: center; vertical-align: middle; cursor: pointer; }
.ks-q::before { content: ''; position: absolute; left: 11px; top: 11px; width: 20px; height: 20px; border: 1px solid #c9d1dc; border-radius: 50%; background: #fff; z-index: -1; }
.ks-q { z-index: 0; }
.ks-help { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: #f3f6fb; font-size: 13px; line-height: 1.6; color: #374151; overflow-wrap: anywhere; }
.ks-help[hidden] { display: none; }
.ks-f-wide { display: block; }
.ks-f-wide .ks-f-l { width: auto; max-width: none; padding: 0 0 6px; }

/* 開關一列 */
.ks-tg { display: flex; align-items: flex-start; min-height: 44px; padding: 8px 0; box-sizing: border-box; cursor: pointer; border-top: 1px solid #f0f2f5; }
.ks-tg:first-child { border-top: 0; }
.ks-tg input { flex: none; width: 22px; height: 22px; margin: 1px 12px 0 0; }
.ks-tg-t { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.ks-tg-t b { font-weight: 700; }
.ks-tg-t small { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.ks-tg.off { opacity: .55; cursor: default; }

.ks-sec { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.ks-sec:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.ks-sec-h { display: flex; align-items: baseline; flex-wrap: wrap; margin: 0 0 8px; }
.ks-sec-t { margin: 0 10px 0 0; font-size: 16px; font-weight: 800; }
.ks-sec-a { font-size: 13px; color: var(--muted); }
.ks-grp { margin: 4px 0 10px; }
.ks-grp + .ks-grp { margin-top: 14px; }
.ks-grp-t { margin: 0 0 4px; font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: .02em; }
.ks-note { margin: 6px 0; padding: 8px 12px; border-radius: 8px; background: #f3f6fb; font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; }
.ks-note.warn { background: #fff7ed; color: #92400e; }
.ks-note.err { background: #fdecea; color: #b42318; }
.ks-note.ok { background: #effaf2; color: #1e7b34; }
.ks-adv { margin: 10px 0 0; border-top: 1px dashed var(--line); }
.ks-adv > summary { min-height: 44px; line-height: 44px; font-size: 14px; font-weight: 700; color: var(--accent, #1971c2); cursor: pointer; }
.ks-adv-b { padding: 0 0 4px; }

/* ---------- 存檔列 ---------- */
.ks-save { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin: 12px -16px -14px; padding: 10px 16px; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius, 12px) var(--radius, 12px); background: #fafbfc; }
.ks-dirty { margin-right: auto; padding-right: 10px; font-size: 13.5px; font-weight: 700; color: #b45309; }
.ks-dirty[hidden] { display: none; }
.ks-res { margin-right: 10px; font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.ks-res.ok { color: #1e7b34; }
.ks-res.err { color: #b42318; }
.ks-res:empty { display: none; }
.ks-save-b button { min-height: 44px; margin: 0 0 0 8px; }

/* ---------- 清單型設定 ---------- */
.ks-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ks-li { display: flex; align-items: center; min-height: 52px; padding: 6px 12px; box-sizing: border-box; border-top: 1px solid var(--line); background: #fff; }
.ks-li:first-child { border-top: 0; }
.ks-li[data-row-act]:hover { box-shadow: none; background: #fff7ed; }
.ks-li-n { flex: none; width: 26px; height: 26px; margin-right: 10px; border-radius: 50%; background: #eef1f5; font-size: 13px; font-weight: 800; line-height: 26px; text-align: center; color: #4b5563; }
.ks-li-tg { flex: none; display: block; width: 44px; height: 44px; margin: 0 6px 0 -8px; text-align: center; cursor: pointer; }
.ks-li-tg input { width: 22px; height: 22px; margin: 11px 0 0; }
.ks-li-t { flex: 1; min-width: 0; }
.ks-li-t b { font-size: 14.5px; }
.ks-li-t small { display: block; margin-top: 1px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-li-s { flex: none; margin-left: 10px; font-size: 13px; color: var(--muted); text-align: right; }
.ks-li-go { flex: none; margin-left: 8px; font-size: 20px; font-weight: 800; color: var(--accent, #1971c2); }
.ks-li-off .ks-li-t b { color: var(--muted); }
.ks-empty { padding: 14px; font-size: 13.5px; color: var(--muted); text-align: center; }
.ks-list-add { margin-top: 8px; }
.ks-list-add button { min-height: 44px; }

/* 編輯視窗 */
.ks-ed .ks-f-l { width: 30%; }

/* 頁籤(一區裡面再分幾頁:帳本、方案設定…):同一種樣子 */
/* 分頁:每一個都是看得出可以按的一格(白底框線);目前這一頁是深色底白字(跟點餐頁的分類鈕同一種做法)。以前是灰字加底線,看起來像一般文字,不好找 */
.ks-tabs { display: flex; overflow-x: auto; margin: 0 0 14px; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; }
.ks-tabs > button { flex: none; min-height: 44px; margin: 0 8px 0 0; padding: 8px 18px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.ks-tabs > button:hover { background: #f1f3f7; }
.ks-tabs > button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* 分段鈕(同一畫面裡切換檢視:每日 / 每月、整月 / 一週、盤點單 / 損耗紀錄…):員工、叫貨等各區共用這一份。
 * 用法:<span class="ks-seg"><button class="on">…</button><button>…</button></span>;選中只看 .on:白底、微微浮起。
 * 外距由各區的版面自己給;按鈕大小要放大(例如櫃檯平板)也在各區調,顏色與選中樣子不另寫。 */
.ks-seg { display: inline-block; vertical-align: middle; max-width: 100%; padding: 3px; border-radius: 12px; background: #eef1f5; white-space: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; box-sizing: border-box; }
.ks-seg > button { display: inline-block; vertical-align: middle; min-height: 40px; margin: 0; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: #4b5563; font-size: 15px; font-weight: 700; white-space: nowrap; box-shadow: none; }
.ks-seg > button.on { background: var(--panel, #fff); color: var(--primary-text); box-shadow: 0 1px 3px rgba(15, 23, 42, .16); }
@media (max-width: 480px) { .ks-seg > button { padding: 0 11px; font-size: 14px; } }

/* 手機:欄位改上下排 */
@media (max-width: 640px) {
  .ks-f { display: block; }
  .ks-f-l { width: auto; max-width: none; padding: 0 0 6px; }
  .ks-f-c input[type="text"], .ks-f-c input[type="email"], .ks-f-c input[type="url"], .ks-f-c input[type="date"], .ks-f-c input:not([type]), .ks-f-c select, .ks-f-c textarea { max-width: none; }
  .ks-card-h { padding-left: 12px; }
  .ks-card-b { padding: 10px 12px 12px; }
  .ks-save { margin: 12px -12px -12px; padding: 10px 12px; }
  .ks-head-a .ks-hbtn { margin: 6px 8px 0 0; }
  .ks-ed .ks-f-l { width: auto; }
}
/* 很窄的螢幕:清單一列放不下時,右邊的金額、狀態、按鈕換到下一行(標題那一行留給標題與 ›) */
@media (max-width: 520px) {
  .ks-li { flex-wrap: wrap; }
  .ks-li-t { flex: 1 1 calc(100% - 40px); }
  .ks-li-s { flex: 1 1 100%; order: 3; margin: 4px 0 2px; text-align: left; white-space: normal !important; }
}
/* 卡片裡所有可按的東西觸控區 >= 44px(包進摘要卡的舊模組也一樣,不各自補) */
.ks-card-b button, .ks-card-b select, .ks-card-b input[type="text"], .ks-card-b input[type="number"], .ks-card-b input[type="date"], .ks-card-b input[type="email"], .ks-card-b input[type="url"] { min-height: 44px; box-sizing: border-box; }

/* ---------- 月曆(public/ks-cal.js 畫格子):員工劃休、店長排班、叫貨到貨日小月曆共用這一份 ----------
 * 星期一開頭、一列 7 格(flex-wrap,每格 1/7,手機 360 寬也放得下);上一行日期、下一行小字(N 人 / 公休 / 禁休 / 滿 / 不送 / 來不及 / 班別)。
 * 顏色意思固定:選的 = 實心藍;同事已休 = 小字橘;已滿 = 淡橘;公休 / 不送 = 灰;禁休 / 來不及 = 淡紅;今天 = 深色框。
 * 沒有 app.css 的頁面(員工手機)也能用:每個顏色都帶預設值。 */
.ks-cal { font-size: 15px; }
.ks-cal-h { display: flex; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
.ks-cal-ym { font-size: 20px; font-weight: 800; margin-right: 8px; }
.ks-cal-nav { min-width: 44px; min-height: 44px; margin-right: 6px; border: 1px solid var(--line, #e3e6ec); border-radius: 10px; background: var(--panel, #fff); font-size: 18px; cursor: pointer; }
.ks-cal-lg { margin: 0 0 8px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.ks-cal-lg i { display: inline-block; width: 12px; height: 12px; margin: 0 4px 0 10px; border-radius: 3px; vertical-align: -1px; border: 1px solid transparent; }
.ks-cal-lg i:first-child { margin-left: 0; }
.ks-cal-wd { display: flex; margin: 0 0 4px; }
.ks-cal-wd > span { flex: none; width: 14.2857%; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.ks-cal-g { display: flex; flex-wrap: wrap; }
.ks-cal-c { flex: none; width: 14.2857%; padding: 2px; box-sizing: border-box; }
.ks-cal-d { display: block; width: 100%; min-height: 56px; margin: 0; padding: 6px 1px 4px; box-sizing: border-box; border: 1px solid var(--line, #e3e6ec); border-radius: 10px; background: var(--panel, #fff); color: var(--ink, #1c2333); font: inherit; text-align: center; cursor: pointer; }
.ks-cal-d b { display: block; font-size: 17px; line-height: 1.2; }
.ks-cal-d small { display: block; min-height: 16px; font-size: 12.5px; line-height: 16px; font-weight: 700; color: var(--warn-fg, #b35c00); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ks-cal-d[disabled] { cursor: not-allowed; }
.ks-cal-d.is-out { visibility: hidden; }
.ks-cal-d.is-sel { background: var(--accent, #1971c2); border-color: var(--accent, #1971c2); color: #fff; }
.ks-cal-d.is-sel small { color: #fff; }
.ks-cal-d.is-full { background: var(--warn-bg, #fff4e6); border-color: var(--warn-bd, #ffd8a8); }
.ks-cal-d.is-closed, .ks-cal-d.is-nosend { background: var(--mute-bg, #f1f3f5); border-color: var(--mute-bg, #f1f3f5); color: var(--muted); }
.ks-cal-d.is-closed small, .ks-cal-d.is-nosend small { color: var(--muted); }
.ks-cal-d.is-forbid, .ks-cal-d.is-late { background: var(--bad-bg, #fff5f5); border-color: var(--bad-bd, #ffc9c9); color: var(--bad-fg, #c92a2a); }
.ks-cal-d.is-forbid small, .ks-cal-d.is-late small { color: var(--bad-fg, #c92a2a); }
.ks-cal-d.is-today { box-shadow: inset 0 0 0 2px var(--ink, #1c2333); }
.ks-cal-d.is-sel.is-today { box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--ink, #1c2333); }
.ks-cal-f { display: flex; justify-content: space-between; margin-top: 6px; }
.ks-cal-f button { min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--accent, #1971c2); font: inherit; font-weight: 700; cursor: pointer; }
/* 頁面若有全域 button 樣式(員工手機整頁按鈕滿版、停用半透明),月曆的鈕照這裡,不被蓋掉 */
.ks-cal-d { -webkit-appearance: none; appearance: none; font-weight: 400; }
.ks-cal-d[disabled] { opacity: 1; filter: none; }
.ks-cal-nav, .ks-cal-f button { display: inline-block; width: auto; -webkit-appearance: none; appearance: none; color: var(--ink, #1c2333); }
.ks-cal-f button { color: var(--accent, #1971c2); }
/* 小月曆(叫貨到貨日):格子矮一點,小字可以沒有 */
.ks-cal.ks-cal-sm .ks-cal-d { min-height: 44px; padding: 4px 1px 2px; }
.ks-cal.ks-cal-sm .ks-cal-d b { font-size: 15px; }
.ks-cal.ks-cal-sm .ks-cal-d small { min-height: 0; font-size: 11px; line-height: 13px; }

/* ---------- 計數、底部固定動作列、紅色提示(員工劃休等;員工手機與 POS 共用) ---------- */
.ks-count { margin: 0 0 8px; font-size: 15px; color: var(--muted); }
.ks-count b { font-size: 34px; line-height: 1.1; color: var(--ink, #1c2333); font-variant-numeric: tabular-nums; }
.ks-count.is-over b { color: var(--bad-fg, #c92a2a); }
.ks-count small { display: block; font-size: 13px; }
.ks-alert { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--bad-fg, #c92a2a); color: #fff; font-weight: 700; line-height: 1.5; }
/* 底部固定列:員工手機有底部四格導覽時疊在它上面(導覽高度 --sm-tabbar-h 由員工手機頁設定) */
.ks-actbar { position: -webkit-sticky; position: sticky; bottom: var(--ks-bottom-offset, var(--sm-tabbar-h, 0px)); z-index: 5; display: flex; align-items: center; margin: 12px -16px -16px; padding: 12px 16px; background: var(--panel, #fff); border-top: 1px solid var(--line, #e3e6ec); box-shadow: 0 -4px 12px rgba(15, 23, 42, .06); }
.ks-actbar > button { flex: none; width: auto; min-height: 48px; margin: 0; }
.ks-actbar > button.ks-grow { flex: 1; margin-left: 12px; }
