/* ==========================================================================
   common.css — 全站共用樣式
   燃料電池補助案管考查詢平臺 / 偉瑟科技
   目錄：1.Design Token 2.基礎 3.App Shell 4.側邊導覽 5.頂部列
        6.內容區 7.表格 8.表單 9.按鈕 10.狀態與標籤 11.卡片
        12.分頁 13.Modal 14.步驟條 15.14階段管線 16.RWD
   ========================================================================== */

/* ---------- 1. Design Token ---------- */
:root {
  /* 品牌色（依 A04 雛型畫面綠色系） */
  --brand-primary: #0F766E;
  --brand-dark: #0B5A54;
  --brand-light: #BFE3DE;
  --brand-pale: #F1F8F6;

  /* 四色狀態系統 */
  --state-done: #10B981;
  --state-doing: #3B82F6;
  --state-warn: #F59E0B;
  --state-late: #EF4444;
  --state-idle: #D1D5DB;
  --state-done-strong: #047857;
  --state-doing-strong: #1D4ED8;
  --state-warn-strong: #B45309;
  --state-late-strong: #B91C1C;   /* 白字放在色塊上用深色版（對比 ≥ 4.5:1） */

  --state-done-bg: #D1FAE5;
  --state-doing-bg: #DBEAFE;
  --state-warn-bg: #FEF3C7;
  --state-late-bg: #FEE2E2;

  /* 中性色 */
  --text-main: #1F2937;
  --text-sub: #4B5563;
  --text-muted: #5F6B7A;   /* 無障礙：淺灰文字對比 ≥ 4.5:1 */
  --line: #E5E7EB;
  --line-strong: #D1D5DB;
  --bg-page: #F9FAFB;
  --bg-card: #FFFFFF;
  --bg-hover: #F3F4F6;

  --focus-ring: #2563EB;

  /* 尺寸 */
  --sidebar-w: 64px;
  --sidebar-w-open: 240px;
  --topbar-h: 56px;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);

  /* 字級（由 common.js 的 A/A+/A++ 控制） */
  --fs-base: 15px;
}

html[data-fontsize="1"] { --fs-base: 15px; }
html[data-fontsize="2"] { --fs-base: 17px; }
html[data-fontsize="3"] { --fs-base: 19px; }

/* ---------- 2. 基礎 ---------- */
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--text-main);
  background: var(--bg-page);
}

/* 數字對齊 */
.num { font-variant-numeric: tabular-nums; }

h1, h2, h3, h4 { line-height: 1.4; font-weight: 700; }

/* ---------- 3. App Shell ---------- */
.app {
  min-height: 100vh;
  padding-left: var(--sidebar-w);
}

.app-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-body {
  flex: 1;
  padding: 24px 28px 40px;
}

/* ---------- 4. 側邊導覽（64px 圖示欄，hover 浮層展開，不推擠內容） ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #10262B;
  color: #CFE0DE;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .22s cubic-bezier(.4, 0, .2, 1);
  box-shadow: var(--shadow);
}
.sidebar:hover,
.sidebar.is-open { width: var(--sidebar-w-open); }

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  flex: none;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  white-space: nowrap;
}
.sidebar-brand .mark {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  background: var(--brand-primary);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
}
.sidebar-brand .txt {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  opacity: 0;
  transition: opacity .18s;
}
.sidebar:hover .sidebar-brand .txt,
.sidebar.is-open .sidebar-brand .txt { opacity: 1; }

.sidebar-nav {
  list-style: none;
  padding: 10px 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .16) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .16);
  border-radius: 99px;
}
.sidebar-nav:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .28); }
.sidebar-nav > li { position: relative; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 20px;
  white-space: nowrap;
  color: #D7F2E6;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.sidebar-link i { font-size: 20px; flex: none; width: 20px; text-align: center; }
.sidebar-link .txt {
  opacity: 0;
  transition: opacity .18s;
  font-size: .95em;
}
.sidebar:hover .sidebar-link .txt,
.sidebar.is-open .sidebar-link .txt { opacity: 1; }

.sidebar-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-link.is-active {
  background: rgba(15, 118, 110, .22);
  border-left-color: var(--brand-primary);
  color: #fff;
  font-weight: 600;
}

/* 子選單（管理模組） */
.sidebar-sub {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s;
  background: rgba(0, 0, 0, .22);
  box-shadow: inset 0 6px 8px -6px rgba(0, 0, 0, .45),
              inset 0 -6px 8px -6px rgba(0, 0, 0, .35);
}
.sidebar:hover .sidebar-sub.is-open,
.sidebar.is-open .sidebar-sub.is-open { max-height: 720px; }

.sidebar-sub a {
  display: block;
  position: relative;
  padding: 8px 16px 8px 54px;
  font-size: .88em;
  line-height: 1.5;
  color: #9DC9BE;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .18s, color .15s, background .15s;
}
/* 導引點：標示子層級 */
.sidebar-sub a::before {
  content: "";
  position: absolute;
  left: 41px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3E5A55;
  transition: background .15s, box-shadow .15s;
}
.sidebar:hover .sidebar-sub a,
.sidebar.is-open .sidebar-sub a { opacity: 1; }
.sidebar-sub a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-sub a:hover::before { background: var(--brand-light); }
.sidebar-sub a.is-active {
  color: #fff;
  font-weight: 600;
  background: rgba(15, 118, 110, .32);
}
.sidebar-sub a.is-active::before {
  background: #2DD4BF;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, .22);
}

.sidebar-foot {
  flex: none;
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: .78em;
  color: #7FB8A3;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .18s;
}
.sidebar:hover .sidebar-foot,
.sidebar.is-open .sidebar-foot { opacity: 1; }

/* 手機遮罩 */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 1035;
}
.sidebar-backdrop.is-show { display: block; }

/* ---------- 5. 頂部列 ---------- */
.topbar {
  height: var(--topbar-h);
  flex: none;
  background: linear-gradient(90deg, var(--brand-light) 0%, #D6EBE8 55%, #EDF5F3 100%);
  border-bottom: 1px solid #9CC9C2;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-toggle {
  display: none;
  background: none;
  border: 0;
  font-size: 22px;
  color: #0F3F32;
  padding: 4px 6px;
  line-height: 1;
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05em;
  color: #0F3F32;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-title i { font-size: 1.15em; }

.topbar-spacer { flex: 1; }

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 契約年度（全域篩選） */
.yearsel-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  border-right: 1px solid rgba(15, 63, 50, .18);
  margin-right: 4px;
}
.yearsel-group .lbl { font-size: .8em; color: #0F3F32; white-space: nowrap; }
.yearsel {
  width: auto;
  min-width: 92px;
  padding: 6px 28px 6px 10px;
  font-size: .85em;
  border-color: rgba(15, 63, 50, .22);
}
/* page-head（如儀表板）情境：拿掉原本 topbar 用的分隔線樣式 */
.page-head .yearsel-group { border-right: none; padding-right: 0; margin-right: 0; }

/* 字級調整 A / A+ / A++ */
.fontsize-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 8px;
  border-right: 1px solid rgba(15, 63, 50, .18);
  margin-right: 4px;
}
.fontsize-group .lbl { font-size: .8em; color: #0F3F32; margin-right: 4px; }
.fs-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #0F3F32;
  border-radius: 6px;
  padding: 2px 8px;
  line-height: 1.4;
  font-weight: 700;
}
.fs-btn:hover { background: rgba(255, 255, 255, .6); }
.fs-btn.is-active { background: #fff; border-color: var(--brand-dark); }
.fs-btn[data-size="1"] { font-size: .82em; }
.fs-btn[data-size="2"] { font-size: .95em; }
.fs-btn[data-size="3"] { font-size: 1.08em; }

.topbar-icon-btn {
  position: relative;
  background: transparent;
  border: 0;
  color: #0F3F32;
  font-size: 19px;
  padding: 4px 8px;
  border-radius: 8px;
}
.topbar-icon-btn:hover { background: rgba(255, 255, 255, .6); }
.topbar-icon-btn .dot {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--state-late);
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88em;
  color: #0F3F32;
  padding-left: 10px;
  border-left: 1px solid rgba(15, 63, 50, .18);
}
.topbar-user .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-dark);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .9em;
  flex: none;
}
.topbar-user .who { line-height: 1.25; }
.topbar-user .who b { display: block; font-weight: 600; }
.topbar-user .who span { font-size: .82em; color: #3A6B5B; }

/* 角色切換器（Demo 專用） */
.role-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .7);
  border: 1px dashed var(--brand-dark);
  border-radius: 999px;
  padding: 3px 6px 3px 12px;
  font-size: .82em;
  color: #0F3F32;
}
.role-switcher .tag {
  font-weight: 700;
  letter-spacing: .04em;
  font-size: .92em;
  color: var(--brand-dark);
}
.role-switcher select {
  border: 0;
  background: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .95em;
  color: var(--text-main);
}

/* ---------- 6. 內容區 ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head h1 {
  font-size: 1.5em;
  letter-spacing: .01em;
}
.page-head .desc {
  color: var(--text-sub);
  font-size: .9em;
}
.page-head .spacer { flex: 1; }

.breadcrumb-bar {
  font-size: .84em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.breadcrumb-bar a:hover { color: var(--brand-dark); }
.breadcrumb-bar .sep { margin: 0 6px; }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-size: 1.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-head h2 i { color: var(--brand-dark); }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }

/* 查詢條件列 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
}
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}
.filter-item > label {
  font-size: .82em;
  color: var(--text-sub);
  font-weight: 600;
}
/* filter-item 本身有 display:flex，會蓋掉瀏覽器內建 [hidden] 的 display:none，
   這裡補上較高優先權的規則，確保 JS 動態隱藏欄位（如搜尋方式切換）正常生效 */
.filter-item[hidden] { display: none; }
.filter-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.result-count {
  font-size: .9em;
  color: var(--text-sub);
}
.result-count b {
  color: var(--brand-dark);
  font-size: 1.35em;
  font-weight: 700;
  margin: 0 3px;
}

/* ---------- 7. 表格 ---------- */
.table-wrap { overflow-x: auto; }

.tbl {
  width: 100%;
  font-size: .9em;
  min-width: 720px;
}
.tbl thead th {
  background: var(--brand-pale);
  color: #0F3F32;
  font-weight: 700;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 2px solid var(--brand-light);
  white-space: nowrap;
}
.tbl thead th.sortable { cursor: pointer; user-select: none; }
.tbl thead th.sortable::after {
  content: "\2195";
  margin-left: 5px;
  color: var(--text-muted);
  font-size: .85em;
}
.tbl tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--brand-pale); }
.tbl tbody tr.is-clickable { cursor: pointer; }
.tbl tbody tr.is-clickable:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
  background: var(--brand-pale);
}
.tbl .ta-r { text-align: right; }
.tbl .ta-c { text-align: center; }
.tbl .nowrap { white-space: nowrap; }

.tbl-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}
.tbl-empty i { font-size: 34px; display: block; margin-bottom: 10px; color: var(--line-strong); }

/* ---------- 8. 表單 ---------- */
.fld {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: .95em;
  transition: border-color .15s, box-shadow .15s;
}
.fld:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .22);
}
.fld:disabled, .fld[readonly] { background: var(--bg-hover); color: var(--text-sub); }
select.fld { padding-right: 30px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 22px;
}
.form-grid .full { grid-column: 1 / -1; }

.form-item { display: flex; flex-direction: column; gap: 5px; }
.form-item > label {
  font-size: .87em;
  font-weight: 600;
  color: var(--text-main);
}
.form-item .req { color: var(--state-late-strong); margin-left: 3px; }
.form-item .hint { font-size: .8em; color: var(--text-muted); }
.form-item .err { font-size: .8em; color: var(--state-late-strong); display: none; }
.form-item.is-invalid .fld { border-color: var(--state-late); }
.form-item.is-invalid .err { display: block; }
.form-item.is-valid .fld { border-color: var(--brand-primary); }

.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .88em;
  cursor: pointer;
}

/* ---------- 開關（toggle switch） ---------- */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--line-strong);
  border-radius: 999px;
  transition: background .15s;
  pointer-events: none;
}
.switch-track::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-track { background: var(--brand-primary); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.switch input:disabled { cursor: not-allowed; }

/* 通知設定：開關列 */
.switch-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-of-type { border-bottom: 0; }
.switch-row-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-label b { display: block; font-size: .92em; font-weight: 700; }
.switch-label span { display: block; font-size: .8em; color: var(--text-sub); margin-top: 2px; }
.switch-row-sub {
  margin-top: 12px;
  padding-left: 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity .15s;
}
.switch-row-sub.is-disabled { opacity: .5; pointer-events: none; }

/* ---------- 稽核欄位（建立/最後更新資訊，唯讀顯示於新增/編輯 Modal 內） ---------- */
.audit-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 28px;
  background: var(--bg-page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px 16px;
  margin-top: 20px;
}
.audit-box-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .78em;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .04em;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.audit-box-title i { font-size: 1.05em; color: var(--brand-primary); }

.audit-col { display: flex; flex-direction: column; gap: 7px; padding: 2px 0; }
.audit-col + .audit-col { border-left: 1px solid var(--line); padding-left: 24px; }
.audit-col-label {
  font-size: .72em;
  font-weight: 700;
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 1px;
}
.audit-col-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .86em;
  color: var(--text-main);
}
.audit-col-key {
  color: var(--text-muted);
  flex: none;
  width: 44px;
}
.audit-col-row b { font-weight: 600; font-variant-numeric: tabular-nums; }

@media (max-width: 480px) {
  .audit-box { grid-template-columns: 1fr; }
  .audit-col + .audit-col {
    border-left: 0;
    padding-left: 0;
    border-top: 1px dashed var(--line);
    padding-top: 10px;
    margin-top: 2px;
  }
}

/* ---------- Excel 批次匯入：驗證圖例／拖曳區 ---------- */
.imp-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .85em; font-weight: 600; color: var(--text-sub); }
.imp-legend span { display: flex; align-items: center; gap: 6px; }
.imp-dot { width: 13px; height: 13px; border-radius: 4px; border: 1px solid; display: inline-block; }
#impDropzone.is-drag { border-color: var(--brand-primary) !important; background: var(--brand-pale) !important; }

/* ---------- 9. 按鈕 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .9em;
  font-weight: 600;
  line-height: 1.5;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-soft { background: var(--brand-light); color: #0F3F32; }
.btn-soft:hover { background: #9CC9C2; }
.btn-outline { background: #fff; border-color: var(--line-strong); color: var(--text-main); }
.btn-outline:hover { border-color: var(--brand-primary); color: var(--brand-dark); }
.btn-danger { background: #fff; border-color: var(--state-late-strong); color: var(--state-late-strong); }
.btn-danger:hover { background: var(--state-late-strong); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: .84em; }
.btn-lg { padding: 11px 26px; font-size: 1em; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon {
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-sub);
  font-size: .95em;
}
.btn-icon:hover { border-color: var(--brand-primary); color: var(--brand-dark); }

/* ---------- 10. 狀態與標籤 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .8em;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge-done { background: var(--state-done-bg); color: #047857; }
.badge-doing { background: var(--state-doing-bg); color: #1D4ED8; }
.badge-warn { background: var(--state-warn-bg); color: #B45309; }
.badge-late { background: var(--state-late-bg); color: #B91C1C; }
.badge-idle { background: #F3F4F6; color: #4B5563; }
.badge-plain::before { display: none; }

/* 狀態圖例 */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: .82em;
  color: var(--text-sub);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

/* ---------- 11. 卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand-primary);
}
.stat-card .lbl {
  font-size: .84em;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-card .val {
  font-size: 1.9em;
  font-weight: 700;
  line-height: 1.25;
  color: #0F3F32;
  font-variant-numeric: tabular-nums;
}
.stat-card .val small { font-size: .48em; font-weight: 600; color: var(--text-sub); margin-left: 4px; }

/* 案件資訊卡（案件查詢用） */
.case-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.case-card:hover,
.case-card:focus-visible {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.case-card .hd {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.case-card .hd h3 { font-size: .98em; flex: 1; }
.case-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  font-size: .86em;
  margin: 0;
}
.case-card dt { color: var(--text-sub); display: flex; align-items: center; gap: 5px; }
.case-card dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 年度分組 */
.year-group { margin-bottom: 18px; }
.year-group > .year-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #0F3F32;
  font-size: .95em;
  margin-bottom: 10px;
}
.year-group > .year-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.year-group > .year-label .n {
  font-size: .82em;
  font-weight: 600;
  color: var(--text-sub);
  background: var(--bg-hover);
  border-radius: 999px;
  padding: 1px 9px;
}

/* 提醒橫幅 */
.alert-bar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--state-warn);
  background: var(--state-warn-bg);
  color: #92400E;
  font-size: .9em;
  margin-bottom: 18px;
}
.alert-bar i { font-size: 1.25em; flex: none; margin-top: 1px; }
.alert-bar b { font-weight: 700; }
.alert-bar .spacer { flex: 1; }
.alert-bar.is-late {
  border-color: var(--state-late);
  background: var(--state-late-bg);
  color: #991B1B;
}
.alert-bar.is-info {
  border-color: var(--brand-primary);
  background: var(--brand-pale);
  color: #065F46;
}

/* ---------- 12. 分頁 ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 16px;
  flex-wrap: wrap;
}
.pager a, .pager span {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .88em;
  background: #fff;
}
.pager a:hover { border-color: var(--brand-primary); color: var(--brand-dark); }
.pager .is-current {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  font-weight: 700;
}
.pager .dots { border: 0; background: none; }

/* ---------- 13. Modal ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: 1060;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask.is-open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-box.is-wide { max-width: 900px; }
.modal-box.is-narrow { max-width: 460px; }

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: linear-gradient(90deg, var(--brand-light), #DCEEEA);
  border-bottom: 1px solid #9CC9C2;
}
.modal-head h2 { font-size: 1em; color: #0F3F32; flex: 1; display: flex; align-items: center; gap: 8px; }
.modal-close {
  background: none;
  border: 0;
  font-size: 20px;
  line-height: 1;
  color: #0F3F32;
  padding: 4px;
  border-radius: 6px;
}
.modal-close:hover { background: rgba(255, 255, 255, .7); }

.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--bg-page);
}

/* 詳細資訊定義列表 */
.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 12px 16px;
  font-size: .9em;
  margin: 0;
}
.detail-grid dt { color: var(--text-sub); font-weight: 600; white-space: nowrap; }
.detail-grid dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Excel 匯出 Modal：欄位／案件 雙欄勾選清單（js/xlsx_export.js 動態注入，全站共用） */
.rp-export-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 20px;
}
.rp-export-col-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.rp-export-col-head h3 { font-size: .95em; flex: 1; }
.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: .82em;
  color: var(--brand-primary);
  cursor: pointer;
  text-decoration: underline;
}
.btn-link:hover { color: var(--brand-dark); }
.rp-check-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rp-check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88em;
  cursor: pointer;
}
.rp-check-list-rows label {
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}
.rp-check-list-rows label:last-child { border-bottom: none; }
.rp-check-list-rows .rp-row-info { display: flex; flex-direction: column; gap: 1px; }
.rp-check-list-rows .rp-row-info b { font-size: 1em; }
.rp-check-list-rows .rp-row-info span { font-size: .82em; color: var(--text-muted); }

@media (max-width: 640px) {
  .rp-export-grid { grid-template-columns: 1fr; }
}
.detail-grid .full-row { grid-column: 2 / -1; }

/* ---------- 14. 步驟條 ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 0 6px;
}
.stepper .step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.stepper .step .no {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--line-strong);
  background: #fff;
  color: var(--text-muted);
  font-weight: 700;
  font-size: .9em;
  flex: none;
}
.stepper .step .tx { font-size: .9em; color: var(--text-sub); white-space: nowrap; }
.stepper .step.is-done .no { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.stepper .step.is-done .tx { color: var(--text-main); }
.stepper .step.is-current .no { border-color: var(--brand-primary); color: var(--brand-dark); box-shadow: 0 0 0 4px rgba(15, 118, 110, .18); }
.stepper .step.is-current .tx { color: var(--brand-dark); font-weight: 700; }
.stepper .bar {
  flex: 1;
  height: 2px;
  background: var(--line-strong);
  margin: 0 14px;
  min-width: 24px;
}
.stepper .bar.is-done { background: var(--brand-primary); }

.step-panel { display: none; }
.step-panel.is-active { display: block; }

/* ---------- 15. 14 階段進度管線（本站簽名元件） ---------- */
.case-progress {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.case-progress.is-clickable { cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.case-progress.is-clickable:hover { box-shadow: var(--shadow); border-color: var(--brand-light); }
.case-progress.is-clickable:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}
.case-progress .cp-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.case-progress .cp-head h3 {
  font-size: 1.08em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.case-progress .cp-head h3 a:hover { color: var(--brand-dark); text-decoration: underline; }
.case-progress .cp-head .spacer { flex: 1; }
.case-progress .cp-pct {
  font-weight: 700;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.case-progress .cp-pct span { font-size: 1.35em; }
.case-progress .cp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  font-size: .86em;
  color: var(--text-sub);
  margin-bottom: 16px;
}
.case-progress .cp-meta b { color: var(--text-main); font-variant-numeric: tabular-nums; }

/* 進度條（總覽用） */
.cp-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-hover);
  overflow: hidden;
  margin-bottom: 16px;
}
.cp-bar > i { display: block; height: 100%; background: var(--brand-primary); border-radius: 999px; }

/* 管線本體 */
.pipeline-scroll { overflow-x: auto; padding-bottom: 6px; }
.pipeline {
  display: flex;
  align-items: flex-start;
  min-width: 1080px;
}
.pipeline .node {
  flex: 1;
  min-width: 74px;
  text-align: center;
  position: relative;
  padding-top: 4px;
}
/* 節點之間的連接線 */
.pipeline .node::before {
  content: "";
  position: absolute;
  top: 24px;
  left: -50%;
  width: 100%;
  height: 3px;
  background: var(--state-idle);
  z-index: 0;
}
.pipeline .node:first-child::before { display: none; }
.pipeline .node.is-linked::before { background: var(--state-done); }

.pipeline .dot {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .95em;
  background: #fff;
  border: 3px solid var(--state-idle);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.pipeline .node.is-done .dot { background: var(--state-done-strong); border-color: var(--state-done-strong); color: #fff; }
.pipeline .node.is-doing .dot { background: var(--state-doing-strong); border-color: var(--state-doing-strong); color: #fff; }
.pipeline .node.is-warn .dot { background: var(--state-warn-strong); border-color: var(--state-warn-strong); color: #fff; }
.pipeline .node.is-late .dot { background: var(--state-late-strong); border-color: var(--state-late-strong); color: #fff; }

.pipeline .nm {
  font-size: .78em;
  line-height: 1.35;
  color: var(--text-main);
  margin-bottom: 6px;
  padding: 0 3px;
  min-height: 2.7em;
}
.pipeline .node.is-late .nm { color: #B91C1C; font-weight: 700; }
.pipeline .node.is-warn .nm { color: #B45309; font-weight: 700; }

.pipeline .dt {
  font-size: .72em;
  line-height: 1.5;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}
.pipeline .dt em { font-style: normal; color: var(--text-muted); }
.pipeline .dt .plan { color: var(--text-muted); }

/* 管線左側日期軸標籤 */
.pipeline-legend {
  display: flex;
  gap: 10px;
  font-size: .74em;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- 16. 其他小元件 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .spacer { flex: 1; }

.tab-switch {
  display: inline-flex;
  background: var(--bg-hover);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}
.tab-switch button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 6px 18px;
  font-size: .88em;
  font-weight: 600;
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-switch button.is-active {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}

/* ---------- 參數設定：共用分頁籤 ---------- */
.param-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.param-tab {
  padding: 10px 16px;
  font-size: .92em;
  font-weight: 600;
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.param-tab:hover { color: var(--brand-dark); background: var(--brand-pale); }
.param-tab.is-active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand-primary);
}
@media (max-width: 767px) {
  .param-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
}

/* ---------- 角色／帳號編輯：頁內分頁籤（JS 切換，非頁面連結） ---------- */
.rtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.rtab {
  padding: 10px 18px;
  font-size: .92em;
  font-weight: 600;
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.rtab:hover { color: var(--brand-dark); background: var(--brand-pale); }
.rtab.is-active { color: var(--brand-dark); border-bottom-color: var(--brand-primary); }

/* ---------- 權限設置：checkbox 矩陣 ---------- */
.perm-tbl th, .perm-tbl td { text-align: center; }
.perm-tbl td:first-child, .perm-tbl th:first-child { text-align: left; }
.perm-chk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand-primary);
}
.perm-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .82em;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
}
.perm-all input { accent-color: var(--brand-dark); cursor: pointer; }

/* ---------- 密碼欄位：顯示／隱藏切換 ---------- */
.pw-field { position: relative; }
.pw-field .fld { padding-right: 38px; }
.pw-field .pw-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}
.pw-field .pw-toggle:hover { color: var(--brand-dark); }

/* ---------- 單選群組（狀態：啟用／關閉） ---------- */
.radio-group { display: flex; gap: 18px; align-items: center; padding-top: 4px; }
.checkbox-group { display: flex; gap: 18px; align-items: center; padding-top: 4px; flex-wrap: wrap; }
.checkbox-group label {
  display: flex; align-items: center; gap: 6px;
  font-size: .88em; font-weight: 400; cursor: pointer;
}
.checkbox-group input { accent-color: var(--brand-primary); cursor: pointer; }
.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .9em;
  font-weight: 400;
  cursor: pointer;
}
.radio-group input { accent-color: var(--brand-primary); cursor: pointer; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: #0F3F32;
  color: #fff;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: .9em;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 1080;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer {
  flex: none;
  background: #0F3F32;
  color: #A9D9C7;
  padding: 22px 28px 10px;
  font-size: .84em;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 40px;
}
.footer h3 { color: #fff; font-size: .95em; margin-bottom: 6px; }
.footer a:hover { color: #fff; text-decoration: underline; }
.footer .col { min-width: 200px; }

.copyright {
  flex: none;
  background: #0A2E24;
  color: #7FB8A3;
  padding: 12px 28px;
  font-size: .78em;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  align-items: center;
}
.copyright .spacer { flex: 1; }
.copyright .logos { display: flex; gap: 14px; align-items: center; }
.copyright .logo-box {
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 5px;
  padding: 3px 10px;
  font-size: .95em;
  color: #C8E6DA;
}

/* ---------- 17. RWD ---------- */

/* 平板 768–991px */
@media (max-width: 991px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: auto 1fr; }
  .detail-grid .full-row { grid-column: 2 / -1; }
  .app-body { padding: 20px 18px 32px; }
}

/* 手機 <768px */
@media (max-width: 767px) {
  .app { padding-left: 0; }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w-open);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar .sidebar-brand .txt,
  .sidebar .sidebar-link .txt,
  .sidebar .sidebar-sub a,
  .sidebar .sidebar-foot { opacity: 1; }
  .sidebar .sidebar-sub.is-open { max-height: 720px; }

  .topbar-toggle { display: block; }
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar-title { font-size: .95em; }
  .topbar-title .long { display: none; }
  .fontsize-group .lbl { display: none; }
  .yearsel-group .lbl { display: none; }
  .yearsel { min-width: 72px; }
  .topbar-user .who { display: none; }
  .role-switcher { padding: 3px 5px 3px 9px; }
  .role-switcher .tag { display: none; }

  .app-body { padding: 16px 12px 28px; }
  .page-head h1 { font-size: 1.25em; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card .val { font-size: 1.5em; }

  .form-grid { grid-template-columns: 1fr; }
  .filter-item { min-width: 100%; }
  .filter-actions { margin-left: 0; width: 100%; }
  .filter-actions .btn { flex: 1; }

  .modal-box { max-height: calc(100vh - 24px); }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }

  .stepper { overflow-x: auto; padding-bottom: 8px; }
  .stepper .step .tx { display: none; }
  .stepper .step.is-current .tx { display: block; }
  .stepper .bar { margin: 0 8px; min-width: 16px; }

  /* 表格改卡片式堆疊 */
  .tbl.is-stack { min-width: 0 !important; width: 100%; }   /* 手機：覆蓋行內 min-width，否則值被推到畫面外 */
  .tbl.is-stack thead { display: none; }
  .tbl.is-stack tbody tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 6px 4px;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }
  .tbl.is-stack tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    border-bottom: 1px dashed var(--line);
    padding: 8px 12px;
    text-align: right;
  }
  .tbl.is-stack tbody td:last-child { border-bottom: 0; }
  .tbl.is-stack tbody td::before {
    content: attr(data-th);
    font-size: .84em;
    color: var(--text-sub);
    font-weight: 600;
    text-align: left;
    flex: none;
  }
  .tbl.is-stack tbody tr:hover { background: #fff; }

  .footer-inner { gap: 14px; }
  .footer, .copyright { padding-left: 14px; padding-right: 14px; }
}

/* 列印 */
@media print {
  .sidebar, .topbar, .footer, .copyright, .filter-bar, .toolbar { display: none !important; }
  .app { padding-left: 0; }
  .panel { box-shadow: none; }
}

/* sidebar 子選單觸發鈕：button 元素需重置外觀以沿用 .sidebar-link */
button.sidebar-link {
  width: 100%;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  text-align: left;
  font: inherit;
}
button.sidebar-link .bi-chevron-down { opacity: 0; transition: opacity .18s, transform .2s; }
.sidebar:hover button.sidebar-link .bi-chevron-down,
.sidebar.is-open button.sidebar-link .bi-chevron-down { opacity: .7; }
button.sidebar-link[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }


/* 子選單分組標籤（管理模組內：案件編輯／系統設定） */
.sidebar-sub .sub-group {
  position: relative;
  margin-top: 12px;
  padding: 11px 16px 4px 41px;
  font-size: .7em;
  font-weight: 700;
  letter-spacing: .22em;
  color: #5F8C81;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .18s;
  user-select: none;
}
/* 群組之間的分隔線（第一組不畫） */
.sidebar-sub .sub-group::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 16px;
  height: 1px;
  background: rgba(255, 255, 255, .09);
}
.sidebar-sub .sub-group:first-child { margin-top: 4px; }
.sidebar-sub .sub-group:first-child::before { display: none; }
.sidebar:hover .sidebar-sub .sub-group,
.sidebar.is-open .sidebar-sub .sub-group { opacity: 1; }
/* 子選單上下留白 */
.sidebar-sub > li:last-child { margin-bottom: 8px; }

/* v1.0：管線上標示已展延的階段 */
.pipeline .ext-dot { display: inline-block; font-size: .72em; font-weight: 700; color: #92400E; background: var(--state-warn-bg); border-radius: 4px; padding: 0 4px; margin-left: 2px; vertical-align: 1px; }

/* v1.0：手機版頂部列不再撐寬頁面（原本 390px 寬時工具列超出約 150px，導致全頁可左右捲動） */
@media (max-width: 560px) {
  .topbar-tools { gap: 4px; min-width: 0; }
  .topbar-tools .fontsize-group .lbl,
  .topbar-tools .role-switcher .tag,
  .topbar-user .who { display: none; }
  .topbar-tools .fontsize-group { padding-right: 4px; margin-right: 0; }
  .topbar-tools .role-switcher select { max-width: 96px; }
}
@media (max-width: 420px) {
  .topbar-tools .fontsize-group, #fcResetDemoBtn { display: none; }
  .topbar-title .long { display: none; }
  .topbar-user { gap: 2px; padding-left: 2px; margin-left: 0; border-left: none; }
  .topbar-tools .role-switcher select { max-width: 68px; padding-right: 18px; }
  .topbar { gap: 6px; }
  .topbar-tools .role-switcher { padding: 2px; }
}

/* v1.0：帶 hidden 屬性的提示列一律隱藏（原本 display:flex 會蓋過 hidden） */
.alert-bar[hidden] { display: none !important; }

/* v1.1 細粒度權限矩陣 */
.perm-tbl tr.perm-mod td { background: var(--bg-page); font-weight: 700; border-top: 2px solid var(--line-strong); }
.perm-tbl tr.perm-mod .perm-cnt { font-weight: 400; font-size: .8em; color: var(--text-muted); margin-left: 10px; }
.perm-tg { border: 0; background: none; cursor: pointer; color: var(--text-sub); margin-right: 4px; padding: 0 4px; }
.perm-item-lb { padding-left: 34px !important; }
.perm-key { font-size: .72em; color: var(--text-muted); background: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 8px; }
.perm-na { color: var(--text-muted); }
.perm-col { accent-color: var(--brand-dark); }
.perm-note { font-size: .78em; color: var(--text-muted); font-weight: 400; margin-top: 2px; }
.alert-bar.is-warn { background: #FFFBEB; border-color: #FCD34D; }
[hidden] { display: none !important; }

/* 日期欄位日曆選擇器（10/29） */
.date-wrap { position: relative; display: block; }
.date-wrap .fld { padding-right: 36px; width: 100%; }
.date-wrap .date-native { position: absolute; right: 8px; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.date-wrap .date-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--text-sub); padding: 4px 6px; cursor: pointer; border-radius: 6px; line-height: 1; }
.date-wrap .date-btn:hover { background: var(--bg-hover); color: var(--primary, #0f766e); }
.date-wrap .fld:disabled ~ .date-btn { display: none; }
