/* ============================================================
   團隊後台的視覺：照 2018 年《Skills for U 視覺識別系統》
   - 標準色：深藍 PANTONE 7693、嫩黃綠 PANTONE 388、藍綠 PANTONE 319
     （色碼取自手冊裡的向量圖：#2B4B7A／#C7DF30／#52C5C3）
   - 字體：思源黑體（Noto Sans TC，手冊指定的輔助打字體；主要打字體思源柔黑體沒有網路字型）
   - 標誌、輔助圖形（二）的波浪：index.html 最上面的 sfu-sprite；
     頁尾的輔助圖形（一）＋精神標語「用技能與社會對話」：brand-slogan.svg
   - 版面語彙（取自手冊的頁首和目錄）：頁面標題下一條深藍細線、區塊標題前一個嫩黃綠方塊
   ============================================================ */
:root {
  --navy: #2B4B7A;          /* 標準色：深藍 */
  --navy-dark: #1F3962;     /* 深藍再深一階：萊姆綠按鈕上的字、hover */
  --navy-tint: #E6EBF3;     /* 深藍的淺底：徽章、hover */
  --lime: #C7DF30;          /* 標準色：嫩黃綠 */
  --lime-dark: #B3CA22;
  --lime-soft: #EDF4C6;     /* 手冊色票的嫩黃綠淺色 */
  --lime-ink: #4A5A00;      /* 嫩黃綠底上的字（對比 6:1 以上） */
  --teal: #52C5C3;          /* 標準色：藍綠 */
  --teal-soft: #DDF3F1;
  --teal-ink: #17706D;      /* 藍綠系的字、達標的進度條（白底 5.9:1） */
  --page-bg: #F1F4F9;
  --card-bg: #ffffff;
  --surface-soft: #F5F7FB;  /* 卡片裡的淺色區塊 */
  --dropzone-bg: #F1FAF9;
  --dropzone-border: #9FD8D4;
  --text-main: #1F2B3D;
  --text-muted: #566377;    /* 白底 6:1；次要文字不要再更淺 */
  --border-light: #DCE2EB;
  --border-soft: #E8ECF3;
  --shadow-sm: 0 1px 2px rgba(31,57,98,0.06), 0 3px 10px rgba(31,57,98,0.05);
  --shadow: 0 1px 3px rgba(31,57,98,0.07), 0 10px 28px rgba(31,57,98,0.07);
  --danger: #d0483f;
  --danger-bg: #fbeceb;
  --success: var(--teal-ink);   /* 完成、已付款：用標準色藍綠（深一階的字色） */
  --success-bg: var(--teal-soft);
  --warn: #b8860b;
  --warn-bg: #fdf6e3;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Heiti TC", "Microsoft JhengHei", -apple-system, system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

/* 頁首、內容、頁尾上下排：內容不夠長時頁尾也貼在畫面最下面 */
body {
  background: var(--page-bg);
  font-family: var(--font);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
::selection { background: var(--lime-soft); color: var(--navy-dark); }
.sfu-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- topbar ---------- */
/* 主選單固定在畫面最上面，往下捲也看得到（app.js 會量高度寫進 --topbar-h，給捲動定位用） */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 100;
  box-shadow: 0 2px 16px rgba(24,45,78,0.25);
}
/* 用 # 連結或程式把東西捲到最上面時，讓出主選單的高度，不會被蓋住 */
html { scroll-padding-top: calc(var(--topbar-h, 72px) + 12px); }
.topbar-inner {
  max-width: 1120px; /* 主選單有六個分頁，跟寬版頁面同寬 */
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 14px; }
/* 組織標誌：橫式標誌＋標準字，深藍底上用嫩黃綠（VI 手冊「標準色綠標誌藍背景色使用」） */
.brand-logo { display: block; height: 30px; width: auto; flex: none; color: var(--lime); fill: currentColor; }
.brand-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.35); flex: none; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.12em; white-space: nowrap; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.8);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 9px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.tab-btn.active { background: var(--lime); color: var(--navy-dark); }
.tab-btn:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
.tab-ext { margin-left: 3px; font-size: 12px; opacity: 0.8; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- 子分頁（認識組織的四頁；影響力成效的團隊目標／計畫與預算；核銷作業的上傳單據／上傳紀錄／財務作業）----------
   白底的分段選單：一格一頁、圖示＋字，選到的那格深藍底、圖示嫩黃綠；寬螢幕平均分，窄螢幕自動換行 */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 720px;
  margin: 0 auto 26px;
  padding: 6px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.app-main-wide .subtabs { max-width: none; }
.subtab-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 8px 18px;
  border-radius: 13px;
  color: var(--navy);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.subtab-ic {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.subtab-btn:hover { background: var(--navy-tint); }
.subtab-btn.active { background: var(--navy); color: #fff; box-shadow: 0 2px 8px rgba(31,57,98,0.25); }
.subtab-btn.active .subtab-ic { color: var(--lime); }
.subtab-btn:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
@media (max-width: 560px) {
  .subtabs { gap: 4px; padding: 4px; margin-bottom: 18px; border-radius: 15px; }
  .subtab-btn { min-height: 48px; padding: 6px 10px; gap: 6px; font-size: 15px; border-radius: 11px; letter-spacing: 0.02em; }
  .subtab-ic { width: 19px; height: 19px; }
}

/* ---------- 頁內的分段選項（期間、負責人、中心、我的單據／全部同仁、財務作業的子頁）----------
   跟上面的子分頁同一套：白底一整條、選到的那格深藍底；比子分頁矮一點，看得出是頁面裡的選項 */
.seg-field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.seg-label { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; color: var(--text-muted); white-space: nowrap; }
.seg, .pt-filter, .scope-toggle, .fo-subnav, .fo-filters, .report-subnav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.card .seg, .card .scope-toggle, .fo-card .fo-filters { background: var(--surface-soft); box-shadow: inset 0 0 0 1px var(--border-soft); }   /* 卡片裡面：淺灰底 */
.seg-opt, .pt-fchip, .scope-btn, .fo-pill, .fo-filter, .report-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--navy);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-opt:hover, .pt-fchip:hover, .scope-btn:hover, .fo-pill:hover, .fo-filter:hover, .report-pill:hover { background: var(--navy-tint); }
.seg-opt[aria-pressed="true"], .pt-fchip[aria-pressed="true"], .scope-btn.active, .fo-pill.is-active, .fo-filter.is-on, .report-pill.is-active {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 1px 4px rgba(31,57,98,0.22);
}
.seg-opt:focus-visible, .pt-fchip:focus-visible, .scope-btn:focus-visible, .report-pill:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
/* 單據報帳底下的上傳單據／上傳紀錄：跟財務作業的子頁同一個樣子（字粗一點） */
.report-subnav { margin-bottom: 20px; }
.report-pill { font-weight: 800; }
.report-pill.is-active:hover { background: var(--navy); }
@media (max-width: 560px) {   /* 手機：選項撐滿整列，換行時不會參差不齊 */
  .seg, .pt-filter, .scope-toggle, .fo-subnav, .fo-filters, .report-subnav { display: flex; }
  .seg-opt, .pt-fchip, .scope-btn, .fo-pill, .fo-filter, .report-pill { flex: 1 1 auto; padding: 0 12px; }
  .seg-field { flex-direction: column; align-items: stretch; gap: 6px; }
}

/* ---------- 頁首：標題＋一條深藍細線（VI 手冊每一頁的頁首）、區塊標題前的嫩黃綠方塊（手冊目錄） ---------- */
.page-rule { border-bottom: 1px solid var(--navy); }
.lime-mark::before {
  content: "";
  display: inline-block;
  flex: none;
  width: 8px;
  height: 1.05em;
  margin-right: 10px;
  border-radius: 2px;
  background: var(--lime);
  vertical-align: -0.14em;
}

/* ---------- layout ---------- */
.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 26px 24px 64px;
}
.view[hidden] { display: none; }
.app-main.app-main-wide { max-width: 1120px; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 28px 32px;
  margin-bottom: 20px;
}

.card-title { font-size: 26px; font-weight: 900; color: var(--navy); margin-bottom: 6px; letter-spacing: 0.03em; }
.card-title-sm { font-size: 20px; font-weight: 800; color: var(--navy); margin-bottom: 4px; letter-spacing: 0.02em; }
.card-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }

/* ---------- 頁尾：輔助圖形（一）的無限線＋精神標語「用技能與社會對話」（VI 手冊輔助圖形一的應用範例） ---------- */
.site-foot { flex: none; background: var(--navy); color: rgba(255,255,255,0.8); }
.site-foot-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}
.site-foot-slogan { display: block; height: 72px; width: auto; max-width: 100%; flex: none; }   /* 線的上下兩端接到頁尾邊緣，所以頁尾不要有上下留白 */
.site-foot-org { font-size: 13px; font-weight: 500; letter-spacing: 0.08em; line-height: 1.6; text-align: right; }
.site-foot-org b { display: block; font-weight: 700; color: #fff; letter-spacing: 0.04em; }

/* ---------- form fields ---------- */
.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 16px;
}
.field-label:first-of-type { margin-top: 0; }
.req { color: var(--danger); }
.field-flag { font-weight: 600; }

.select-input, .text-input, .textarea-input {
  width: 100%;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  background: #fff;
  appearance: none;
  transition: border-color 0.15s;
}
.select-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%232b4b7a' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}
.text-input::placeholder, .textarea-input::placeholder { color: var(--text-muted); font-weight: 400; }
.select-input:focus, .text-input:focus, .textarea-input:focus {
  outline: none;
  border-color: var(--navy);
}
.textarea-input { resize: vertical; font-weight: 400; }
.text-input[readonly] { background: #F5F7FB; color: var(--text-muted); font-weight: 600; }

.select-input-sm { font-size: 13px; padding: 9px 32px 9px 12px; font-weight: 600; width: auto; min-width: 140px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-field.span-2 { grid-column: 1 / -1; }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- dropzone ---------- */
.dropzone {
  margin-top: 22px;
  border: 3px dashed var(--dropzone-border);
  background: var(--dropzone-bg);
  border-radius: var(--radius-lg);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  padding: 24px;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--lime-dark); background: #E4F5F3; }
.dropzone-inner { text-align: center; }
.plus-circle {
  width: 68px; height: 68px;
  background: var(--lime);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  font-size: 30px;
  font-weight: 700;
  color: var(--navy);
}
.dz-title { font-weight: 800; font-size: 18px; color: var(--navy); margin-bottom: 6px; }
.dz-sub { color: var(--text-muted); font-size: 13px; }

.dz-preview { text-align: center; width: 100%; }
.dz-preview img {
  max-width: 100%; max-height: 220px;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 10px rgba(31,57,98,0.15);
  object-fit: contain;
  margin-bottom: 10px;
}
.dz-filename { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; word-break: break-all; }
.link-btn {
  background: none; border: none;
  color: var(--navy);
  font-family: inherit; font-weight: 700; font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- buttons ---------- */
.primary-btn {
  width: 100%;
  margin-top: 22px;
  background: var(--lime);
  color: var(--navy-dark);
  border: none;
  border-radius: var(--radius-md);
  padding: 17px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.primary-btn:hover:not(:disabled) { background: var(--lime-dark); }
.primary-btn:active:not(:disabled) { transform: scale(0.99); }
.primary-btn:disabled {
  background: #D3DAE5;
  color: #8E99AB;
  cursor: not-allowed;
}

.ghost-btn {
  background: #fff;
  border: 1.5px solid var(--border-light);
  color: var(--navy);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--navy); }
.ghost-btn-sm { padding: 9px 14px; font-size: 13px; border-radius: var(--radius-sm); }
.ghost-btn-danger { color: var(--danger); }
.ghost-btn-danger:hover { border-color: var(--danger); background: var(--danger-bg); }

.btn-row { display: flex; gap: 12px; margin-top: 24px; }
.btn-row .ghost-btn { flex: 1; }
.btn-row .primary-btn { flex: 2; margin-top: 0; }

/* ---------- ocr progress ---------- */
.ocr-progress { margin-top: 18px; }
.ocr-progress-bar {
  height: 8px;
  background: #E4E9F1;
  border-radius: 999px;
  overflow: hidden;
}
.ocr-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--lime);
  transition: width 0.2s;
}
.ocr-progress-label { font-size: 13px; color: var(--text-muted); margin-top: 8px; text-align: center; font-weight: 600; }

/* ---------- confidence banner ---------- */
.confidence-banner {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 18px;
}
.confidence-banner.high { background: var(--success-bg); color: var(--success); }
.confidence-banner.mid { background: var(--warn-bg); color: var(--warn); }
.confidence-banner.low { background: var(--danger-bg); color: var(--danger); }

.field-flag.ok { color: var(--success); }
.field-flag.low::after { content: "⚠ 請確認"; color: var(--warn); font-size: 12px; }

.raw-ocr-toggle { margin-top: 20px; }
.raw-ocr-toggle summary {
  cursor: pointer; font-size: 13px; color: var(--text-muted); font-weight: 600;
}

.field-label input[type="checkbox"] {
  width: 16px; height: 16px;
  margin-right: 8px;
  vertical-align: middle;
  accent-color: var(--navy);
}

.sync-help {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.7;
}
.sync-help ol { padding-left: 20px; margin-bottom: 12px; }
.sync-help li { margin-bottom: 6px; }
.sync-help code {
  background: #EFF2F7;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
}
.sync-help p { color: var(--warn); font-weight: 600; }

.cloud-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.cloud-badge.synced { background: var(--success-bg); color: var(--success); }
.cloud-badge.unsynced { background: var(--warn-bg); color: var(--warn); }

.field-hint {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.field-hint-example {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--input-bg, rgba(127,127,127,0.08));
  border: 1px dashed var(--border, rgba(127,127,127,0.35));
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-line;
}
.field-hint-example strong {
  color: var(--text-main);
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 10px;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--navy);
}

/* ---------------- 緊急/一般 切換 ---------------- */
.segmented {
  display: flex;
  gap: 8px;
}
.seg-btn {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border-light);
  background: #fff;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.seg-btn:hover { border-color: var(--navy); }
.seg-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.seg-btn-urgent.active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.paid-badge {
  display: inline-block;
  background: var(--success-bg);
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.urgent-badge {
  display: inline-block;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------------- 名單設定 ---------------- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  min-height: 20px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #EFF2F7;
  border: 1.5px solid var(--border-light);
  border-radius: 999px;
  padding: 7px 8px 7px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}
.tag-chip button {
  background: #DCE2EB;
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.tag-chip button:hover { background: var(--danger); color: #fff; }
.tag-list-empty { color: var(--text-muted); font-size: 13px; padding: 6px 0; }

.add-item-row { display: flex; gap: 10px; }
.add-item-row .text-input { flex: 1; }
.add-item-row .ghost-btn { flex-shrink: 0; }

.list-hint { margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.raw-ocr-pre {
  margin-top: 10px;
  background: #F5F7FB;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: #444F63;
  max-height: 200px;
  overflow-y: auto;
}

/* ---------- record list ---------- */
.filter-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }

.record-list { display: flex; flex-direction: column; gap: 12px; }
.record-item {
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.record-item:hover { border-color: var(--navy); box-shadow: 0 2px 10px rgba(31,57,98,0.08); }
.record-main { min-width: 0; }
.record-title { font-weight: 800; color: var(--navy); font-size: 15px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-meta { font-size: 12.5px; color: var(--text-muted); }
.record-meta span + span::before { content: "・"; margin: 0 2px; }
.record-amount { font-weight: 800; color: var(--navy); font-size: 16px; white-space: nowrap; }

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-badge.pending { background: var(--warn-bg); color: var(--warn); }
.status-badge.approved { background: var(--success-bg); color: var(--success); }
.status-badge.rejected { background: var(--danger-bg); color: var(--danger); }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 14px; }

.stat-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.stat-pill { padding: 10px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; }
.stat-pill span { font-size: 18px; margin-right: 4px; }
.stat-pending { background: var(--warn-bg); color: var(--warn); }
.stat-approved { background: var(--success-bg); color: var(--success); }
.stat-rejected { background: var(--danger-bg); color: var(--danger); }

/* ---------- 彈出視窗（單據明細、補上發票）：照 2018 VI ----------
   跟各頁一樣：標題下一條深藍細線、區塊標題前一個嫩黃綠方塊；完成的狀態用藍綠 */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(31,57,98,0.55);   /* 深藍的半透明 */
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px));
  overflow-y: auto;
  z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  padding: 28px 30px 26px;
  position: relative;
  box-shadow: 0 18px 50px rgba(20,34,58,0.28);
}
.modal-close {
  position: absolute; top: 18px; right: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  background: #fff; border: 1.5px solid var(--border-light); border-radius: 50%;
  color: var(--navy); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.modal-close:hover { background: var(--navy-tint); border-color: var(--navy); }
.modal-close:focus-visible, .modal-card :focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

.detail-img { display: block; width: 100%; max-height: 260px; object-fit: contain; border-radius: var(--radius-md); background: var(--surface-soft); margin-bottom: 14px; }
.detail-title { font-size: 22px; font-weight: 900; line-height: 1.35; letter-spacing: 0.02em; color: var(--navy); margin-bottom: 4px; padding-right: 56px; overflow-wrap: anywhere; }
.detail-sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 18px; }

/* 單據明細：上面是這張單據（店家、用途、金額、狀態、進度），下面分「付款」「審核」「單據」 */
.dm-head { padding-bottom: 18px; border-bottom: 1px solid var(--navy); }
.dm-purpose { font-size: 15px; line-height: 1.6; color: #36435A; padding-right: 56px; overflow-wrap: anywhere; }
.dm-sum { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 14px; }
.dm-amount { display: flex; align-items: baseline; gap: 6px; font-size: 32px; font-weight: 900; line-height: 1.1; color: var(--navy); font-variant-numeric: tabular-nums; }
.dm-amount-label { align-self: center; margin-right: 4px; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.dm-cur { font-size: 16px; font-weight: 800; }
.dm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dm-chips .status-badge, .dm-chips .urgent-badge { padding: 5px 12px; font-size: 13px; }
.dm-chip-ok, .dm-state { display: inline-flex; align-items: center; gap: 4px; }
.dm-quote-total { margin-top: 6px; font-size: 13.5px; color: var(--text-muted); }
.dm-head .progress-steps { margin-top: 18px; }
.dm-sec { padding-top: 20px; }
.dm-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 15px; font-weight: 800; letter-spacing: 0.04em; color: var(--navy); }
.dm-h::before { content: ""; flex: none; width: 6px; height: 16px; border-radius: 2px; background: var(--lime); }
.dm-grid { display: grid; grid-template-columns: 7.4em minmax(0, 1fr); gap: 8px 14px; font-size: 14.5px; line-height: 1.6; }
.dm-grid dt { padding-top: 1px; font-size: 13.5px; font-weight: 700; color: var(--text-muted); }
.dm-grid dd { min-width: 0; font-weight: 500; color: var(--text-main); overflow-wrap: anywhere; }
.dm-ic { width: 16px; height: 16px; flex: none; }
.dm-ok { font-weight: 700; color: var(--teal-ink); }
.dm-warn { align-items: flex-start; font-weight: 700; color: #8a5a00; }
.dm-warn .dm-ic { margin-top: 4px; }
.dm-file-name { font-size: 13.5px; color: var(--text-muted); }
.dm-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border-soft); }
.dm-actions[hidden] { display: none; }
.dm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 1 1 220px; width: auto; min-height: 48px; margin-top: 0; padding: 12px 18px; font-size: 15px; text-decoration: none; }
.dm-ext { font-size: 12px; }
.dm-cloud { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; }
.modal-card .record-note { margin-top: 16px; }
@media (max-width: 560px) {
  .modal-overlay { padding-top: 16px; padding-bottom: 16px; }
  .modal-card { padding: 22px 18px 20px; }
  .modal-close { top: 14px; right: 14px; }
  .detail-title { font-size: 20px; padding-right: 50px; }
  .dm-amount { font-size: 28px; }
  .dm-grid { grid-template-columns: 6.4em minmax(0, 1fr); gap: 6px 10px; font-size: 14px; }
}

.reject-reason-box { margin-top: 16px; }
.reject-reason-box textarea { margin-top: 6px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  background: var(--navy-dark);
  color: #fff;
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  z-index: 2000;
  animation: toast-in 0.2s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- 帳號區（登入後右上角顯示登入者） ---------- */
.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.account-chip .account-name { opacity: 0.92; }
.account-chip .link-btn {
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.account-chip .link-btn:hover { background: rgba(255,255,255,0.26); }

/* ---------- 登入畫面（未登入前蓋住整個畫面）----------
   版面照 VI 手冊的封面：白底、彩色標誌在上，最下面一整排輔助圖形（二）的波浪 */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #fff;
  overflow: hidden auto;
}
.login-main {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px 24px calc(min(25.1vw, 42vh) + 24px);   /* 下面留出波浪的高度 */
}
.login-logo { display: block; height: 56px; width: auto; max-width: 100%; color: var(--navy); fill: currentColor; }
.login-wave {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: min(25.1vw, 42vh);   /* 圖的長寬比 348:87；太扁的螢幕從上面裁一點（VI：可擷取部分區域使用） */
  pointer-events: none;
}
.w-lime { fill: var(--lime); }
.w-teal { fill: var(--teal); }
.w-navy { fill: var(--navy); }
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 6px rgba(31,57,98,0.06), 0 18px 48px rgba(31,57,98,0.12);
  padding: 34px 32px 38px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-title { font-size: 24px; font-weight: 900; color: var(--navy); letter-spacing: 0.16em; margin-bottom: 8px; }
.login-title::after { content: ""; display: block; width: 36px; height: 4px; margin: 12px auto 0; border-radius: 2px; background: var(--lime); }
.login-sub { color: var(--text-muted); font-size: 14px; line-height: 1.6; margin-bottom: 26px; }
.login-btn-wrap { display: flex; justify-content: center; min-height: 44px; }
.login-hint {
  margin-top: 18px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  line-height: 1.6;
}
.login-hint.login-hint-info { color: var(--navy); background: var(--page-bg); } /* 中性狀態（登入中…），不是錯誤 */

/* ---------- 單據類型徽章 ---------- */
.doc-badge {
  display: inline-block;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  vertical-align: middle;
}

/* ---------- 報價單案子 ---------- */
.quote-case-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.quote-case {
  border: 1.5px solid var(--warn);
  background: var(--warn-bg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.quote-case-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.quote-case-title { font-weight: 700; color: var(--navy); }
.quote-case-proj { color: var(--text-muted); font-weight: 500; font-size: 13px; margin-left: 6px; }
.quote-case-nums {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  font-size: 13px; color: var(--text-main);
}
.quote-case-nums b { color: var(--navy); }
.quote-case-nums .remain-pos b { color: var(--danger); }
.quote-case-nums .remain-zero b { color: var(--success); }

/* ---------- 上傳紀錄篩選面板（重新設計，有標籤、日期用「從～到」） ---------- */
.filter-panel {
  background: var(--surface-soft);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 16px 14px;
  margin-bottom: 12px;
}
.filter-title { font-size: 12px; font-weight: 800; color: var(--navy); margin-bottom: 10px; letter-spacing: 0.03em; }
.filter-fields { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.filter-field { display: flex; flex-direction: column; gap: 5px; }
.filter-label { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.date-range { display: flex; align-items: center; gap: 8px; }
.date-range-sep { color: var(--text-muted); font-size: 14px; }
.date-input { font-size: 13px; padding: 9px 12px; font-weight: 600; width: auto; }
.filter-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- 2026-10 上傳表單改版：「這筆錢要怎麼付？」 ---------- */
.env-badge {
  margin-left: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--lime);
  color: var(--navy-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.ai-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #E3E9F3;
  color: var(--navy);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}
.pay-fieldset { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.pay-fieldset > legend.field-label { margin-top: 0; padding: 0; }
.pay-options { display: grid; gap: 8px; }
.pay-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pay-option:hover { border-color: var(--navy); }
.pay-option input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--navy); }
.pay-option > span { display: flex; flex-direction: column; gap: 2px; }
.pay-option b { color: var(--navy); font-size: 15px; }
.pay-option small { color: var(--text-muted); font-size: 12.5px; font-weight: 500; }
.pay-option.selected { border-color: var(--navy); background: #F1F4FA; box-shadow: inset 4px 0 0 var(--navy); }
.pay-option:focus-within { outline: 2px solid var(--lime-dark); outline-offset: 1px; }
.pay-panel {
  margin-top: 10px;
  padding: 14px 16px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #F6F8FB;
  min-width: 0;
}
.pay-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.pay-panel legend.field-label, .pay-panel > .field-label:first-child { margin-top: 0; padding: 0; }
.pay-panel .checkbox-row { margin-top: 14px; font-weight: 500; }
.pay-panel .checkbox-row b { color: var(--navy); }
.pay-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .pay-row { grid-template-columns: 1fr; } }
.mono-input { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: 0.04em; }
.hint-ok { color: var(--success); font-weight: 700; }
.hint-bad { color: var(--danger); font-weight: 700; }
.pill-options { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-option { position: relative; cursor: pointer; }
.pill-option input { position: absolute; opacity: 0; pointer-events: none; }
.pill-option span {
  display: inline-block;
  padding: 9px 18px;
  border: 1.5px solid var(--border-light);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
}
.pill-option input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.pill-option input:focus-visible + span { outline: 2px solid var(--lime-dark); outline-offset: 2px; }
#cardLinkField, #cardConfirmField { margin-top: 12px; }
/* 代扣（2026-10）：直接匯款面板裡的「這筆要代扣所得稅／二代健保」 */
.withhold-box {
  padding: 12px 14px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #fff;
  min-width: 0;
}
.withhold-intro { margin: 0 0 4px; }
.withhold-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--border-soft);
}
/* 標籤照字的寬度、不換行；金額欄在 96～150px 之間伸縮（手機上縮小），說明自己一行 */
.withhold-check { flex: none; display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 14px; font-weight: 700; color: var(--navy); cursor: pointer; }
.withhold-check input { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--navy); }
.withhold-amt { flex: 1 1 96px; max-width: 150px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.withhold-amt .text-input { flex: 1 1 auto; width: auto; min-width: 0; padding: 10px 12px; text-align: right; font-variant-numeric: tabular-nums; }
.withhold-amt .text-input:disabled { background: #EEF1F6; color: var(--text-muted); cursor: not-allowed; }
.withhold-unit { flex: none; font-size: 14px; font-weight: 700; color: var(--text-muted); }
.withhold-hint { flex-basis: 100%; margin-top: 0; }
.withhold-net {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--navy-tint);
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}
.withhold-net-amt { font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.withhold-net-calc { flex-basis: 100%; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.withhold-net-bad { background: var(--danger-bg); color: #b03a32; }
.done-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.done-actions .primary-btn { margin-top: 0; font-size: 15px; padding: 15px; }
.done-link { align-self: flex-start; margin-top: 4px; font-size: 14px; }

/* ---------- 2026-10 上傳紀錄改版：我的單據／全部同仁、進度條 ---------- */
.scope-toggle { margin-bottom: 16px; }
.stat-row-4 .stat-pill { flex: 1 1 120px; }
.stat-row-4 .stat-pill span { display: block; font-size: 22px; font-weight: 900; margin: 0 0 2px; }
.stat-approved { background: #E6ECF5; color: var(--navy); }
.stat-paid { background: var(--success-bg); color: var(--success); }
.status-badge.approved { background: #E6ECF5; color: var(--navy); }
.status-badge.paid { background: var(--success-bg); color: var(--success); }
.status-badge.held { background: var(--warn-bg); color: #8a5a00; }

.record-item { display: block; }
.record-item:focus-visible { outline: 2px solid var(--lime-dark); outline-offset: 2px; }
.record-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.record-head .record-main { flex: 1 1 240px; }
.record-side { text-align: right; flex: 0 0 auto; }
.record-badges { margin-top: 4px; }
.record-purpose { font-size: 14px; color: #3D4A5E; margin-bottom: 2px; }
.record-note {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
}
.record-note + .record-note { margin-top: 8px; }
.record-note-info { background: #F5F7FB; color: #3D4A5E; }
.record-note-bad { background: var(--danger-bg); color: #b03a32; font-weight: 700; font-size: 14px; }
.record-note-warn { background: var(--warn-bg); color: #8a5a00; font-weight: 700; font-size: 14px; }

.progress-steps { list-style: none; display: flex; margin-top: 14px; padding: 0; }
.ps { flex: 1 1 0; min-width: 0; }
.ps-track { display: flex; align-items: center; }
.ps-dot {
  width: 14px; height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid #9EA9BA;
  background: #fff;
}
.ps-line { flex: 1 1 auto; height: 3px; margin: 0 6px; background: var(--border-light); }
.ps-last .ps-line { background: transparent; }
.ps-label { display: block; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.ps-date { display: block; font-size: 12px; color: var(--text-muted); }
.ps-done .ps-dot { background: var(--teal-ink); border-color: var(--teal-ink); }
.ps-done .ps-line { background: var(--teal-ink); }
.ps-done .ps-label { color: var(--teal-ink); }
.ps-current .ps-dot { background: var(--lime); border-color: #7D8F12; }
.ps-current .ps-label { color: var(--navy); }
.ps-rejected .ps-dot { background: #b03a32; border-color: #b03a32; }
.ps-rejected .ps-label { color: #b03a32; }
.ps-held .ps-dot { background: #e0a100; border-color: #8a5a00; }
.ps-held .ps-label { color: #8a5a00; }
.ps-last .ps-line { background: transparent !important; }
@media (max-width: 560px) {
  .filter-fields { gap: 12px; }
  .filter-field { width: 100%; }
  .filter-field .select-input-sm { width: 100%; }
  .date-range { width: 100%; }
  .date-range .date-input { flex: 1 1 0; min-width: 0; }
}

/* ---------- 手機版頂欄：品牌＋帳號一列、主分頁一列（太多時左右滑，不會整頁左右捲動） ---------- */
@media (max-width: 720px) {
  .topbar-inner { padding: 12px 16px 10px; gap: 8px 12px; }
  .brand { order: 1; flex: 1 1 auto; min-width: 0; gap: 8px; }
  .account-chip { order: 2; }
  .tabs {
    order: 3;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 0 16px 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex: none; white-space: nowrap; padding: 8px 12px; }
  .app-main { padding: 16px 16px 48px; }
  .site-foot-inner { padding: 0 16px; }
}
@media (max-width: 560px) {
  .brand { gap: 6px; }
  .site-foot-slogan { height: 56px; }
  .site-foot-org { display: none; }
  .brand-logo { height: 22px; }
  .brand-divider { height: 16px; }
  .brand-name { font-size: 15.5px; letter-spacing: 0.06em; }
  .login-logo { height: 44px; }
  .env-badge { margin-left: 4px; }
  .card { padding: 22px 18px 26px; }
}
