/* CRM library, file 7 of 7: data. Loaded after lib/timeline.css and directly before app.css, the stylesheet of the pages.

   Belongs here: the table (crm-table, and crm-mini-table on a card of a record) with its head, its cells and the bar above it
   (crm-dt-*), the density of a table (cell padding from the density tokens, the .end alignment, the footer row), a cell with a line
   under it (crm-cell), a column of codes, the narrow table (columns that drop and a lead column that takes the room that is left) and
   the table of a phone. The board is not here yet. The sticky name and checkbox columns of the lists (crm-th-name, crm-td-select)
   and the card of a list page (crm-table-card) are app.css, with the lists.

   Contract: a base rule is ONE class, a modifier two, descendant parts go inside :where(); no id, no element selector, no @layer.
   Widths are the three breakpoints in @media and 24, 40, 48 or 64rem in @container, both written as a range; what a page adjusts
   is a --k-* knob or a rule in context, and a class that moves here loses its rule in app.css in the same commit. */

/* ── The table ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   Every table is crm-table (createDataTable of components/data-table.js, the list table of pages/list/table.js) or crm-mini-table
   (createDataTable({ mini: true }) on a card of a record); they moved here from app.css on 18-11-2026, when Marley found the tables
   "niet zo netjes": the small table had its own head (normal case next to the capitals of the lists), its own lines, a frame of its
   own inside its card and text over two lines. Now both are one table:
     the head        one look on every table: small capitals in the muted ink on the sunken band, a strong line under it, never a
                     second line, and never the face of its cells (a code column is mono in its cells only); it stays at the top
                     of the scroll box
     a cell          one line: a text is cut off (with its whole text as its title, components/data-table.js), a figure is never
                     cut; a line between the rows, the row under the pointer a step darker
     the scroll box  crm-table-wrap scrolls both ways (a list fills its card and only the box scrolls); crm-mini-wrap has no frame:
                     a small table always stands in a card, and a frame in a card is a card in a card
   A cell and a head are found inside :where(), so the rule weighs one class and a page rule in context (`.crm-ac-table td`) or on a
   column of its own (`.crm-th-select`) wins. */
.crm-table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; outline: none; }
.crm-mini-wrap { overflow: auto; outline: none; }
.crm-table, .crm-mini-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-md); }
.crm-table :where(th), .crm-mini-table :where(th) { position: sticky; top: 0; z-index: 3; background: var(--surface-2); color: var(--muted); border-bottom: 1px solid var(--line-strong);
  font-family: inherit; font-size: var(--fs-2xs); font-weight: var(--crm-fw-bold); letter-spacing: var(--crm-track-caps); text-align: left; text-transform: uppercase; white-space: nowrap; vertical-align: middle; }
.crm-table :where(td), .crm-mini-table :where(td) { max-width: 22rem; background: var(--surface); border-bottom: 1px solid var(--line-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.crm-table :where(tbody tr:hover td), .crm-mini-table :where(tbody tr:hover td) { background: var(--surface-2); }
.crm-table :where(tbody tr.on td) { background: var(--blue-soft); }
/* a table that stands in a card already (createDataTable without bare inside createCard, the stock of a record until 18-11-2026) is
   the card's: its own card loses its frame, so there is never a card in a card */
:where(.crm-card-body) .crm-card-table { border: 0; border-radius: 0; box-shadow: none; }

/* The head of a column that sorts: a button with the label and the arrow; the arrow shows on hover and focus, and stays on the column
   that is sorted on (in the blue). In a column of figures the arrow stands before the label, so the label ends where the figures end. */
.crm-th-btn { display: inline-flex; align-items: center; gap: var(--sp-1); padding: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; white-space: nowrap; vertical-align: middle; cursor: pointer; }
.crm-th-btn:hover, .crm-th-btn.on { color: var(--ink); }
.crm-sort-icon { font-size: var(--crm-icon-xs); opacity: 0; transition: opacity var(--crm-dur-fast); }
:where(.crm-th-btn:hover, .crm-th-btn:focus-visible) > .crm-sort-icon { opacity: .55; }
:where(.crm-th-btn.on) > .crm-sort-icon { opacity: 1; color: var(--blue); }
@media (hover: none) { :where(.crm-th-btn:not(.on)) > .crm-sort-icon { opacity: .45; } }
:where(.crm-table, .crm-mini-table) :where(th.end) > .crm-th-btn { flex-direction: row-reverse; }

/* ── The bar above a table ───────────────────────────────────────────────────────────────────────────────────────────────────────
   crm-dt-host holds the bar (Kolommen, and "Weergave aangepast" with Opslaan) and the table. Under a toolbar the bar goes into the
   end of the toolbar (detachBar; the Kolommen there is a toolButton() next to Exporteren), so there is one bar and not a second row
   with one button; it is as high as the rest of the toolbar there. */
.crm-dt-host { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.crm-dt-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2); min-height: 2rem; }
.crm-dt-state { color: var(--muted); font-size: var(--fs-sm); }
:where(.crm-toolbar-end .crm-dt-bar) > .btn { min-height: var(--crm-ctl-h); }

/* ── The density of a table ──────────────────────────────────────────────────────────────────────────────────────────────────────
   What every table shares and what follows the density of where it stands:
     the room of a cell   --crm-row-y above and under, --crm-cell-x left and right (lib/tokens.css), so a table inside
                          [data-density="compact"] (createCard({ density: 'compact' })) is a step tighter without a rule of its own
     .end                 a column of figures: at the right, the digits one width, never over two lines (a column gets it with
                          align: 'end'); it was a class `num` with a rule per page
     the footer row       the totals (table.setFooter(row)): a line above it and bold; it was three looks on three pages
   A cell is found inside :where(), so the rule weighs one class and a page rule on a cell of its own (`.crm-th-select`) wins. */
.crm-table :where(th, td), .crm-mini-table :where(th, td) { padding: var(--crm-row-y) var(--crm-cell-x); }
/* a text cut off in a cell (crm-truncate with the whole text as its title, 18-11-2026): one line up to --k-max, not a cell that grows */
:where(.crm-table, .crm-mini-table) :where(td) > .crm-truncate { display: block; max-width: var(--k-max, 24rem); }
.crm-table :where(th, td).end, .crm-mini-table :where(th, td).end { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.crm-table :where(tfoot td), .crm-mini-table :where(tfoot td) { border-top: 2px solid var(--line); font-weight: var(--crm-fw-bold); }

/* A row that folds open (createDataTable({ expand }), 10-11-2026): the chevron first, as narrow as a control; the row under it holds
   what folds open over the whole width, on the sunken band, and its text runs over as many lines as it needs. */
.crm-dt :where(.crm-dt-toggle) { width: 2.5rem; padding-right: 0; }
.crm-dt :where(tr.crm-dt-open > td) { border-bottom-color: transparent; }
.crm-dt :where(tr.crm-dt-detail > td) { max-width: none; padding: var(--sp-2) var(--sp-5) var(--sp-5) 3.25rem; background: var(--surface-2); white-space: normal; }

/* ── A cell ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   crm-cell (cellLines() of components/data-table.js, 18-11-2026; review 12-11 asked for it): a main line with a small line under
   it, a name over its EAN and kind, an amount over its unit ("13.000 stuks" over "52 dozen"). Before, the two stood glued on one
   line. Each line is one line, cut off with its whole text as its title; in a column of figures both stand at the right.
   A column of codes (code: true; an EAN, an order number, a ticket): the mono face with figures of one width, in the weight of the
   text around it; a link in it is told by the colour of a link alone (it was blue and bold next to plain codes), and keeps the
   underline under the pointer and the focus ring of crm-link. The rule weighs two classes, as `.crm .crm-link` does, and is later. */
.crm-cell { display: flex; flex-direction: column; min-width: 0; max-width: var(--k-max, 24rem); line-height: 1.3; }
:where(.crm-cell) > :where(.crm-cell-main, .crm-cell-sub) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:where(.end) > .crm-cell { align-items: flex-end; margin-left: auto; }
.crm-table :where(td.code), .crm-mini-table :where(td.code) { font-family: var(--crm-font-mono); font-variant-numeric: tabular-nums; }
.crm-dt :where(td.code) .crm-link { font-weight: inherit; }

/* ── A narrow table ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
   A table follows the width of the box it stands in (createDataTable measures it; Marley 18-11-2026: in a card of the middle
   column of a record the last column was cut off, with a scroll bar). Under 64rem the table is `narrow`: the lead column
   (data-fit="lead") takes the room that is left and cuts its text off, its head too, so the other columns keep their whole value
   and nothing is cut at the right edge. The columns with priority 4 drop there, under 48rem those with 3 too, under 40rem those
   with 2 (in the default view; Kolommen shows them unticked). The lead keeps at least 8rem: in a box too narrow for the rest the
   table scrolls rather than lose its name. */
.crm-table.narrow :where([data-fit="lead"]), .crm-mini-table.narrow :where([data-fit="lead"]) { width: 100%; min-width: 8rem; max-width: 0; }
:where(.crm-table.narrow, .crm-mini-table.narrow) :where(th[data-fit="lead"]) :where(.crm-th-btn, .crm-th-label) { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* ── A table on a phone ──────────────────────────────────────────────────────────────────────────────────────────────────────────
   Under 40rem a table with phone columns (the option phone of a column: config/columns.js for the lists, createDataTable for the rest;
   Marley 12-11-2026; the small table of a card too, since 18-11-2026: the tabs of Member 360) shows those, and the table is `phone`: it fits the screen instead of scrolling sideways. The script sets that
   class only on a phone (isPhone() of dom.js), so these rules need no @media, and the gallery can show one at any width. Every cell says its
   role in data-phone: `ctl` is a control (the checkbox, the tick of a task, the chevron of a row that folds open) at the width of a
   touch target, `fit` is as wide as what it holds up to --k-fit and cuts off the rest, `lead` (the name, the subject) takes the room
   that is left, its name or subject (a link, or the main line of a crm-cell) over at most two lines (a long word is hyphenated, or breaks where it must), and no longer
   sticks to the left: there is nothing to scroll past. The head of a column is short there (the option short of a list column:
   "Eigenaar" over a column of faces) and ends in an ellipsis if it is still too long, the arrow of a column that is not sorted on
   is gone, and a cell has less room at its sides. */
.crm-table.phone, .crm-mini-table.phone { --k-fit: 10rem; }
.crm-table.phone :where(th, td), .crm-mini-table.phone :where(th, td) { min-width: 0; max-width: var(--k-fit); padding-inline: var(--sp-2); }
.crm-table.phone :where(th[data-phone="fit"]) :where(.crm-th-btn, .crm-th-label), .crm-mini-table.phone :where(th[data-phone="fit"]) :where(.crm-th-btn, .crm-th-label) { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.crm-table.phone :where(.crm-th-btn:not(.on)) > :where(.crm-sort-icon), .crm-mini-table.phone :where(.crm-th-btn:not(.on)) > :where(.crm-sort-icon) { display: none; }
.crm-table.phone :where([data-phone="ctl"]), .crm-mini-table.phone :where([data-phone="ctl"]) { width: 2.75rem; }
.crm-table.phone :where([data-phone="lead"]), .crm-mini-table.phone :where([data-phone="lead"]) { position: static; width: 100%; max-width: 0; border-right: 0; }
.crm-table.phone :where([data-phone="fit"]), .crm-mini-table.phone :where([data-phone="fit"]) { width: 1%; }
.crm-table.phone :where(td[data-phone="lead"]) :where(.crm-link, .crm-cell-main), .crm-mini-table.phone :where(td[data-phone="lead"]) :where(.crm-link, .crm-cell-main) { display: -webkit-box; overflow: hidden; white-space: normal; overflow-wrap: anywhere; hyphens: auto; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
