/* 設備報修系統 視覺系統(票 01 定案)
 *
 * 方向：像一塊乾淨的工務白板。米白底(入口站同色)、深墨字，庭芳桃紅只用在「要你動手」的地方
 * (主要按鈕、目前分頁、待接單、焦點)。狀態色各司其職不混用：
 *   急        實心紅標(報修人勾的緊急程度，一眼就要看到)
 *   逾期      紅字紅邊(處理中過了預計完成日)
 *   處理中    琥珀
 *   已完成    綠
 *   不處理    灰
 * 手機優先：單欄、大觸控區(最小 44px)、整頁捲動(iPhone Safari 不做整頁 fixed 版面)；
 * 720px 以上電腦版內容置中、最寬 880px，卡片改兩段式排版。
 *
 * token 分四組：顏色、字級、間距、圓角與陰影。元件只准用 token，不寫死數值。
 */
:root {
  /* 一、顏色：底與字 */
  --bg: #F7F7F3; --surface: #FFFFFF; --surface-2: #F0F0EA; --surface-3: #E7E7DF;
  --ink: #26302D; --ink-2: #44504B; --muted: #6B7571; --ph: #9DA49F;
  --line: #E2E4DD; --line-2: #CFD3CB;
  /* 品牌：庭芳桃紅(按鈕底用深一階，白字對比 5:1 以上) */
  --brand: #E4007F; --primary: #C8006F; --primary-hover: #A8005D; --primary-soft: #FCE8F2; --on-primary: #FFFFFF;
  /* 狀態 */
  --urgent: #C0271D; --urgent-soft: #FBE9E7; --on-urgent: #FFFFFF;
  --late: #B42318; --late-soft: #FDECEA; --late-line: #F4C7C2;
  --working: #9A5800; --working-soft: #FFF4DF; --working-line: #F1D9A6;
  --ok: #1D6B45; --ok-soft: #E5F3EB;
  --off: #6B7571; --off-soft: #ECEDE9;
  --focus: rgba(200, 0, 111, .24);
  /* 二、字級(手機基準 16px，不小於 13px) */
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 13px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 18px; --fs-xl: 21px; --fs-2xl: 26px;
  /* 三、間距：4 的倍數 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;
  /* 四、圓角與陰影 */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(38, 48, 45, .05), 0 2px 10px rgba(38, 48, 45, .04);
  --shadow-2: 0 2px 4px rgba(38, 48, 45, .06), 0 10px 28px rgba(38, 48, 45, .08);
  --shadow-3: 0 18px 50px rgba(38, 48, 45, .22);
  --wrap: 880px;
  color-scheme: light;
}
/* 深色：跟著系統(prefers-color-scheme)，也可以用 data-theme 強制。登入頁(gate-mode)不跟著走，見下方。 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151817; --surface: #1D2120; --surface-2: #242928; --surface-3: #2C3230;
    --ink: #ECEFEC; --ink-2: #CBD1CD; --muted: #98A29D; --ph: #6C7571;
    --line: #2C3230; --line-2: #3A413E;
    --brand: #FF4DA6; --primary: #FF5CAD; --primary-hover: #FF85C1; --primary-soft: #3A1B2B; --on-primary: #1B0912;
    --urgent: #FF7B6E; --urgent-soft: #3C1A17; --on-urgent: #1B0912;
    --late: #FF8A7E; --late-soft: #3A1B18; --late-line: #5B2A25;
    --working: #F4B860; --working-soft: #372A12; --working-line: #54401C;
    --ok: #6FD19A; --ok-soft: #16301F;
    --off: #98A29D; --off-soft: #262B29;
    --focus: rgba(255, 92, 173, .32);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 8px 24px rgba(0, 0, 0, .35); --shadow-3: 0 18px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151817; --surface: #1D2120; --surface-2: #242928; --surface-3: #2C3230;
  --ink: #ECEFEC; --ink-2: #CBD1CD; --muted: #98A29D; --ph: #6C7571;
  --line: #2C3230; --line-2: #3A413E;
  --brand: #FF4DA6; --primary: #FF5CAD; --primary-hover: #FF85C1; --primary-soft: #3A1B2B; --on-primary: #1B0912;
  --urgent: #FF7B6E; --urgent-soft: #3C1A17; --on-urgent: #1B0912;
  --late: #FF8A7E; --late-soft: #3A1B18; --late-line: #5B2A25;
  --working: #F4B860; --working-soft: #372A12; --working-line: #54401C;
  --ok: #6FD19A; --ok-soft: #16301F;
  --off: #98A29D; --off-soft: #262B29;
  --focus: rgba(255, 92, 173, .32);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 8px 24px rgba(0, 0, 0, .35); --shadow-3: 0 18px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ── 基礎 ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* [hidden] 的預設權重最低，任何自己寫的 display 都蓋得過它，所以要 !important */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); font-size: var(--fs-md); line-height: 1.6; color: var(--ink); background: var(--bg);
       min-height: 100vh; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.view { max-width: var(--wrap); margin: 0 auto;
        padding: var(--s3) max(var(--s4), env(safe-area-inset-right)) calc(var(--s8) + env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-left)); }

/* ── 頂欄：sticky 黏在上方；整頁照常捲動、不用 fixed，iPhone Safari 的工具列才不會蓋住內容 ── */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, var(--surface)); border-bottom: 1px solid var(--line); }
.top-in { max-width: var(--wrap); margin: 0 auto; height: 60px; display: flex; align-items: center; gap: var(--s3);
          padding: 0 max(var(--s4), env(safe-area-inset-right)) 0 max(var(--s4), env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: var(--fs-lg);
         letter-spacing: .02em; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 右邊：電腦是一排文字連結「名字｜管理｜臉或指紋綁定｜登出」，手機是名字按鈕加選單。
   斷點 720px 跟物資系統、交班系統、電郵待處理同一個數字；app.js 的 寬螢幕() 也用 720px。 */
.me { margin-left: auto; position: relative; }
.me-links { display: flex; align-items: center; gap: var(--s4); font-size: var(--fs-sm); white-space: nowrap; }
.me-links b { color: var(--ink); }
.me-links a, .me-links button { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0;
                                padding: 4px 0; font: inherit; cursor: pointer; }
.me-links a:hover, .me-links button:hover { color: var(--primary); }
.me-links a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.me-links [hidden] { display: none; }
.me-btn { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border: 1px solid var(--line-2);
          background: var(--surface); border-radius: var(--r-pill); cursor: pointer; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2);
          max-width: 10em; }
.me-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-btn:hover { border-color: var(--primary); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 200px; background: var(--surface);
        border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: 6px; }
.menu button, .menu a { display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
                        padding: 12px; border-radius: var(--r-sm); color: var(--ink); font-size: var(--fs-md); }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
@media (min-width: 720px) { .me-btn, .menu { display: none !important; } }
/* 手機不出現「管理」(跨系統既定規則)：管理連結只在電腦那一排裡，手機整排藏起來 */
@media (max-width: 719px) { .me-links { display: none; } .brand { font-size: var(--fs-md); } }

/* ── 按鈕 ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
       border: 0; border-radius: var(--r-pill); cursor: pointer; font-weight: 700; white-space: nowrap;
       background: var(--primary); color: var(--on-primary); transition: background .15s, transform .06s, box-shadow .15s;
       box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 12px color-mix(in srgb, var(--primary) 22%, transparent); }
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; transform: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); box-shadow: none; }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn.quiet { background: transparent; color: var(--ink-2); box-shadow: none; }
.btn.quiet:hover { background: var(--surface-2); }
.btn.danger { background: var(--urgent); color: var(--on-urgent); box-shadow: none; }
.btn.danger:hover { background: color-mix(in srgb, var(--urgent) 85%, #000); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: var(--fs-sm); }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.actions { display: flex; gap: var(--s2); margin-top: var(--s5); }
.actions .btn { flex: 1; }

/* ── 輸入 ── */
.field { display: block; }
.field + .field { margin-top: var(--s4); }
.field > span { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 48px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 10px 14px; outline: none; font-size: var(--fs-md); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
input::placeholder, textarea::placeholder { color: var(--ph); }
textarea { resize: vertical; line-height: 1.6; }
/* 開關(只看我報的) */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { position: relative; width: 44px; height: 26px; border-radius: var(--r-pill); background: var(--line-2); transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ── 卡片、標籤、提示條 ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s5); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: var(--r-pill);
        font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.chip svg { width: 14px; height: 14px; }
/* 狀態標籤：待接單桃紅(要人動手)、處理中琥珀、已完成綠、不處理灰；急實心紅、逾期紅字 */
.chip.open { background: var(--primary-soft); color: var(--primary); }
.chip.working { background: var(--working-soft); color: var(--working); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.off { background: var(--off-soft); color: var(--off); }
.chip.urgent { background: var(--urgent); color: var(--on-urgent); }
.chip.late { background: var(--late-soft); color: var(--late); }
.chip.brand { background: var(--primary-soft); color: var(--primary); }
.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md);
          font-size: var(--fs-sm); background: var(--surface-2); color: var(--ink-2); }
.banner.warn { background: var(--working-soft); color: var(--working); }
.banner.late { background: var(--late-soft); color: var(--late); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* ── 頁首(每一頁的標題列) ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.page-head h1 { font-size: var(--fs-2xl); line-height: 1.25; letter-spacing: .01em; }
.page-head p { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }

/* ── 清單頁：標題與分頁黏在頂欄下方(只用 sticky，整頁仍正常捲動) ── */
.stick-head { position: sticky; top: 60px; z-index: 20; background: var(--bg);
              margin: 0 calc(-1 * var(--s4)); padding: var(--s1) var(--s4) 0; }
.list-head { align-items: center; margin-bottom: var(--s3); }
.list-head .switch { margin-left: auto; }
/* 分頁(三個)：平均分配寬度，不換行、不橫向捲動 */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; margin-bottom: var(--s4); }
.tab { flex: 1 1 auto; min-width: 0; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 12px;
       border-radius: var(--r-pill); color: var(--ink-2); font-weight: 700; font-size: var(--fs-md); }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-1); }
.tab .count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); display: inline-grid; place-items: center;
              font-size: 13px; background: var(--surface-3); color: var(--muted); }
.tab.on .count { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 719.98px) {
  .tabs { gap: 2px; padding: 3px; }
  .tab { gap: 5px; padding: 0 4px; min-height: 44px; font-size: var(--fs-md); }
  .tab .count { min-width: 20px; height: 20px; padding: 0 5px; font-size: 12px; }
}

/* ── 報修單卡片：左邊一條狀態色，一眼分出待接單、處理中、逾期、完成、不處理 ── */
.items { display: grid; gap: var(--s3); }
.item { position: relative; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
        box-shadow: var(--shadow-1); padding: var(--s4) var(--s4) var(--s4) calc(var(--s4) + 4px); color: var(--ink); overflow: hidden;
        transition: box-shadow .15s, border-color .15s, transform .06s; }
.item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.item:hover { text-decoration: none; box-shadow: var(--shadow-2); border-color: var(--line-2); }
.item:active { transform: scale(.995); }
.item.open::before { background: var(--primary); }
.item.working::before { background: var(--working); }
.item.late { border-color: var(--late-line); } .item.late::before { background: var(--late); }
.item.done { opacity: .82; } .item.done::before { background: var(--ok); }
.item.dismissed { opacity: .72; } .item.dismissed::before { background: var(--off); }
.item-top { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: 6px; }
.item .no { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.item h3 { font-size: var(--fs-lg); line-height: 1.45; font-weight: 800; }
.item .place { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-size: var(--fs-sm); margin-top: 2px; }
.item .place svg { width: 15px; height: 15px; opacity: .85; }
.item .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: var(--s3); font-size: var(--fs-xs); color: var(--muted); }
.item .meta span { display: inline-flex; align-items: center; gap: 4px; }
.item .meta svg { width: 14px; height: 14px; opacity: .8; }
.when { margin-left: auto; font-weight: 800; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.item.late .when { color: var(--late); } .item.working .when { color: var(--working); }
@media (min-width: 720px) {
  .item { display: grid; grid-template-columns: 1fr auto; column-gap: var(--s5); padding: var(--s5) var(--s5) var(--s5) calc(var(--s5) + 4px); }
  .item-top { grid-column: 1 / -1; }
  .item .meta { grid-column: 1 / -1; }
}

/* ── 報修按鈕(票 02)：手機是右下角的浮動大鈕(整頁照常捲動、fixed bottom 配 safe-area)，電腦放回標題列右邊 ── */
.new-btn { gap: 6px; }
.new-btn svg { width: 22px; height: 22px; }
@media (max-width: 719.98px) {
  .list-head .switch { margin-left: auto; }
  .new-btn { position: fixed; right: max(var(--s4), env(safe-area-inset-right)); bottom: calc(var(--s5) + env(safe-area-inset-bottom)); z-index: 40;
             min-height: 56px; padding: 0 22px 0 18px; font-size: var(--fs-lg); box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 10px 28px color-mix(in srgb, var(--primary) 38%, transparent); }
  .new-btn:hover { text-decoration: none; }
}
@media (min-width: 720px) { .list-head .switch { margin-left: auto; } .list-head .new-btn { margin-left: var(--s3); } }

/* ── 報修表單(#/new) ── */
.form-card { padding: var(--s5); }
.form-card .field + .field, .form-card .field + .banner, .form-card .banner + .actions { margin-top: var(--s5); }
.hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; line-height: 1.5; }
.hint.center { text-align: center; margin-top: var(--s3); }
.form-card .actions { margin-top: var(--s6); }
.form-card .actions .btn.quiet { flex: 0 0 auto; }
/* 縮圖：三格，可刪 */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
                background: rgba(20, 23, 22, .72); color: #fff; display: grid; place-items: center; }
.thumb button svg { width: 16px; height: 16px; }
.photo-actions { display: flex; gap: var(--s2); }
.thumbs:not(:empty) + .photo-actions { margin-top: var(--s2); }
.photo-actions .btn { flex: 1; }
/* 緊急程度：兩段式，一般預設；選到「急」整格變紅，一眼就看到 */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-pill); }
.seg label { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; border-radius: var(--r-pill);
            font-weight: 700; color: var(--ink-2); transition: background .15s, color .15s; }
.seg span svg { width: 18px; height: 18px; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg input[value=urgent]:checked + span { background: var(--urgent); color: var(--on-urgent); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ── 詳細頁(#/t/<單號>)：手機單欄；900px 以上主欄加右側異動紀錄兩欄 ── */
.detail-head { align-items: flex-start; }
.detail-head .item-top { margin-bottom: 4px; }
.detail-head h1 { font-size: var(--fs-2xl); line-height: 1.25; }
.detail-head .place { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-size: var(--fs-md); margin-top: 4px; }
.detail-head .place svg { width: 16px; height: 16px; }
.detail-head .btn { flex: none; }
#sentBanner { margin-bottom: var(--s4); }
.detail { display: grid; gap: var(--s4); align-items: start; }
.detail-main, .detail-side { display: grid; gap: var(--s4); min-width: 0; }
.sec { font-size: var(--fs-sm); font-weight: 800; color: var(--muted); letter-spacing: .06em; margin-bottom: var(--s3); display: flex; align-items: baseline; gap: 8px; }
.sec .muted { font-weight: 600; letter-spacing: 0; }
.sec + .sec, .photos + .sec { margin-top: var(--s5); }
.desc { font-size: var(--fs-md); line-height: 1.75; white-space: pre-wrap; word-break: break-word; margin-bottom: var(--s4); }
.kv { display: grid; gap: 0; border-top: 1px solid var(--line); }
.kv-row { display: grid; grid-template-columns: 6.5em 1fr; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.kv dt { font-size: var(--fs-sm); color: var(--muted); font-weight: 700; }
.kv dd { font-size: var(--fs-md); color: var(--ink); word-break: break-word; }
.kv dd .muted { font-size: var(--fs-sm); margin-left: 6px; }
.kv dd.late-text { color: var(--late); font-weight: 700; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.photo { padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); aspect-ratio: 1; cursor: zoom-in; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-actions { margin-top: 0; }
.detail-actions .btn.danger { flex: 0 0 auto; }
/* 異動紀錄時間軸：左邊一條線，一點一則 */
.timeline { list-style: none; display: grid; gap: var(--s3); position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--line-2); border-radius: 2px; }
.timeline li { position: relative; font-size: var(--fs-sm); line-height: 1.55; }
.timeline li::before { content: ""; position: absolute; left: -17px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--surface); }
.timeline time { display: block; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline .chip { height: 20px; font-size: 12px; vertical-align: 1px; }
/* 通知紀錄(管理者限定，票 05)：一筆一列，誰、什麼事件、結果 */
.notify-list { list-style: none; display: grid; gap: var(--s2); }
.notify-list li { padding: var(--s2) var(--s3); background: var(--surface-2); border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.5; }
.notify-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.notify-head time { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.notify-result { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; color: var(--ink-2); }
.notify-head .chip, .notify-result .chip { height: 20px; font-size: 12px; }
.notify-result .err { color: var(--late); word-break: break-word; }
#notifyCard .hint { margin-top: var(--s3); }
@media (min-width: 900px) {
  .detail { grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s5); }
  .detail-side { position: sticky; top: calc(60px + var(--s5)); }
  .kv-row { grid-template-columns: 8em 1fr; }
}

/* ── 彈窗裡的標題與照片大圖 ── */
.modal-title { font-size: var(--fs-xl); line-height: 1.3; margin-bottom: var(--s3); }
.modal .field + .field { margin-top: var(--s4); }
.modal .banner { margin-top: var(--s4); }
.modal.photo { max-width: min(96vw, 1100px); padding: var(--s3); background: var(--ink); }
.modal.photo .big { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto var(--s3); border-radius: var(--r-sm); object-fit: contain; }
.modal.photo .btn.ghost { background: transparent; color: var(--bg); border-color: var(--muted); }
@media (max-width: 480px) { .modal.photo { border-radius: 0; } }

/* ── 空狀態 ── */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s2); padding: var(--s8) var(--s5);
         background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty .art { width: 96px; height: 96px; margin-bottom: var(--s2); }
.empty h2 { font-size: var(--fs-xl); }
.empty p { color: var(--muted); font-size: var(--fs-sm); max-width: 28em; }

/* ── 登入與門口(此系統未開放)頁 ──
   版面、文字、配色逐項照人事帳號系統示範站 demo.tinfun.org.tw(Jacky 指定的各系統登入範本)，只有系統名稱不同。
   示範站只有亮色，所以登入頁不跟著深色模式走：html.gate-mode 時整組色票換成示範站的(app.js 的 門口() 掛上、畫外框() 拿掉)。
   選擇器多掛一個 :root 是為了壓過上面深色模式那條 :root:not([data-theme="light"])。 */
html.gate-mode:root {
  --bg: #F7F7F3; --surface: #FFFFFF; --ink: #303735; --ink-2: #303735; --muted: #66706D; --ph: #929996;
  --primary: #E4007F; --primary-hover: #B10063; --primary-soft: #FDEEF6; --on-primary: #FFFFFF;
  --line: #E0E4DF; --line-2: #D9DED9; --focus: rgba(228, 0, 127, .12);
  --ok: #1B5E33; --late: #A32C15; --off: #66706D; --off-soft: #ECEDE9;
  color-scheme: light;
}
html.gate-mode body { line-height: 1.7; }
/* 上方留白刻意小(示範站：logo 上面不要空太多)，不做垂直置中 */
.gate { max-width: 26rem; margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem; text-align: center; }
html.gate-mode .view { padding-top: 0; }
.gate .logo { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto .7rem;
              box-shadow: 0 6px 18px rgba(48, 55, 53, .16); }
.gate h1 { font-size: 1.45rem; margin-bottom: .25rem; line-height: 1.7; }
/* 卡片寬度跟著裡面那條 200px 直欄走(--欄寬 只寫這裡一處，標籤、輸入框、兩顆按鈕、忘記登入碼都切齊它) */
.gate .card { --欄寬: 200px; max-width: 16rem; margin: 0 auto; padding: 1.5rem 1.4rem; text-align: left; border-radius: 16px;
              box-shadow: 0 1px 2px rgba(48, 55, 53, .05), 0 8px 24px rgba(48, 55, 53, .06); }
.gate .field { width: var(--欄寬); margin: 0 auto 1.1rem; }
.gate .field + .field { margin-top: 0; }
.gate .field > span { font-weight: 600; font-size: .9rem; margin-bottom: .4rem; color: var(--muted); }
.gate input[type=text], .gate input[type=tel] { min-height: 0; font-size: 1rem; line-height: 1.7; border: 1.5px solid var(--line-2);
              border-radius: 10px; padding: .55em .75em; }
.gate input:focus { box-shadow: 0 0 0 3px var(--focus); }
/* 四位數字碼：固定寬置中、四個點的 placeholder；左邊多 12px 補 letter-spacing 在最後一字後面多的那格 */
.gate #code { font-size: 28px; letter-spacing: 12px; text-align: center; padding: 10px 0 10px 12px; border-width: 2px; border-radius: 12px; }
/* 登入那一列：左半「登入」、右半臉或指紋的圖示鈕，兩顆同色同高；忘記登入碼是右下角一行底線文字 */
.gate .btn { min-height: 0; font-weight: 600; box-shadow: 0 2px 8px rgba(177, 0, 99, .22); }
.gate .login-actions { display: flex; gap: .6rem; width: var(--欄寬); margin: 0 auto; }
.gate .login-actions .btn { flex: 1 1 0; font-size: 1.05rem; padding: .85em 0; }
.gate .login-actions .btn svg { width: 30px; height: 30px; }
.gate #passkey[aria-busy="true"] { opacity: .45; }
.gate .forgot { width: var(--欄寬); margin: 1rem auto 0; text-align: right; font-size: .875rem; }
.gate .forgot a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
/* 此系統未開放(非台灣籍)：中性灰的插圖，一句話，一顆「換一個帳號」 */
.gate-closed { text-align: center; }
.gate-closed .art { width: 88px; height: 88px; margin: 0 auto var(--s3); }
.gate-closed h2 { font-size: var(--fs-xl); }
.gate-closed p { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--s2); }
.gate-closed .btn.ghost { box-shadow: none; padding: .45em 1em; }
/* 登入頁的彈窗照示範站：置中、上緣色帶就是語氣(綠＝成功、紅＝失敗)，一顆「關閉」 */
html.gate-mode .modal-bg { background: rgba(48, 55, 53, .45); align-items: center; padding: 1.25rem; }
.modal.gate-modal { max-width: 19rem; padding: 1.5rem 1.4rem; text-align: center; border-radius: 16px; border-top: 5px solid var(--line);
                    box-shadow: 0 12px 40px rgba(48, 55, 53, .28); }
.modal.gate-modal.ok { border-top-color: var(--ok); }
.modal.gate-modal.no { border-top-color: var(--late); }
.modal.gate-modal .modal-msg { font-size: 1rem; line-height: 1.75; margin-bottom: 1.25rem; word-break: break-word; }
.modal.gate-modal .btn { font-size: 1.05rem; padding: .85em 1.6em; }

/* ── 彈窗、提示、載入 ── */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(20, 23, 22, .45); display: grid; place-items: center; padding: var(--s4); }
.modal { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: var(--s6) var(--s5) var(--s5); }
.modal p { font-size: var(--fs-md); line-height: 1.7; }
@media (max-width: 480px) { .modal-bg { align-items: end; padding: 0; } .modal { max-width: none; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom)); } }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
         background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: var(--r-pill); font-size: var(--fs-sm);
         font-weight: 700; box-shadow: var(--shadow-3); max-width: calc(100vw - 32px); }
.loading { display: grid; place-items: center; min-height: 160px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 2s !important; } }

/* ── 管理頁(電腦版，720px 以上；票 07 填內容)：左側導覽，右邊一塊；整頁放寬到 1240px ── */
html.admin-wide { --wrap: 1240px; }
.adm { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: var(--s7); align-items: start; }
.adm-side { position: sticky; top: calc(60px + var(--s5)); }
.adm-title { font-size: var(--fs-2xl); line-height: 1.25; margin: 2px 0 var(--s4) var(--s3); }
.adm-nav { display: grid; gap: 2px; }
.adm-link { position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px 0 12px; border-radius: var(--r-md);
            color: var(--ink-2); font-weight: 700; font-size: var(--fs-sm); transition: background .15s, color .15s; }
.adm-link svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.adm-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.adm-link.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.adm-link.on svg { color: var(--primary); }
.adm-link.on::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: var(--primary); }
.adm-main { min-width: 0; }
.adm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); padding: 4px 0 var(--s4); border-bottom: 1px solid var(--line); margin-bottom: var(--s4); }
.adm-head h2 { font-size: var(--fs-xl); line-height: 1.3; }
.adm-head p { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; max-width: 46em; }
.adm-empty { display: grid; justify-items: center; text-align: center; gap: var(--s2); padding: var(--s7) var(--s5);
             background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.adm-empty .art { width: 72px; height: 72px; margin-bottom: var(--s1); }
.adm-empty h3 { font-size: var(--fs-lg); }
.adm-empty p { color: var(--muted); font-size: var(--fs-sm); max-width: 34em; }
@media (max-width: 1099.98px) {
  .adm { grid-template-columns: 1fr; gap: var(--s4); }
  .adm-side { position: static; }
  .adm-nav { grid-template-columns: repeat(3, 1fr); }
}
/* 管理功能只在電腦版(跟管理頁同一條規則，720px) */
@media (max-width: 719.98px) { .pc-only { display: none !important; } }
@media (min-width: 720px) { .mobile-only { display: none !important; } }

/* ── 樣式頁(#/style)：視覺系統的樣張，截圖自查用 ── */
.section-title { font-size: var(--fs-sm); font-weight: 800; color: var(--muted); letter-spacing: .08em; margin: var(--s7) 0 var(--s3); }
.section-title:first-of-type { margin-top: var(--s4); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--s2); }
.swatch { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); font-size: var(--fs-xs); }
.swatch i { display: block; height: 44px; }
.swatch b, .swatch span { display: block; padding: 0 10px; }
.swatch b { padding-top: 6px; } .swatch span { color: var(--muted); padding-bottom: 8px; }
.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.type-sample { display: grid; gap: var(--s2); }
.type-sample > div { display: grid; grid-template-columns: 6em 1fr; gap: var(--s3); align-items: baseline; padding: var(--s2) 0; border-bottom: 1px dashed var(--line); }
.type-sample code { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }
.space-sample { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; }
.space-sample > div { display: grid; justify-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--muted); font-family: var(--mono); }
.space-sample i { display: block; background: var(--primary-soft); border: 1px solid var(--primary); border-radius: 2px; }
.radius-sample { display: flex; gap: var(--s3); flex-wrap: wrap; }
.radius-sample > div { display: grid; justify-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); font-family: var(--mono); }
.radius-sample i { display: block; width: 72px; height: 56px; background: var(--surface); border: 1px solid var(--line); }

/* ── 承辦(票 03)：進度備註、承辦人按鈕、接單與完成窗 ── */
.notes { list-style: none; display: grid; gap: var(--s2); }
.notes li { padding: var(--s3) var(--s4); background: var(--surface-2); border-radius: var(--r-md); border-left: 3px solid var(--working); }
.note-head { display: flex; align-items: baseline; gap: var(--s2); font-size: var(--fs-xs); color: var(--muted); margin-bottom: 2px; }
.note-head b { color: var(--ink); font-size: var(--fs-sm); }
.note-head time { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.notes p { font-size: var(--fs-md); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.note-empty { font-size: var(--fs-sm); }
/* 處理中的五顆：已完成整排主色，其他四顆兩兩一列 */
.handler-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.handler-actions .btn.wide { grid-column: 1 / -1; min-height: 52px; font-size: var(--fs-lg); }
.handler-actions .btn.ghost { padding: 0 10px; font-size: var(--fs-sm); }
#lateBanner { margin-bottom: var(--s4); }
.banner.late b, .banner.warn b { color: inherit; }
.modal-sub { color: var(--muted); font-size: var(--fs-sm); line-height: 1.6; margin: -4px 0 var(--s4); }
.modal-sub b { color: var(--ink); }
.field > span .muted { font-weight: 600; margin-left: 4px; }
.quick { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.quick button { min-height: 32px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface);
                color: var(--ink-2); font-size: var(--fs-xs); font-weight: 700; cursor: pointer; }
.quick button:hover { border-color: var(--primary); color: var(--primary); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.modal .field + .two, .modal .two + .field { margin-top: var(--s4); }
.two .field + .field { margin-top: 0; }

/* ── 管理頁：承辦人名單(票 03)。左邊名冊可勾、右邊目前承辦人；1100px 以下改上下排 ── */
.roster { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
.roster-col .sec { margin-bottom: var(--s3); }
.roster-list { display: grid; gap: 6px; max-height: 56vh; overflow-y: auto; margin-top: var(--s3); padding: 2px; }
.pick-row { display: flex; align-items: center; gap: var(--s3); min-height: 52px; padding: var(--s2) var(--s3); border: 1px solid var(--line-2);
            border-radius: var(--r-md); cursor: pointer; background: var(--surface); }
.pick-row:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.pick-row.taken { cursor: default; opacity: .72; background: var(--surface-2); }
.pick-row input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; margin: 0; }
.pick-row .who { display: grid; min-width: 0; flex: 1; }
.pick-row small { color: var(--muted); font-size: var(--fs-xs); }
.pick-row .chip { flex: none; }
.roster-actions { margin-top: var(--s3); }
.roster-actions .btn { flex: none; }
.byid { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s3); }
.byid summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 700; color: var(--primary); min-height: 40px; display: flex; align-items: center; gap: 6px; list-style: none; }
.byid summary::-webkit-details-marker { display: none; }
.byid summary svg { width: 16px; height: 16px; }
.byid-row { display: flex; gap: var(--s2); margin-top: var(--s2); }
.byid-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: var(--fs-sm); }
.byid-row .btn { flex: none; }
#rosterErr { margin-top: var(--s3); }
.handler-list { list-style: none; display: grid; gap: var(--s2); }
.handler-list li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.handler-list li > div { display: grid; min-width: 0; flex: 1; }
.handler-list small { color: var(--muted); font-size: var(--fs-xs); }
.handler-list .btn { flex: none; }
.ava { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; flex: none; }
.roster-col .hint { margin-top: var(--s4); }
@media (max-width: 1099.98px) { .roster { grid-template-columns: 1fr; } }

/* ── 管理頁：國定假日(票 06)。表格、年份窗 ── */
.holiday-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); }
.holiday-head .sec { margin-bottom: 0; }
.holiday-card .banner { margin: var(--s4) 0; }
.holiday-card .hint { margin-top: var(--s4); }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: var(--fs-xs); font-weight: 800; color: var(--muted); letter-spacing: .04em; white-space: nowrap; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td small { display: block; font-size: var(--fs-xs); }
.mono { font-family: var(--mono); font-size: var(--fs-sm); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: 700; cursor: pointer; text-align: left; min-height: 32px; }
.link-btn:hover { text-decoration: underline; }
.link-btn svg { width: 16px; height: 16px; flex: none; }
#calErr { margin-top: var(--s3); }
.modal.cal-modal { max-width: 720px; }
.cal-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin: var(--s4) 0 var(--s5); }
.cal-stat { display: grid; gap: 2px; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-2); }
.cal-stat b { font-size: var(--fs-2xl); line-height: 1.1; }
.cal-stat span { font-size: var(--fs-sm); font-weight: 700; }
.cal-stat small { font-size: var(--fs-xs); color: var(--muted); }
.cal-stat.off { background: var(--late-soft); color: var(--late); }
.cal-stat.work { background: var(--working-soft); color: var(--working); }
.cal-stat.off small, .cal-stat.work small { color: inherit; opacity: .8; }
.cal-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s3) var(--s5); margin-bottom: var(--s5); }
.cal-month h4 { font-size: var(--fs-sm); color: var(--muted); margin-bottom: 4px; }
.cal-month ul, .cal-work { list-style: none; display: grid; gap: 2px; }
.cal-day { display: flex; gap: var(--s2); align-items: baseline; font-size: var(--fs-sm); padding: 3px 0; }
.cal-date { font-family: var(--mono); font-size: var(--fs-xs); white-space: nowrap; min-width: 5.5em; }
.cal-day.off .cal-date { color: var(--late); }
.cal-day.work .cal-date { color: var(--working); }
.cal-work { margin-bottom: var(--s4); }

/* ── 管理頁：匯出與稽核(票 07)。匯出列、稽核表；管理者名單沿用承辦人名單的 .roster ── */
.export-card { margin-bottom: var(--s5); }
.export-row { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; }
.export-row .field { flex: 0 1 200px; }
.export-row .field + .field { margin-top: 0; }
.export-row .btn { flex: none; }
.export-card .quick { margin-top: var(--s3); }
.export-card .hint { margin-top: var(--s4); }
#exportErr { margin-top: var(--s3); }
.audit-card { margin-top: var(--s5); }
.audit-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s3); }
.audit-head .sec { margin-bottom: 0; }
.audit-tools { display: flex; align-items: center; gap: var(--s4); }
.audit-tools input[type=search] { width: 240px; font-family: var(--mono); font-size: var(--fs-sm); min-height: 40px; }
/* 固定欄寬：細節(detail)可能很長(匯入國定假日那筆是一段 JSON)，不固定的話會把時間與前後值擠到一字一行 */
.audit-tbl { table-layout: fixed; }
.audit-tbl th:nth-child(1) { width: 124px; } .audit-tbl th:nth-child(2) { width: 84px; } .audit-tbl th:nth-child(4) { width: 96px; }
.audit-tbl th:nth-child(5), .audit-tbl th:nth-child(6) { width: 104px; } .audit-tbl th:nth-child(7) { width: 108px; }
.audit-tbl td { vertical-align: top; overflow-wrap: anywhere; }
.audit-tbl td.when { white-space: nowrap; color: var(--muted); font-size: var(--fs-xs); padding-top: 12px; }
.audit-tbl td small { margin-top: 2px; }
.audit-tbl td b { font-weight: 700; }
.audit-tbl a.mono { color: var(--primary); font-weight: 700; white-space: nowrap; }
.handler-list .chip { height: 20px; padding: 0 8px; font-size: 11px; margin-left: 4px; vertical-align: 2px; }
