/*
 * 風格沿用 OfficeHub 設計系統的原則（不是照抄畫面）：
 * 黑白負責結構、顏色只負責狀態；一頁只有一顆實心鍵；用 1px 線分層，不用陰影分層；
 * 虛線只給「新增」；圖示一律線性、描邊 1.6、跟著文字色。
 */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --canvas: #f6f6f7;
  --surface: #ffffff;
  --surface-sunken: #fafafb;
  --surface-muted: #f1f1f3;
  --thumb: #e7e7ea;
  --line: #e6e6e9;
  --line-strong: #d9d9dd;
  --line-dashed: #c9c9ce;
  --ink: #0b0b0c;
  --ink-2: #5a5a60;
  --ink-3: #78787e;
  --ink-placeholder: #85858c;
  --ink-inverse: #ffffff;
  --success: #0e7c52;
  --success-bg: #e8f4ee;
  --attention: #8a5a00;
  --attention-bg: #f7f0e2;
  --danger: #b3261e;
  --danger-line: #e3d6d5;
  --link: #1f4fd8;
  --scrim: rgba(11, 11, 12, .5);
  --shadow-card: 0 1px 2px rgba(11, 11, 12, .04);
  --shadow-bar: 0 -8px 24px rgba(11, 11, 12, .06);

  --gutter: 20px;
  --tab-h: 60px;
  --font: "Space Grotesk", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0a0a0b;
    --surface: #161618;
    --surface-sunken: #1c1c1f;
    --surface-muted: #232326;
    --thumb: #2a2a2e;
    --line: #262629;
    --line-strong: #34343a;
    --line-dashed: #3a3a40;
    --ink: #f4f4f5;
    --ink-2: #a3a3aa;
    --ink-3: #8a8a92;
    --ink-placeholder: #7a7a82;
    --ink-inverse: #0a0a0b;
    --success: #3fbe86;
    --success-bg: #14291f;
    --attention: #d79a2b;
    --attention-bg: #2a2113;
    --danger: #f2645c;
    --danger-line: #4a2b28;
    --link: #8fb0ff;
    --scrim: rgba(0, 0, 0, .62);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-bar: 0 -8px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--canvas); }
body { min-height: 100vh; font-family: var(--font); font-size: 15px; line-height: 21px; color: var(--ink); -webkit-text-size-adjust: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.md { width: 20px; height: 20px; }

.demo-ribbon { background: var(--surface-muted); color: var(--ink-3); font-size: 11.5px; line-height: 16px; text-align: center; padding: 6px 12px; border-bottom: 1px solid var(--line); }

.page { max-width: 560px; margin: 0 auto; padding: 0 var(--gutter) calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); }
.page.has-action { padding-bottom: calc(var(--tab-h) + 104px + env(safe-area-inset-bottom)); }

/* ---------- 導覽列 ---------- */
.topbar { height: 56px; display: flex; align-items: center; justify-content: space-between; }
.wordmark { font-size: 17px; line-height: 22px; font-weight: 700; letter-spacing: -.015em; }
.user { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--ink); color: var(--ink-inverse); display: grid; place-items: center; font-size: 13px; font-weight: 600; }

.title { font-size: 27px; line-height: 31px; font-weight: 700; letter-spacing: -.025em; margin: 6px 0 4px; }
.subtitle { color: var(--ink-2); margin: 0 0 14px; }

/* 區塊標題（eyebrow）：永遠是 ink-3 */
.eyebrow { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 8px; font-size: 11.5px; line-height: 16px; font-weight: 600; letter-spacing: .1em; color: var(--ink-3); }
.eyebrow span { font-weight: 400; letter-spacing: 0; }

/* ---------- 卡片 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-card); padding: 16px; margin-bottom: 12px; }
.card.flush { padding: 0 16px; }

/* ---------- 狀態標籤：顏色只出現在這裡 ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; font-weight: 500; padding: 5px 10px; border-radius: 999px; background: var(--surface-muted); color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.pill.success { background: var(--success-bg); color: var(--success); }
.pill.attention { background: var(--attention-bg); color: var(--attention); }
.pill.plain::before { display: none; }

/* ---------- 按鈕：一頁只有一顆實心 ---------- */
.btn { min-height: 52px; padding: 0 20px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px; font-weight: 600; letter-spacing: -.01em; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--ink-inverse); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-text { position: relative; min-height: 30px; padding: 0 12px; border: 1px solid var(--danger-line); border-radius: 10px; background: transparent; color: var(--danger); font-size: 12px; font-weight: 500; }

/* 視覺 30 高，觸控區撐到 44 */
.btn-text::after { content: ""; position: absolute; inset: -7px -4px; }

/* ---------- 打卡 ---------- */
.clock { text-align: center; padding: 28px 16px 16px; }
.clock .date { font-size: 12.5px; color: var(--ink-3); }
.clock .time { font-size: 56px; line-height: 60px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 6px 0 14px; }
.clock .btn { margin-top: 24px; min-height: 60px; font-size: 18px; letter-spacing: .2em; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .t { font-size: 18px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.rows .meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); }
.empty { color: var(--ink-3); font-size: 12.5px; text-align: center; padding: 20px 0; }

/* ---------- 日報：檢核 ---------- */
.check { padding: 14px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check p { margin: 0 0 10px; font-size: 14.5px; line-height: 20px; font-weight: 500; display: flex; gap: 8px; }
.check p b { font-size: 12px; font-weight: 600; color: var(--ink-3); min-width: 14px; padding-top: 1px; }
.check.missing p { color: var(--danger); }
.check.missing p b { color: var(--danger); }
/* 分段選擇：選中是浮起的白塊，不做實心填滿；「否」用 attention 字色 */
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--surface-muted); }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(11, 11, 12, .1); }
.seg button[data-v="否"][aria-pressed="true"] { color: var(--attention); }
.check.missing .seg { box-shadow: inset 0 0 0 1px var(--danger); }

/* ---------- 日報：事項 ---------- */
.item-head { display: flex; align-items: center; justify-content: space-between; margin: -2px 0 12px; }
.row-label { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .04em; color: var(--ink-2); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; line-height: 18px; color: var(--ink-3); margin-bottom: 6px; }
.input { display: block; width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: var(--surface-sunken); font-size: 16px; line-height: 21px; }
textarea.input { min-height: 88px; resize: vertical; }
.input::placeholder { color: var(--ink-placeholder); }
.input:focus { outline: none; border-color: var(--ink); background: var(--surface); }

.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }
.photos:empty { display: none; }
.photo { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); position: relative; }
.photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--thumb); }
.photo.busy img { opacity: .5; }
.photo .cap { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); padding: 10px; font-size: 16px; line-height: 20px; background: var(--surface); }
.photo .cap::placeholder { color: var(--ink-placeholder); }
.photo .cap:focus { outline: none; background: var(--surface-sunken); }
.photo .rm { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: 0; border-radius: 999px; background: var(--scrim); color: #fff; display: grid; place-items: center; }
/* 照片鍵是一個動作，不是空欄位：實心外框，不用虛線 */
.photo-btn { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 12.5px; font-weight: 500; }
.photo-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
/* 虛線只給「新增」 */
.add-item { width: 100%; min-height: 52px; border: 1.5px dashed var(--line-dashed); border-radius: 16px; background: transparent; color: var(--ink-2); font-size: 14.5px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ---------- 底部操作列 ---------- */
.action-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow-bar); z-index: 2; }
.action-bar .inner { max-width: 560px; margin: 0 auto; padding: 12px var(--gutter); display: flex; align-items: center; gap: 12px; }
.action-bar .status { flex: 1; font-size: 11.5px; line-height: 16px; color: var(--ink-3); }
.action-bar .btn { min-width: 132px; }

/* ---------- 已提交 ---------- */
.done { text-align: center; padding: 28px 16px 16px; }
.done .mark { width: 48px; height: 48px; border-radius: 999px; background: var(--success-bg); color: var(--success); display: grid; place-items: center; margin: 0 auto 14px; }
.done .mark svg { width: 24px; height: 24px; }
.done h2 { font-size: 18px; line-height: 24px; letter-spacing: -.02em; margin: 0 0 6px; }
.done p { margin: 0 0 2px; color: var(--ink-2); font-size: 12.5px; }
.done .btns { display: grid; gap: 10px; margin-top: 22px; }
.kv { display: flex; justify-content: space-between; min-height: 50px; align-items: center; border-top: 1px solid var(--line); font-size: 14.5px; }
.kv:first-child { border-top: 0; }
.kv span:last-child { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- 底部分頁 ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 3; }
.tabbar a { flex: 1; max-width: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--ink-3); font-size: 11.5px; font-weight: 500; }
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------- 登入 ---------- */
.login { min-height: calc(100vh - 29px); display: flex; flex-direction: column; justify-content: center; padding: 24px var(--gutter); max-width: 420px; margin: 0 auto; }
.login .mark { width: 64px; height: 64px; border-radius: 16px; background: var(--ink); color: var(--ink-inverse); display: grid; place-items: center; font-size: 28px; font-weight: 700; margin-bottom: 20px; }
.login .title { margin: 0 0 6px; }
.login .subtitle { margin-bottom: 32px; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 52px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); font-size: 15px; font-weight: 600; }
.notice { border-radius: 14px; padding: 12px 14px; font-size: 12.5px; line-height: 18px; margin-bottom: 16px; }
.notice b { display: block; font-size: 14.5px; line-height: 20px; margin-bottom: 2px; }
.notice.attention { background: var(--attention-bg); color: var(--attention); }
.notice.danger { background: var(--surface); border: 1px solid var(--danger-line); color: var(--danger); }
.login .foot { font-size: 11.5px; color: var(--ink-3); margin-top: 14px; text-align: center; }

/* ---------- 提示 ---------- */
.toast { position: fixed; left: 50%; top: 68px; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--ink-inverse); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; font-weight: 500; transition: .2s; z-index: 10; max-width: calc(100vw - 40px); box-shadow: 0 6px 16px rgba(11, 11, 12, .12); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- 網頁專屬：導覽列固定、hover、鍵盤焦點 ---------- */
.topbar { position: sticky; top: 0; z-index: 4; background: var(--canvas); margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); transition: box-shadow .2s; }
.topbar.scrolled { box-shadow: 0 6px 16px rgba(11, 11, 12, .06); }
.topnav { display: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.input:focus-visible, .photo .cap:focus-visible { outline: none; }
@media (hover: hover) {
  .btn:not([disabled]):hover { background: var(--surface-muted); }
  .btn.primary:not([disabled]):hover { background: var(--ink); opacity: .86; }
  .seg button:not([aria-pressed="true"]):hover { color: var(--ink); }
  .add-item:hover, .photo-btn:hover { border-color: var(--ink-3); color: var(--ink); }
  .btn-text:hover { background: var(--danger-line); }
  .tabbar a:hover, .topnav a:hover { color: var(--ink); }
}
.photo-btn.drag { border-color: var(--ink); background: var(--surface-muted); }
.only-desktop { display: none; }

/* ---------- 電腦版（≥ 768px）：底部分頁改成頂部導覽 ---------- */
@media (min-width: 768px) {
  :root { --gutter: 32px; }
  .page { max-width: 720px; padding-bottom: 48px; }
  .page.has-action { padding-bottom: 120px; }
  .topbar { height: 64px; }
  .topnav { display: flex; gap: 4px; margin-left: 28px; flex: 1; }
  .topnav a { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 10px; text-decoration: none; color: var(--ink-3); font-weight: 500; }
  .topnav a[aria-current="page"] { color: var(--ink); background: var(--surface-muted); font-weight: 600; }
  .tabbar { display: none; }
  .action-bar { bottom: 0; }
  .action-bar .inner { max-width: 720px; }
  .photos { grid-template-columns: repeat(3, 1fr); }
  .clock { padding: 40px 48px 32px; }
  .clock .time { font-size: 72px; line-height: 76px; }
  .clock .btn { max-width: 360px; margin-left: auto; margin-right: auto; }
  .only-mobile { display: none; }
  .only-desktop { display: inline; }
}

/* ---------- 管理者後台 ---------- */
.subnav { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--surface-muted); margin: 4px 0 16px; }
.subnav a { flex: 1; min-height: 38px; display: grid; place-items: center; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.subnav a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(11, 11, 12, .1); }

.stats { display: grid; grid-template-columns: 1fr 1fr; padding: 0; }
.stats div { padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.stats div + div { border-left: 1px solid var(--line); }
.stats b { font-size: 32px; line-height: 36px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stats small { font-size: 15px; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.stats span { font-size: 12.5px; color: var(--ink-3); }

.avatar.sm { width: 32px; height: 32px; font-size: 13px; flex: none; }
.avatar.off { background: var(--surface-muted); color: var(--ink-3); }
.rows small { display: block; font-size: 11.5px; line-height: 16px; color: var(--ink-3); font-weight: 400; }
.people li { padding: 0; }
.person { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 0; border: 0; background: transparent; text-align: left; text-decoration: none; color: inherit; }
.person .who { flex: 1; min-width: 0; }
.person .who b { font-weight: 600; font-size: 15px; }
.person .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .states { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.person > svg { color: var(--ink-3); }

.filters { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; padding-bottom: 4px; }
.filters .field { min-width: 0; }
.filters .field:first-child, .filters .field:nth-child(4) { grid-column: 1 / -1; }
input[type="date"].input { width: 100%; min-width: 0; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378787e' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 36px; }
input[type="date"].input { min-height: 44px; }

.day-head { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 16px 2px 8px; }
.table li { flex-wrap: wrap; gap: 4px 12px; padding: 12px 0; }
.table .c-name { display: flex; align-items: center; gap: 10px; flex: 1 1 100%; min-width: 0; }
.table .c-name b { font-weight: 600; }
.punch-table .c-name { flex: 1 1 auto; }
.punch-table .c-time { order: -1; min-width: 52px; }
.table .c-state, .table .c-sum, .table .c-dev, .table .c-acc, .table .c-map, .table .c-open { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.report-table .c-name { flex: 1 1 auto; }
.report-table .c-sum { flex: 1 1 auto; flex-direction: column; align-items: flex-start; gap: 0; padding-left: 42px; color: var(--ink); font-size: 14px; }
.report-table .c-state { margin-left: auto; flex-direction: column; align-items: flex-end; gap: 2px; }
.report-table .c-open { margin-left: auto; }
.link { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; border: 0; background: none; padding: 0; color: var(--link); font-size: 12.5px; font-weight: 500; text-decoration: none; }
.hint { font-size: 12.5px; line-height: 18px; color: var(--ink-3); margin: -4px 0 16px; }

/* 底部浮層；電腦版改成置中對話框 */
.sheet-wrap { position: fixed; inset: 0; background: var(--scrim); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--surface); border-radius: 26px 26px 0 0; box-shadow: 0 -14px 44px rgba(11, 11, 12, .26); padding: 10px var(--gutter) calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
.sheet .handle { width: 38px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 0 auto 14px; }
.sheet h2 { font-size: 18px; line-height: 24px; letter-spacing: -.02em; margin: 0 0 16px; }
.sheet-actions { display: flex; align-items: center; gap: 10px; }
.sheet-actions .btn { flex: 1; }
.sheet-actions .btn-text { margin-right: auto; }

@media (min-width: 768px) {
  .page.wide { max-width: 960px; }
  .page.wide .subnav { max-width: 420px; }
  .filters { grid-template-columns: 2fr 1fr 1fr; align-items: end; }
  .filters .field:first-child { grid-column: auto; }
  .filters .field:nth-child(4) { grid-column: 1 / -1; max-width: 320px; }
  .table li { flex-wrap: nowrap; }
  .table .c-name { flex: 0 0 200px; }
  .punch-table .c-time { order: 0; flex: 0 0 80px; }
  .punch-table .c-dev { flex: 0 0 60px; }
  .punch-table .c-acc { flex: 1; }
  .punch-table .c-map { flex: 0 0 72px; justify-content: flex-end; }
  .report-table .c-state { flex: 0 0 150px; padding-left: 0; flex-direction: column; align-items: flex-start; gap: 2px; }
  .report-table .c-sum { flex: 1; padding-left: 0; }
  .report-table .c-open { flex: 0 0 100px; justify-content: flex-end; }
  .add-staff { width: fit-content; margin-left: auto; display: flex; }
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 20px; max-width: 480px; padding: 20px 24px 24px; }
  .sheet .handle { display: none; }
  .stats { max-width: 480px; }
}
@media (hover: hover) {
  .person:hover .who b { text-decoration: underline; text-underline-offset: 3px; }
  .link:hover { text-decoration: underline; }
}

/* 導覽列上的使用者：點一下可登出 */
button.user { border: 0; background: transparent; padding: 0; cursor: pointer; }
/* Google 官方登入鈕的容器，保留高度避免載入時跳動 */
.gsi { min-height: 44px; display: flex; justify-content: center; }
a.btn { text-decoration: none; }
