/* =====================================================================
   原質娛樂系統 · 全站共用樣式（app.css）
   結構：1) Token（雙主題）  2) 基礎與共用元件  3) 側欄／底部導覽 layout
   主題：<html data-theme="warm">＝前台暖色、<html data-theme="pro">＝後台專業色
   各頁自己的 <style> 排在本檔之後，同名規則以頁內為準（頁面特有樣式照舊）。
   ===================================================================== */

/* ---------- 1) Token ---------- */
:root {
  --font: 'Noto Sans TC', system-ui, sans-serif;
  --radius-card: 16px;
  --radius-btn: 12px;
  --shadow-card: 0 2px 10px rgba(36, 34, 43, 0.06);
  --nav-w: 232px;
  --nav-w-slim: 64px;
  --bottomnav-h: 58px;

  /* 字級：只有這六級，不要再出現 11.5 / 12.8 / 14.5 這種零散尺寸
     12 提示、附註、狀態標籤、表頭 ｜ 13 欄位標籤、表格內容、次要按鈕
     14 輸入框、選項按鈕、內文、主要按鈕 ｜ 16 區塊標題、卡片標題、送出按鈕
     20 頁面標題、單一重點數字 ｜ 24 統計卡數字 */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 24px;

  /* 間距與控制項高度：所有輸入框、選項、按鈕都對齊同一個高度才不會參差 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --ctl-h: 42px;      /* 輸入框／選項／檔案按鈕的統一高度 */
  --field-gap: 18px;  /* 欄位之間的垂直間距 */
  --col-gap: 24px;    /* 表單兩欄之間的水平間距 */
}

/* 前台（暖色）：沿用原本全站的米白＋珊瑚橘 */
html[data-theme="warm"] {
  --bg: #FBF6EF;
  --surface: #fff;
  --ink: #24222B;
  --muted: #8A8578;
  --line: #ECE6DA;
  --line-soft: #F4EFE6;   /* 表格列分隔線 */
  --th-bg: #FBF9F4;       /* 表頭底色 */
  --row-hover: #FCFBF8;
  --accent: #FF6B4F;
  --accent-soft: #FFF1EC;
  --ok: #17B98C;
  --ok-soft: #EFFBF6;
  --warn: #C77700;
  --warn-soft: #FFF4E5;
  --danger: #E5484D;
  --danger-soft: #FDECEC;
}

/* 後台（專業）：白底灰階層次＋沉穩藍 accent，高資訊密度 */
html[data-theme="pro"] {
  --bg: #F4F5F7;
  --surface: #fff;
  --ink: #1B1F27;
  --muted: #6B7280;
  --line: #E2E5EA;
  --line-soft: #EEF0F3;
  --th-bg: #F8F9FB;
  --row-hover: #F6F8FB;
  --accent: #3056D3;
  --accent-soft: #EAEFFC;
  --ok: #0E9E77;
  --ok-soft: #E7F7F1;
  --warn: #B45309;
  --warn-soft: #FEF3E2;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --radius-card: 12px;
  --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.08);
}

/* ---------- 2) 基礎與共用元件 ---------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  font-family: var(--font);
  color: var(--ink);
}
input, select, textarea, button { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; font-size: var(--fs-sm); }

/* 卡片 */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* 頁首（後台頁通用：圖示＋標題＋副標） */
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.head-icon {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px;
}
.head h1 { font-size: 20px; font-weight: 900; line-height: 1.1; margin: 0; }
.head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 按鈕 */
.btn-primary {
  border: none; border-radius: var(--radius-btn); background: var(--accent); color: #fff;
  font-weight: 700; font-family: inherit; cursor: pointer;
}
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-mini {
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: 12px; font-weight: 700; padding: 6px 11px; cursor: pointer; white-space: nowrap; color: var(--ink);
}
.btn-mini.danger { color: var(--danger); border-color: #F3C6C8; }

/* 表單欄位 */
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; font-size: 15px; font-family: inherit; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-btn); background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }

/* 工具列／篩選列（後台通用） */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; margin-bottom: 14px; align-items: center; }
.toolbar a, .toolbar button, .toolbar label {
  font-size: 13px; font-weight: 700; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
}
.toolbar .btn-primary { border: none; background: var(--accent); color: #fff; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 14px; margin-bottom: 12px; }

/* 統計卡 */
.stats { display: grid; gap: 12px; }
.stat { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-card); padding: 14px 16px; }
.stat .label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.stat .amount { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* 表格 */
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 700; background: var(--th-bg); white-space: nowrap; }
tr:hover td { background: var(--row-hover); }
td.num, td.amt { text-align: right; font-variant-numeric: tabular-nums; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 44px; font-size: 13.5px; }

/* 分頁 */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px; }
.pager .info { font-size: 12.5px; color: var(--muted); }
.pager button { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 13px; font-weight: 700; padding: 7px 14px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }

/* Modal */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.modal-form { display: flex; flex-direction: column; gap: 4px; }
.modal-form label { font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 10px; }
.modal-form input, .modal-form select, .modal-form textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--ink);
}

/* 窄螢幕：表格轉卡片（每列一張卡，欄名靠 td 的 data-label 顯示） */
@media (max-width: 760px) {
  .table-card { overflow-x: visible; background: transparent; box-shadow: none; }
  .table-card table, .table-card tbody, .table-card tr, .table-card td { display: block; width: 100%; }
  .table-card thead { display: none; }
  .table-card tr { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-card); margin-bottom: 12px; padding: 6px 12px; }
  .table-card tr:hover td { background: transparent; }
  .table-card td {
    border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between;
    align-items: flex-start; gap: 14px; padding: 9px 2px; text-align: right;
  }
  .table-card td:last-child { border-bottom: none; }
  .table-card td::before {
    content: attr(data-label); font-size: 11.5px; font-weight: 700; color: var(--muted);
    text-align: left; flex-shrink: 0;
  }
  .table-card td.amt, .table-card td.num { text-align: right; }
  .table-card td.empty { justify-content: center; text-align: center; }
  .table-card .actions-cell { justify-content: flex-end; }
}

/* ---------- 2.5) 新系統（預算與請款）共用元件 ---------- */
/* 命名雖然叫「新系統」，但表單元件（.fld / .row2 / .chips / .notice / .seg / .my-app…）
   vendor-apply、yt-proposal、contract、invoice 等頁面也在用，所以元件規則一律不加 scope，
   全站共用同一套；只有「版面寬度」與「後台表格／統計卡／篩選列」的覆寫才綁在 .ns-wrap 底下
   （那些是 §2 既有元件的覆寫，加 scope 才不會動到舊報帳頁）。
   字級一律用 --fs-* 六級，控制項一律 --ctl-h 高，欄位間距一律 --field-gap，
   目的是讓每一排的左右邊界、上下節奏都落在同一條線上。 */

/* 版面：申請表單頁收在可讀寬度內置中；後台（.ns-wide）維持滿版好放表格 */
.ns-wrap { max-width: 1240px; margin: 0 auto; padding: 24px 26px 64px; }
.ns-wrap.ns-wide { max-width: none; margin: 0; }
@media (max-width: 900px) { .ns-wrap { padding: 16px 14px 40px; } }

/* 頁首 */
.ns-wrap .head { gap: var(--sp-3); margin-bottom: var(--sp-4); }
.ns-wrap .head h1 { font-size: var(--fs-xl); font-weight: 900; letter-spacing: -0.01em; }
.ns-wrap .head .sub { font-size: var(--fs-sm); line-height: 1.55; margin-top: 3px; }

/* 表單：寬螢幕排成兩欄。row2 也是「滿寬切兩半」，而且和外層用同一個 --col-gap，
   兩排欄位的分界線才會落在同一條垂直線上（原本外層 26px、row2 12px，差 7px）。 */
.ns-form {
  display: grid; grid-template-columns: 1fr;
  column-gap: var(--col-gap); row-gap: var(--field-gap); align-items: start;
}
/* 只有單行欄位（.fld）和成對欄位列（.row2）分欄，其他東西一律整排：
   說明條、切換鈕、額度盒、分段標題、QR、附件、送出鈕… */
.ns-form > *:not(.fld) { grid-column: 1 / -1; }
/* 多行輸入、點選式選項、內含表格的欄位也自己占一整排：
   前者高度和單行欄位差太多，後兩者橫向展開才不會被擠成三四排 */
.ns-form > .fld:has(textarea),
.ns-form > .fld:has(.chips),
.ns-form > .fld:has(table) { grid-column: 1 / -1; }
/* 包一層的欄位群組要讓子項直接參與網格，不然會被擠成一欄 */
.ns-form > .fld-group { display: contents; }
.ns-form > .notice { margin-bottom: 0; }
@media (min-width: 1100px) {
  .ns-form { grid-template-columns: 1fr 1fr; }
  .ns-form.one-col { grid-template-columns: 1fr; max-width: 860px; }
}

/* 分段標題 */
.sect { margin-top: var(--sp-6); }
.sect-title {
  font-size: var(--fs-lg); font-weight: 800; color: var(--ink);
  margin: 0 0 var(--sp-3); display: flex; align-items: center; gap: 10px;
}
.sect-title .no {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: var(--fs-sm); font-weight: 800;
}

/* 欄位：標籤 → 控制項 → 說明，三段固定節奏。
   .ns-form／.row2 裡的間距由網格 row-gap 決定；沒有用網格的頁面則靠 margin。 */
.fld { margin-bottom: var(--field-gap); min-width: 0; }
.ns-form > .fld, .row2 .fld { margin-bottom: 0; }
.fld > label {
  display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--ink);
  line-height: 1.4; margin-bottom: 6px;
}
.req { color: var(--danger); font-weight: 900; margin-left: 1px; }
.fld input[type=text], .fld input[type=number], .fld input[type=date],
.fld input[type=month], .fld input[type=search],
.fld textarea, .fld select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: var(--fs-md); font-family: inherit; line-height: 1.45;
}
/* 單行控制項固定同一個高度。特別是 input[type=date]：它自帶日曆按鈕，
   只給 min-height 會比旁邊的欄位高 2px，兩欄併排就對不齊。 */
.fld input[type=text], .fld input[type=number], .fld input[type=date],
.fld input[type=month], .fld input[type=search], .fld select { height: var(--ctl-h); }
.fld textarea { min-height: 96px; resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.fld input:disabled, .fld select:disabled { background: var(--bg); color: var(--muted); }
.hint { font-size: var(--fs-xs); line-height: 1.6; color: var(--muted); margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--field-gap) var(--col-gap); }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }

.notice {
  background: var(--warn-soft); border: 1px solid #F0D9A8; border-radius: 12px;
  padding: 14px 16px; font-size: var(--fs-sm); line-height: 1.8; color: var(--warn);
  margin-bottom: var(--sp-4);
}

/* 二選一切換（新預算／追加、內部／外部會議…） */
.seg { display: flex; gap: var(--sp-2); }
.seg label {
  flex: 1; min-height: 46px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; text-align: center;
  font-size: var(--fs-md); font-weight: 700; cursor: pointer; background: var(--surface);
}
.seg label.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg input { display: none; }

/* 額度盒（選定預算／零用金後顯示）：寬螢幕不要把標籤和數字拉到左右兩端，
   改成一格一個數字的小卡條 */
.budget-box {
  display: none; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3) var(--sp-5); background: var(--bg); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 14px 16px; margin: 0;
}
.budget-box.on { display: grid; }
.budget-box .line { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0; }
.budget-box .line > span:first-child { font-size: var(--fs-xs); color: var(--muted); }
.budget-box .line b { font-size: var(--fs-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.budget-box .left { font-size: var(--fs-xl); font-weight: 900; color: var(--ok); font-variant-numeric: tabular-nums; }
.budget-box .left.over { color: var(--danger); }

/* 發票 QR 掃描：改成靠左的一列，和其他欄位共用同一條左邊界 */
.qr-box { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--surface); }
.qr-head { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.qr-note { font-size: var(--fs-xs); line-height: 1.6; color: var(--muted); margin: -6px 0 12px; }
.qr-idle { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; text-align: left; }
.qr-ic {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: var(--ctl-h); height: var(--ctl-h); border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); font-size: var(--fs-xl); line-height: 1;
}
.qr-txt { flex: 1; min-width: 220px; }
.qr-t { font-size: var(--fs-md); font-weight: 800; }
.qr-s { font-size: var(--fs-xs); color: var(--muted); line-height: 1.6; margin-top: 2px; }
.qr-acts { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.qr-link, .qr-manual {
  display: inline-flex; align-items: center; height: var(--ctl-h); padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  font-size: var(--fs-sm); font-weight: 700; font-family: inherit; cursor: pointer; text-decoration: none;
}
.qr-link:hover, .qr-manual:hover { border-color: var(--accent); color: var(--accent); }
.qr-scanning { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.qr-scanning video { width: 100%; max-width: 380px; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: #000; }
.qr-scanning .qr-hint { font-size: var(--fs-sm); color: var(--muted); }
.qr-done-top { display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-3); }
.qr-done-top .btn-mini { margin-left: auto; }
.qr-chk {
  display: flex; align-items: center; gap: 8px; margin-top: var(--sp-3);
  font-size: var(--fs-sm); color: var(--ink); cursor: pointer;
}
.qr-chk input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.hint.err { color: var(--danger); font-weight: 700; }

/* 附件 */
.file-btns { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.file-btn {
  display: inline-flex; align-items: center; height: var(--ctl-h); padding: 0 16px;
  border: 1px dashed var(--line); border-radius: 10px; background: var(--surface);
  font-size: var(--fs-sm); font-weight: 700; cursor: pointer;
}
.file-btn:hover { border-color: var(--accent); color: var(--accent); }
.file-btn.cam { border-style: solid; }
.file-list { margin-top: var(--sp-2); display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm);
  background: var(--bg); border-radius: 10px; padding: 9px 12px;
}
.file-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .rm {
  border: none; background: none; color: var(--danger); font-weight: 900;
  cursor: pointer; font-size: var(--fs-lg); line-height: 1;
}

/* 狀態標籤：基底維持原樣（vendor-／yt-proposal- 等舊頁面也在用），新系統只調字級與內距 */
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.ns-wrap .pill { padding: 3px 10px; font-size: var(--fs-xs); font-weight: 700; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.approved { background: var(--ok-soft); color: var(--ok); }
.pill.rejected { background: var(--danger-soft); color: var(--danger); }
.pill.voided { background: #ECEEF2; color: #6B7280; }
.pill.paid { background: var(--accent-soft); color: var(--accent); }

/* 點選式選項（專案、費用類別…）：高度和輸入框一致，左右兩欄才對得起來 */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; min-height: var(--ctl-h); }
.chip {
  height: 38px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: var(--fs-md); font-weight: 600;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.chips-empty {
  display: inline-flex; align-items: center; height: var(--ctl-h); padding: 0 14px;
  border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: var(--fs-sm);
}

/* 申請單卡片 */
.my-app {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  margin-bottom: var(--sp-3); background: var(--surface);
}
.my-app .top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.my-app .nm { font-size: var(--fs-lg); font-weight: 800; }
.my-app .rev { font-size: var(--fs-xs); color: var(--muted); }
.my-app .meta { font-size: var(--fs-xs); line-height: 1.7; color: var(--muted); margin-top: 6px; }
.my-app .reason { font-size: var(--fs-sm); line-height: 1.7; color: var(--danger); margin-top: 6px; }
.my-app .note { font-size: var(--fs-sm); line-height: 1.7; color: var(--ok); margin-top: 6px; }
.my-app .settle-cta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px dashed var(--line);
  font-size: var(--fs-sm);
}
.my-app .settle-cta .btn-primary { min-height: 36px; padding: 0 16px; font-size: var(--fs-sm); }
.my-app .settle-cta > a { margin-left: auto; }

/* 異動軌跡：申請單卡片與後台列表共用 */
.lg-act { margin-top: var(--sp-2); }
.ns-log-box { margin-top: var(--sp-2); }
.ns-log { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.ns-log > li { position: relative; padding: 0 0 var(--sp-3) var(--sp-3); }
.ns-log > li:last-child { padding-bottom: 0; }
.ns-log > li::before {
  content: ''; position: absolute; left: -5px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
.ns-log .lg-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: var(--fs-sm); }
.ns-log .lg-top .who { color: var(--ink); }
.ns-log .lg-top .when { color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.ns-log .lg-note { font-size: var(--fs-xs); color: var(--muted); line-height: 1.7; margin-top: 2px; }
.ns-log .lg-chg { list-style: none; margin: 4px 0 0; padding: 0; font-size: var(--fs-xs); line-height: 1.9; }
.ns-log .lg-chg .f { color: var(--muted); margin-right: 6px; }
.ns-log .lg-chg .b { color: var(--muted); text-decoration: line-through; }
.ns-log .lg-chg .a { color: var(--ink); font-weight: 700; }

/* 專案預算使用進度 */
.prj {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  margin-bottom: var(--sp-3); background: var(--surface);
}
.prj-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.prj-name { font-size: var(--fs-lg); font-weight: 800; }
.prj-cnt { font-size: var(--fs-xs); color: var(--muted); }
.prj-left { margin-left: auto; font-size: var(--fs-xl); font-weight: 900; color: var(--ok); font-variant-numeric: tabular-nums; }
.prj-left.hot { color: var(--danger); }
.prj-bar { display: flex; height: 8px; border-radius: 5px; background: var(--line-soft); overflow: hidden; margin: 10px 0 8px; }
.prj-bar > i { display: block; height: 100%; }
.prj-bar > i.used { background: var(--ok); }
.prj-bar > i.used.hot { background: var(--danger); }
.prj-bar > i.pend { background: var(--warn); opacity: .55; }
.prj-meta { font-size: var(--fs-xs); line-height: 1.7; color: var(--muted); }
.prj-meta .pend-txt { color: var(--warn); font-weight: 700; }
.prj-sub { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: var(--sp-2); display: flex; flex-direction: column; gap: 6px; }
.prj-row { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-sm); }
.prj-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prj-row .addon { color: var(--accent); font-weight: 700; margin-left: 6px; }
.prj-row .st { color: var(--muted); font-size: var(--fs-xs); }
.prj-row .rt { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 560px) { .prj-row { flex-wrap: wrap; gap: 4px 8px; } }

/* 按鈕 */
.ns-wrap .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--ctl-h); padding: 0 20px; font-size: var(--fs-md); font-weight: 700;
}
.ns-wrap .btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.ns-wrap .btn-block { width: 100%; min-height: 50px; font-size: var(--fs-lg); font-weight: 800; }
.ns-wrap .btn-mini { font-size: var(--fs-sm); font-weight: 700; padding: 7px 12px; border-radius: 9px; }
.ns-wrap .btn-mini:hover { border-color: var(--accent); color: var(--accent); }
.ns-wrap .btn-mini.danger:hover { border-color: var(--danger); color: var(--danger); }

/* 提示條 */
.banner { padding: 12px 16px; border-radius: 11px; font-size: var(--fs-md); font-weight: 700; margin-bottom: var(--sp-4); display: none; }
.banner.ok { background: var(--ok-soft); color: var(--ok); display: block; }
.form-err { color: var(--danger); font-size: var(--fs-sm); font-weight: 700; line-height: 1.7; display: none; }

/* 後台：統計卡、篩選列、表格 */
.ns-wrap .stats { gap: var(--sp-3); }
.ns-wrap .stat { border-radius: 12px; padding: 14px 16px; }
.ns-wrap .stat .label { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
.ns-wrap .stat .amount { font-size: var(--fs-2xl); font-weight: 900; margin-top: 4px; letter-spacing: -0.02em; }
.ns-wrap .filters { gap: var(--sp-3); padding: 14px 16px; align-items: end; }
.ns-wrap .filters .fld > label { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
/* 篩選列是高密度區，控制項用 36px 這一個較矮的高度，但全列一致 */
.ns-wrap .flt { display: flex; flex-direction: column; gap: 4px; min-width: 122px; }
.ns-wrap .flt > span { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
.ns-wrap .filters select, .ns-wrap .filters input, .ns-wrap .filters .btn-mini { min-height: 36px; }
.ns-wrap .filters .cnt { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); }
.ns-wrap .toolbar a, .ns-wrap .toolbar button, .ns-wrap .toolbar label { font-size: var(--fs-sm); }
.ns-wrap table { font-size: var(--fs-sm); }
.ns-wrap th, .ns-wrap td { padding: 11px 12px; }
.ns-wrap th { font-size: var(--fs-xs); font-weight: 700; }
.ns-wrap .mono { font-size: var(--fs-sm); }
.ns-wrap .empty { font-size: var(--fs-md); padding: 48px 20px; }
.ns-wrap .pager { gap: var(--sp-4); }
.ns-wrap .pager .info, .ns-wrap .pager button { font-size: var(--fs-sm); }
@media (max-width: 760px) { .ns-wrap .table-card td::before { font-size: var(--fs-xs); } }

/* 月結鎖定格／零用金設定 */
.lock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2); }
.lock-cell {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start; font-size: var(--fs-xs);
}
.lock-cell.locked { background: var(--bg); }
.lock-cell b { font-size: var(--fs-md); }
.set-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-2); }
.set-row {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--ctl-h);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: var(--fs-md); cursor: pointer;
}
.set-row.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.pu-box { display: flex; gap: 6px; flex-wrap: wrap; max-width: 520px; }
.pu {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; background: var(--surface);
}
.pu.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pu input { margin: 0; }

/* 登入提醒視窗（一天跳一次）：掛在 body 上，不在 .ns-wrap 內 */
.ns-notice {
  position: fixed; inset: 0; z-index: 130; background: rgba(16, 20, 30, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ns-notice-panel {
  background: var(--surface); border-radius: 16px; box-shadow: 0 18px 50px rgba(16, 24, 40, .3);
  width: min(400px, 100%); padding: 8px 8px 12px;
}
.ns-notice-head { display: flex; align-items: center; padding: 12px 12px 10px; }
.ns-notice-head b { flex: 1; font-size: var(--fs-lg); }
.ns-notice-x { border: none; background: none; font-size: var(--fs-xl); line-height: 1; color: var(--muted); cursor: pointer; }
.ns-notice-row {
  display: block; padding: 12px 14px; border-radius: 12px; margin-bottom: 6px;
  background: var(--bg); color: var(--ink);
}
.ns-notice-row:hover { background: var(--accent-soft); }
.ns-notice-row.warn { background: var(--warn-soft); }
.ns-notice-row.danger { background: var(--danger-soft); }
.ns-notice-row .t { display: block; font-size: var(--fs-md); font-weight: 800; }
.ns-notice-row .d { display: block; font-size: var(--fs-xs); line-height: 1.6; color: var(--muted); margin-top: 3px; }
.ns-notice-later {
  width: 100%; margin-top: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); font-family: inherit; font-size: var(--fs-md); font-weight: 700; cursor: pointer;
}

/* 側欄的子功能選單（點「請款」「預算」跳出來的面板） */
.nav-menu {
  position: fixed; inset: 0; z-index: 120; background: rgba(16, 20, 30, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.nav-menu-panel {
  background: var(--surface); border-radius: 16px; box-shadow: 0 18px 50px rgba(16, 24, 40, .28);
  width: min(420px, 100%); max-height: 80vh; overflow-y: auto; padding: 8px;
}
.nav-menu-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px; }
.nav-menu-head b { font-size: var(--fs-md); flex: 1; }
.nav-menu-ic { display: flex; width: 22px; height: 22px; }
.nav-menu-ic svg { width: 20px; height: 20px; }
.nav-menu-x {
  border: none; background: none; font-size: var(--fs-2xl); line-height: 1; color: var(--muted);
  cursor: pointer; padding: 0 4px;
}
.nav-menu-item {
  display: block; padding: 12px 14px; border-radius: 12px; color: var(--ink); margin-bottom: 4px;
}
.nav-menu-item:hover { background: var(--bg); }
.nav-menu-item.active { background: var(--accent-soft); }
.nav-menu-item .t { display: block; font-size: var(--fs-md); font-weight: 800; }
.nav-menu-item .d { display: block; font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

/* ---------- 3) 側欄／底部導覽 layout（由 nav.js 注入元素） ---------- */
.app-sidebar, .app-bottomnav, .app-sheet { display: none; }

/* 待辦數字徽章（側欄／手機底部導覽共用） */
.sb-badge, .bn-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: var(--fs-xs); font-weight: 800; line-height: 1; flex-shrink: 0;
}
.bn-badge { position: absolute; top: 4px; left: 50%; margin-left: 4px; }

/* 桌機：左側欄推開內容 */
@media (min-width: 900px) {
  body.has-nav { padding-left: var(--nav-w); }
  body.has-nav.nav-slim { padding-left: var(--nav-w-slim); }

  .app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--nav-w); z-index: 90;
    display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .nav-slim .app-sidebar { width: var(--nav-w-slim); }

  .sb-brand { display: flex; align-items: center; gap: 10px; padding: 16px 14px 12px; color: var(--ink); }
  .sb-brand img { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); object-fit: cover; flex-shrink: 0; }
  .sb-brand-name { font-size: var(--fs-md); font-weight: 800; white-space: nowrap; }

  .sb-groups { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
  .sb-group-label {
    display: flex; align-items: center; gap: 5px; width: 100%; box-sizing: border-box;
    font-size: var(--fs-xs); font-weight: 700; color: var(--muted); padding: 14px 8px 5px; white-space: nowrap;
    background: none; border: none; font-family: inherit; text-align: left; cursor: pointer;
  }
  .sb-group-label:hover { color: var(--ink); }
  /* 收合箭頭：展開朝下，收合朝右 */
  .sb-group-label .sb-caret { width: 9px; height: 9px; flex-shrink: 0; transition: transform .18s; opacity: .75; }
  .sb-group.collapsed .sb-group-label .sb-caret { transform: rotate(-90deg); }
  .sb-group.collapsed .sb-item { display: none; }
  .sb-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 10px;
    font-size: var(--fs-sm); font-weight: 700; color: var(--ink); margin-bottom: 2px;
  }
  .sb-item:hover { background: var(--bg); }
  button.sb-item { width: 100%; border: none; background: none; font-family: inherit; text-align: left; cursor: pointer; }
  .sb-more { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }
  .nav-slim .sb-more { display: none; }
  .sb-item.active { background: var(--accent-soft); color: var(--accent); }
  .sb-ico { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; flex-shrink: 0; }
  .sb-ico svg { width: 19px; height: 19px; }
  .sb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* 待辦數字（新系統：總監看待審、申請人看被退回） */
  .nav-slim .sb-item { position: relative; }
  .nav-slim .sb-badge { position: absolute; top: 3px; right: 6px; }

  .sb-foot { border-top: 1px solid var(--line); padding: 10px; }
  .sb-user { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; min-width: 0; }
  .sb-user b { font-size: var(--fs-sm); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sb-role {
    font-size: var(--fs-xs); font-weight: 700; color: var(--accent); background: var(--accent-soft);
    border-radius: 7px; padding: 2px 7px; flex-shrink: 0;
  }
  .sb-foot-btns { display: flex; gap: 6px; }
  .sb-logout {
    flex: 1; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); background: var(--surface);
    border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; cursor: pointer;
  }
  .sb-collapse {
    width: 34px; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); background: var(--surface);
    border: 1px solid var(--line); border-radius: 9px; cursor: pointer; flex-shrink: 0;
  }
  /* 收合（icon-only）狀態 */
  .nav-slim .sb-brand { justify-content: center; padding-left: 8px; padding-right: 8px; }
  .nav-slim .sb-brand-name, .nav-slim .sb-group-label, .nav-slim .sb-label, .nav-slim .sb-user { display: none; }
  .nav-slim .sb-groups { padding-left: 8px; padding-right: 8px; }
  /* icon-only 模式看不到群組標題，就沒有東西可以展開，一律全開 */
  .nav-slim .sb-group.collapsed .sb-item { display: flex; }
  .nav-slim .sb-item { justify-content: center; padding: 9px 0; }
  .nav-slim .sb-foot-btns { flex-direction: column; }
  .nav-slim .sb-collapse { width: 100%; }
  .nav-slim .sb-logout { padding: 7px 4px; font-size: var(--fs-xs); }
}

/* 手機：底部導覽＋「更多」面板 */
@media (max-width: 899px) {
  body.has-nav { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }

  .app-bottomnav {
    position: fixed; inset: auto 0 0 0; z-index: 90;
    display: flex; align-items: stretch;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bn-item {
    position: relative;
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: var(--fs-xs); font-weight: 700; color: var(--muted);
    background: none; border: none; cursor: pointer; padding: 0; min-width: 0;
  }
  .bn-item span.bn-txt { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
  .bn-item svg { width: 21px; height: 21px; }
  .bn-item.active { color: var(--accent); }

  .app-sheet { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, .45); }
  .app-sheet.open { display: block; }
  .sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-radius: 18px 18px 0 0;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    max-height: 70vh; overflow-y: auto;
  }
  .sheet-title { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); padding: 8px 6px 6px; }
  .sheet-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 8px; border-radius: 12px;
    font-size: var(--fs-md); font-weight: 700; color: var(--ink);
  }
  .sheet-item.active { background: var(--accent-soft); color: var(--accent); }
  .sheet-item svg { width: 20px; height: 20px; flex-shrink: 0; }
  .sheet-user { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
  .sheet-user b { font-size: var(--fs-md); }
  .sheet-logout {
    width: 100%; margin-top: 10px; font-size: var(--fs-md); font-weight: 700; color: var(--danger);
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer;
  }
}
