/* THE ONE GRID (D520). Every table of rows in the store is drawn by this one rule set: `.grid` (the data grid, `backstore-grid.js`) and, until the screens that still build their own table move onto
   the data grid, its three old names `.txn` (Transactions, Customers' panel and the customer's own lists), `.cust-table` (Customers) and `.accounts-table` (Accounts), which are aliases here and keep
   only their density. Loaded on every page (the customer's lists use `.txn`).
   Tokens only: a header on `--surface-2` in `--ink-2`, a row `--accent-2` under the pointer, a selected row `--accent-2` with a 3 px `--brand` rule at its left, rows 44 px (`.dense`: 32 px). */

/* The toolbar above a grid: search, filters, Clear filters, the screen's own buttons, Export CSV. */
.grid-filters { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin: .5rem 0 1rem; }
/* The toolbar is Search, one "Filters" button (the number in use beside it), the screen's own tools, Export CSV at the right (D1247). The filters themselves open in a panel under the row. */
.grid-filters :is(label.search, .grid-search-label) { flex: 1 1 22rem; max-width: 34rem; display: block; margin: 0; }
.grid-filters :is(label.search, .grid-search-label) input { width: 100%; min-width: 9rem; }
.grid-filters > .grid-export { margin-left: auto; }
.grid-filters > .cust-copy ~ .grid-export { margin-left: 0; }
.grid-filters-toggle { display: inline-flex; align-items: center; gap: .5rem; }
.grid-filters-toggle::after { content: ""; width: .4em; height: .4em; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-.1em) rotate(45deg); }
.grid-filters-toggle[aria-expanded=true]::after { transform: translateY(.1em) rotate(-135deg); }
.grid-filter-count { min-width: 1.5rem; padding: 0 .4rem; font-size: .85rem; line-height: 1.5rem; text-align: center; color: #fff; background: var(--brand); border-radius: 99px; }
.grid-filter-count[hidden] { display: none; }
.grid-filters-panel { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem 1.5rem; margin: 0 0 1rem; padding: 1rem; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 6px; }
.grid-filters-panel[hidden] { display: none; }
.grid-filters-panel .grid-filter { flex: 1 1 8rem; max-width: 14rem; }
.grid-filters-panel .order-period { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem 1rem; }
.grid-filter-set { display: contents; }
.grid-filters label { display: grid; gap: .15rem; margin: 0; font-size: .85rem; color: var(--ink-2); }
.grid-filter { display: grid; gap: .15rem; min-width: 0; flex: 1 1 9rem; max-width: 18rem; align-content: start; }
.grid-filter-label { font-size: .85rem; color: var(--ink-2); }
.grid-filters input[type=search], .grid-filters input[type=number], .grid-filters select { width: 100%; box-sizing: border-box; padding: .4rem .5rem; font: inherit; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); }
/* Filters sit on ONE row and wrap only when they must (WCAG 1.4.10): a select or search the screen puts straight into the bar is as wide as its words, not the whole row. */
.grid-filters > select { width: auto; flex: 0 1 8.5rem; min-width: 7rem; }
/* A cell breaks only when its whole value cannot fit on a line: `.staff td` lets any letter break, which squeezed an email to four characters a line (the audit, 2026-11-09). The grid's box scrolls instead. */
table.grid td { overflow-wrap: break-word; word-break: normal; }
.grid-filters input.grid-search { min-width: 14rem; }

/* The bar that takes the toolbar's place while rows are ticked: "3 selected . actions . Clear". */
.grid-batch { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0; padding: .4rem .75rem; background: var(--accent-2); border: 1px solid var(--fill); border-left: 3px solid var(--brand); border-radius: 6px; }
.grid-batch-count { font-weight: 700; color: var(--accent-tx); }
.grid-page { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem; margin: .5rem 0; }
.grid-page-label { margin-right: .5rem; color: var(--ink-2); }
.grid-page select { width: auto; }

.grid-wrap { background: var(--surface); overflow-x: auto; max-width: 100%; border: 1px solid var(--rule); border-radius: 6px; }
.txn-wrap { overflow-x: auto; }

/* The table. */
:is(.grid, .txn, .cust-table, .accounts-table) { width: 100%; border-collapse: collapse; }
:is(.grid, .txn, .cust-table, .accounts-table) :is(th, td) { text-align: left; padding: .5rem .6rem; border-top: 1px solid var(--rule); vertical-align: top; }
:is(.grid, .txn, .cust-table, .accounts-table) th { font-size: .85rem; color: var(--ink-2); border-top: 0; background: var(--surface-2); }
:is(.grid, .txn, .cust-table, .accounts-table) th .link-row { font: inherit; font-weight: 600; color: inherit; padding: 0; background: none; border: 0; cursor: pointer; }
:is(.grid, .txn, .cust-table, .accounts-table) .num { text-align: right; white-space: nowrap; }
:is(.grid, .txn, .cust-table, .accounts-table) tbody tr:not(.editing):hover > td { background: var(--accent-2); }
:is(.grid, .txn, .cust-table, .accounts-table) :is(tr.selected, tr.chosen) > td { background: var(--accent-2); }
.grid tr.chosen { cursor: pointer; }
.grid tbody tr[class*=chosen] strong, .grid tr.chosen strong { color: var(--accent-tx); }
:is(.grid, .txn, .cust-table, .accounts-table) :is(tr.selected, tr.chosen) > td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.grid { margin: .75rem 0; }
.grid-wrap > .grid { margin: 0; }
.grid th { white-space: nowrap; }
/* A column name is never broken inside a word and a column is as wide as its name (D692): `.staff` lets any word break and `.staff button` lets a button wrap, which cut "People" and "Instruments" in two. */
.grid thead :is(th, th .link-row) { overflow-wrap: normal; word-break: keep-all; hyphens: none; white-space: nowrap; max-width: none; }
.grid thead th { min-width: min-content; }
/* The header row stays in view (D692): `backstore-grid.js` moves the cells down while the page scrolls. Above the rows and their sticky first columns, below the menus (20), the bars and the dialogs. */
.grid thead th { position: relative; z-index: 3; box-shadow: 0 1px 0 var(--rule), 0 2px 4px rgb(0 0 0 / 8%); }
.grid thead th.grid-select, .grid thead th.grid-actions { position: sticky; z-index: 4; }
.grid td { height: 2.75rem; vertical-align: middle; }
.grid.dense td { height: 2rem; padding-top: .25rem; padding-bottom: .25rem; }
.grid th .link-row { display: inline-flex; flex-direction: row; width: auto; }
.grid th[aria-sort="none"] .link-row::after { content: "\2195"; margin-left: .3rem; opacity: .45; }
.grid .state { white-space: nowrap; }
.grid td .link-row { width: auto; display: inline-block; padding: 0; border: 0; margin: 0; }
.grid .wrapping { min-width: 10rem; max-width: 22rem; }
.grid td .muted { font-size: .8rem; }
.grid tr.inactive td { color: var(--muted); }
.grid .tree-cell { display: inline-block; }
.grid .tree-mark { color: var(--muted); }
.grid tr.tree-context td { color: var(--muted); }          /* a parent shown only to keep a match under it (D751) */
.grid tr.tree-context strong { font-weight: 500; }
.grid tr.editing > td { background: var(--surface-2); padding: .6rem; }
.grid tr.editing form.stack { max-width: 44rem; margin: 0; }
.txn td:first-child { white-space: nowrap; }
.txn td:first-child .link-row { display: block; width: auto; text-align: left; padding: 0; border: 0; }       /* in a table the cell has the padding and the row has the rule: the name sits on the row's line like the other columns */

/* The first column stays in view when the table scrolls sideways: the checkbox. */
.grid .grid-select { position: sticky; left: 0; z-index: 1; width: 2.75rem; padding-right: 0; background: var(--surface); }
.grid th.grid-select { background: var(--surface-2); }
/* A tick box is a 24 px target (WCAG 2.5.8): the box is drawn at that size in every grid, in the header and in each row. */
.grid .grid-select input[type=checkbox] { width: 1.5rem; height: 1.5rem; margin: 0; cursor: pointer; }
.grid td.grid-menu-cell { width: 2.5rem; text-align: right; white-space: nowrap; }

/* The "..." menu at the right of a row. */
.grid-menu { position: relative; display: inline-block; }
.grid-menu > summary { list-style: none; cursor: pointer; min-width: 2rem; min-height: 2rem; line-height: 2rem; text-align: center; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); }
.grid-menu > summary::-webkit-details-marker { display: none; }
.grid-menu-list { position: absolute; right: 0; z-index: 20; min-width: 11rem; margin: 2px 0 0; padding: .3rem; list-style: none; text-align: left; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 6px 18px rgb(0 0 0 / 14%); }
.grid-menu-list button { width: 100%; text-align: left; }

/* The old names keep their density, which the screens that still use them were drawn with. */
.accounts-table { font-size: .85rem; }
.accounts-table th, .accounts-table td { padding: .4rem .4rem; vertical-align: middle; }
.accounts-table td:not(:first-child) { white-space: nowrap; }
.accounts-table td:first-child { min-width: 11rem; }

/* A file chooser with its name above it (the software upload): a visible label and a bordered button, not a bare input. */
.file-field { display: grid; gap: .25rem; margin: 0 0 .75rem; }
.file-label { font-weight: 600; color: var(--ink); }
input.file-pick { padding: .4rem; font: inherit; background: var(--surface); border: 1px dashed var(--rule); border-radius: 6px; }
input.file-pick::file-selector-button { margin-right: .75rem; padding: .35rem .8rem; font: inherit; color: var(--accent-tx); background: var(--accent-2); border: 1px solid var(--fill); border-radius: 6px; cursor: pointer; }

/* A long cell is one line with an ellipsis; "Show details" opens the whole text under the row (backstore-grid-more.js, D705). */
.grid .grid-long { display: block; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .grid-more { width: 2.75rem; padding: 0; text-align: center; }
.grid-more-toggle { min-width: 2rem; min-height: 2rem; padding: 0; font-size: 1.25rem; line-height: 1; color: var(--accent-tx); background: none; border: 0; border-radius: 6px; cursor: pointer; transition: transform .15s; }
.grid-more-toggle[aria-expanded=true] { transform: rotate(90deg); }
@media (pointer: coarse) { .grid-more-toggle { min-width: 44px; min-height: 44px; } }
.grid tr.grid-detail > td { height: auto; background: var(--surface-2); }
.grid-detail-box { position: sticky; left: 0; display: grid; gap: .5rem; width: min(60rem, 88vw); padding: .25rem 0 .25rem 2.75rem; }
.grid-detail-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* A heading that follows a grid starts a new block: room above it (the owner's screenshot of KPM Employees, 2026-11-03: "put a space between the account and people section"). */
h3.after-a-grid { margin-top: 2.25rem; }
