/* S12 kit data table. Loaded after app.css (see app-shell.mjs), so these rules
   win over the older table/view rules without touching app.css. Our own
   ap- prefix throughout; the kit dt- sample was the visual reference only. */

/* ---------- views row: left-aligned compact tabs, icon + label + count ---------- */
.ap-tpage { display: grid; gap: 14px; min-width: 0; }
.ap-tpage .ap-views { min-width: 0; display: flex; align-items: center; justify-content: flex-start; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.ap-tpage .ap-views::-webkit-scrollbar { display: none; }
.ap-tpage .ap-view { position: relative; flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; margin-left: 0; padding: 6px 10px 10px; border: 0; border-radius: 8px 8px 0 0; background: none; font: 600 .86rem var(--font); color: var(--text-2); cursor: pointer; white-space: nowrap; }
.ap-tpage .ap-view .qq-ic { width: 15px; height: 15px; flex: none; }
.ap-tpage .ap-view em { font-style: normal; font-size: .72rem; font-weight: 600; padding: 2px 7px; border-radius: var(--pill); background: var(--surface-2); color: var(--text-2); font-variant-numeric: tabular-nums; }
.ap-tpage .ap-view:hover { background: var(--surface-2); color: var(--text); }
.ap-tpage .ap-view.is-on { background: none; color: var(--text); }
.ap-tpage .ap-view.is-on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.ap-tpage .ap-view.is-on em { background: var(--ink); color: var(--on-ink); }
.ap-tpage .ap-view--add { margin-left: 6px; color: var(--text-2); font-size: .84rem; }
.ap-tpage .ap-view--add:hover { background: none; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.ap-tpage .ap-view--add::after { content: none; }
.ap-tpage .ap-views__custom { display: contents; }
.ap-tpage .ap-saveview { position: relative; flex: none; }
.ap-tpage .ap-view__x { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; opacity: .7; }
.ap-tpage .ap-view__x:hover { opacity: 1; background: var(--surface-3); }

/* ---------- toolbar ---------- */
.ap-tpage .ap-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-tpage .ap-tsearch { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 170px; max-width: 360px; min-height: 38px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.ap-tpage .ap-tsearch:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.ap-tpage .ap-tsearch .qq-ic { width: 16px; height: 16px; color: var(--text-2); flex: none; }
.ap-tpage .ap-tsearch input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; color: var(--text); }
.ap-tpage .ap-fwrap { position: relative; flex: none; }
.ap-tpage .ap-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 13px; border-radius: var(--pill); border: 1px solid var(--line-2); background: var(--surface); font: 600 .84rem var(--font); color: var(--text); white-space: nowrap; cursor: pointer; }
.ap-tpage .ap-pill:hover { border-color: var(--ink); }
.ap-tpage .ap-pill .qq-ic { width: 15px; height: 15px; color: var(--text-2); }
.ap-tpage .ap-pill b { font-weight: 700; }
.ap-tpage .ap-fbtn__n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--pill); background: var(--ink); color: var(--on-ink); font-style: normal; font-size: .72rem; }
.ap-tpage .ap-fbtn__n[hidden] { display: none; }
.ap-tpage [data-grp-v] { font-weight: 700; }
.ap-tpage .ap-fbtn[aria-expanded="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.ap-tpage .ap-spacer { flex: 1 1 auto; }
.ap-tpage .ap-fclear { flex: none; }
/* joined segmented controls: no gaps between the buttons */
.ap-tpage .ap-seg { display: inline-flex; padding: 3px; gap: 2px; }
.ap-tpage .ap-seg button { display: inline-grid; place-items: center; min-width: 34px; min-height: 32px; padding: 4px 9px; border: 0; border-radius: 8px; background: none; color: var(--text-2); cursor: pointer; }
.ap-tpage .ap-seg button .qq-ic { width: 16px; height: 16px; }
.ap-tpage .ap-seg button:hover { color: var(--text); }
.ap-tpage .ap-seg button.is-on { background: var(--ink); color: var(--on-ink); }
.ap-tpage .ap-toolbar > .qq-iconbtn { width: 36px; height: 36px; flex: none; }
.ap-tpage .ap-fwrap > .qq-iconbtn { width: 36px; height: 36px; }
.ap-tpage [data-refresh].is-spin .qq-ic { animation: ap-spin .7s linear; }
@keyframes ap-spin { to { transform: rotate(360deg); } }
.ap-tpage .ap-menu--grp { width: 220px; }
.ap-tpage .ap-menu--xp { left: auto; right: 0; width: 200px; }
.ap-tpage .ap-menu--grp .ap-menu__it[aria-checked="true"] { font-weight: 700; background: var(--surface-2); }

/* ---------- chips ---------- */
.ap-tpage .ap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-tpage .ap-chips[hidden] { display: none; }

/* ---------- table card + grid ---------- */
.ap-tpage .ap-tablewrap { min-width: 0; }
.ap-tpage .ap-table { position: relative; padding: 0; overflow: clip; border-radius: 18px; }
.ap-tpage .ap-tr { display: grid; grid-template-columns: var(--ap-cols); align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: .88rem; }
.ap-tpage .ap-tr[hidden] { display: none; }
.ap-tpage .ap-th { border-top: 0; background: var(--surface-2); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.ap-tpage .ap-tr:not(.ap-th):hover { background: var(--bg-2); }
.ap-tpage .ap-tr.is-sel { background: var(--accent-soft); }
.ap-tpage .ap-table .ap-tr[data-href] { cursor: pointer; }
.ap-tpage .ap-table.is-compact .ap-tr { padding-top: 5px; padding-bottom: 5px; font-size: .82rem; }
.ap-tpage .ap-table.is-compact .ap-thumb { width: 30px; }
.ap-tpage .ap-tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ap-tpage .ap-act { opacity: 0; transition: opacity .15s; }
.ap-tpage .ap-tr:hover .ap-act, .ap-tpage .ap-tr:focus-within .ap-act { opacity: 1; }
@media (hover: none) { .ap-tpage .ap-act { opacity: 1; } }

/* ---------- group headers ---------- */
.ap-tpage .ap-gh { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 4px 12px; border: 0; border-top: 1px solid var(--line); background: var(--surface-2); font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.ap-tpage .ap-gh .qq-ic { width: 14px; height: 14px; color: var(--text-2); transition: transform .2s; }
.ap-tpage .ap-gh.is-closed .qq-ic { transform: rotate(-90deg); }
.ap-tpage .ap-gh b { font-weight: 700; font-size: .86rem; }
.ap-tpage .ap-gh em { font-style: normal; font-size: .72rem; font-weight: 600; padding: 2px 7px; border-radius: var(--pill); background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums; }
.ap-tpage .ap-gh:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- list / cards / board ---------- */
.ap-tpage .ap-alt[hidden] { display: none; }
.ap-tpage[data-layout="list"] .ap-table > .ap-tr,
.ap-tpage[data-layout="cards"] .ap-table > .ap-tr,
.ap-tpage[data-layout="board"] .ap-table > .ap-tr,
.ap-tpage[data-layout="list"] .ap-table > .ap-gh,
.ap-tpage[data-layout="cards"] .ap-table > .ap-gh,
.ap-tpage[data-layout="board"] .ap-table > .ap-gh { display: none; }
.ap-tpage[data-layout="list"] [data-density],
.ap-tpage[data-layout="cards"] [data-density],
.ap-tpage[data-layout="board"] [data-density] { display: none; }
.ap-tpage[data-layout="board"] .ap-tfoot { display: none; }
/* list rows */
.ap-tpage .ap-alt--list { display: grid; }
.ap-tpage .ap-li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.ap-tpage .ap-li:first-child { border-top: 0; }
.ap-tpage .ap-li:hover { background: var(--bg-2); }
.ap-tpage .ap-li.is-sel { background: var(--accent-soft); }
.ap-tpage .ap-li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ap-tpage .ap-li__m { display: grid; gap: 2px; min-width: 0; }
.ap-tpage .ap-li__meta { color: var(--text-2); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* cards */
.ap-tpage .ap-alt--cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 14px; background: var(--bg-2); border-top: 1px solid var(--line); }
.ap-tpage .ap-card { display: grid; gap: 10px; align-content: start; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; min-width: 0; }
.ap-tpage .ap-card:hover { border-color: var(--line-2); box-shadow: var(--sh-1); }
.ap-tpage .ap-card.is-sel { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.ap-tpage .ap-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-tpage .ap-card__h { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-width: 0; }
.ap-tpage .ap-card__dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 0; }
.ap-tpage .ap-card__dl dt { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.ap-tpage .ap-card__dl dd { margin: 2px 0 0; font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-tpage .ap-card__f { display: flex; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
/* board */
.ap-tpage .ap-alt--board { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: var(--bg-2); border-top: 1px solid var(--line); overflow-x: auto; }
.ap-tpage .ap-bcol { flex: 0 0 272px; max-width: 272px; display: grid; gap: 8px; align-content: start; padding: 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.ap-tpage .ap-bcol__h { display: flex; align-items: center; gap: 8px; padding: 2px 4px 6px; }
.ap-tpage .ap-bcol__h b { font-size: .86rem; }
.ap-tpage .ap-bcol__h em { font-style: normal; margin-left: auto; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: var(--pill); background: var(--surface); border: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.ap-tpage .ap-bcard { display: grid; gap: 6px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.ap-tpage .ap-bcard:hover { border-color: var(--line-2); box-shadow: var(--sh-1); }
.ap-tpage .ap-bcard.is-sel { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.ap-tpage .ap-bcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ap-tpage .ap-bcard__meta { color: var(--text-2); font-size: .78rem; }
.ap-tpage .ap-bcard__f { display: flex; align-items: center; gap: 8px; }
.ap-tpage .ap-bempty { padding: 12px; text-align: center; color: var(--text-2); font-size: .8rem; border: 1px dashed var(--line-2); border-radius: 12px; }

/* ---------- empty states ---------- */
.ap-tpage .ap-empty { display: grid; justify-items: center; gap: 6px; padding: 34px 16px; text-align: center; color: var(--text-2); }
.ap-tpage .ap-empty[hidden] { display: none; }
.ap-tpage .ap-empty b { color: var(--text); font-size: 1rem; }
.ap-tpage .ap-empty p { margin: 0; font-size: .86rem; max-width: 44ch; }
.ap-tpage .ap-empty--full { padding: 48px 16px; gap: 8px; }
.ap-tpage .ap-empty--full .qq-img { width: min(320px, 100%); }

/* ---------- calculation row ---------- */
.ap-tpage .ap-calc { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 9px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: .8rem; color: var(--text-2); }
.ap-tpage .ap-calc[hidden] { display: none; }
.ap-tpage .ap-calc__n { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); }
.ap-tpage .ap-calc__n .qq-ic { width: 14px; height: 14px; color: var(--text-2); }
.ap-tpage .ap-calc button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 6px; border-radius: 8px; font: inherit; color: inherit; cursor: pointer; }
.ap-tpage .ap-calc button:hover { background: var(--surface-3); color: var(--text); }
.ap-tpage .ap-calc button b { color: var(--text); font-variant-numeric: tabular-nums; }
.ap-tpage .ap-calc button small { font-size: .72rem; }

/* ---------- pager ---------- */
.ap-tpage .ap-tfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--text-2); font-size: .86rem; }
.ap-tpage .ap-tfoot > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ap-tpage .ap-tfoot .qq-iconbtn { width: 32px; height: 32px; }
.ap-tpage .ap-psize { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; }
.ap-tpage [data-psize-btn] { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font: inherit; font-weight: 600; color: var(--text); cursor: pointer; }
.ap-tpage [data-psize-btn] .qq-ic { width: 13px; height: 13px; color: var(--text-2); }
.ap-tpage [data-psize-btn][aria-expanded="true"] { border-color: var(--ink); }
.ap-tpage .ap-menu--psize { left: auto; right: 0; top: auto; bottom: calc(100% + 6px); width: 90px; }
.ap-tpage .ap-menu--psize .ap-menu__it.is-on { font-weight: 700; background: var(--surface-2); }
.ap-tpage .ap-tfoot [data-pages] { display: inline-flex; gap: 4px; }
.ap-tpage .ap-tfoot [data-pages] button { min-width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; font: inherit; cursor: pointer; color: var(--text-2); }
.ap-tpage .ap-tfoot [data-pages] button:hover { background: var(--surface-2); color: var(--text); }
.ap-tpage .ap-tfoot [data-pages] button.is-on { background: var(--ink); color: var(--on-ink); font-weight: 700; }
.ap-tpage .ap-pagesall { display: inline-grid; place-items: center; min-height: 32px; padding: 0 10px; font-size: .8rem; color: var(--text-2); }

/* ---------- bulk bar: floating pill, kit-danger delete ---------- */
.ap-tpage .ap-bulk { position: fixed; top: auto; bottom: 84px; left: calc(50% + 126px); transform: translateX(-50%); z-index: 70; width: max-content; max-width: calc(100vw - 32px); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-radius: var(--pill); background: var(--ink); color: var(--on-ink); box-shadow: var(--sh-3); }
.ap-tpage .ap-bulk[hidden] { display: none; }
.ap-tpage .ap-bulk > b { font-size: .84rem; padding-right: 8px; border-right: 1px solid rgba(255, 255, 255, .2); white-space: nowrap; }
.ap-tpage .ap-bulk button { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, .2); border-radius: var(--pill); background: none; color: inherit; font: 600 .82rem var(--font); cursor: pointer; white-space: nowrap; }
.ap-tpage .ap-bulk button .qq-ic { width: 14px; height: 14px; }
.ap-tpage .ap-bulk button:hover { background: rgba(255, 255, 255, .1); }
.ap-tpage .ap-bulk .is-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.ap-tpage .ap-bulk .is-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.ap-tpage .ap-bulk__x { border: 0; padding: 0 8px; }
:root[data-theme="dark"] .ap-tpage .ap-bulk { background: #fff; color: #0a0a0a; }
:root[data-theme="dark"] .ap-tpage .ap-bulk > b { border-right-color: rgba(0, 0, 0, .16); }
:root[data-theme="dark"] .ap-tpage .ap-bulk button { border-color: rgba(0, 0, 0, .2); }
:root[data-theme="dark"] .ap-tpage .ap-bulk button:hover { background: rgba(0, 0, 0, .06); }
:root[data-theme="dark"] .ap-tpage .ap-bulk .is-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
@media (max-width: 960px) { .ap-tpage .ap-bulk { left: 50%; } }

/* ---------- row menu / confirm inherit app.css; keep them above the bar ---------- */
.ap-tpage .ap-menu--ctx { z-index: 80; }
.ap-tpage .ap-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.ap-tpage .ap-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

/* ---------- responsive: page actions never overlap the table ---------- */
.ap-tpage .ap-tablewrap { overflow-x: auto; scrollbar-width: thin; }
@media (max-width: 1180px) {
  .ap-tpage .ap-table { min-width: 980px; }
  .ap-tpage .ap-tsearch { max-width: 300px; }
}
@media (max-width: 960px) {
  .ap-tpage .ap-table { min-width: 720px; }
  .ap-tpage .ap-tsearch { flex: 1 1 160px; }
}
@media (max-width: 640px) {
  .ap-tpage .ap-toolbar { gap: 6px; }
  .ap-tpage .ap-tsearch { flex: 1 1 100%; max-width: none; }
  .ap-tpage .ap-spacer { display: none; }
  .ap-tpage .ap-table { min-width: 0; }
  .ap-tpage .ap-table > .ap-tr { min-width: 0; }
  .ap-tpage .ap-menu--grp, .ap-tpage .ap-menu--xp { position: fixed; left: 16px; right: 16px; top: 120px; width: auto; }
  .ap-tpage .ap-alt--cards { grid-template-columns: 1fr; }
  .ap-tpage .ap-li { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .ap-tpage .ap-li .ap-li__st { display: none; }
  .ap-tpage .ap-calc { font-size: .76rem; gap: 6px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .ap-tpage [data-refresh].is-spin .qq-ic { animation: none; }
  .ap-tpage .ap-gh .qq-ic { transition: none; }
}

/* Phones: keep row actions reachable alongside the overflow menu. */
@media (max-width: 640px) {
  .ap-tpage .ap-table > .ap-tr, .ap-tpage .ap-table .ap-tr { grid-template-columns: 28px minmax(0, 1fr) auto auto max-content !important; column-gap: 8px; }
  .ap-tpage .ap-tr > .ap-act { width: auto; justify-content: flex-end; opacity: 1; }
  .ap-tpage .ap-tr > .ap-name { min-width: 0; }
  .ap-tpage .ap-tr > .ap-name > span { min-width: 0; overflow: hidden; }
  .ap-tpage .ap-tr > .ap-name b, .ap-tpage .ap-tr > .ap-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
