/* PCI 餐廳回饋系統 — 樣式
   設計原則：手機優先、大字體、大按鈕
   （工廠現場、光線不佳、可能單手或戴手套操作） */


/* ===== 設計基礎（所有顏色與尺寸都從這裡取，不要在下面寫死）=====

   ⚠️ 要調整整體風格改這一區就好，不必逐條找。

   設計方向（關卡 5-1 定案，參考 madebypan.com）：
   **中性米白底 + 近黑主動作 + 顏色只給有意義的東西。**

   核心原則是「**畫面上只要有顏色，就一定代表意義**」——
   狀態（未處理紅 / 處理中黃 / 已結案綠）與星等是僅有的彩色，
   其餘一律中性。這樣那幾個顏色才真的跳得出來。

   ⚠️ 原本的品牌藍 #2563eb 已經拿掉。`--brand` 系列保留成別名
      （CSS 裡有 51 處在用），現在指向近黑主色，不必逐一改寫。
*/

:root {
  /* 只支援淺色。
     不宣告的話，部分 Android 瀏覽器會強制反轉整頁，
     精心調的米白會變成深褐色，狀態色也會跟著跑掉 */
  color-scheme: light;

  /* --- 基本表面與文字 --- */
  --bg:            #EFEFED;   /* 中性米白。不是白、也不是冷灰 */
  --surface:       #F9F9F8;   /* 卡片，比底色亮一階 */
  --surface-alt:   #E7E7E6;
  --text:          #1A1A1D;   /* 對底色 15.1:1 */
  --text-muted:    #53535A;   /* 對底色 6.6:1 */
  --text-subtle:   #6A6A70;   /* 對底色 4.7:1，剛好通過 WCAG AA */
  --border:        #DEDEDD;   /* 純裝飾的分隔線，沒有對比度要求 */
  --border-strong: #CBCBCA;   /* 較明顯的分隔線，仍屬裝飾 */

  /* ⚠️ 輸入框、可點按鈕的**邊界**另外一個顏色，不能用上面那兩個。
     WCAG 1.4.11 要求「互動元件的邊界」對背景至少 3:1——
     #CBCBCA 只有 1.41:1，在工廠光線下等於看不到輸入框在哪裡。
     這一條是裝飾線與互動邊界的差別，很容易被當成同一件事。 */
  --border-input:  #80807A;   /* 對底色 3.45:1 */

  /* 大型裝飾數字（步驟編號）。
     ⚠️ 不可以再淡了——原本用 --border-strong 只有 1.41:1，
        在工廠的爛光線下等於看不見。這個值是 3.55:1，通過大字的 3:1 */
  --num:           #7E7E77;

  /* --- 主要動作 ---
     近黑，不是彩色。整個畫面只有它與逾期案件有重陰影，
     所以它想被忽略都難 */
  --action:        #1A1A1C;
  --action-press:  #35353A;

  /* --- 舊的品牌色別名（相容用，全部指向近黑）---
     ⚠️ 這幾個名字在 CSS 裡有 51 處在用（員工端 26、管理端 25）。
        保留別名，管理端就會自動拿到新配色而不必在 5-2 動它 */
  --brand:        var(--action);
  --brand-dark:   var(--action-press);
  --brand-light:  var(--surface-alt);
  --brand-border: var(--border-strong);

  /* --- 狀態色：畫面上僅有的彩色，每個都算過對比度 --- */
  --ok:          #046C4E;
  --ok-bg:       #E7F5EE;
  --ok-border:   #BFE3D3;
  --danger:      #A81E1E;
  --danger-bg:   #FBEDEC;
  --danger-border:#F3CFCD;
  --danger-tag:  #F7DEDC;
  --warn:        #8A5300;
  --warn-bg:     #FBF2E3;
  /* ⚠️ 星星的對比度是由**描邊**負責的，不是填色。
     越鮮豔的金色越亮、對比越低——單靠填色最多只能到 3.18:1（很勉強）。
     改成「鮮豔填色 + 深色描邊」之後，填色可以放開，
     而深色的邊在工廠的爛光線下本來就更好認。 */
  --star:      #F2A007;   /* 填色：鮮豔的琥珀金 */
  --star-edge: #7A4E00;   /* 描邊：對底色 6.2:1，遠高於圖形要求的 3:1 */

  /* ⚠️ 圖表的滿意度線是**另一個顏色**，不能跟著星星變鮮豔。
     星星靠描邊撐對比度，但一條線沒有描邊——它的對比度只能靠自己。
     這兩個很容易被當成同一件事（它們講的都是「滿意度」），
     所以分成兩個 token，並由 check-contrast.js 各自把關。 */
  --chart-rating: #C07405;   /* 對卡片 3.15:1 */

  /* --- 圓角 --- */
  --radius-sm:   10px;
  --radius:      14px;
  --radius-lg:   20px;
  --radius-pill: 999px;

  /* --- 字級 ---
     clamp(最小, 隨螢幕寬度連續變化, 最大)：手機到電腦是平滑過渡，
     不是「手機一種、電腦一種」的跳變。

     ⚠️ --fs-input 的下限鎖死 16px。低於 16px 的話，
        iOS 一點輸入框就會自動放大整個畫面，使用者要手動縮回來。

     ⚠️ 列印時 vw 指的是「紙張寬度」，算出來的字級無法預期，
        所以 @media print 裡會把這一整組改回固定值（見檔案最後）。 */
  --fs-xs:      clamp(12px, 0.70rem + 0.15vw, 13px);
  --fs-sm:      clamp(13px, 0.78rem + 0.20vw, 15px);
  --fs-body:    clamp(15px, 0.88rem + 0.25vw, 17px);
  --fs-input:   clamp(16px, 0.95rem + 0.20vw, 17px);
  --fs-lg:      clamp(17px, 1.00rem + 0.40vw, 20px);
  --fs-title:   clamp(23px, 1.30rem + 1.30vw, 34px);
  --fs-display: clamp(30px, 1.60rem + 2.60vw, 52px);

  /* --- 觸控目標最小高度（工廠現場可能戴手套，不要小於 48px）--- */
  --tap-min: 48px;

  /* --- 間距：也跟著螢幕變，電腦上版面會自然變鬆，
         而不是「手機版被整個放大」 --- */
  --gap:      clamp(12px, 0.70rem + 0.40vw, 18px);
  --pad-card: clamp(16px, 0.90rem + 0.60vw, 24px);
  --sec-gap:  clamp(28px, 1.50rem + 2.00vw, 56px);

  /* --- 陰影：兩階 ---

     ⚠️ 關鍵不是「有沒有陰影」，是**陰影強度要跟重要性成正比**。
        改版前每一張卡片都有 `0 1px 3px rgba(0,0,0,.06)`，
        平均分配的結果就是沒有任何一張被強調——那正是「單調」的來源。

     陰影色用帶灰的深色，不用純黑：純黑打在米白底上會顯髒。 */
  --lift-1: 0 1px 2px rgba(38,38,44,.05), 0 6px 14px -8px rgba(38,38,44,.16);
  --lift-2: 0 10px 24px -10px rgba(40,40,45,.20), 0 24px 48px -24px rgba(40,40,45,.24);
}


/* ===== 表面 / 表面上的文字（surface / on-surface）=====

   📌 文字與按鈕會自動跟著背景走，靠的是這一組。

      作法不是用 JS 偵測背景色，而是**讓每個表面自己帶著
      「放在我上面的文字該是什麼顏色」**。
      元件一律寫 `color: var(--fg)`，不寫死顏色。

   ⚠️ 為什麼不用 JS 即時運算：背景可能是漸層、半透明、或被圖片蓋住，
      JS 取到的值不一定是眼睛看到的，而且每次重繪都要算一次。
      用 token 是靜態的、可驗證的、零成本。

   ⚠️ 實際踩過的坑：`.empty span { color: ... }` 這種寫法會**滲進深色按鈕裡面**，
      把淺色文字蓋成深灰（1.5:1，等於看不見）。
      因為按鈕自己的顏色是「繼承」來的，而繼承的優先度輸給直接指定。
      **兩個對策：選擇器用 `>` 限定直接子層，而且深色元件自己帶 --fg。**

   驗證方式：node tools/check-contrast.js
*/

.on-base   { --surf: var(--bg);        --fg: var(--text); --fg-muted: var(--text-muted); --fg-subtle: var(--text-subtle); --line: var(--border); }
.on-raised { --surf: var(--surface);   --fg: var(--text); --fg-muted: var(--text-muted); --fg-subtle: var(--text-subtle); --line: var(--border); }
.on-dark   { --surf: var(--action);    --fg: #F2F2EF; --fg-muted: #C2C2BD; --fg-subtle: #93938E; --line: rgba(255,255,255,.16); }
.on-danger { --surf: var(--danger-bg); --fg: #7A1616; --fg-muted: #8E3232; --fg-subtle: #9A4A4A; --line: rgba(122,22,22,.18); }
.on-warn   { --surf: var(--warn-bg);   --fg: #6E4200; --fg-muted: #855A1E; --fg-subtle: #8A6534; --line: rgba(110,66,0,.18); }
.on-ok     { --surf: var(--ok-bg);     --fg: #04543D; --fg-muted: #2A6B57; --fg-subtle: #3A7360; --line: rgba(4,84,61,.18); }


* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Noto Sans TC", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 48px;
}

.hidden { display: none !important; }
.muted  { color: var(--text-muted); font-size: 14px; }
.hint   { color: var(--text-muted); font-size: 13px; margin-top: 12px; }


/* ===== 語言切換 ===== */

.lang-switch {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.lang-btn {
  flex: 0 0 auto;
  /* ⚠️ 44px 是最低標。原本 40px——工廠現場可能戴手套，按不準 */
  min-height: 44px;
  padding: 8px 16px;
  font-size: var(--fs-sm);
  font-family: inherit;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: 999px;
  cursor: pointer;
}

.lang-btn.active {
  color: var(--surface);
  background: var(--brand);
  border-color: var(--brand);
  font-weight: 600;
}

.lang-switch-compact { margin: 0; }
.lang-switch-compact .lang-btn { padding: 6px 12px; font-size: var(--fs-xs); min-height: 44px; }


/* ===== 頁首標誌列 ===== */

.app-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
}

/* 語言切換推到右邊 */
.app-bar .lang-switch { margin-left: auto; margin-bottom: 0; }


/* ===== PCI GA 文字標誌（關卡 5-2）=====

   ⚠️ 這是**純文字**排出來的，沒有圖檔。

      理由：載入零成本（工廠 wifi 不好時圖檔會晚一步出現）、
      無限放大不糊（海報放到 A2 一樣銳利）、可以跟著背景變色。
      而且完全避開品牌資產的使用問題——
      集團給的那個檔案是「金色的樹 + 三個事業單位的標誌」的合體圖，
      不是 PCI 單獨的標記，也不是真的向量圖（247KB 點陣圖包在 SVG 外殼裡）。

      正式的單色向量檔拿到之後要換，那時只要改這一個元件。

   效果來自四個槓桿：字重落差、大小落差、字距、對齊。
   不能用顏色和漸層——那是這一版設計的原則。
*/

.wordmark {
  display: inline-flex;
  align-items: flex-start;
  flex: none;
  color: var(--fg, var(--text));
  text-decoration: none;
}

.wordmark b {
  font-weight: 800;
  font-size: var(--fs-lg);
  letter-spacing: .1em;
  line-height: 1.1;
}

/* GA 縮小、拉開字距、對齊上緣——這是 W1-b 的做法 */
.wordmark i {
  font-style: normal;
  font-weight: 400;
  font-size: var(--fs-xs);
  letter-spacing: .3em;
  line-height: 1;
  color: var(--fg-muted, var(--text-muted));
  margin: 2px 0 0 .45em;
}

/* 內頁頁首：標誌旁邊補一行小字說明現在在哪一頁。
   ⚠️ 首頁不需要（大標題緊接著就寫了），但回報頁與查詢頁沒有大標題，
      沒有這行的話頁首就真的只剩 PCI GA，使用者不知道自己在哪 */
.page-tag {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  padding-left: 10px;
  margin-left: 10px;
  border-left: 1px solid var(--border);
  line-height: 1.35;
}


/* ===== 首頁 ===== */

/* 主視覺：小標 + 大標題 + 一行說明。
   ⚠️ 不置中——左對齊在手機上比較好讀，而且與下方的卡片對齊成一條線 */
.hero {
  text-align: left;
  padding: var(--sec-gap) 0 calc(var(--sec-gap) * .6);
}

/* ⚠️ 首頁不再用大 emoji 當主視覺（關卡 5-2）。
   改成「小標 + 大標題」的排版層次——那才是這一版的識別，
   而且一張彩色圖會立刻搶走那顆黑色主按鈕的焦點 */
.hero-icon { display: none; }

.hero-eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.hero h1 {
  font-size: var(--fs-title);
  line-height: 1.25;
  letter-spacing: .01em;
  margin-top: 10px;
}

.hero-tagline {
  color: var(--text-muted);
  font-size: var(--fs-body);
  margin-top: 10px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/*
 * ⚠️ 兩張卡片刻意做成**不一樣的份量**，這是整個改版的重點。
 *
 *    改版前兩張都是白底 + 1px 框，「主要」那張只差在框粗了 1px——
 *    掃過去根本分不出來，而那正是「單調」的來源：
 *    **沒有東西比別的東西重要。**
 *
 *    現在：主要動作是近黑實心 + 重陰影，次要是淺色平面。
 *    想忽略那顆黑的都難。
 */
.menu-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px var(--pad-card);
  min-height: var(--tap-min);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--fg, var(--text));
  box-shadow: var(--lift-1);
}

.menu-card:active { background: var(--surface-alt); }

/* 主要動作：深色表面，自己帶著 on-surface token。
   ⚠️ 內部文字一律讀 --fg / --fg-muted，不靠繼承——
      靠繼承的話，外層任何一條 `.xxx span { color }` 都會把它蓋掉
      （這個坑在 5-1 的預覽頁實際踩過，深灰字打在近黑底上 1.5:1）*/
.menu-card-primary {
  --fg: #F2F2EF;
  --fg-muted: #C2C2BD;

  background: var(--action);
  box-shadow: var(--lift-2);
}

.menu-card-primary:active { background: var(--action-press); }

/* 序號取代圖示：01 / 02。
   數字比圖示更能表達「先做這個，再做那個」的順序 */
/* 操作說明入口。份量刻意比兩張卡片輕——它是「需要時才找」的東西，
   不該跟主要動作搶注意力。

   ⚠️ 但「輕」曾經輕過頭：v3.6 之前是小一級的灰字 + 20px 圖示 + **無底無框**，
      使用者實機回饋「圖示跟字都有點小」。真正的問題不是字小，是
      **看不出來那是可以按的東西**——一段沒有邊界的灰字，長得像說明文字。

   ⚠️ 所以 v3.7 補的是「邊界」而不只是「大小」：框線 + 淺底。
      用**框線**不用陰影是刻意的——在這個系統裡陰影是卡片的語言
      （`.menu-card` 用 --lift-1），框線是「輸入框 / 可按元件」的語言。
      用陰影的話它會被看成第三張卡片，那正是當初刻意避開的事
      （兩張卡片的份量差異是為了讓人兩秒內決定要做什麼）。

   📌 它仍然不會被誤認成卡片：膠囊形、矮一截、置中、沒有編號也沒有箭頭。

   ⚠️ 框線一定要用 --border-input，不可以用 --border / --border-strong。
      後兩者是裝飾線（1.41:1），而這是**可點按元件的邊界**，
      WCAG 1.4.11 要求 3:1——在工廠的爛光線下差別是「看得到」與「看不到」。 */
.menu-help {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 10px;
  padding: 12px 20px;
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 600;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-pill);
}
.menu-help:active { background: var(--surface-alt); }
.menu-help-icon { width: 24px; height: 24px; flex: none; display: block; }

.menu-num {
  font-size: var(--fs-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted, var(--text-subtle));
  flex: none;
}

.menu-icon svg { width: 26px; height: 26px; display: block; }
.menu-text  { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.menu-title { font-size: var(--fs-lg); font-weight: 700; color: var(--fg, var(--text)); }
.menu-desc  { font-size: var(--fs-sm); color: var(--fg-muted, var(--text-muted)); margin-top: 2px; }
.menu-arrow { font-size: 22px; color: var(--fg-muted, var(--text-subtle)); line-height: 1; flex: none; }


/* ===== 頁首（內頁）===== */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: var(--gap);
}

.topbar-back {
  flex: 0 0 auto;
  width: var(--tap-min);
  height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  color: var(--text);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  text-decoration: none;
}

.topbar-back:active { background: var(--surface-alt); }

/* ⚠️ 內頁沒有大標題，所以頁首要負責回答「我在哪一頁」。
   首頁不需要（大標題緊接著就寫了），但這兩頁需要 */
.topbar-title {
  flex: 1;
  font-size: var(--fs-lg);
  min-width: 0;
}


/* ===== 表單 ===== */

/*
 * ⚠️ 每一段用「大號碼 + 標題」開頭，取代原本的框線卡片。
 *
 *    原本每個欄位都是白底 + 1px 框，八個欄位就是八個一模一樣的框，
 *    使用者看不出「還剩幾步」。編號能回答那個問題，
 *    而且大數字在工廠的爛光線下比細框線好認得多。
 */
.field {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin-bottom: var(--sec-gap);
}

.field-num {
  display: block;
  font-size: var(--fs-display);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  /* ⚠️ 不可以再淡了。原本用 --border-strong 只有 1.41:1，
     在工廠光線下等於看不見。--num 是算過的 3.55:1 */
  color: var(--num);
}

.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  font-size: var(--fs-lg);
  margin: 2px 0 10px;
}

.tag {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  background: var(--surface-alt);
}

.tag-required {
  color: var(--danger);
  background: var(--danger-tag);
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: var(--tap-min);
  /* ⚠️ 絕不可小於 16px：小於的話 iOS 一點輸入框就會自動放大整個畫面 */
  font-size: var(--fs-input);
  font-family: inherit;
  color: var(--text);
  padding: 12px 14px;
  /* ⚠️ 互動元件的邊界要 3:1，不能用裝飾用的 --border-strong（1.41:1）*/
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--surface);
}

select { height: var(--tap-min); }
textarea { resize: vertical; }

input::placeholder,
textarea::placeholder { color: var(--text-subtle); }

/* 焦點外框用 PCI 藍——這是整個 app 唯一出現品牌藍的地方。
   它不參與版面配色，只在鍵盤操作時出現，所以不會破壞「顏色只給意義」的原則 */
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #214A8C;
  outline-offset: 2px;
  border-color: transparent;
}

.field-note {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 8px;
  min-height: 20px;
}

.field-note.ok { color: var(--ok); font-weight: 700; }
.field-note.ng { color: var(--danger); font-weight: 700; }
.field-note.rated { color: var(--warn); font-weight: 700; }


/* ===== 問題分類 ===== */

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.category-btn {
  display: flex;
  min-height: 88px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 4px;
  font-family: inherit;
  color: var(--fg, var(--text));
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

/* ⚠️ 不用 opacity。opacity 會把文字往背景混，對比度變成算不準也控制不了；
   而且巢狀的 opacity 會相乘。改成直接指定「停用」的顏色 */
.category-btn.disabled {
  color: var(--text-subtle);
  background: var(--surface-alt);
  cursor: not-allowed;
}

/* 選中＝實心近黑。自己帶 on-dark 的 token，
   裡面的文字與 SVG 圖示（stroke=currentColor）都會自動變淺色 */
.category-btn.selected {
  --fg: #F2F2EF;
  color: var(--fg);
  background: var(--action);
  font-weight: 700;
  box-shadow: var(--lift-1);
}

.category-icon svg { width: 24px; height: 24px; display: block; }
.category-label { font-size: var(--fs-xs); text-align: center; line-height: 1.35; }


/* ===== 星等 ===== */

.stars {
  display: flex;
  gap: 6px;
}

.star {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 8px 0;
  background: none;
  border: none;
  cursor: pointer;
}

.star svg {
  width: 34px;
  height: 34px;
  display: block;
  /* 未選：只有外框。
     ⚠️ 顏色用 --num（3.55:1）不用 --border-strong（1.4:1）——
        後者在工廠光線下看不見，使用者會不知道總共有五顆 */
  fill: none;
  stroke: var(--num);
  stroke-width: 1.7;
  transition: transform .12s ease-out;
}

/* 已選：鮮豔實心 + 深色描邊 + 一點點浮起。
   描邊是對比度的來源，所以填色可以放心用鮮豔的 */
.star.on svg {
  fill: var(--star);
  stroke: var(--star-edge);
  stroke-width: 1.4;
  filter: drop-shadow(0 2px 3px rgba(122, 78, 0, .32));
}

/* 按下去的回饋。⚠️ 有些人開了「減少動態」，要尊重 */
.star:active svg { transform: scale(.88); }

@media (prefers-reduced-motion: reduce) {
  .star svg { transition: none; }
  .star:active svg { transform: none; }
}


/* ===== 按鈕 ===== */

.btn-primary,
.btn-secondary,
.btn-danger {
  display: block;
  width: 100%;
  margin-top: var(--gap);
  min-height: 54px;
  padding: 16px;
  font-size: var(--fs-lg);
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  border: none;
  /* 膠囊形。這一版的識別之一，而且 54px 高度不受影響 */
  border-radius: var(--radius-pill);
  cursor: pointer;
}

/* 主要動作：近黑實心 + 重陰影。
   整個畫面只有它與逾期案件有這種陰影，所以它想被忽略都難 */
.btn-primary {
  color: #F2F2EF;
  background: var(--action);
  box-shadow: var(--lift-2);
}

.btn-primary:active  { background: var(--action-press); }
/* 停用：降成平面 + 灰底。用顏色與陰影表達，不用 opacity */
.btn-primary:disabled {
  color: var(--text-subtle);
  background: var(--surface-alt);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-input);
  box-shadow: var(--lift-1);
}

/* 破壞性動作（目前只有「刪除管理者帳號」）。
   ⚠️ 刻意做成**淺底 + 紅字 + 紅框**，不是紅色實心：
      紅色實心的份量會超過同一排的其他按鈕，變成整頁最搶眼的東西——
      而它是最不該被順手按到的那一顆。
      顏色只負責「這個不一樣」，份量仍然是次要動作。
   ⚠️ 框線用 --danger 本身（對底色 6.1:1），不是 --danger-border（那是裝飾線，
      對比不足以當互動元件的邊界，WCAG 1.4.11 要 3:1）。 */
.btn-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  box-shadow: none;
}
.btn-danger:active   { background: var(--danger-tag); }
.btn-danger:disabled { color: var(--text-subtle); background: var(--surface-alt);
                       border-color: var(--border-input); cursor: not-allowed; }


/* ===== 訊息 ===== */

.result {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  line-height: 1.7;
  margin-top: 12px;
}

/* ⚠️ 「查無此工號」是試辦期最常出現的畫面（名冊還沒補齊）。
   所以錯誤訊息不能只說「錯了」，要告訴他下一步能做什麼 */
.result.error {
  color: #7A1616;
  background: var(--danger-bg);
  border: 0;
  font-weight: 600;
}


/* ===== 狀態畫面（載入中 / 成功）=====

   ⚠️ 這個 app 的載入時間是 **3～8 秒**（Apps Script 的固定成本）。
      那幾秒使用者看到什麼，決定他覺得系統「在跑」還是「壞了」。
*/

.state-box {
  text-align: center;
  padding: var(--sec-gap) 20px;
  color: var(--text-muted);
}

/*
 * 骨架：先把「等一下會出現什麼形狀」畫出來。
 *
 * ⚠️ 為什麼不用轉圈圈：轉圈圈只表達「還在忙」，
 *    形狀則表達「東西正在來，而且長這樣」——後者讓人願意多等幾秒。
 */
.skeleton {
  display: block;
  height: 48px;
  border-radius: var(--radius);
  background: linear-gradient(90deg,
              var(--surface-alt) 25%, var(--surface) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton + .skeleton { margin-top: 10px; }
.skeleton-sm { height: 20px; width: 42%; border-radius: var(--radius-sm); }

@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--action);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ⚠️ 有些人開了系統的「減少動態」（會頭暈、或前庭功能敏感）。
   要尊重那個設定，否則這兩個動畫會讓他們不舒服 */
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .spinner  { animation-duration: 2.4s; }
}

.success-box {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
}

/* 打勾放進一個實心圓裡：顏色是「已結案」的綠，
   而綠色在這一版是有意義的顏色（成功），不是裝飾 */
.success-icon {
  width: 62px; height: 62px; margin: 0 auto 4px;
  border-radius: 50%;
  background: var(--ok); color: #F2F2EF;
  display: flex; align-items: center; justify-content: center;
}
.success-icon svg { width: 30px; height: 30px; stroke-width: 2.4; }

.success-box h2 {
  font-size: var(--fs-title);
  margin: 14px 0 4px;
}

/* 案件編號是整段流程的情緒高點，也是使用者唯一需要記住的東西。
   ⚠️ 原本用虛線框——虛線在這一版看起來像「未完成」。改成實心卡片 */
.case-box {
  margin: var(--sec-gap) 0 8px;
  padding: 18px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--lift-1);
}

.case-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.case-id {
  font-size: var(--fs-title);
  font-weight: 700;
  letter-spacing: .04em;
  /* 等寬數字：編號要一眼看清楚、抄得下來 */
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-top: 4px;
  word-break: break-all;
}


/* ===== 頁尾系統資訊 ===== */

.site-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  line-height: 1.8;
}

.site-footer:empty {
  display: none;      /* SYSTEM_INFO 全部留空時不要留一條孤零零的線 */
}


/* ===== 餐別（單選）===== */

.meal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.meal-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 76px;
  padding: 10px 4px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.meal-btn.selected {
  color: var(--brand-dark);
  background: var(--brand-light);
  border-color: var(--brand);
  font-weight: 600;
}

.meal-icon svg { width: 22px; height: 22px; display: block; }
.meal-label { font-size: var(--fs-xs); text-align: center; line-height: 1.3; }


/* ===== 照片 ===== */

.photo-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.photo-list:empty { display: none; }

.photo-item {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-size {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 4px;
  font-size: 11px;
  text-align: center;
  color: #F2F2EF;
  background: rgba(26, 26, 28, .62);
}

.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  font-size: 18px;
  line-height: 1;
  color: #F2F2EF;
  background: rgba(26, 26, 28, .68);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.photo-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap-min);
  margin-top: 10px;
  padding: 12px;
  font-size: var(--fs-body);
  font-family: inherit;
  color: var(--brand-dark);
  background: var(--brand-light);
  border: 1.5px dashed var(--brand-border);
  border-radius: var(--radius);
  cursor: pointer;
}

.photo-add:disabled {
  color: var(--text-muted);
  background: var(--surface-alt);
  border-color: var(--border-strong);
  cursor: wait;
}

.photo-add-icon svg { width: 20px; height: 20px; display: block; }


/* ===== 查詢結果 ===== */

.result-info {
  margin: 16px 0 10px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.case-card {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  overflow: hidden;
}

/* 展開中的案件：用陰影浮起來，不用框線換色
   （一整頁灰卡片裡，1px 的框線差異掃過去根本看不到）*/
.case-card.open { box-shadow: var(--lift-1); }

.case-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px;
  font-family: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.case-head-main { flex: 1; min-width: 0; }

.case-no {
  font-size: var(--fs-body);
  font-weight: 700;
  letter-spacing: .3px;
}

.case-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.case-head-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.case-arrow { color: var(--text-subtle); font-size: 14px; }

/* 狀態徽章：紅 = 未處理、黃 = 處理中、綠 = 已結案 */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* ⚠️ 顏色一律走 token，不要寫死。
   員工端查詢頁、管理端案件列表、排程寄出的信這三個地方顯示的是同一批狀態，
   三邊用不同色碼的話，同一件案子會出現三種顏色 */
.status-badge.new  { color: var(--danger); background: var(--danger-bg); }
.status-badge.proc { color: var(--warn);   background: var(--warn-bg); }
.status-badge.done { color: var(--ok);     background: var(--ok-bg); }

.case-detail {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.case-row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  font-size: var(--fs-sm);
}

.case-row-label {
  flex: 0 0 92px;
  color: var(--text-muted);
}

.case-row-value {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.chip {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 2px 10px;
  font-size: var(--fs-xs);
  color: var(--brand-dark);
  background: var(--brand-light);
  border-radius: var(--radius-pill);
}

.case-stars { color: var(--star); letter-spacing: 2px; }

.case-photo {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 6px 12px;
  font-size: var(--fs-sm);
  color: var(--brand-dark);
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.case-reply {
  margin-top: 12px;
  padding: 12px;
  font-size: var(--fs-sm);
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}

.case-reply.empty {
  color: var(--text-muted);
  background: var(--surface-alt);
  border-color: var(--border);
}

.case-reply-title {
  font-weight: 600;
  color: var(--ok);
  margin-bottom: 4px;
}

.case-reply-time {
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}


/* ===== 照片縮圖與全螢幕檢視 ===== */

.case-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.case-thumb {
  width: 88px;
  height: 88px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-alt);
  cursor: zoom-in;
}

.case-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 20, 22, .93);
  cursor: zoom-out;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.no-scroll { overflow: hidden; }


/* ===== 管理端 ===== */

/* 登入頁比員工端窄一些，看起來才像一張「表單」而不是一整頁 */
.page-narrow { max-width: 420px; }

/* 登入 / 改密碼畫面上方的大圖示 */
/* 登入 / 改密碼畫面上方的圖示。
   ⚠️ 原本是 emoji（🔐 / 🔑）——每支手機長得不一樣，而且不能上色。
      改成線性 SVG，顏色跟著文字走 */
.admin-badge {
  width: 56px;
  height: 56px;
  margin: var(--sec-gap) auto 10px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--lift-1);
}

.admin-badge svg { width: 26px; height: 26px; }

.admin-title {
  font-size: var(--fs-title);
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}

.admin-lead {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
}

/* 登入後顯示「你好，某某」與登出按鈕 */
.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 10px 14px;
  margin-bottom: var(--gap);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
  font-size: var(--fs-sm);
}

.admin-bar-who {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;               /* 姓名太長時才會正確截斷而不是撐破版面 */
}

.admin-bar-who > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-bar-logout {
  flex-shrink: 0;
  /* ⚠️ 原本只有 37px。管理者一天要按好幾次，而且可能在現場用手機 */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: var(--fs-sm);
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.admin-bar-logout:active { background: var(--surface-alt); }

/* 員工端首頁角落的低調管理者入口 */
/* ⚠️ 這個連結刻意保持低調（規格 §6.4），所以視覺上很小。
   但「看起來小」不代表「按起來要小」——用 padding 把可點範圍撐到 44px，
   外觀完全不變。管理者一天要按好幾次 */
.admin-entry {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  margin-top: 4px;
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  text-decoration: none;
}

.admin-entry:active { color: var(--text-muted); }


/* ===== 管理端：案件列表 ===== */

/* 案件列表資訊量大，比員工端寬一些 */
.page-wide { max-width: 760px; }

/* --- 統計卡片 --- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: var(--gap);
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px;
  font-family: inherit;
  color: inherit;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--lift-1);
  cursor: pointer;
}

.stat-card:active { background: var(--surface-alt); }

/* 目前正依這個狀態篩選。
   ⚠️ 原本只是把框線換色——在一排三張一模一樣的卡片裡，
      1px 的框線差異幾乎看不出來。改成實心反白，一眼就知道正在篩哪一個 */
.stat-card.active {
  --fg: #F2F2EF;
  color: var(--fg);
  background: var(--action);
  box-shadow: var(--lift-1);
}

.stat-card.active .stat-label { color: #C2C2BD; }
/* 反白之後那三個狀態色會看不清楚，統一改成淺色 */
.stat-card.active .stat-num   { color: var(--fg); }

.stat-num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

.stat-new  .stat-num { color: var(--danger); }
.stat-proc .stat-num { color: var(--warn); }
.stat-done .stat-num { color: var(--ok); }

/* 逾期提示。是按鈕（點一下跳到全部時間 + 未處理），但看起來像提示列 */
.overdue-note {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: var(--gap);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: left;
  color: #7A1616;
  background: var(--danger-bg);
  border: 0;
  border-radius: var(--radius-lg);
  /* 整個管理端只有這一列有重陰影——它是唯一「現在就要動」的東西 */
  box-shadow: var(--lift-2);
  cursor: pointer;
}

.overdue-note:active { background: var(--danger-tag); }

/* --- 篩選區 --- */

.filter-box {
  margin-bottom: var(--gap);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px var(--pad-card);
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: 600;
  color: inherit;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.filter-arrow {
  margin-left: auto;
  color: var(--text-subtle);
  font-size: 14px;
}

.tag-active {
  color: var(--brand);
  background: var(--brand-light);
}

.filter-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
  padding: 0 var(--pad-card) var(--pad-card);
  border-top: 1px solid var(--border);
  padding-top: var(--pad-card);
}

.filter-field { display: flex; flex-direction: column; gap: 6px; }

/* 關鍵字欄位佔滿一整列 */
.filter-field-wide { grid-column: 1 / -1; }

.filter-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}

/* 日期欄位在 iOS 上預設高度會跟其他欄位對不齊 */
input[type="date"] {
  width: 100%;
  height: 46px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: var(--fs-input);
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.filter-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}

/* 篩選區裡的按鈕不要像主要按鈕那樣佔滿整行 */
.btn-inline {
  flex: 1;
  margin-top: 0;
  padding: 12px;
  font-size: var(--fs-body);
}

/* --- 清單上方的資訊列 --- */

.list-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 8px;
}

.list-count {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* 頁首的重新整理鈕：重新載入並回到初始畫面 */
.topbar-refresh {
  flex-shrink: 0;
  /* 手指點得到：觸控目標不可小於 44px（設計變數 --tap-min 是 48） */
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
}

.topbar-refresh:active { background: var(--surface-alt); }
.topbar-refresh:disabled { opacity: .5; cursor: not-allowed; }

.refresh-icon { display: inline-block; }

/* 載入中時讓圖示轉起來，看得出正在做事 */
.topbar-refresh.spinning .refresh-icon {
  animation: refresh-spin .8s linear infinite;
}

@keyframes refresh-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.result.warn {
  color: var(--warn);
  background: var(--warn-bg);
  border: 0;
  margin-bottom: var(--gap);
}

/* --- 逾期案件（規格 §6.5：未處理超過 3 天整列標紅）--- */

.case-card.overdue {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.case-card.overdue.open { border-color: var(--danger); }

.overdue-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-tag);
  border-radius: var(--radius-pill);
  vertical-align: middle;
}

/* 工號用等寬字，前導零看得比較清楚 */
.case-emp-id {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.case-soon {
  margin-top: 10px;
  padding: 10px;
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  text-align: center;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}

/* 桌機上篩選欄位排三欄比較不浪費空間 */
@media (min-width: 640px) {
  .filter-body { grid-template-columns: repeat(3, 1fr); }
}


/* ===== 管理端：回覆表單 ===== */

.result.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  margin-bottom: var(--gap);
}

.reply-form {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-alt);
  border: 0;
  border-radius: var(--radius-lg);
}

.reply-title {
  font-size: var(--fs-body);
  font-weight: 600;
  margin-bottom: 12px;
}

.reply-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* 狀態下拉與回覆框之間要有距離，否則看起來像同一個欄位 */
.reply-form .reply-status { margin-bottom: 14px; }

.reply-lang {
  font-size: var(--fs-xs);
  color: var(--brand);
  margin-bottom: 8px;
}

/* --- 回覆範本快捷按鈕 --- */

.template-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.template-label {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}

.template-btn {
  max-width: 100%;
  padding: 6px 10px;
  font-family: inherit;
  font-size: var(--fs-xs);
  color: var(--brand);
  text-align: left;
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-pill);
  cursor: pointer;

  /* 範本可能很長，一律截斷成一行，版面才不會被撐開 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-btn:active { background: var(--brand-border); }

/* --- 必填提示 --- */

.reply-required {
  margin-top: 8px;
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}

/* 切到「處理中」或「已結案」時才變醒目 */
.reply-required.active {
  color: var(--warn);
  font-weight: 600;
}

.reply-error { margin-top: 10px; }

/* 逾期案件是紅底，表單改成白底才看得清楚 */
.case-card.overdue .reply-form {
  background: var(--surface);
}


/* ===== 月份選擇 ===== */

/* --- 檢視範圍列 --- */

.period-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap-min);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: 600;
  color: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
}

.period-bar:active { background: var(--surface-alt); }

.period-count {
  margin-left: auto;
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-muted);
}

.period-caret {
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1;
}

/*
 * ⚠️ 這份清單會**隨著時間越來越長**——每個有案件的月份都是一列。
 *    現在只有幾個月還好，一年後就是十幾列，展開之後整頁被推得很長，
 *    使用者得先捲過一大片才看得到案件。
 *
 *    所以限制高度：一次露出「全部時間 + 約 3 個月」，其餘用捲的。
 *
 * ⚠️ 高度刻意不是整數列，而是**留半列露在下面**——
 *    那是「下面還有東西」最便宜也最有效的提示。
 *    切齊整列的話，使用者會以為清單就這麼多。
 */
.month-picker {
  margin-bottom: var(--gap);
  padding: 8px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);

  /*
   * 高度跟著螢幕走，不是固定值：
   *
   *   手機直立（812px）→ 約 244px：全部時間 + 3 個多月（使用者要的就是這個）
   *   電腦（1200px）    → 約 360px：全部時間 + 5 個多月，大螢幕不浪費
   *   手機橫放（400px） → 夾在下限 190px，才不會整個畫面被清單佔滿
   *
   * ⚠️ 用 dvh 而不是 vh：手機瀏覽器的網址列會伸縮，
   *    `vh` 算的是「網址列縮起來時」的高度，所以清單會比實際可視範圍還高。
   *    下面兩行是漸進式的——不支援 dvh 的舊瀏覽器會用到第一行。
   */
  max-height: clamp(190px, 30vh,  420px);
  max-height: clamp(190px, 30dvh, 420px);

  overflow-y: auto;
  -webkit-overflow-scrolling: touch;   /* iOS 的慣性捲動 */
  overscroll-behavior: contain;        /* 捲到底不要連帶把整頁也捲動 */
}

/* 捲動時標題留在最上面，才知道自己在看什麼 */
.month-picker-title {
  position: sticky;
  top: -8px;                            /* 抵銷 .month-picker 的 padding */
  z-index: 1;
  padding: 8px 8px 8px;
  margin: -8px -8px 0;
  background: var(--surface);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.month-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 12px;
  font-family: inherit;
  font-size: var(--fs-body);
  color: inherit;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.month-item:active { background: var(--surface-alt); }

/* 選中＝實心近黑，與分類按鈕、統計卡片同一套語彙。
   原本是「深色字 + 淺灰底」，在一長串同樣的列裡不夠明顯 */
.month-item.active {
  --fg: #F2F2EF;
  color: var(--fg);
  font-weight: 700;
  background: var(--action);
}

.month-count {
  flex-shrink: 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.month-item.active .month-count { color: #C2C2BD; }


/* ===== 指派處理者 ===== */

.reply-form .reply-handler { margin-bottom: 4px; }

.reply-handler-hint {
  margin-bottom: 14px;
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}

/* 案件摘要上的「已指派給誰」 */
.case-assigned { color: var(--brand); }


/* ===== 管理端：帳號管理（僅 SUPER）===== */

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;          /* 觸控目標不可小於 44px */
  margin-bottom: 4px;
  padding: 0 2px;
  color: var(--brand);
  font-size: var(--fs-sm);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.add-form { padding: var(--pad-card); }

.add-form-title {
  margin: 0 0 12px;
  font-size: var(--fs-lg);
  font-weight: 600;
}

.field-hint {
  margin: 4px 0 12px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

/* --- 管理者列表 --- */

.admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--pad-card);
  margin-bottom: 10px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
}

/* 已停用的整列調淡，一眼就能分辨誰還在用 */
.admin-row-disabled { background: var(--surface-alt); }
.admin-row-disabled .admin-row-name,
.admin-row-disabled .admin-row-account { color: var(--text-muted); }

.admin-row-main { flex: 1 1 220px; min-width: 0; }

.admin-row-name {
  font-size: var(--fs-body);
  font-weight: 600;
  word-break: break-word;
}

.admin-row-account {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  word-break: break-all;   /* 帳號通常是 email，長字串要能斷行才不會撐破版面 */
}

.admin-row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.admin-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  color: var(--text-subtle);
  font-size: var(--fs-xs);
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag-role-super {
  color: var(--brand-dark);
  background: var(--brand-light);
}

.tag-status-active {
  color: var(--ok);
  background: var(--ok-bg);
}

.tag-status-disabled {
  color: var(--text-muted);
  background: var(--surface-alt);
}

.tag-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

/*
 * 列上的動作按鈕。
 *
 * ⚠️ display / width / margin-top 三個一定要蓋掉：
 *    .btn-primary 與 .btn-secondary 的基底是 `display:block; width:100%`
 *    （那是給表單裡的整排大按鈕用的）。不蓋掉的話，
 *    這兩顆按鈕在桌機上會各自撐滿一整行、上下疊起來。
 *
 * 高度仍然維持 44px 以上——工廠現場可能戴著手套操作。
 */
.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 44px;
  margin-top: 0;
  padding: 0 14px;
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.btn-small:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* --- 一次性密碼彈窗 --- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 20, 22, .68);
}

.pw-box {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
}

.pw-title {
  margin: 0 0 8px;
  font-size: var(--fs-lg);
  font-weight: 600;
}

.pw-who {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/*
 * 密碼本體。刻意用等寬字體並放大——
 * 這組字要被人抄到紙上或唸給對方聽，
 * 分不出 l 和 1 的話對方就登不進去。
 */
.pw-value {
  padding: 14px 12px;
  margin-bottom: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 2px;
  word-break: break-all;
  user-select: all;              /* 點一下就整組選起來，方便手動複製 */
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
}

.pw-warn {
  margin: 16px 0 8px;
  padding: 10px 12px;
  color: var(--danger);
  font-size: var(--fs-xs);
  line-height: 1.6;
  text-align: left;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
}

.pw-next {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.6;
  text-align: left;
}

/* 窄螢幕：動作按鈕改成整列平分，才不會被擠成兩行又難點 */
@media screen and (max-width: 480px) {
  .admin-row-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .btn-small { width: 100%; }
}


/* 資訊列右側：帳號管理連結 + 登出 */
.admin-bar-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.admin-bar-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;          /* 觸控目標不可小於 44px */
  color: var(--brand);
  font-size: var(--fs-sm);
  text-decoration: none;
  white-space: nowrap;
}
.admin-bar-link:hover { text-decoration: underline; }


/* --- 重設密碼對話框 --- */

.pw-box-form { text-align: left; }

.pw-choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 44px;              /* 觸控目標 */
  padding: 12px;
  margin-bottom: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/*
 * 被選到的那一項要一眼看得出來，不能只靠圓點那幾個像素。
 * `:has()` 在很舊的瀏覽器上不支援——那種情況只是少了底色，
 * 圓點還是會顯示選中狀態，功能不受影響。
 */
.pw-choice:has(input:checked) {
  background: var(--brand-light);
  border-color: var(--brand-border);
}

.pw-choice input { margin-top: 3px; flex: none; }

.pw-choice-title {
  display: block;
  font-size: var(--fs-body);
  font-weight: 500;
}

.pw-choice-hint {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

.pw-manual { margin: 4px 0 12px; }

.pw-manual input[type="password"],
.pw-manual input[type="text"] {
  width: 100%;
  margin-top: 4px;
}

.pw-show {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  cursor: pointer;
}


/* --- 修改姓名對話框 --- */

.pw-box-form input[type="text"] {
  width: 100%;
  margin-top: 4px;
}

/*
 * 一列現在有三顆按鈕（改名字 / 重設密碼 / 停用）。
 * 窄螢幕維持兩欄，第三顆自動掉到下一行——
 * 硬擠成三欄的話，印尼文的「Reset Kata Sandi」會被切掉。
 */


/* ===== 管理端：Dashboard 動態表（僅 SUPER）===== */

.dash-title {
  margin: 0 0 14px;
  font-size: var(--fs-title);
  font-weight: 600;
}

/*
 * 卡片的「立體感」：四邊都有框線，但下緣與右緣加粗一階。
 * 不用陰影是刻意的——這一頁未來可能要複製到 Google Sheet 或截圖給人看，
 * 而框線是各種環境都做得出來的效果。
 */
.dash-card,
.dash-tile {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
}

.dash-card { padding: var(--pad-card); margin-bottom: 6px; }

.dash-card-table { padding: 4px var(--pad-card) var(--pad-card); overflow-x: auto; }

/* --- 控制列 --- */

.dash-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: flex-end;
  padding: 12px var(--pad-card);
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-strong);
  border-right: 2px solid var(--border-strong);
  border-radius: var(--radius);
}

.dash-control { display: flex; flex-direction: column; gap: 4px; }
.dash-control select { min-height: 44px; }

.dash-updated {
  margin-left: auto;
  color: var(--text-subtle);
  font-size: var(--fs-xs);
}

/* --- 區塊標題 --- */

.dash-section {
  margin: 0 0 12px;
  font-size: var(--fs-lg);
  font-weight: 600;
}

/* 年度區塊上方拉一條線，跟月份區塊分開——兩個區塊各有自己的下拉，
   沒有分隔的話很容易以為下面的數字也是跟著月份走的 */
.dash-section-top {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
}

.dash-sub {
  margin: 16px 0 8px;
  font-size: var(--fs-body);
  font-weight: 600;
}

.dash-note {
  margin: -4px 0 8px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

/* --- 數字方塊 --- */

.dash-tiles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.dash-tiles-4 { grid-template-columns: repeat(4, 1fr); }

.dash-tile { padding: 12px; }

.dash-tile-num {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

/* 未處理件數用警示色——那是唯一一個「數字大就是壞事」的欄位 */
.dash-tile-alert { color: var(--danger); }

.dash-tile-label {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.4;
}

/* --- 橫條圖 --- */


.dash-bar-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.dash-bar-row:last-child { margin-bottom: 0; }

.dash-bar-name {
  flex: none;
  width: 104px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-bar-track {
  flex: 1;
  height: 18px;
  overflow: hidden;
  background: var(--surface-alt);
  border-radius: 4px;
}

.dash-bar-fill { height: 100%; border-radius: 4px; }

.dash-bar-value {
  flex: none;
  width: 46px;
  font-size: var(--fs-sm);
  text-align: right;
}

/* --- 趨勢圖 --- */

.dash-trend { width: 100%; height: auto; }
.dash-trend line { stroke: var(--border); stroke-width: 1; }

.dash-trend-label {
  fill: var(--text-subtle);
  font-size: 11px;
  text-anchor: middle;
}

.dash-legend {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.legend-line {
  display: inline-block;
  width: 14px;
  height: 2px;
  vertical-align: middle;
}
/* ⚠️ 圖例的顏色要跟圖表本身一致。
   回報數用中性深色——**回報數多不代表壞，也不代表好**，上色等於幫讀者下結論；
   滿意度沿用星等色，因為它跟星星講的是同一件事 */
.legend-count  { background: var(--action); }  /* 與 js/admin-dashboard.js 的 TREND_COUNT_COLOR 一致 */
.legend-rating { background: var(--chart-rating); }   /* 與 js/admin-dashboard.js 的 TREND_RATING_COLOR 一致 */

/* --- 各餐廳表現表 --- */

.dash-table {
  width: 100%;
  min-width: 460px;
  font-size: var(--fs-sm);
  border-collapse: collapse;
}

.dash-table th {
  padding: 8px 6px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  border-bottom: 2px solid var(--border);
}

.dash-table td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--border);
}

.dash-table .num { text-align: right; }

/* 窄螢幕：方塊改兩欄、雙欄圖表改單欄，才不會擠成一團看不清楚 */
@media screen and (max-width: 700px) {
  .dash-tiles,
  .dash-tiles-4 { grid-template-columns: repeat(2, 1fr); }
  .dash-bar-name { width: 84px; }
  .dash-updated { margin-left: 0; width: 100%; }
}


/* ===== 管理端：頁籤導覽 ===== */

/*
 * 三個管理頁共用。之前這些入口是資訊列右邊的幾個小連結，
 * 位置不夠放（再多一個功能就爆了），而且看不出「我現在在哪一頁」。
 */
.admin-nav {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-nav::-webkit-scrollbar { display: none; }

/* 操作說明：推到導覽列最右邊，顏色比其他分頁淡一階——
   它不是「另一個功能頁」，是需要時才會去點的東西。
   ⚠️ 用 --text-muted 不用 --text-subtle：管理列的底是 --surface，
      比頁面底色亮，淡色在上面的對比度會再掉一點 */
.admin-nav-help {
  margin-left: auto;
  color: var(--text-muted);
}
.admin-nav-help::before {
  content: '?';
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-right: 6px;
  border: 1.5px solid currentColor; border-radius: 50%;
  font-size: 11px; font-weight: 700; line-height: 1;
}

.admin-nav-tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;              /* 觸控目標 */
  padding: 0 14px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.admin-nav-tab:hover { color: var(--text); }

/* 目前這一頁：底線 + 加深。它是 <span> 不是 <a>，點自己沒有意義 */
/* ⚠️ 底線用 3px 不是 2px：2px 在手機上幾乎看不出來，
   而這條線是「我在哪一頁」的唯一線索 */
.admin-nav-tab.active {
  color: var(--text);
  font-weight: 700;
  border-bottom-width: 3px;
  border-bottom-color: var(--action);
  cursor: default;
}

/* 頁籤進來之後，資訊列改成左右兩塊：左邊頁籤、右邊登入者 */
.admin-bar-who {
  display: flex;
  gap: 10px;
  align-items: center;
  white-space: nowrap;
}

/* 窄螢幕：頁籤自己一行，登入者資訊掉到第二行 */
@media screen and (max-width: 560px) {
  .admin-bar {
    flex-wrap: wrap;
    padding-top: 0;
  }
  .admin-nav { flex: 1 0 100%; }
  .admin-bar-who {
    flex: 1 0 100%;
    justify-content: flex-end;
    padding-bottom: 8px;
  }
}


/* ===== 電腦螢幕：版面自動加寬 ===== */

/*
 * 沒有任何切換開關——純粹依螢幕寬度自動調整。
 *
 * ⚠️ 只放寬管理端（.page-wide），員工端維持 520px。
 *    回報表單拉到 1200px 寬的話，眼睛要橫掃很遠才填得完一欄，
 *    而且員工幾乎都用手機，那個寬度根本用不到。
 *    管理端相反：表格、圖表、月度趨勢都是越寬越好讀。
 */
@media (min-width: 1000px) {
  .page-wide { max-width: 940px; }
}

@media (min-width: 1280px) {
  .page-wide { max-width: 1160px; }
}

/* 超寬螢幕就停在這裡：再寬下去一列會太長，眼睛跟不上 */
@media (min-width: 1600px) {
  .page-wide { max-width: 1320px; }
}


/* ===== 電腦螢幕：字級放大、卡片浮起 ===== */

/*
 * ⚠️ 這裡原本有一段「電腦上把字級換成固定值」的規則，關卡 5-2 已移除。
 *
 *    字級改用 clamp() 之後，手機到電腦本來就是連續縮放的，
 *    這一段固定值反而會在 1000px 以上**蓋掉 clamp**，
 *    電腦上就變回跳一階、而且不再隨視窗變化。
 *
 *    要調整電腦上的字級，改 :root 裡那組 clamp 的第三個參數（上限）就好。
 */

/*
 * 卡片的浮起效果。
 *
 * 先前用「下緣右緣框線加粗」是因為當時還在考慮日後搬回 Google Sheet，
 * 而 Sheet 做不出陰影。動態表確定做成網頁之後那個限制就不存在了，
 * 改用真的陰影，層次比框線清楚很多。
 */
/* ⚠️ 用統一的 --lift-1，不要自己另外算一組陰影。
   陰影一旦有兩套來源，日後調整只會改到其中一套，
   同一頁上就會出現深淺不一的卡片 */
.dash-card,
.dash-tile,
.dash-controls {
  border: 0;
  box-shadow: var(--lift-1);
}

.dash-tile { transition: box-shadow .15s; }

/* --- 三張圖表在寬螢幕並排 --- */

/*
 * 原本是「兩欄 + 一個整寬」，在 1160px 的版面上第三張圖左右一片空白。
 * 改成同一個 grid：手機一欄、平板兩欄、電腦三欄，空間才用得滿。
 */
.dash-charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  margin-bottom: 6px;
}

@media (min-width: 700px)  { .dash-charts { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .dash-charts { grid-template-columns: repeat(3, 1fr); } }

/*
 * 三張圖表的條數不一樣（餐廳 4 條、狀態 3 條、分類 5 條），
 * 拉成等高的話，條數少的那張下半部就是一片空白。
 * 讓每張卡片維持自然高度，上緣對齊即可——空白就消失了。
 */
.dash-charts { align-items: start; }
.dash-chart-block .dash-card { margin-bottom: 0; }

/* --- 電腦上把數字放大，卡片才不會一片空 --- */

@media (min-width: 1000px) {
  .dash-tile     { padding: 16px 18px; }
  .dash-tile-num { font-size: 30px; }
  .dash-card     { padding: 18px; }
  .dash-bar-row  { margin-bottom: 10px; }
  .dash-bar-track { height: 22px; }
  .dash-bar-name { width: 120px; }
  .dash-table td { padding: 11px 8px; }
}

/* --- 手機：各餐廳表現改成一張一張的卡片 --- */

/*
 * 表格在 375px 上一定塞不下五欄，原本是靠橫向捲動——
 * 但捲動軸在手機上看不到，使用者根本不知道右邊還有東西。
 * 改成每間餐廳一張卡片，欄位名稱用 ::before 從 data-label 帶出來。
 */
@media screen and (max-width: 700px) {
  .dash-card-table { overflow-x: visible; }

  .dash-table { min-width: 0; }
  .dash-table thead { display: none; }

  .dash-table tbody,
  .dash-table tr,
  .dash-table td { display: block; width: 100%; }

  .dash-table tr {
    padding: 10px 0 4px;
    border-bottom: 1px solid var(--border);
  }
  .dash-table tr:last-child { border-bottom: none; }

  .dash-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 4px 0;
    border-bottom: none;
    text-align: left;
  }

  /* 第一格是餐廳名稱，當成這張卡片的標題 */
  .dash-table td:first-child {
    margin-bottom: 4px;
    font-size: var(--fs-body);
    font-weight: 600;
  }

  .dash-table td:not(:first-child)::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--fs-sm);
  }

  .dash-table .num { text-align: right; }
}


/* ===== 列印 / 匯出 PDF ===== */

/*
 * 動態表的〔列印 / 存成 PDF〕走的是瀏覽器原生的列印功能。
 *
 * 為什麼不做成「輸出圖片」：瀏覽器沒有原生把網頁轉成圖片的 API，
 * 唯一的作法是引入 html2canvas 之類的函式庫——那會是這個專案的第一個外部依賴，
 * 而且它是「用 canvas 重畫一次 CSS」，某些樣式會走鐘。
 * 列印是原生功能，零依賴、版面完全可控，而且手機與電腦都能「另存為 PDF」。
 *
 *
 * ⚠️ 手機版的斷點一律寫成 `@media screen and (max-width: ...)`。
 *    A4 扣掉邊界之後的內容寬度約 703px，剛好卡在 700px 斷點上——
 *    不限定 screen 的話，列印時會不定地跳成手機版的卡片排版。
 */

.print-only,
.print-watermark { display: none; }

@media print {

  @page {
    size: A4;
    margin: 12mm;
  }

  /*
   * ⚠️ 字級一定要在這裡改回固定值。
   *
   *    :root 的字級是 clamp(..., ...vw, ...)，而**列印時的 vw 指的是紙張寬度**，
   *    算出來的字級無法預期（跟螢幕寬度完全無關）。
   *    用 pt 是因為紙張的單位本來就是 pt，不受縮放影響。
   */
  :root {
    --fs-xs:      8pt;
    --fs-sm:      9pt;
    --fs-body:    10pt;
    --fs-input:   10pt;
    --fs-lg:      12pt;
    --fs-title:   16pt;
    --fs-display: 22pt;
    --gap:        8pt;
    --pad-card:   10pt;
    --sec-gap:    14pt;
  }

  /* 紙張沒有捲動，版面上限拿掉才不會左右留白 */
  .page,
  .page-wide { max-width: none; padding: 0; }

  /* 紙張本來就是白的，而且白底最省墨。
     ⚠️ 文字色不改回黑——螢幕上的 #1A1A1D 印出來也很正常，
        兩邊一致比較好對照 */
  body { background: #ffffff; color: var(--text); }

  /*
   * 預設瀏覽器會把背景色與圖片省略以節省墨水，
   * 但這一頁的重點就是彩色長條圖——省略之後整張圖會變成空白框。
   */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* --- 螢幕上才有意義的東西，紙上一律不要 --- */
  .topbar,
  .admin-bar,
  .site-footer,
  .dash-controls,
  .lang-switch,
  #bootView,
  #errorView { display: none !important; }

  /* --- 紙本專用的抬頭：把被隱藏的下拉換成文字 --- */
  .print-only { display: block; }

  .print-header {
    padding-bottom: 10px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--text);
  }

  .print-header-title {
    font-size: 18pt;
    font-weight: 600;
  }

  .print-header-meta {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10pt;
  }

  /* --- 紙上的字級另外定，不能沿用螢幕的 --- */

  /*
   * 螢幕的字級放大只在 min-width:1000px 生效，
   * 而紙張寬度只有 ~700px，不設的話會拿到手機用的 12px，印出來很吃力。
   */
  .dash-title    { display: none; }          /* 抬頭已經有標題了 */
  .dash-section  { font-size: 14pt; margin: 0 0 8px; }
  .dash-sub      { font-size: 11pt; margin: 10px 0 6px; }
  .dash-note     { font-size: 8.5pt; }
  .dash-tile-num { font-size: 16pt; }
  .dash-tile-label,
  .dash-bar-name,
  .dash-bar-value,
  .dash-legend,
  .dash-table    { font-size: 9pt; }

  /* --- 卡片：紙上不要陰影，留框線就好 --- */
  .dash-card,
  .dash-tile {
    box-shadow: none;
    border: 1px solid var(--border-strong);
  }

  .dash-card { padding: 10px; }
  .dash-tile { padding: 8px 10px; }

  /* --- 版面：紙張放得下三欄 --- */
  /*
   * ⚠️ 紙是直的，三張圖並排會很難讀。
   *
   *    A4 扣掉邊界只有 703px 寬，切三欄之後每欄只剩約 230px——
   *    長條圖短到分不出「42 件」跟「31 件」的差別，那張圖就白畫了。
   *
   *    改成一欄之後每張圖有整個紙寬可以伸展，而且**剛好把第 1 頁填滿**——
   *    原本月份區塊只佔第 1 頁的 37%，下面 63% 是空白。
   */
  .dash-charts { grid-template-columns: 1fr; gap: 14px; }
  .dash-tiles  { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .dash-tiles-4 { grid-template-columns: repeat(4, 1fr); }

  /* 紙上的長條圖可以做大：看得清楚比塞得多重要 */
  .dash-bar-track { height: 20px; }
  .dash-bar-row   { margin-bottom: 12px; }
  .dash-bar-name  { width: 130px; }
  .dash-tile      { padding: 14px 12px; }
  .dash-tile-num  { font-size: 22pt; }

  /* --- 斷頁 --- */

  /* 一張卡片被切成兩頁是最難讀的情況，寧可整張推到下一頁 */
  .dash-card,
  .dash-tile,
  .dash-chart-block,
  .dash-table tr { break-inside: avoid; page-break-inside: avoid; }

  /* 標題不可以留在頁尾、內容跑到下一頁 */
  .dash-section,
  .dash-sub { break-after: avoid; page-break-after: avoid; }

  /*
   * 第 1 頁＝月份、第 2 頁＝年度。
   *
   * ⚠️ 斷頁指令下在 `<section>` 上，不是下在裡面的 `<h3>` 上。
   *    原本下在 h3，而那個 h3 同時還有 `break-after: avoid`（標題不可與內容分離）——
   *    兩個指令打在同一個元素上，某些瀏覽器會多插一次斷頁，
   *    結果中間跑出一整片空白。
   */
  #yearSection {
    break-before: page;
    page-break-before: always;
  }

  .dash-section-top {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  /*
   * ⚠️ 月份區塊不要再被切開。
   *    它裡面的圖表若有一塊放不下而整塊被推到下一頁，
   *    第 1 頁下半就會空掉，看起來像「中間空白太大」。
   */
  #monthSection { break-inside: avoid; page-break-inside: avoid; }

  /* --- 浮水印 --- */

  /*
   * ⚠️ 用 `position: fixed` 才會**每一頁都出現**（列印時 fixed 元素會重複在每頁）。
   *
   * ⚠️ z-index 不能用負值。列印時 body 有白色底色，
   *    負的 z-index 會讓浮水印被那片白底蓋掉，變成完全看不見。
   *    正確做法是浮水印 z-index:0、內容 z-index:1。
   *
   * ⚠️ 字級不能太大。旋轉之後的水平寬度若超過紙寬（A4 扣邊界約 703px），
   *    會撐出額外的空白頁。54pt 旋轉 30 度後約 460px，安全。
   */
  .print-watermark {
    display: block;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    z-index: 0;

    /*
     * 兩行：中文主標 + 印尼文副標（v3.9）。
     *
     * ⚠️ **字級不是隨便挑的，是量出來的。** 限制在於「最長的那一行」——
     *    `Laporan internal GA PCI` 有 23 個字元，它決定了整體能多大。
     *
     *    實測（A4 可用寬度 703px，旋轉 30 度後的外框）：
     *      兩行都 54pt   → 1039px  🔴 超出 336px，會被裁掉還可能多一張空白頁
     *      34pt / 17pt   →  372px  ✅ 目前採用
     *      46pt / 23pt   →  498px  ✅ 也可以（跟舊版單行的 507px 幾乎一樣）
     *
     *    所以要放大的話，**上限大約在 46/23 那一組**，再大就要縮短印尼文那一行。
     *
     * ⚠️ 中文那行需要 CJK 字型。字型堆疊裡的 "Noto Sans TC" 並沒有被載入
     *    （這個專案刻意不載外部字型），所以實際上是掉到系統的 CJK 字型。
     *    在沒有中文字型的電腦上列印會變成方框——但那台電腦本來也看不懂這份報表。
     */
    font-weight: 800;
    letter-spacing: .12em;
    line-height: 1.3;
    white-space: nowrap;
    text-align: center;
    color: var(--text);
    /*
     * 淡到不影響閱讀，但轉 PDF 或影印之後仍看得出來。
     *
     * ⚠️ 這個值不能再往下調太多。螢幕上的 PDF 預覽會比實際印在紙上明顯，
     *    低於 4% 之後很多雷射印表機會直接把它當成白色不印。
     *    真的印出來看不到的話，把這裡調回 .06～.07。
     */
    opacity: .08;
    pointer-events: none;
  }

  .print-watermark div { white-space: nowrap; }
  .wm-l1 { font-size: 34pt; }

  /*
   * 副標再淡一階。
   * ⚠️ opacity 會**相乘**：外層 .08 × 這裡的 .85 = 實際約 6.8%，
   *    仍高於「低於 4% 印表機會直接不印」的下限。
   *    要再淡的話改外層那個值，不要動這裡——這裡是兩行之間的層次，不是整體濃度。
   */
  .wm-l2 { font-size: 17pt; letter-spacing: .10em; opacity: .85; }

  /* 內容壓在浮水印上面 */
  #mainView { position: relative; z-index: 1; }

  /* --- 表格：紙上維持表格，不要變成卡片 --- */
  .dash-card-table { overflow: visible; }
  .dash-table { min-width: 0; }
  .dash-table th { font-size: 9pt; }
  .dash-table td { padding: 6px 4px; }
}

/* 列印按鈕：跟兩個下拉排在同一列，但要對齊在下緣（下拉上方有標籤） */
.dash-print { align-self: flex-end; }
