/* Notion 風格表格（v2.104.0）。載入在 ruyi-dark.css 之後，淺色與深色共用同一套變數。
   A 安靜表格：沒有外框與直線，只有列與列之間一條細線；表頭小字灰色；滑過整列才有淡灰底。
   B 柔色圓角狀態標籤。C 標題列固定、欄位圖示、欄寬把手。D 右側列預覽面板。 */

/* ---------- A 安靜表格 ---------- */
html[data-ui][data-ui][data-ui] .table-card{padding:0;background:transparent;border:0;box-shadow:none;border-radius:0;overflow:clip}
html[data-ui][data-ui][data-ui] .table-card>.filter-bar{background:transparent;border-bottom:0;padding-left:8px;padding-right:8px}
html[data-ui][data-ui][data-ui] .table-card>.section-heading,
html[data-ui][data-ui][data-ui] .card.table-card>.section-heading:first-child{padding-left:8px;padding-right:8px;border-bottom:0;background:transparent}
html[data-ui][data-ui][data-ui] .table-card .table-scroll{background:transparent;border:0;border-radius:0}
html[data-ui][data-ui][data-ui] table :is(th,td){border-left:0;border-right:0}
html[data-ui][data-ui][data-ui] thead th{background:var(--paper);color:var(--muted);font-size:var(--fs-label);font-weight:var(--fw-regular);letter-spacing:0;text-transform:none;
  padding:10px 14px;border-bottom:0;box-shadow:inset 0 -1px 0 var(--rule);white-space:nowrap}
html[data-ui][data-ui][data-ui] .card:not(.table-card) thead th{background:var(--sheet)}
html[data-ui][data-ui][data-ui] tbody td{padding:13px 14px;border-bottom:1px solid color-mix(in srgb,var(--rule) 75%,transparent);vertical-align:middle}
html[data-ui][data-ui][data-ui] :is(thead th,tbody td):first-child{padding-left:8px}
html[data-ui][data-ui][data-ui] :is(thead th,tbody td):last-child{padding-right:8px}
html[data-ui][data-ui][data-ui] tbody tr:last-child td{border-bottom:0}
html[data-ui][data-ui][data-ui] .main-content tbody tr:not(.table-group-row):hover>td{background:color-mix(in srgb,var(--ink) 4.5%,transparent)}
html[data-ui][data-ui][data-ui] .main-content tbody tr:not(.table-group-row):hover>td:first-child{box-shadow:none}
html[data-ui][data-ui][data-ui] .main-content tbody tr.is-previewing>td{background:color-mix(in srgb,var(--ink) 7%,transparent)}
html[data-ui][data-ui][data-site-density=compact] tbody td{padding-top:6px;padding-bottom:6px}
html[data-ui][data-ui][data-site-density=comfortable] tbody td{padding-top:18px;padding-bottom:18px}
html[data-ui][data-ui][data-ui] tbody td,html[data-ui][data-ui][data-ui] tbody th{font-variant-numeric:tabular-nums}

/* ---------- B 狀態標籤：樣式與語意色已集中到 ruyi-semantic.css ---------- */

/* ---------- C 標題列固定、欄位圖示、欄寬把手 ---------- */
html[data-ui][data-ui][data-ui] .table-scroll.is-fit{overflow:visible}
@media(min-width:761px){html[data-ui][data-ui][data-ui] .table-scroll.is-fit thead th{position:sticky;top:var(--topbar-h,56px);z-index:3}}
html[data-ui][data-ui][data-ui] thead th{position:relative}
html[data-ui][data-ui][data-ui] .th-icon{width:14px;height:14px;margin:-2px 6px -2px 0;vertical-align:middle}
html[data-ui][data-ui][data-ui] table[data-cols-fixed] :is(th,td){overflow-wrap:anywhere}
html[data-ui][data-ui][data-ui] .col-resizer{position:absolute;top:0;right:0;z-index:4;width:10px;height:100%;cursor:col-resize;touch-action:none}
html[data-ui][data-ui][data-ui] .col-resizer::after{content:'';position:absolute;top:22%;bottom:22%;right:3px;width:2px;border-radius:2px;background:var(--ui-link);opacity:0;transition:opacity var(--motion-feedback,140ms) ease}
@media (hover:hover){html[data-ui][data-ui][data-ui] thead th:hover .col-resizer::after{opacity:.35}}
html[data-ui][data-ui][data-ui] .col-resizer:is(:hover,:focus-visible,.is-active)::after{opacity:1}
html[data-ui][data-ui][data-ui] .col-resizer:focus-visible{outline:2px solid var(--ui-link);outline-offset:-2px}
body.is-col-resizing{cursor:col-resize;user-select:none}
@media(max-width:760px){html[data-ui][data-ui][data-ui] .col-resizer{width:18px}html[data-ui][data-ui][data-ui] .col-resizer::after{right:8px;opacity:.25}}

/* ---------- C2 表頭與第一欄固定（如意 v0.29.0，DL 2026-12-02；v0.31.0 搬回參考 #526 的改良） ----------
   表格比畫面寬（.has-overflow，ruyi-interactions.js 判斷）時：
   1. 電腦版表格框最高只到視窗底，橫向捲軸一直在畫面裡，不用先捲到表格最底才拉得到（Windows 滑鼠沒有左右滑）；
      框裡上下捲動時表頭固定在框的頂端。滑鼠在表格上滾滾輪，先捲整頁到表格框整個進到畫面，再捲表格（ruyi-tables.js）。
   2. 第一欄（員工、日期、單號這類標題欄）左右捲動時固定在左邊，右側一條細線分隔（用背景圖層畫，各模組第一格左邊的色條 box-shadow 照常顯示）。
   3. 手機第一欄比 8 個字寬時收成 8 個字寬（.is-capped-first）；收完仍超過表格框 6 成寬就不固定第一欄（.is-wide-first）。
   表格沒有比畫面寬時照舊（.is-fit）：表頭跟著整頁捲動固定在頂端列下面。
   多列表頭（例如投保資料）每一列的固定位置由 ruyi-tables.js 算好放在 --thead-top。
   固定的格子一定要實心：--stick-bg 實心底色，--stick-tint 疊在上面的半透明顏色（滑過、預覽中、警示列）；格子本身有特別底色的列在那一格一起設。
   不要這個效果的表格在 .table-scroll 加 data-no-sticky；第一欄只是勾選框／排序把手／小圖時加 data-no-sticky-col。完整規則：docs/全站表格固定表頭與第一欄.md */
html[data-ui][data-ui][data-ui] .table-scroll{--stick-bg:var(--bg)}
html[data-ui][data-ui][data-ui] .card:not(.table-card) .table-scroll{--stick-bg:var(--sheet)}
@media (min-width:761px){
  html[data-ui][data-ui][data-ui] .table-scroll.has-overflow:not([data-no-sticky]){max-height:calc(100dvh - var(--topbar-h,56px) - 24px);overflow:auto;scrollbar-gutter:auto}
  html[data-ui][data-ui][data-ui] .table-scroll.has-overflow:not([data-no-sticky])>table>thead th{position:sticky;top:var(--thead-top,0px);z-index:3}
}
html[data-ui][data-ui][data-ui] .table-scroll.has-overflow:not([data-no-sticky],[data-no-sticky-col],.is-wide-first)>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan]))>:is(thead,tbody,tfoot)>tr>:first-child{
  position:sticky;left:0;z-index:2;background-color:var(--stick-bg);
  background-image:linear-gradient(var(--rule),var(--rule)),linear-gradient(var(--stick-tint,transparent),var(--stick-tint,transparent));
  background-size:1px 100%,100% 100%;background-position:100% 0,0 0;background-repeat:no-repeat}
/* 多列表頭的第二列以後，第一格不是第一欄（第一欄的標題跨兩列寫在第一列）：只固定在上方，不固定在左邊 */
html[data-ui][data-ui][data-ui] .table-scroll.has-overflow:not([data-no-sticky],[data-no-sticky-col],.is-wide-first)>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan]))>thead>tr:not(:first-child)>:first-child{left:auto;z-index:3;background-color:var(--paper);background-image:none;box-shadow:inset 0 -1px 0 var(--rule)}
html[data-ui][data-ui][data-ui] .table-scroll.has-overflow:not([data-no-sticky],[data-no-sticky-col],.is-wide-first)>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan]))>thead>tr:first-child>:first-child{z-index:4;background-color:var(--paper);box-shadow:inset 0 -1px 0 var(--rule)}
html[data-ui][data-ui][data-ui] .card:not(.table-card) .table-scroll.has-overflow:not([data-no-sticky],[data-no-sticky-col],.is-wide-first)>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan]))>thead>tr:first-child>:first-child{background-color:var(--sheet)}
/* 手機：第一欄收成 8 個字寬、太長換行（只用在 4 欄以上、手機一定會左右捲的表） */
@media (max-width:760px){html[data-ui][data-ui][data-ui] .table-scroll.is-capped-first:not([data-no-sticky],[data-no-sticky-col])>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan])):has(thead th:nth-child(4))>:is(thead,tbody,tfoot)>tr>:first-child{width:8rem;min-width:0}}
/* 列的狀態：鍵盤停在列上、滑過、正在側滑頁預覽 */
html[data-ui][data-ui][data-ui] .main-content .table-scroll.has-overflow:not([data-no-sticky],[data-no-sticky-col],.is-wide-first)>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan]))>tbody>tr[data-row-link]:focus-within>:first-child{--stick-bg:color-mix(in srgb,var(--blue) 6%,var(--sheet))}
html[data-ui][data-ui][data-ui] .main-content .table-scroll.has-overflow:not([data-no-sticky],[data-no-sticky-col],.is-wide-first)>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan]))>tbody>tr:not(.table-group-row):hover>:first-child{--stick-tint:color-mix(in srgb,var(--ink) 4.5%,transparent)}
html[data-ui][data-ui][data-ui] .main-content .table-scroll.has-overflow:not([data-no-sticky],[data-no-sticky-col],.is-wide-first)>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan]))>tbody>tr.is-previewing>:first-child{--stick-tint:color-mix(in srgb,var(--ink) 7%,transparent)}
/* 剛新增的備份紀錄會閃一下底色（platform.css）：動畫會蓋掉實心底色並停在透明，固定的第一格不閃 */
html[data-ui][data-ui][data-ui] .table-scroll.has-overflow:not([data-no-sticky],[data-no-sticky-col],.is-wide-first)>table:not(.mobile-cards,.case-table,.case-stats-table,.files-table,.audit-log,:has(tbody [rowspan]))>tbody>tr.is-fresh>:first-child{animation:none}
@media print{html[data-ui][data-ui][data-ui] .table-scroll.has-overflow:not([data-no-sticky]){max-height:none;overflow:visible}}

/* ---------- D 右側列預覽面板 ---------- */
html[data-ui][data-ui] .main-content tbody tr[data-row-link]{cursor:pointer}
.row-preview{position:fixed;top:0;right:0;bottom:0;z-index:95;display:flex;flex-direction:column;width:min(640px,100vw);background:var(--sheet);color:var(--ink);border-left:1px solid var(--rule);box-shadow:-12px 0 32px var(--shadow);transform:translateX(100%);transition:transform var(--motion-travel,180ms) cubic-bezier(.22,1,.36,1)}
.row-preview[hidden]{display:none}
.row-preview.is-open{transform:none}
.row-preview-head{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--rule);background:var(--paper)}
.row-preview-title{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--fs-body);font-weight:var(--fw-strong)}
.row-preview-head .button{flex:0 0 auto;min-height:40px}
.row-preview-body{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;padding:16px 20px 32px;outline:0}
.row-preview-body .main-content{padding:0;max-width:none;margin:0}
.row-preview-body .page-heading{margin-bottom:16px}
.row-preview-body .card{box-shadow:none}
.row-preview-note{margin:0 0 12px;color:var(--muted)}
/* 側滑頁直接載入完整頁面，可在裡面編輯與存檔（v2.138.0） */
.row-preview-body:has(>.row-preview-frame){padding:0;overflow:hidden;display:flex;flex-direction:column}
.row-preview-body>.row-preview-note{padding:16px 20px;margin:0}
.row-preview-frame{flex:1 1 auto;width:100%;min-height:0;border:0;background:var(--paper,var(--bg))}
.row-preview-frame[hidden]{display:none}
html.ui-side-resizing .row-preview-frame{pointer-events:none}
/* 頁面在側滑頁裡：只留內容，隱藏側邊選單、頂端列、手機選單背景與模組版本列 */
html[data-embedded] :is(.sidebar,.topbar,.skip-link,.menu-backdrop,.module-page-version){display:none!important}
html[data-embedded][data-embedded] .workspace{margin-left:0!important;padding-left:0!important}
html[data-embedded][data-embedded] .main-content{max-width:none;padding:20px 24px 40px}
html[data-embedded] body{min-height:0}
html[data-embedded]{--topbar-h:0px}   /* 側滑頁裡沒有頂端列：固定的表頭貼齊頂端，不留一段空白讓下面的列透出來（參考 #526） */
@media(prefers-reduced-motion:reduce){.row-preview{transition:none}}
@media(max-width:760px){.row-preview{width:100vw;border-left:0}.row-preview-body{padding:12px 14px 28px}}
@media print{.row-preview{display:none!important}}

/* 表格裡的附件卡片不可被旁邊的長文字欄擠成一個字一行：最小寬度固定，表格太寬就左右捲動 */
html[data-ui][data-ui][data-ui] td .attachment-card{min-width:var(--td-attachment-min,17rem)}
/* 手機卡片清單（v2.269.0）：table.mobile-cards 在手機上每列變成一張卡片。
   第一格 .card-title 當標題；其他格用 data-label 顯示欄名；.card-hide 只在手機隱藏（避免和標題重複）。 */
html[data-ui] table.mobile-cards .card-only{display:none}
@media (max-width:760px){
  html[data-ui][data-ui] table.mobile-cards .card-only{display:inline}
  html[data-ui][data-ui][data-ui] .table-scroll table.mobile-cards{display:block;min-width:0;width:100%}
  html[data-ui] table.mobile-cards thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  html[data-ui] table.mobile-cards tbody{display:block}
  html[data-ui] table.mobile-cards tr{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 14px;padding:14px 16px;border-top:1px solid var(--line)}
  html[data-ui] table.mobile-cards tr:first-child{border-top:0}
  html[data-ui][data-ui][data-ui] :is(table.mobile-cards,table.case-table,table.case-stats-table) td{display:block;position:static;padding:0;border:0;min-width:0;max-width:none;width:auto;height:auto;background:none;box-shadow:none}
  html[data-ui] table.mobile-cards td{font-size:var(--fs-body)}
  /* 手機卡片表與 2、3 欄的小表不撐寬，附件卡片跟著欄寬走；4 欄以上會左右捲動的表保留最小寬度（照參考 v2.522.0） */
  html[data-ui] table:where(.mobile-cards,.case-table,.case-stats-table,:not(:has(thead th:nth-child(4)))){--td-attachment-min:0}
  html[data-ui][data-ui] table.mobile-cards td.card-title{flex:0 0 100%;font-size:var(--fs-body);font-weight:var(--fw-strong)}
  html[data-ui][data-ui] table.mobile-cards td.card-hide{display:none}
  /* 簽核清單卡片（v2.525.0，DL 2026-12-02「做」P1）：第一列單號＋右邊狀態，第二列主旨，其餘是灰色小字資訊。 */
  html[data-ui] table.mobile-cards tr:has(>td.card-status)>td.card-title{order:-3;flex:1 1 0;white-space:normal;overflow-wrap:anywhere}
  html[data-ui] table.mobile-cards td.card-status{order:-2;flex:0 0 auto;margin-left:auto;text-align:right}
  html[data-ui] table.mobile-cards td.card-main{order:-1;flex:0 0 100%;font-weight:var(--fw-strong)}
  html[data-ui] table.mobile-cards td.card-meta{font-size:var(--fs-aux);color:var(--muted)}
  html[data-ui] table.mobile-cards td[data-label]:is(.card-title,.card-status,.card-main)::before{content:none}
  html[data-ui] table.mobile-cards td[data-label]::before{content:attr(data-label) '：';color:var(--muted)}
  html[data-ui] table.mobile-cards td[colspan]{flex:0 0 100%}
}
