/* ============================================================
   聯倉中繼站 — 設計系統 v2
   ------------------------------------------------------------
   風格：Trust & Authority（深藍 + 藍色 CTA）
   選它的理由：這套系統按下去會產生【不可刪除】的 ERP 單據。
   介面要讓人覺得「這是正經的東西，要看清楚再按」，
   而不是輕快好玩。所以不用漸層、不用圓潤大色塊、不用動來動去的裝飾。

   🔴 兩處刻意偏離設計系統產生器的建議，理由寫在下面：

   ① 不用 Calistoga 當標題字體
      它是 Latin-only 的展示襯線體，沒有 CJK 字符。
      中文標題會整片 fallback 到系統字，等於這個「字體配對」從來不會生效 ——
      那是一個看起來有做、實際上沒有的決定。

   ② 不載 Google Fonts
      中文 web font 一套 3–8 MB。我們的客戶是用手機網路在 LINE 裡開這個頁面的團媽。
      系統內建的 PingFang TC／Noto Sans CJK／微軟正黑體 品質已經足夠，
      而且沒有第三方請求、沒有 FOIT、沒有 CLS。
      數字用 tabular-nums 對齊，那才是資料型介面真正需要的。
   ============================================================ */

/* ── 1. 語意化色彩 token ───────────────────────────────────
   🔴 元件裡不准出現裸的 hex。全部走 token，
      否則暗色模式要一個一個找，而且一定會漏。                */
:root {
  color-scheme: light dark;

  /* 中性階 */
  --c-bg:            #f1f5f9;
  --c-surface:       #ffffff;
  --c-surface-2:     #f8fafc;
  --c-surface-sunken: #eef2f7;
  --c-border:        #dbe2ea;
  --c-border-strong: #c3ccd8;

  /* 文字 —— 全部對 surface 驗過 4.5:1 以上 */
  --c-text:          #0f172a;
  --c-text-2:        #475569;   /* 6.0:1 on #fff */
  --c-text-3:        #64748b;   /* 4.6:1 on #fff，只用於次要標籤 */
  --c-text-on-brand: #ffffff;

  /* 品牌 */
  --c-brand:         #0f172a;
  --c-accent:        #0369a1;
  --c-accent-hover:  #075985;
  --c-accent-soft:   #e0f2fe;
  --c-accent-text:   #075985;   /* 在 accent-soft 上 7.1:1 */

  /* 狀態 —— 每一種都有 soft 底 ＋ 可讀的文字色 */
  --c-ok:            #15803d;
  --c-ok-soft:       #dcfce7;
  --c-ok-text:       #14532d;
  --c-warn:          #b45309;
  --c-warn-soft:     #fef3c7;
  --c-warn-text:     #78350f;
  --c-danger:        #dc2626;
  --c-danger-soft:   #fee2e2;
  --c-danger-text:   #991b1b;
  --c-info:          #0369a1;
  --c-info-soft:     #e0f2fe;
  --c-info-text:     #075985;

  --c-focus:         #0369a1;
  --c-scrim:         rgba(15, 23, 42, .55);

  /* 陰影階（elevation）—— 只有這五級，不准臨時發明 */
  --e-0: none;
  --e-1: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
  --e-2: 0 2px 6px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.05);
  --e-3: 0 8px 24px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.06);
  --e-4: 0 20px 48px rgba(15,23,42,.18), 0 4px 12px rgba(15,23,42,.10);

  /* 間距 —— 4pt 制。不准出現 13px、17px 這種數字 */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  /* 動態 —— 全站共用同一組節奏 */
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 260ms;
  --ease-out: cubic-bezier(.22,.61,.36,1);
  --ease-in:  cubic-bezier(.55,.06,.68,.19);

  /* z 階 —— 定死，不准臨時加 */
  --z-base: 0; --z-sticky: 20; --z-bar: 40; --z-scrim: 90; --z-dialog: 100; --z-toast: 120;

  /* 密度（由 <body data-density> 覆寫） */
  --font-base: 16px;
  --tap: 44px;
  --row-y: var(--s-3);
}

/* 🔴 暗色不是把顏色反過來 —— 是另一組去飽和的色階。
      文字對比要獨立驗過，不能假設亮色的數值可以沿用。 */
@media (prefers-color-scheme: dark) {
  :root {
    --c-bg:            #0b1220;
    --c-surface:       #131c2b;
    --c-surface-2:     #18222f;
    --c-surface-sunken: #0f1826;
    --c-border:        #29354a;
    --c-border-strong: #3b4a63;

    --c-text:          #eef2f8;
    --c-text-2:        #b3c0d1;   /* 8.9:1 on surface */
    --c-text-3:        #8fa0b6;   /* 5.5:1 on surface */

    --c-brand:         #e2e8f0;
    --c-accent:        #38bdf8;
    --c-accent-hover:  #7dd3fc;
    --c-accent-soft:   #0c2b3f;
    --c-accent-text:   #bae6fd;
    --c-text-on-brand: #04121c;

    --c-ok:            #4ade80;  --c-ok-soft:     #0d2a1a;  --c-ok-text:     #bbf7d0;
    --c-warn:          #fbbf24;  --c-warn-soft:   #33240a;  --c-warn-text:   #fde68a;
    --c-danger:        #f87171;  --c-danger-soft: #381515;  --c-danger-text: #fecaca;
    --c-info:          #38bdf8;  --c-info-soft:   #0c2b3f;  --c-info-text:   #bae6fd;

    --c-focus:         #7dd3fc;
    --c-scrim:         rgba(2, 8, 18, .70);

    --e-1: 0 1px 2px rgba(0,0,0,.4);
    --e-2: 0 2px 8px rgba(0,0,0,.45);
    --e-3: 0 8px 24px rgba(0,0,0,.5);
    --e-4: 0 20px 48px rgba(0,0,0,.6);
  }
}

/* ── 2. 密度 ───────────────────────────────────────────────
   同一套語言、兩種密度。理由：這個系統有兩種完全不同的使用者。
   · comfortable：團媽，60 歲，用手機在 LINE 裡開，一次做一件事
   · compact    ：打單小姐，桌機，一天看一百多張單，要一次看得到很多
   把它們硬塞進同一個密度，一定有一邊很難用。                */
body[data-density="comfortable"] { --font-base: 17px; --tap: 48px; --row-y: var(--s-4); }
body[data-density="compact"]     { --font-base: 15px; --tap: 40px; --row-y: var(--s-2); }

/* ── 3. 基礎 ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;              /* 🔴 不用 100vh：手機網址列會讓它算錯 */
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Noto Sans TC", "Microsoft JhengHei", "Hiragino Sans", sans-serif;
  font-size: var(--font-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 🔴 數字一律等寬對齊。金額與數量在滾動時會跳動的話，
      人對不上帳，而這是一個對帳系統。 */
.num, td.num, th.num, .mono, input[type="number"], .amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .92em;
}

h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 var(--s-3); }
a  { color: var(--c-accent); text-underline-offset: 3px; }

/* 🔴 焦點框永遠看得見。移除它是最常見、也最傷的無障礙錯誤 ——
      鍵盤使用者會完全不知道自己在哪裡。 */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--c-accent-soft); color: var(--c-accent-text); }

/* 🔴 尊重系統的「減少動態效果」設定。前庭系統敏感的人看動畫會頭暈。 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── 4. 版面 ───────────────────────────────────────────── */
.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding: var(--s-5) var(--s-4) calc(var(--s-12) + env(safe-area-inset-bottom));
}
.wrap--narrow { max-width: 520px; }
.wrap--wide   { max-width: 1400px; }

/* 底部固定操作列存在時，內容要留出空間，否則最後一列永遠被蓋住 */
body:has(.actionbar) .wrap { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }

.stack     { display: flex; flex-direction: column; gap: var(--s-3); }
.stack--lg { gap: var(--s-5); }
.row       { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.row--tight{ gap: var(--s-2); }
.row--nowrap { flex-wrap: nowrap; }
.spacer    { flex: 1 1 auto; }
.hide      { display: none !important; }
@media (max-width: 767px) { .hide\@sm { display: none !important; } }
@media (min-width: 768px) { .only\@sm { display: none !important; } }

/* ── 5. App bar ────────────────────────────────────────── */
/* 🔴 position:sticky 是相對【最近的捲動祖先】黏住的，
      但它只能在【自己父層的邊界內】黏 —— 父層是一個只有 bar 高度的 div 時，
      捲過那個高度它就掉了（實測：捲一段之後標題列整個消失）。
      display:contents 讓包裝層的盒子不存在，appbar 直接參與 body 的版面。 */
#bar { display: contents; }
.appbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--c-surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border);
  padding-top: env(safe-area-inset-top);
}
.appbar__inner {
  max-width: 1120px; margin-inline: auto;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); min-height: 56px;
}
.appbar--wide .appbar__inner { max-width: 1400px; }
.appbar__title { font-size: 1.0625rem; font-weight: 700; letter-spacing: -.01em; }
.appbar__sub   { font-size: .8125rem; color: var(--c-text-2); font-weight: 400; }
.brandmark {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: var(--c-brand); color: var(--c-text-on-brand);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}

/* ── 6. 卡片 ───────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--e-1);
}
.card__body   { padding: var(--s-4); }
.card__header {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: var(--s-3);
  font-weight: 600;
}
.card__footer {
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.card--flush .card__body { padding: 0; }

/* ── 7. 提示條 ─────────────────────────────────────────── */
/* 🔴 每一種狀態都【同時】有顏色與圖示。
      只靠顏色的話，色盲使用者（男性約 8%）分不出成功與失敗。 */
.callout {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: .9375rem; line-height: 1.55;
}
.callout__icon { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.callout__body { flex: 1; min-width: 0; }
.callout__title { font-weight: 700; }
.callout--info   { background: var(--c-info-soft);   color: var(--c-info-text);
                   border-color: color-mix(in srgb, var(--c-info) 26%, transparent); }
.callout--ok     { background: var(--c-ok-soft);     color: var(--c-ok-text);
                   border-color: color-mix(in srgb, var(--c-ok) 26%, transparent); }
.callout--warn   { background: var(--c-warn-soft);   color: var(--c-warn-text);
                   border-color: color-mix(in srgb, var(--c-warn) 30%, transparent); }
.callout--danger { background: var(--c-danger-soft); color: var(--c-danger-text);
                   border-color: color-mix(in srgb, var(--c-danger) 32%, transparent); }
.callout--loud   { box-shadow: var(--e-2); font-size: 1rem; }

/* ── 8. 按鈕 ───────────────────────────────────────────── */
/* 🔴 最小 44×44。手指的接觸面積約 8–10 mm，比游標大得多 —— 
      按鈕做小的代價是按錯，而這裡按錯會寫進不可刪的帳。 */
.btn {
  --btn-bg: var(--c-surface);
  --btn-fg: var(--c-text);
  --btn-bd: var(--c-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); min-width: var(--tap);
  padding: 0 var(--s-4);
  font: inherit; font-weight: 600; font-size: .9375rem;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-bd); border-radius: var(--r-md);
  cursor: pointer; user-select: none; text-decoration: none;
  touch-action: manipulation;      /* 🔴 消掉行動裝置 300ms 點擊延遲 */
  transition: background var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out);
}
.btn:hover:not(:disabled)  { background: var(--c-surface-2); border-color: var(--c-text-3); }
/* 🔴 按下去用 scale 不用 margin/padding —— 後者會讓周圍的東西跟著跳 */
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--primary {
  --btn-bg: var(--c-accent); --btn-fg: var(--c-text-on-brand); --btn-bd: var(--c-accent);
  box-shadow: var(--e-1);
}
.btn--primary:hover:not(:disabled) { --btn-bg: var(--c-accent-hover); --btn-bd: var(--c-accent-hover); }
.btn--danger {
  --btn-bg: var(--c-danger); --btn-fg: #fff; --btn-bd: var(--c-danger);
}
.btn--danger:hover:not(:disabled) { filter: brightness(.92); }
.btn--ghost  { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--c-text-2); }
.btn--ghost:hover:not(:disabled) { --btn-bg: var(--c-surface-2); --btn-fg: var(--c-text); }
.btn--lg  { min-height: 56px; font-size: 1.0625rem; padding: 0 var(--s-6); border-radius: var(--r-lg); }
.btn--sm  { min-height: 36px; font-size: .875rem; padding: 0 var(--s-3); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: var(--tap); }
.btn__icon { width: 18px; height: 18px; flex: none; }

/* 🔴 非同步操作中要看得出來，而且不能再按第二次。
      「按了沒反應所以再按一次」是重複送單最常見的來源。 */
.btn[aria-busy="true"] { pointer-events: none; position: relative; color: transparent !important; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--btn-fg);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 9. 表單 ───────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
/* 🔴 標籤永遠看得見，不用 placeholder 當標籤 ——
      一開始打字 placeholder 就消失了，人會忘記這一格是什麼。 */
.field__label { font-size: .875rem; font-weight: 600; color: var(--c-text-2); }
.field__label .req { color: var(--c-danger); margin-left: 2px; }
.field__hint  { font-size: .8125rem; color: var(--c-text-3); }
.field__error { font-size: .8125rem; color: var(--c-danger-text); font-weight: 600;
                display: flex; gap: var(--s-1); align-items: center; }

.input, input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s-2) var(--s-3);
  font: inherit;
  /* 🔴 行動裝置上輸入框字級 < 16px 時，iOS 會自動放大整頁 —— 
        那會讓版面在她打字的當下整個跳掉。 */
  font-size: max(16px, .9375rem);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-accent) 20%, transparent);
  outline: none;
}
.input:disabled, input:disabled, select:disabled {
  background: var(--c-surface-sunken); color: var(--c-text-3); cursor: not-allowed;
}
.input[aria-invalid="true"], input[aria-invalid="true"] {
  border-color: var(--c-danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-danger) 18%, transparent);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  padding-right: var(--s-8);
}
.check { display: inline-flex; align-items: center; gap: var(--s-2);
         min-height: var(--tap); cursor: pointer; font-size: .9375rem; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--c-accent); }

.search { position: relative; }
.search__icon { position: absolute; left: var(--s-3); top: 50%; transform: translateY(-50%);
                width: 18px; height: 18px; color: var(--c-text-3); pointer-events: none; }
/* 🔴 特異度陷阱：上面的 `input:not([type=checkbox]):not([type=radio])` 是 (0,2,1)，
      比 `.search .input` 的 (0,2,0) 高，它的 padding 簡寫會把這裡的 padding-left 蓋掉。
      實測結果是放大鏡圖示直接壓在 placeholder 上。用 `.search input.input` 拉到 (0,2,1) 並列，
      再靠「後定義者勝」贏回來。 */
.search input.input, .search .input { padding-left: var(--s-10); }

/* ── 10. 表格 ──────────────────────────────────────────── */
/* 🔴 寬表格一律包在自己的橫向捲軸裡。
      讓 body 橫向捲動的話，整個版面會在手機上跑掉。 */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--c-surface-2);
  color: var(--c-text-2); font-weight: 600; font-size: .8125rem;
  text-align: left; white-space: nowrap;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--c-border);
}
tbody td { padding: var(--row-y) var(--s-3); border-bottom: 1px solid var(--c-border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--c-surface-2); }
td.num, th.num { text-align: right; }
tfoot th, tfoot td { padding: var(--s-3); font-weight: 700; border-top: 2px solid var(--c-border-strong); }

/* 手機上把表格翻成卡片。
   🔴 用 data-label 產生欄名，這樣不需要在 HTML 裡重複寫兩份標記。 */
@media (max-width: 640px) {
  .table--cards thead { display: none; }
  .table--cards tbody tr {
    display: block; margin-bottom: var(--s-3);
    border: 1px solid var(--c-border); border-radius: var(--r-md);
    background: var(--c-surface); padding: var(--s-2);
  }
  /* 🔴 標籤用 float，值側維持【單一文字流】。
        試過的兩種都不行：
        · flex ＋ space-between：值側是多行內容時會被擠扁 ——
          實測匯入台的「上次匯入」欄被壓成一團，連圓角標籤都擠成一個圓圈
        · grid 兩欄：<td> 裡的每個子元素會各自被放進一格，
          於是「品名 ＋ P0 標籤」的標籤被丟到下一列的左欄
        float 讓標籤佔住第一行的左側，值不論有幾個子元素都在同一個流裡，
        自然換行、標籤不會被拆走。 */
  .table--cards tbody td {
    display: block; border: 0; padding: var(--s-2); text-align: right;
    overflow: hidden;              /* 撐住 float，避免它跑出格子 */
  }
  .table--cards tbody td::before {
    content: attr(data-label); float: left;
    font-size: .8125rem; font-weight: 600; color: var(--c-text-3);
    text-align: left; margin-right: var(--s-3);
  }
  /* 沒有標籤的欄（狀態圖示、操作鈕）整格靠左 */
  .table--cards tbody td[data-label=""] { text-align: left; }
  .table--cards tbody td[data-label=""]::before { content: none; display: none; }
}

/* ── 11. 標籤 ──────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--s-2); border-radius: var(--r-full);
  font-size: .75rem; font-weight: 700; line-height: 1.6;
  white-space: nowrap;
}
.tag__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.tag--accent { background: var(--c-accent-soft); color: var(--c-accent-text); }
.tag--ok     { background: var(--c-ok-soft);     color: var(--c-ok-text); }
.tag--warn   { background: var(--c-warn-soft);   color: var(--c-warn-text); }
.tag--danger { background: var(--c-danger-soft); color: var(--c-danger-text); }
.tag--muted  { background: var(--c-surface-sunken); color: var(--c-text-2); }

/* ── 12. 清單列 ────────────────────────────────────────── */
.list { list-style: none; margin: 0; padding: 0; }
.list__item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  min-height: var(--tap);
  cursor: pointer;
  transition: background var(--t-fast);
}
.list__item:last-child { border-bottom: 0; }
.list__item:hover { background: var(--c-surface-2); }
.list__item[aria-selected="true"] {
  background: var(--c-accent-soft);
  box-shadow: inset 3px 0 0 var(--c-accent);
}
.list__main { flex: 1; min-width: 0; }
.list__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__meta  { font-size: .8125rem; color: var(--c-text-2); }

/* ── 13. 空狀態 ────────────────────────────────────────── */
/* 🔴 空白的畫面不會告訴人任何事。要說明「為什麼是空的」與「接下來做什麼」。 */
.empty { text-align: center; padding: var(--s-12) var(--s-5); color: var(--c-text-2); }
.empty__icon { width: 44px; height: 44px; margin: 0 auto var(--s-3); color: var(--c-text-3); opacity: .7; }
.empty__title { font-weight: 700; color: var(--c-text); margin-bottom: var(--s-1); }
.empty__hint  { font-size: .9375rem; }

/* ── 14. 骨架屏 ────────────────────────────────────────── */
/* 🔴 超過 300ms 的等待要有骨架，而且要【先佔好位置】——
      不佔位的話資料一到版面就整個跳，那是 CLS。 */
.skeleton {
  background: linear-gradient(90deg,
    var(--c-surface-sunken) 25%, var(--c-border) 37%, var(--c-surface-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skeleton--line { height: 1em; margin-bottom: var(--s-2); }
.skeleton--row  { height: 56px; margin-bottom: var(--s-2); border-radius: var(--r-md); }

/* ── 15. 底部操作列 ────────────────────────────────────── */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-bar);
  background: color-mix(in srgb, var(--c-surface) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--c-border);
  box-shadow: 0 -4px 20px rgba(15,23,42,.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.actionbar__inner {
  max-width: 1120px; margin-inline: auto;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
}
@media (max-width: 520px) {
  .actionbar__inner { flex-wrap: wrap; }
  .actionbar__inner .btn { flex: 1 1 auto; }
}

/* ── 16. 對話框 ────────────────────────────────────────── */
/* 🔴 用自己的對話框，不用瀏覽器的 confirm()。
      瀏覽器對話框的預設按鈕是「確定」，而 Enter 會直接按下去 ——
      在一個整天用鍵盤的介面裡，那等於把最危險的操作綁在肌肉記憶上。 */
dialog.modal {
  border: 0; padding: 0; max-width: min(520px, calc(100vw - var(--s-8)));
  width: 100%; border-radius: var(--r-xl);
  background: var(--c-surface); color: var(--c-text);
  box-shadow: var(--e-4);
}
dialog.modal::backdrop { background: var(--c-scrim); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: dialogIn var(--t-slow) var(--ease-out); }
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal__head { padding: var(--s-5) var(--s-5) var(--s-3); display: flex; gap: var(--s-3); }
.modal__icon { width: 40px; height: 40px; flex: none; border-radius: var(--r-md);
               display: grid; place-items: center; }
.modal__icon svg { width: 22px; height: 22px; }
.modal__icon--danger { background: var(--c-danger-soft); color: var(--c-danger); }
.modal__icon--warn   { background: var(--c-warn-soft);   color: var(--c-warn); }
.modal__icon--info   { background: var(--c-info-soft);   color: var(--c-info); }
.modal__title { font-size: 1.0625rem; font-weight: 700; }
.modal__body  { padding: 0 var(--s-5) var(--s-4); color: var(--c-text-2); font-size: .9375rem; }
.modal__foot  { padding: var(--s-4) var(--s-5) var(--s-5); display: flex; gap: var(--s-3);
                justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 480px) {
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .btn { width: 100%; }
}
.recap { background: var(--c-surface-sunken); border-radius: var(--r-md);
         padding: var(--s-3); margin-top: var(--s-3); font-size: .9375rem; }
.recap dl { display: grid; grid-template-columns: auto 1fr; gap: var(--s-1) var(--s-4); margin: 0; }
.recap dt { color: var(--c-text-3); font-size: .875rem; }
.recap dd { margin: 0; text-align: right; font-weight: 600; }
.recap dd.total { font-size: 1.125rem; color: var(--c-text); }

/* ── 17. Toast ─────────────────────────────────────────── */
/* 🔴 toast 不搶焦點（會打斷鍵盤操作），用 aria-live 讓螢幕閱讀器唸出來。 */
.toasts {
  position: fixed; z-index: var(--z-toast);
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s-2);
  width: min(440px, calc(100vw - var(--s-8)));
  pointer-events: none;
}
body:has(.actionbar) .toasts { bottom: calc(88px + env(safe-area-inset-bottom)); }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--c-brand); color: var(--c-text-on-brand);
  box-shadow: var(--e-3); font-size: .9375rem; font-weight: 500;
  animation: toastIn var(--t-slow) var(--ease-out);
}
.toast--ok     { background: var(--c-ok);     color: #fff; }
.toast--danger { background: var(--c-danger); color: #fff; }
.toast--warn   { background: var(--c-warn);   color: #fff; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.toast.is-leaving { animation: toastOut var(--t-base) var(--ease-in) forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ── 18. 其他 ──────────────────────────────────────────── */
.muted   { color: var(--c-text-2); font-size: .875rem; }
.muted-2 { color: var(--c-text-3); font-size: .8125rem; }
.sectionhead {
  display: flex; align-items: baseline; gap: var(--s-2);
  margin: var(--s-6) 0 var(--s-2);
  font-weight: 700; font-size: .9375rem; color: var(--c-text-2);
}
.sectionhead::after { content: ""; flex: 1; height: 1px; background: var(--c-border); }
.kbd {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 1px 6px; border-radius: var(--r-sm);
  border: 1px solid var(--c-border-strong); border-bottom-width: 2px;
  background: var(--c-surface); font-size: .75rem; font-weight: 600;
  font-family: ui-monospace, Menlo, monospace;
}
.divider { height: 1px; background: var(--c-border); margin: var(--s-4) 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* 🔴 鍵盤使用者要能跳過導覽直接到內容 */
.skiplink {
  position: absolute; left: var(--s-4); top: -60px; z-index: var(--z-toast);
  background: var(--c-accent); color: #fff; padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md); font-weight: 600;
  transition: top var(--t-base) var(--ease-out);
}
.skiplink:focus { top: var(--s-3); }

@media print {
  .appbar, .actionbar, .toasts, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #999; }
}
