/* ══════════════════════════════════════════════════
   iTracker Design System — 表格（.table-wrap、.data-table、儲存格 .cell-*、可排序表頭）
   正本：design-system/components/table.css（tracker 建置複製到 wwwroot/css/ds/，勿手改產物）。
   v1.0 自 wwwroot/css/site.css 原樣搬入（規則與原相對順序不變）。
   ══════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-card);
  border-radius: var(--r-md); background: var(--bg-card); }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
table.data-table th, table.data-table td {
  padding: 0 var(--space-3); border-bottom: 1px solid var(--border-faint);
  text-align: left; color: var(--text-primary); vertical-align: middle;
}
table.data-table td { height: var(--row-data); padding-top: var(--space-1); padding-bottom: var(--space-1); }
table.data-table th {
  height: var(--row-group); background: transparent; font-weight: var(--fw-medium);
  color: var(--text-tertiary); font-size: var(--fs-caption); white-space: nowrap;
  border-bottom-color: var(--border-card);
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background-color: var(--row-hover-bg); }
/* 表格數字欄等寬數字（工時／金額對齊） */
table.data-table td.num { font-variant-numeric: tabular-nums; }
/* 清單列形式的表格（角色管理、報價單列表；list-presentation「清單列」）：無外框、首欄齊內容邊、列＝清單列。
   保留 <table> 結構＝欄位排序（mxInitTableSort）照舊可用。 */
.table-wrap--list { border: 0; border-radius: 0; background: transparent; }
.table-wrap--list table.data-table th:first-child, .table-wrap--list table.data-table td:first-child { padding-left: var(--space-4); }
.table-wrap--list table.data-table th:last-child,  .table-wrap--list table.data-table td:last-child  { padding-right: var(--space-4); }
.table-wrap--list table.data-table tbody tr:last-child td { border-bottom: 1px solid var(--border-faint); }
/* 整列可點的清單表格（報價單列表：點列進 detail、刪除鈕防冒泡在頁面 JS） */
table.data-table tr.row-link { cursor: pointer; }
table.data-table tr.row-link:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus-ring-color); }
.cell-title { color: var(--text-primary); font-weight: var(--fw-medium); }
.cell-sub   { color: var(--text-secondary); font-size: var(--fs-caption); }
.cell-actions { display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.cell-name { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cell-name .badge { flex: none; }
.cell-note { color: var(--text-tertiary); font-size: var(--fs-caption); }
/* 長文字欄單行截斷＋滑過看全文（呼叫端補 title） */
table.data-table td.cell-clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data-table th.num, table.data-table td.num { text-align: center; white-space: nowrap; }
/* 數字欄靠右（表頭與數值同側；搭配 .num 的等寬數字）、動作欄靠右（.tar） */
table.data-table th.tar, table.data-table td.tar { text-align: right; white-space: nowrap; }
table.data-table td.tar .cell-actions { justify-content: flex-end; }
/* 可排序表頭（由 site-util.js 的 mxInitTableSort 掛上）：整格可點，hover 才透出可互動感。
   排序 icon 佔位恆存（.th-sort-ico 有固定寬），切換排序欄時表頭寬度不跳動。
   .num 欄置中對齊，icon 跟在文字後同一 inline flow。 */
table.data-table th.th-sortable { cursor: pointer; user-select: none; }
table.data-table th.th-sortable:hover { color: var(--text-primary); background: var(--bg-hover); }
table.data-table th.th-sortable:focus-visible { box-shadow: var(--focus-ring); }
table.data-table th.sorted { color: var(--text-primary); }
/* 排序 icon 三態：平時隱形但佔位（表頭不因排序切換而位移）／hover 淡色透出＝提示可排序／
   排序中 accent 實色。未排序欄只透出 chevron-down，不預告方向。 */
.th-sort-ico { display: inline-flex; width: 14px; height: 14px; margin-left: var(--space-1);
  vertical-align: -2px; color: var(--text-tertiary); opacity: 0; transition: opacity .12s; }
table.data-table th.th-sortable:hover .th-sort-ico { opacity: .55; }
table.data-table th.sorted .th-sort-ico { opacity: 1; color: var(--accent-text); }
