/* BK Design v3 — 沿用 v2.3.3 的配色與版面 */

/* 品牌標題字體：Titan One（SIL Open Font License，授權條款見 fonts/OFL.txt） */
@font-face {
  font-family: "Titan One";
  src: url("../fonts/TitanOne-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  --bk-red: #e72410;      /* Brand / Primary */
  --bk-red-dark: #c41d0c; /* 主要按鈕滑過 */
  --bk-yellow: #ffb600;   /* Accent */
  --bk-brown: #5c3327;    /* 主要操作、已啟用 */
  --bk-brown-hover: #7a4636; /* 主要按鈕滑過（深色按鈕滑過時變淺） */
  --brown-tint: #f6eee6;  /* 已啟用的淡底、懸浮 */
  --bk-orange: #f0831e;   /* 提醒、即將到期 */
  --cream: #fff8ee;
  --ink: #252525;
  --muted: #6f6f6f;
  --line: #eadfd3;
  --bg: #f5ebdc;   /* Surface / App：漢堡王 CI 色 */
  --green: #1e6b34;
  --green-bg: #e7f4ea;
  --danger: #b3261e;
  --danger-bg: #fff0f0;
  --danger-line: #efb7b7;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: Arial, "Noto Sans TC", "Microsoft JhengHei", sans-serif; font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.prewrap { white-space: pre-wrap; }
:focus-visible { outline: 3px solid rgba(92, 51, 39, .45); outline-offset: 2px; }

/* ── 表單元件 ── */
input, select, textarea { border: 1px solid #d8cec3; border-radius: 8px; padding: 10px 11px; background: #fff; min-width: 0; }
input[readonly] { background: #f7f3ee; color: var(--muted); }
textarea { resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px; padding: 10px 15px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
/* 主要操作（派發、提交、驗收結案…）用咖啡色；紅色系只留給退回、取消等需要小心的操作 */
.btn.primary { background: var(--bk-brown); color: #fff; }
.btn.primary:hover { background: var(--bk-brown-hover); }
.btn.ghost { background: #f1ece6; color: #333; }
.btn.ghost:hover { background: #e8e0d7; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger-line); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.danger-solid { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .6; cursor: wait; }
.link-btn { border: 0; background: none; color: var(--bk-brown); font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.field-error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.field-error:empty { margin: 0; }
.hint { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.ok-text { color: var(--green); }
.err-text { color: var(--danger); }
.alert { padding: 12px 14px; border-radius: 10px; font-weight: 700; margin: 12px 0; line-height: 1.5; }
.alert.err { background: #c62828; color: #fff; }
.alert.ok { background: #eaf7ee; border: 1px solid #b8dfc4; color: #176b35; }
.rules { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.rules .rule.pass { color: var(--green); font-weight: 700; }
.req { color: var(--bk-red); font-size: 12px; font-weight: 700; }

/* ── 登入／註冊 ── */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #fff8ee, #f4e8dc); padding: 20px; }
.loginbox { width: 400px; max-width: 100%; background: #fff; border-radius: 16px; border: 1px solid var(--line); padding: 34px; box-shadow: 0 15px 45px #00000012; display: flex; flex-direction: column; }
.loginbrand { display: flex; justify-content: center; align-items: center; gap: 12px; font-family: "Titan One", Arial, sans-serif; font-size: 30px; font-weight: 400; color: var(--bk-red); margin-bottom: 8px; white-space: nowrap; }
.loginbox .sub { text-align: center; color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.loginbox h2 { margin: 6px 0; }
.loginbox input[type=text], .loginbox input[type=password] { width: 100%; margin: 6px 0; }
.loginbox .lbl { font-size: 13px; font-weight: 700; margin-top: 8px; }
.loginbox .btn.primary { width: 100%; margin-top: 10px; padding: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; }
.linkline { text-align: center; margin-top: 12px; font-size: 13px; color: var(--muted); }
.linkline a { color: var(--bk-brown); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.demo-box { margin-top: 18px; padding: 14px; border: 1px dashed #d8cec3; border-radius: 10px; font-size: 13px; color: var(--muted); }
.demo-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.demo-btns .btn { padding: 8px 10px; font-size: 13px; }
.logo-img { width: 52px; height: 52px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; }

/* ── 版面 ── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 238px; background: var(--bk-red); color: #fff; padding: 18px 14px; position: fixed; inset: 0 auto 0 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 24px; font-family: "Titan One", Arial, sans-serif; font-weight: 400; font-size: 22px; white-space: nowrap; }
.brand .logo-img { width: 44px; height: 44px; border-radius: 9px; }
.nav a { display: block; color: rgba(255, 255, 255, .88); text-decoration: none; padding: 12px 14px; margin: 3px 0; border-radius: 8px; font-weight: 700; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.nav a.active, .nav a.active:hover { background: var(--bk-yellow); color: var(--bk-brown); box-shadow: inset 3px 0 0 var(--bk-brown); }
.main { margin-left: 238px; flex: 1; min-width: 0; }
.topbar { height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.usermenu { position: relative; }
.userbtn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.userbtn:hover { background: #f6f1eb; }
.caret { color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--bk-yellow); display: grid; place-items: center; font-weight: 800; color: var(--bk-red); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px #0000001a; min-width: 160px; padding: 6px; z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 7px; cursor: pointer; }
.menu button:hover { background: #f6f1eb; }
.page { max-width: 1600px; margin: 0 auto; padding: 28px 32px; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 14px; }
h3 { font-size: 16px; margin: 0 0 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.section-head h2 { margin: 0; }
.list-head { margin-top: 32px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.panel + .panel { margin-top: 18px; }
.loading, .empty { padding: 30px; text-align: center; color: var(--muted); }

/* ── 首頁卡片 ── */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; cursor: pointer; text-align: left; transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-1px); box-shadow: 0 5px 18px #00000012; }
.card.selected { border-color: #c8b3a6; background: var(--brown-tint); box-shadow: inset 4px 0 0 var(--bk-brown); }
.card .label { color: var(--muted); font-weight: 700; }
.card .num { font-size: 34px; font-weight: 900; margin-top: 8px; line-height: 1.1; }
.card.due { background: #fff; border-color: #f3c9a3; box-shadow: inset 4px 0 0 var(--bk-orange); }
.card.due .num { color: var(--danger); }
.card.due.selected { border-color: #c8b3a6; background: var(--brown-tint); box-shadow: inset 4px 0 0 var(--bk-brown); }
.filter-note { font-size: 14px; color: var(--muted); display: flex; gap: 10px; align-items: center; }

/* ── 專案列表 ── */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 240px; max-width: 360px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 10px; border-bottom: 1px solid #eee6df; font-size: 14px; white-space: nowrap; vertical-align: middle; }
th { color: #6d6259; background: #fffaf5; font-weight: 700; }
td.name-cell { white-space: normal; min-width: 160px; font-weight: 700; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tr.clickable:focus td { background: #faf7f3; }
tr.clickable:focus { outline: none; }
.status { display: inline-block; padding: 4px 10px; border-radius: 99px; background: #f4eee8; font-size: 12px; font-weight: 700; }
.status.s-closed { background: var(--green-bg); color: var(--green); }
.tag-returned { display: inline-block; padding: 3px 8px; border-radius: 6px; background: var(--danger-bg); color: var(--danger); font-size: 12px; font-weight: 700; margin-left: 6px; }
.tag-pending { display: inline-block; padding: 3px 8px; border-radius: 6px; background: #fff4d6; color: #7a5200; font-size: 12px; font-weight: 700; margin-left: 6px; }
.overdue { color: var(--danger); font-weight: 700; }

/* ── 專案詳細頁 ── */
.back { margin-bottom: 14px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid #eee6df; margin-bottom: 18px; }
.detail-head h1 { margin-top: 4px; }
.head-tags { display: flex; gap: 6px; align-items: center; }
.head-tags .tag-returned { margin: 0; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 24px; }
.info .k, .block .k { font-size: 13px; color: var(--muted); }
.info .v { margin-top: 3px; font-weight: 700; }
.block { margin-top: 18px; }
.block .v { margin-top: 4px; line-height: 1.7; }
.path-box { display: flex; gap: 8px; align-items: center; background: #faf7f3; border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 12px; margin-top: 6px; }
.path-box code { flex: 1; word-break: break-all; font-family: Consolas, "Courier New", monospace; font-size: 14px; }
.reject-box { background: var(--danger-bg); border: 1px solid var(--danger-line); color: var(--danger); border-radius: 10px; padding: 12px 14px; margin-top: 18px; line-height: 1.6; }
.sec { border-top: 1px solid #eee6df; margin-top: 22px; padding-top: 18px; }
.timeline { border-left: 3px solid var(--bk-yellow); padding-left: 16px; }
.event { margin-bottom: 14px; }
.event:last-child { margin-bottom: 0; }
.event small { color: var(--muted); display: block; margin-top: 2px; }
.event .reason { color: var(--danger); margin-top: 4px; }
.actions-area { background: #faf7f3; border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-top: 24px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-row select { min-width: 180px; }
.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.wait-box { display: flex; gap: 10px; align-items: center; color: var(--muted); font-weight: 700; }

/* ── 表單頁 ── */
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > b { font-size: 14px; }
.full { grid-column: 1 / -1; }
.checks { display: flex; gap: 20px; padding: 9px 0; }
.checks label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
tr.editing td { background: #fffaf5; vertical-align: top; }
tr.editing input, tr.editing select { width: 100%; min-width: 110px; padding: 8px; }
.row-actions { white-space: normal; min-width: 150px; }
.row-actions .btn { padding: 8px 12px; }

/* ── 提示與對話框 ── */
.toast { position: fixed; top: calc(18px + env(safe-area-inset-top, 0px)); left: 50%; z-index: 1000; display: flex; align-items: center; gap: 12px; min-width: min(340px, calc(100vw - 32px)); max-width: min(560px, calc(100vw - 32px)); padding: 14px 20px; border-radius: 12px; background: #222; color: #fff; box-shadow: 0 14px 36px rgba(0, 0, 0, .22); opacity: 0; transform: translate(-50%, -16px); pointer-events: none; cursor: pointer; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.success { background: #1e6b34; }
.toast.error { background: var(--danger); }
.toast-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 255, .22); display: grid; place-items: center; font-weight: 900; font-size: 15px; }
.toast-text b { display: block; font-size: 16px; }
.toast-text small { display: block; font-size: 13px; opacity: .9; margin-top: 2px; }
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; z-index: 999; padding: 18px; }
.dialog { background: #fff; border-radius: 16px; padding: 26px; max-width: 440px; width: 100%; }
.dialog h3 { margin: 0 0 10px; font-size: 19px; }
.dialog p { white-space: pre-line; line-height: 1.7; color: #555; margin: 0; }
.dialog .form-actions { margin-top: 20px; }
.version { position: fixed; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); font-size: 11px; color: #8a7f75; background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; z-index: 4; }

@media (prefers-reduced-motion: reduce) {
  .card, .toast { transition: none; }
  .card:hover { transform: none; }
}

@media (max-width: 1000px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .formgrid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { position: sticky; top: 0; width: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  :root { padding-top: 0; }
  .brand { padding: 0; font-size: 17px; }
  .brand .logo-img { width: 34px; height: 34px; }
  .nav { display: flex; gap: 2px; }
  .nav a { padding: 8px 10px; margin: 0; font-size: 13px; }
  .main { margin-left: 0; }
  .topbar { position: static; height: 54px; padding: 0 14px; }
  .page { padding: 16px; }
  .panel { padding: 16px; }
  /* 手機版：版本號改放在頁面最下方（不浮在畫面上，避免蓋住內容） */
  .version { position: static; display: block; width: fit-content; margin: 4px auto calc(16px + env(safe-area-inset-bottom, 0px)); }
}

/* ── v3.1 ── */
.status.s-canceled { background: #ecebea; color: #77716b; }
.event .reply { color: var(--green); margin-top: 4px; }
.cancel-box { background: #f4f2f0; border: 1px solid #ddd6cf; color: #5d5650; border-radius: 10px; padding: 12px 14px; margin-top: 18px; line-height: 1.6; }
.note-field { margin-bottom: 12px; }
.note-field textarea { background: #fff; }
.actions-extra { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px dashed #ddd2c6; }
.link-danger { border: 0; background: none; color: var(--danger); font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
.toolbar .check { margin: 0 4px; white-space: nowrap; }

/* ── v3.2 管理員後台：帳號展開設定 ── */
.acct-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.acct-row { display: grid; grid-template-columns: 110px minmax(80px, 1fr) 100px minmax(170px, 1.6fr) 90px 20px; gap: 12px; align-items: center; padding: 13px 14px; border-top: 1px solid #eee6df; font-size: 14px; cursor: pointer; }
.acct-row:first-child { border-top: 0; }
.acct-row:hover, .acct-row.open { background: #fffaf5; }
.acct-row.head { cursor: default; background: #fffaf5; color: #6d6259; font-weight: 700; font-size: 13px; }
.acct-row .acc { font-weight: 700; }
.acct-row .caret { color: var(--muted); }
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.perm-chip { min-width: 22px; text-align: center; font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: #f4eee8; color: #6d6259; }
.perm-chips .tag-pending { margin-left: 2px; }
.acct-panel { padding: 18px; background: #fffaf5; border-top: 1px dashed #e6d9cc; }
.formgrid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.perm-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.perm-item { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--line); cursor: pointer; font-size: 14px; font-weight: 700; }
.perm-item.on { border-color: #f0b8a6; }
.perm-item input { margin-top: 3px; }
.perm-item small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.perm-item .mk { font-size: 12px; margin-left: 6px; font-weight: 700; }
.mk.add { color: var(--green); }
.mk.rem { color: var(--danger); }
.form-actions.start { justify-content: flex-start; align-items: center; }
@media (max-width: 1000px) {
  .formgrid.four { grid-template-columns: 1fr 1fr; }
  .acct-row { grid-template-columns: 90px 1fr 80px 20px; }
  .acct-row > :nth-child(4), .acct-row > :nth-child(5) { display: none; }
}

/* v3.3 預計完成日 vs 實際交付 */
.est-note { display: block; font-size: 12px; font-weight: 700; margin-top: 3px; color: var(--muted); }
.est-note.ok { color: var(--green); }
.est-note.bad { color: var(--danger); }

/* ── v3.3.1 側欄圖示與文字 ── */
.nav a { display: flex; align-items: center; gap: 12px; }
.nav .ic { width: 16px; text-align: center; }

/* ── v3.3.1 手機版：只上下滑動，專案列表改為卡片 ── */
.m-list { display: none; }
@media (max-width: 760px) {
  /* 只在 html 隱藏左右捲動；body 用 clip（不會變成獨立的捲動區），
     否則 iPhone（WebKit）上方紅色列無法固定、底部分頁列會跟著頁面捲走 */
  html { overflow-x: hidden; }
  body { overflow-x: clip; }
  .table-wrap.projects { display: none; }
  .m-list { display: grid; gap: 10px; }
  .m-card { display: block; text-decoration: none; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
  .m-card:active { background: #faf7f3; }
  .m-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
  .m-top b { font-size: 16px; line-height: 1.4; }
  .m-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; flex: none; max-width: 50%; }
  .m-tags .tag-returned { margin-left: 0; }
  .m-meta { font-size: 13px; color: var(--muted); margin-top: 6px; }
  .m-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted); }
  .m-dates b { display: block; color: var(--ink); font-size: 14px; margin-top: 2px; }
  .m-dates b.overdue { color: var(--danger); }
  .panel:has(.m-list) { background: transparent; border: 0; padding: 0; }
  .toolbar { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
  .toolbar input[type=search] { flex: 1 1 100%; max-width: none; }
  .toolbar input[type=date] { flex: 1 1 0; min-width: 0; }
  .toolbar .check { flex: 1 1 100%; margin: 0; }
  .toolbar .btn { flex: 1 1 0; }
  .filter-note { width: 100%; justify-content: space-between; }
  .nav .ic { display: none; }
  .nav a { padding: 8px 9px; }
  .brand { font-size: 16px; gap: 8px; }
  .detail-head h1 { font-size: 20px; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
  .path-box { flex-wrap: wrap; }
  .path-box code { flex: 1 1 100%; }
  .actions-row > select, .actions-row > .inline, .actions-row > .inline input { width: 100%; }
  .actions-row > .btn { flex: 1 1 auto; }
  .formgrid.four { grid-template-columns: 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
  .dialog { padding: 22px; }
}

/* ── v3.4 管理員重設密碼 ── */
.reset-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.reset-row select { min-width: 260px; }
.status-cell { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.status-cell .tag-pending { margin-left: 0; }
.pw-banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; background: #fff4d6; border-bottom: 1px solid #e8c66a; color: #7a5200; font-weight: 700; padding: 12px 32px; }
.pw-banner .btn { padding: 8px 14px; }
@media (max-width: 760px) {
  .reset-row select, .reset-row .btn { width: 100%; }
  .pw-banner { padding: 12px 16px; }
  .pw-banner .btn { width: 100%; }
}

/* ── v3.4.1 平均分行（權限勾選、詳細頁資訊區共用） ──
   欄數由程式依項目數計算（--cols），每列寬度相同，最後一列置中 */
.balanced { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.balanced > * { flex: 0 0 calc((100% - (var(--cols) - 1) * 10px) / var(--cols)); min-width: 0; }
@media (max-width: 1000px) { .balanced { --cols: 2 !important; } }
@media (max-width: 760px) { .perm-grid.balanced { --cols: 1 !important; } }

/* 權限卡片：內容垂直置中、勾選時更明顯 */
.perm-grid.balanced .perm-item { align-items: center; padding: 12px 14px; transition: border-color .15s, background .15s; }
.perm-grid.balanced .perm-item.on { background: #fff7f3; border-color: #f0b8a6; }
.perm-grid.balanced .perm-item input { margin-top: 0; width: 16px; height: 16px; flex: none; }

/* 詳細頁資訊區：每個欄位一個淺色區塊 */
.info-grid.balanced .info { background: #faf7f3; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.info-grid.balanced .info .v { margin-top: 4px; }

/* 專案編號 */
.proj-id { font-size: 13px; color: var(--muted); }
.proj-id b { color: var(--ink); font-family: Consolas, "Courier New", monospace; font-size: 14px; letter-spacing: .3px; }

/* 篩選中提示與「顯示全部」按鈕 */
.filter-chip { background: #fff8ee; border: 1px solid #e6c9ad; color: #7a4a1f; border-radius: 99px; padding: 6px 12px; font-size: 13px; }
.filter-chip b { color: var(--bk-brown); }
.btn.show-all { background: #fff; color: var(--bk-brown); border: 1.5px solid var(--bk-brown); padding: 8px 16px; font-size: 14px; }
.btn.show-all:hover { background: var(--bk-brown); color: #fff; }
@media (max-width: 760px) {
  .filter-note { flex-wrap: wrap; gap: 8px; }
  .btn.show-all { width: 100%; }
}

/* ── v3.4.2 右上角使用者：名稱（大）＋職稱（小）、箭頭樣式 ── */
.userbtn { gap: 10px; padding: 6px 10px 6px 6px; border: 1px solid transparent; border-radius: 10px; }
.userbtn:hover, .userbtn[aria-expanded="true"] { background: #f6f1eb; border-color: var(--line); }
.user-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; text-align: left; }
.user-text b { font-size: 15px; }
.user-text small { font-size: 12px; color: var(--muted); }
.user-text small:empty { display: none; }
.chev { width: 16px; height: 16px; fill: none; stroke: #8a7f75; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.userbtn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.menu-head { padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
@media (max-width: 760px) { .user-text b { font-size: 14px; } }

/* v3.5.0 背景更新提示 */
.refreshing { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; vertical-align: middle; }

/* ── v3.6 首頁（待我處理）與需求列表 ── */
.page-sub { margin: -6px 0 16px; }
.count-chip { display: inline-block; min-width: 28px; padding: 2px 10px; border-radius: 99px; background: var(--bk-red); color: #fff; font-size: 14px; text-align: center; vertical-align: middle; }
.todo-step { display: inline-block; padding: 3px 10px; border-radius: 6px; background: #fff4d6; color: #7a5200; font-size: 13px; font-weight: 700; }
.m-step { margin-top: 6px; font-size: 13px; color: #7a5200; }
.list-count { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.card.stat { text-decoration: none; color: inherit; display: block; }
.card.stat .muted { margin-top: 6px; }

/* ── v3.6 系統說明頁 ── */
.help-btn { position: absolute; left: 22px; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); width: 42px; height: 42px; border-radius: 50%; background: var(--bk-yellow); color: var(--bk-red); font-weight: 900; font-size: 20px; display: grid; place-items: center; text-decoration: none; box-shadow: 0 4px 12px rgba(0, 0, 0, .18); }
.help-btn:hover { transform: translateY(-1px); }
.help-card { padding: 28px 32px; }
.help-card h2 { font-size: 20px; margin: 28px 0 10px; }
.help-card h3 { font-size: 16px; margin: 24px 0 10px; }
.help-card ul { margin: 6px 0 10px; padding-left: 20px; line-height: 1.8; }
.help-card .lead { font-size: 16px; line-height: 1.8; margin: 12px 0; }
.help-tag { display: inline-block; padding: 4px 12px; border-radius: 99px; background: #fde7e1; color: var(--bk-red); font-weight: 700; font-size: 13px; }
.help-note { background: #fff8e1; border-left: 4px solid var(--bk-yellow); border-radius: 6px; padding: 12px 16px; margin: 12px 0; line-height: 1.7; }
.help-flow { overflow-x: auto; margin: 6px 0 12px; }
.help-flow svg { width: 100%; max-width: 860px; min-width: 640px; height: auto; display: block; }
.ds-title { margin-top: 12px !important; }
.swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.swatch { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.swatch .sw-color { display: block; height: 64px; border-bottom: 1px solid var(--line); }
.swatch .sw-text { padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.swatch .sw-text span { color: var(--muted); }
.type-rows .type-row { display: flex; align-items: baseline; gap: 20px; padding: 12px 0; border-bottom: 1px solid #eee6df; }
.t-meta { flex: none; width: 170px; font-size: 13px; color: var(--muted); }
.t-brand { font-family: "Titan One", Arial, sans-serif; color: var(--bk-red); font-size: 22px; }
.spacing { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0; }
.spacing div { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; font-size: 12px; color: var(--muted); font-weight: 700; }
.spacing i { display: block; height: 8px; border-radius: 99px; background: var(--bk-red); }
.comp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid #eee6df; }
.comp-row .est-note { display: inline-block; margin: 0; }
.comp-row .tag-returned, .comp-row .tag-pending { margin-left: 0; }
.toast-demo { display: inline-flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 12px; background: #1e6b34; color: #fff; }
.toast-demo .toast-text b { font-size: 15px; }

@media (max-width: 1000px) {
  .swatches { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .help-btn { position: static; width: 34px; height: 34px; font-size: 16px; box-shadow: none; }
  .help-card { padding: 18px; }
  .swatches { grid-template-columns: 1fr; }
  .t-meta { width: 110px; }
}

/* v3.7.1 首頁五張卡片 */
.cards.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.home-list { margin-top: 18px; }
.home-list .section-head h2 { font-size: 18px; }
@media (max-width: 1000px) { .cards.five { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .cards.five { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── v3.8.2 需求列表篩選：兩排都對齊同一組 5 等分格線 ──
   第一排：關鍵字與四個下拉選單等寬
   第二排：建立日期（第 1 格，開始／結束各半）、快速選擇（第 2 格，各半）、搜尋／清除（第 5 格，各半） */
.filters { display: flex; flex-direction: column; gap: 16px; padding-bottom: 18px; margin-bottom: 14px; border-bottom: 1px solid #eee6df; }
.f-row1, .f-row2 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.f-row2 { align-items: end; }
.f-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f-field > span { font-size: 13px; font-weight: 700; color: #4a4440; }
.filters input, .filters select { height: 42px; padding: 0 12px; width: 100%; }
.f-date { grid-column: 1; }
.f-quick { grid-column: 2; }
.date-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; }
.date-range input { width: 100%; min-width: 0; padding: 0 8px; }
.date-range .sep { color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; height: 42px; border: 1px solid #d8cec3; border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 0 6px; font-weight: 700; font-size: 14px; color: #6d6259; cursor: pointer; white-space: nowrap; }
.seg button + button { border-left: 1px solid #d8cec3; }
.seg button:hover { background: var(--brown-tint); color: var(--bk-brown); }
.seg button.on, .seg button.on:hover { background: var(--bk-brown); color: #fff; }
.f-actions { grid-column: 5; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.f-actions .btn { height: 42px; width: 100%; min-width: 0; padding: 0 8px; }
/* 半格放不下日期時（寬度 1700px 以下）：日期佔第 1～2 格、快速選擇第 3 格、按鈕維持第 5 格 */
@media (max-width: 1700px) {
  .f-date { grid-column: 1 / span 2; }
  .f-quick { grid-column: 3; }
}
/* 再窄一些（1200px 以下）：快速選擇改佔第 3～4 格 */
@media (max-width: 1200px) {
  .f-quick { grid-column: 3 / span 2; }
}
@media (max-width: 1100px) {
  .f-row1, .f-row2 { grid-template-columns: 1fr 1fr; }
  .f-row1 .f-q, .f-date { grid-column: 1 / -1; }
  .f-quick { grid-column: 1; }
  .f-actions { grid-column: 2; }
}
@media (max-width: 760px) {
  .f-row2 { grid-template-columns: 1fr; }
  .f-date, .f-quick, .f-actions { grid-column: 1; }
}

/* ── v3.7.3 元件一致性 ── */
/* 按鈕最小寬度：同一組按鈕等寬（文字較長時才會變寬） */
.btn { min-width: 96px; }
/* 被退回、待啟用等標籤與狀態標籤同樣是膠囊形 */
.tag-returned, .tag-pending { border-radius: 99px; padding: 4px 10px; }

/* v3.8 系統說明：側欄狀態示範（放在品牌紅底上） */
.nav-demo { display: flex; gap: 6px; background: var(--bk-red); padding: 8px; border-radius: 10px; }
.nav-demo a { margin: 0; cursor: pointer; }
.comp-row .seg { height: 38px; }

/* ── 側欄圖示：同一套線條圖示 ── */
.nav .ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── 操作區表單：輸入欄位與按鈕之間留出間距（避免焦點外框蓋住按鈕） ── */
#actions .formgrid ~ .actions-row, #actions .field ~ .actions-row { margin-top: 16px; }
#actions .field-error:empty { display: none; }

/* ── v3.8.5 手機版：底部分頁列（電腦版不受影響；只套用在真正的導覽 #nav，說明頁的示範元件不受影響） ──
   選項平均分配整條寬度、各自置中；已啟用：黃色膠囊底＋咖啡色圖示與文字 */
@media (max-width: 760px) {
  #nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; gap: 0; background: #fff; border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, .06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  #nav a, #nav a:hover {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    margin: 0; padding: 4px 2px; border-radius: 0; background: transparent; box-shadow: none;
    color: #6f6f6f; font-size: 11px; font-weight: 700;
  }
  #nav .ic { display: block; width: 48px; height: 28px; padding: 4px 14px; box-sizing: border-box; border-radius: 14px; }
  #nav a.active, #nav a.active:hover { background: transparent; box-shadow: none; color: var(--bk-brown); }
  #nav a.active .ic { background: var(--bk-yellow); }
  /* 為底部分頁列預留空間，最後一張卡片與版本號不會被蓋住 */
  body.signed-in { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
  body.signed-in .version { margin-bottom: 12px; }

  /* iPhone 日期欄位：取消系統預設的最小寬度，兩個日期剛好放進畫面 */
  .date-range input[type="date"] { -webkit-appearance: none; appearance: none; min-width: 0; width: 100%; display: block; text-align: left; line-height: 40px; }
  .date-range input[type="date"]::-webkit-date-and-time-value { text-align: left; }
}

/* ── v3.9 管理員後台：角色與權限、帳號管理 ── */
.adm-head { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.adm-head h2 { margin: 0; }
.adm-head p { margin: 4px 0 0; }
.adm-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.adm-tools input[type=search] { width: 230px; height: 38px; }
.adm-tools select { height: 38px; }
.adm-tools .check { margin: 0; }
.adm-table { width: 100%; border-collapse: collapse; }
.adm-table th { text-align: left; font-size: 13px; color: #5d5650; background: var(--cream); padding: 10px 12px; }
.adm-table td { padding: 12px; border-top: 1px solid #eee6df; vertical-align: middle; }
.adm-table .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 400; }
.adm-table .w-sw { width: 90px; }
.adm-table .w-act { width: 150px; }
.adm-table .acc { font-weight: 700; }
.adm-table .lockt { font-size: 11px; color: var(--muted); margin-left: 6px; }
.adm-actions { white-space: nowrap; }
.adm-actions .link-btn, .adm-table .link-btn { margin-right: 12px; }
.link-btn.danger { color: var(--danger); }
.link-btn.warn { color: #7a5200; }
.adm-table tr.deleted td { color: #9a9089; }
.adm-table tr.deleted .acc { text-decoration: line-through; }
.chip { display: inline-block; font-size: 12px; background: #f1ece6; color: #5d5650; border-radius: 99px; padding: 3px 10px; font-weight: 700; white-space: nowrap; }
.chip.pend { background: #fff4d6; color: #7a5200; }
.chip.gone { background: #ecebea; color: #77716b; }
/* 啟用開關：開＝綠色、旋鈕在右；關＝灰色、旋鈕在左 */
.sw { display: inline-block; position: relative; width: 44px; height: 24px; border-radius: 12px; background: #c9c2bb; cursor: pointer; transition: background .18s; vertical-align: middle; }
.sw i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .18s; }
.sw.on { background: #2e7d32; }
.sw.on i { left: 23px; }
.sw.lock { opacity: .45; cursor: not-allowed; }
/* 編輯視窗 */
.dialog.wide { max-width: 600px; max-height: calc(100vh - 36px); overflow: auto; }
.dialog .formgrid { margin-top: 12px; }
.dialog .hint { color: var(--muted); font-size: 13px; }
.perm-head { display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; flex-wrap: wrap; }
.tag { font-size: 12px; border-radius: 99px; padding: 2px 9px; font-weight: 700; background: #f1ece6; color: #5d5650; }
.tag.def { background: #e7f4ea; color: #1e6b34; }
.tag.cus { background: #fff4d6; color: #7a5200; }
.perm-group { border: 1px solid var(--line); border-radius: 10px; background: #fbf8f5; padding: 10px 14px; margin-bottom: 8px; }
.perm-group > b { display: block; margin-bottom: 8px; }
.perm-opts { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.perm-opt { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.perm-opt input { accent-color: var(--bk-brown); width: 16px; height: 16px; }
.xfer { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 10px 0; background: #fbf8f5; }
.xfer ul { margin: 6px 0 10px; padding-left: 20px; line-height: 1.7; }
/* 已刪除（離職）的人：名字加刪除線 */
.person-gone { color: #9a9089; }
.person-gone s { text-decoration: line-through; }
@media (max-width: 760px) {
  .adm-tools, .adm-tools input[type=search], .adm-tools select { width: 100%; }
  .adm-table .c-title { display: none; }
  .adm-table td, .adm-table th { padding: 10px 8px; }
  .adm-table .w-sw { width: 56px; }
  .adm-actions { white-space: normal; }
  .adm-actions .link-btn { display: inline-block; margin: 2px 10px 2px 0; }
}

/* ── v3.9.1 對齊 ──
   兩個表格的「啟用」「操作」欄固定寬度，上下切齊；權限選項用固定 4 欄格線，兩組上下對齊 */
.adm-table { table-layout: fixed; }
.adm-table .w-sw { width: 96px; }
.adm-table .w-act { width: 240px; }
.adm-table td { overflow-wrap: anywhere; }
.dialog.wide { max-width: 740px; }
.perm-opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; }
.perm-opt { align-items: flex-start; line-height: 1.4; }
.perm-opt input { margin: 2px 0 0; flex: none; }
@media (max-width: 760px) {
  .adm-table { table-layout: auto; }
  .adm-table .w-act { width: auto; }
  .adm-table .w-sw { width: 56px; }
  .perm-opts { grid-template-columns: 1fr 1fr; }
}

/* v3.9.2 重置完成：預設密碼放大顯示 */
.pw-show { display: flex; align-items: center; gap: 12px; margin: 12px 0; padding: 14px 16px; border: 1px dashed #d8cec3; border-radius: 10px; background: #fbf8f5; }
.pw-show code { flex: 1; font-family: Consolas, "Courier New", monospace; font-size: 26px; font-weight: 700; letter-spacing: 1px; color: var(--bk-brown); user-select: all; }
.pw-show .btn { min-width: 84px; }

/* v3.9.4 詳細頁資訊卡：改用格線排版（欄數同原本的平均分配），每一排高度相同（以最高的一格為準） */
.info-grid.balanced { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 10px; }

/* ── v3.9.6 現階段執行者；需求列表固定欄寬 ── */
.table-wrap.projects table.fixed { table-layout: fixed; width: 100%; }
.table-wrap.projects table.fixed td { overflow-wrap: anywhere; }
.table-wrap.projects table.fixed .name-cell .nm { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cur b { display: block; color: var(--bk-brown); }
.cur small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.m-cur { margin-top: 6px; font-size: 13px; color: var(--muted); }
.m-cur b { color: var(--bk-brown); }

/* 固定欄寬時：文字在格子內換行，不擠到隔壁欄；狀態標籤整顆換到下一行 */
.table-wrap.projects table.fixed td, .table-wrap.projects table.fixed td * { white-space: normal; }
.table-wrap.projects table.fixed .name-cell .nm { white-space: nowrap; }
.table-wrap.projects table.fixed .status, .table-wrap.projects table.fixed .tag-returned { display: inline-block; white-space: nowrap; margin: 2px 6px 2px 0; }
.table-wrap.projects table.fixed .nw, .nw { white-space: nowrap; }

/* ── v3.9.7 電腦版：Logo 與上方橫條同一條中心線 ──
   上方橫條加高到 80px；側欄品牌區同樣 80px、Logo 垂直置中，底部細線與橫條的下框線對齊 */
@media (min-width: 761px) {
  .topbar { height: 80px; }
  .sidebar { padding-top: 0; }
  .brand { height: 80px; box-sizing: border-box; margin: 0 -14px 14px; padding: 0 24px; border-bottom: 1px solid rgba(255, 255, 255, .2); }
}

/* v4.0 需求列表：移除「搜尋」按鈕（條件即時套用）；「清除」維持原本大小與位置（第 5 格的右半格） */
.f-actions #fclear { grid-column: 2; }

/* ── v4.0 桌面通知 ── */
.push-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.push-state { font-weight: 700; }
.push-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.push-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #fff8ee; border: 1px solid #f3c9a3; box-shadow: inset 4px 0 0 var(--bk-orange); border-radius: 12px; padding: 12px 16px; margin: 0 0 16px; }
.push-banner .pb-msg { flex: 1; min-width: 200px; }
.push-banner .btn { height: 38px; }
