/* HR薪資系統 － 全站樣式
   ★ 外觀比照「現場管理平台」（使用者 2026-10-04：不要讓客戶覺得兩套差很多，要無縫接軌）：
     顏色、字級、卡片、按鈕、表單、底部分頁、面板、清單在手機變卡片，都和平台同一套數值。
     這份是照平台的 style.css／components.css 的樣式重寫的；執行時不依賴平台的任何檔案。
   手機優先；深淺色自動切換。 */

:root {
  /* 告訴瀏覽器這一頁有深淺兩種：不寫的話，深色模式下瀏覽器自己畫的下拉選單、日期欄會是白底配淺字 */
  color-scheme: light dark;
  --bg: #f5f6f8;  --bg2: #ffffff; --bg3: #eef1f5;
  --border: #d8dde5; --text: #1a1d21; --dim: #626b78;
  --accent: #1f4e79; --accent2: #1e7a3c; --warn: #b45309; --bad: #b3261e;
  --radius: 10px;
  --on-accent: #ffffff;
  --tint-good: #edf6ee; --tint-info: #eaf1f8; --tint-warn: #fdf6e7; --tint-bad: #fdf0ef;
  --line-good: #a9cfae; --line-info: #bfd3e6; --line-warn: #e0c878; --line-bad: #e6b5b1;
  --ink-good: #1e5b2a; --ink-warn: #7f5f10;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --bg2: #1c2027; --bg3: #232833;
    --border: #333b47; --text: #e6e9ee; --dim: #98a2b3;
    --accent: #5b9bd5; --accent2: #4ec27a; --warn: #e0a458; --bad: #ef6b63;
    --on-accent: #0b1f33;
    --tint-good: #1d3324; --tint-info: #1c2f44; --tint-warn: #3a2f14; --tint-bad: #3d2220;
    --line-good: #2f5a3a; --line-info: #2f4d6e; --line-warn: #6b5620; --line-bad: #6d3632;
    --ink-good: #8fd3a3; --ink-warn: #e8c07d;
  }
}

* { box-sizing: border-box; }
a { color: var(--accent); }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 "微軟正黑體", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body.center { display: grid; place-items: center; min-height: 100vh; min-height: 100svh; padding: 16px; }
body.no-scroll { overflow: hidden; }

h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
.sub, .dim { color: var(--dim); font-size: .88rem; }
.small { font-size: .82rem; }
.ico { display: block; flex: 0 0 auto; }

.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin: 0 0 14px; }
.login { width: min(360px, 100%); }

label { display: block; margin: 14px 0 0; font-size: .88rem; color: var(--dim); }
/* ★ 字級固定 16px：包在 label 裡會繼承到 .88rem（約 14px），iPhone 的 Safari 遇到小於 16px 的輸入框，
     一點進去就自動把整頁放大——對話框右邊被切掉、輸入框右框線不見（使用者 2026-10-04 實機回報）。模擬器不會放大，所以用字級檢查擋。 */
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 11px 12px; font: inherit; font-size: 16px;
  color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
/* 日期、月份欄位固定一行一個：iPhone 上日期欄和別的欄位擠同一行會被壓到看不到年份（平台踩過） */
input[type=date], input[type=month] { min-height: 46px; }
input[type=checkbox] { display: inline-block; width: 22px; height: 22px; margin: 0; flex: 0 0 auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font: inherit; padding: 11px 16px; border-radius: 8px; cursor: pointer; min-height: 44px;
  border: 1px solid var(--border); background: var(--bg3); color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
/* 長得像主要按鈕的連結（帶人去別的地方用，例：打卡頁的「回現場管理平台打卡」） */
a.primary { display: block; margin-top: 10px; padding: 14px 16px; border-radius: 8px; text-align: center; text-decoration: none;
            background: var(--accent); color: var(--on-accent); font-weight: 600; }
a.primary[hidden] { display: none; }
form > button.primary { width: 100%; margin-top: 18px; }
button.danger { color: var(--bad); border-color: var(--line-bad); background: transparent; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; }

.msg { min-height: 1.4em; margin: 12px 0 0; font-size: .88rem; }
.msg.bad { color: var(--bad); }
.msg.ok  { color: var(--accent2); }

/* ── 主畫面：頂端列＋左側選單（電腦）／底部分頁（手機）── */
/* 示範環境的標示（主機設定 HR_DEMO=1 才有）：每一頁最上面一條，顏色和警告框同一組 */
.demo-bar { padding: 6px 12px; text-align: center; font-size: .85rem; font-weight: 600;
            background: var(--tint-warn); color: var(--warn); border-bottom: 1px solid var(--line-warn); }
body.center .demo-bar { position: fixed; top: 0; left: 0; right: 0; }

button small.demo-off { display: block; font-size: .78rem; font-weight: 600; color: var(--warn); line-height: 1.3; }
button.primary small.demo-off { color: inherit; }      /* 主要按鈕：跟著按鈕的字色走（淺色、深色都看得清楚） */
button[data-demo-off] { opacity: .6; }
.demo-note { margin: 0 0 12px; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.topbar .grow { flex: 1; }
.topbar .back { font-size: .88rem; text-decoration: none; white-space: nowrap; }
.wrap { max-width: 960px; margin: 0 auto; padding: 16px; }
.shell { display: grid; grid-template-columns: 200px 1fr; gap: 0; max-width: none; margin: 0; padding: 0; align-items: stretch; }
.sidebar {
  padding: 14px 10px; background: var(--bg2); border-right: 1px solid var(--border);
  min-height: calc(100vh - 61px); min-height: calc(100svh - 61px);
}
.shell > main { padding: 16px 20px; min-width: 0; }
.navgrp { font-size: .76rem; color: var(--dim); letter-spacing: .05em; margin: 12px 0 5px 10px; }
.navitem {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin-bottom: 3px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: .92rem; white-space: nowrap; overflow: hidden; min-height: 0;
}
.navitem:hover { background: var(--bg3); }
.navitem.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.ni { flex: 0 0 18px; display: flex; align-items: center; justify-content: center; }
button.navitem { width: 100%; background: transparent; border: 0; font: inherit; font-size: .92rem; text-align: left; }
.navacct { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--border); }
.navme { margin: 0 0 4px 12px; font-size: .85rem; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .shell > main { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .topbar #topWho, .topbar #logout { display: none; }
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg3); font-weight: 600; white-space: nowrap; }
.scroll { overflow-x: auto; }
.wrap-text { word-break: break-word; }

.tag { display: inline-block; padding: 1px 8px; margin: 0 4px 2px 0; border-radius: 20px;
       background: var(--bg3); border: 1px solid var(--border); font-size: .78rem; }
.tag.ok { background: var(--tint-good); color: var(--ink-good); border-color: var(--line-good); }
.tag.bad { background: var(--tint-bad); color: var(--bad); border-color: var(--line-bad); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 160px; }
.row label { margin-top: 0; }
.row input, .row select { margin-top: 5px; }

/* 提示框（說明、警告、錯誤、完成） */
.note { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg3);
        font-size: .9rem; line-height: 1.6; margin: 10px 0; }
.note.warn { background: var(--tint-warn); border-color: var(--line-warn); color: var(--ink-warn); }
.note.bad { background: var(--tint-bad); border-color: var(--line-bad); color: var(--bad); }
.note.ok { background: var(--tint-good); border-color: var(--line-good); color: var(--ink-good); }
.secret { font: 1.3rem/1.4 ui-monospace, Consolas, monospace; letter-spacing: .08em; padding: 10px 12px;
          background: var(--bg3); border-radius: 8px; user-select: all; word-break: break-all; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; color: var(--text); font-size: .95rem; }
.check small { display: block; color: var(--dim); }
.group { font-size: .78rem; color: var(--dim); margin: 14px 2px 6px; }

/* 清單列上的操作鈕 */
td.act { white-space: nowrap; }
td.act button { padding: 7px 12px; font-size: .85rem; min-height: 36px; margin: 0 4px 4px 0; }
@media (max-width: 760px) {
  td.act { white-space: normal; flex-wrap: wrap; }
  td.act button { min-height: 44px; margin: 0 0 4px 6px; }
}

/* ── 首頁 ── */
.home { max-width: 720px; }
.clist { display: grid; gap: 8px; }
.ccard { display: block; padding: 12px 14px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--border);
         color: var(--text); text-decoration: none; }
a.ccard:active { background: var(--bg3); }
.ccard strong { font-size: .98rem; line-height: 1.45; display: block; }
.ccard-sub { font-size: .88rem; margin-top: 2px; color: var(--dim); }
.empty { padding: 18px 12px; text-align: center; color: var(--dim); font-size: .9rem;
         border: 1px dashed var(--border); border-radius: 12px; }
.license-notice { padding: 12px 14px; border: 1px solid var(--warn); border-radius: 12px; line-height: 1.6; margin: 0 0 12px; }
.license-notice b { color: var(--warn); }

/* ── 底部分頁（手機）── */
.tabbar { display: none; }
@media (max-width: 760px) {
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    /* iPhone：自成一層＋依可視視窗校正（--vv-dy 由 viewport-fix.js 設，正常時是 0） */
    transform: translate3d(0, var(--vv-dy, 0px), 0); will-change: transform;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding: 4px 4px env(safe-area-inset-bottom);
    background: var(--bg2); border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-height: 56px; padding: 4px 0;
    font-size: .74rem; color: var(--dim); text-decoration: none; background: none; border: 0; border-radius: 10px;
  }
  .tabbar .on { color: var(--accent); font-weight: 600; }
  .tabbar .on .ico { stroke-width: 2.3; }
}

/* 鍵盤開著時收起底部分頁（viewport-fix.js 加 kb-open）：手機 App 的慣例，也不會擋住正在打字的欄位 */
body.kb-open .tabbar { display: none; }

/* ── 面板（手機由下滑出；電腦置中）：內容自己捲，按鈕釘在底部 ── */
.sheet-mask { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .42);
              display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { width: min(520px, 100%); max-height: 86vh; max-height: 86svh; overflow: auto;
         background: var(--bg2); border-radius: 16px; padding: 6px 16px 18px; }
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between;
              position: sticky; top: 0; background: var(--bg2); padding: 10px 0 6px; z-index: 1; }
.sheet-head strong { font-size: 1.05rem; }
.sheet-x { padding: 6px 12px; background: none; border: 0; font-size: 1.1rem; color: var(--dim); }
.sheet-group { font-size: .78rem; color: var(--dim); margin: 14px 2px 6px; }
.fs-err { margin: 12px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--tint-bad); color: var(--bad); font-size: .9rem; }
.sheet:has(.fs-btns) { padding-bottom: 0; }
/* 「儲存」和其他按鈕各佔一整行、中間隔開：手機上不會誤按到旁邊那一顆（平台踩過） */
.fs-btns { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 16px;
           position: sticky; bottom: 0; background: var(--bg2); padding: 10px 0 18px;
           box-shadow: 0 -8px 12px -10px rgba(0, 0, 0, .35); }
.fs-btns button { width: 100%; margin: 0; min-height: 46px; }
.me-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--bg3); margin: 4px 0 6px; }
.me-avatar { flex: 0 0 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
             background: var(--accent); color: var(--on-accent); font-size: 1.4rem; font-weight: 700; }
.me-info { min-width: 0; line-height: 1.5; }
.me-info strong { font-size: 1.1rem; color: var(--text); }
.me-line { font-size: .86rem; color: var(--text); }
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.more-item { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 10px 12px;
             border-radius: 12px; background: var(--bg3); border: 1px solid transparent; color: var(--text);
             text-decoration: none; font-size: .95rem; text-align: left; width: 100%; margin: 0; }
.more-item span { min-width: 0; }
.more-item.on { border-color: var(--accent); color: var(--accent); }
.more-item.more-back { grid-column: 1 / -1; border-color: var(--accent); color: var(--accent); font-weight: 600; }
.more-item.more-logout { justify-content: center; margin-top: 14px; }
@media (max-width: 760px) {
  .sheet-mask { align-items: flex-end; padding: 0; }
  .sheet { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .sheet-grip { display: block; width: 40px; height: 4px; margin: 4px auto 0; border-radius: 2px; background: var(--border); }
  .fs-btns { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

/* ── 提示 ── */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
         max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
         background: var(--text); color: var(--bg2); font-size: .9rem; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
@media (max-width: 760px) { body.has-tabbar .toast { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* ── 清單：電腦是表格、手機自動變卡片（每格的欄名寫在 data-label）── */
@media (max-width: 760px) {
  table.rtable, .rtable tbody { display: block; width: 100%; }
  .rtable thead { display: none; }
  .rtable tr { display: flex; flex-direction: column; width: 100%; margin-bottom: 8px; padding: 10px 12px;
               border-radius: 12px; background: var(--bg2); border: 1px solid var(--border); }
  /* 一格裡有好幾個標籤（帳號的狀態）時要能換行，不然會把整頁撐寬：欄名靠左、內容靠右，放不下就往下一行繼續靠右 */
  .rtable td { display: flex; flex-wrap: wrap; gap: 2px 10px; justify-content: flex-end; align-items: baseline;
               padding: 3px 0; border: 0; text-align: right; }
  .rtable td::before { content: attr(data-label); color: var(--dim); text-align: left; flex: 0 0 auto; font-size: .85rem; margin-right: auto; }
  .rtable td:first-child { font-weight: 600; font-size: 1rem; }
  .rtable td.act { justify-content: flex-end; padding-top: 8px; }
  .rtable td.act::before, .rtable td[colspan]::before { content: none; }
  .rtable td.act:empty { display: none; }
  .rtable td > div { text-align: right; }
  .card { padding: 16px; }
}
