/* Apps reuse the Desk's app cards, list and record form; only these are their own. */
#data .page-actions input[type="search"] { width: 260px; }
.apps-grid { margin-top: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.apps-card { align-items: stretch; justify-content: flex-start; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.apps-card .app-card-heading { margin-bottom: 0; align-items: center; }
.apps-card h2 { font-size: 15px; margin: 0; }
.apps-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
/* An app's menu sections stay cards, though a record list is now an unframed toolbar and table. */
.list-card.apps-menu { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.apps-menu h3 { margin: 0 0 10px; font-size: 14px; }
.apps-menu .app-pages { margin: 0; }
.apps-report { opacity: .7; cursor: default; }
.apps-link { display: block; }
.apps-link input { width: 100%; }
.app-nav-mark { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: var(--radius-sm); background: var(--mark); color: #fff; font-size: 10px; font-weight: 700; line-height: 1; flex: none; }
.recent-card .recent-card-heading { display: flex; align-items: center; gap: 10px; }
/* A file field: its file as a chip that downloads it, then the buttons that change it. Laid out
   like a label, without being one, so its name never opens a picker. */
.file-field { margin: 14px 0; color: var(--ink); font-size: 14px; font-weight: 500; }
.file-control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-weight: 400; }
.file-control > button { min-height: 36px; }
.file-chip { max-width: 100%; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.file-chip:hover { background: var(--surface-low); }
.file-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .icon { color: var(--muted); }
.file-empty { color: var(--muted); font-size: 13px; }
/* The import dialog: the shared modal and its transfer styles, and these. */
.import-kind { margin: 0; padding: 0; border: 0; }
.import-kind .transfer-check { margin: 0 16px 0 0; display: inline-flex; }
.import-kind input[type="radio"] { width: auto; box-shadow: none; }
.transfer-preview .import-field { color: var(--accent); font-size: 12px; font-weight: 500; }
.transfer-preview .import-skipped { color: var(--muted); font-size: 12px; font-style: italic; }
.transfer-preview thead th { background: var(--surface-low); }
.file-note { flex-basis: 100%; margin-top: 0; }
/* The browser's own file button, dressed as one of the Desk's. */
.transfer-field input[type="file"] { padding: 4px; }
.transfer-field input[type="file"]::file-selector-button { margin-right: 10px; padding: 5px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.transfer-field input[type="file"]::file-selector-button:hover { background: var(--surface-low); }

/* ---- The record list (docs/designs/record-lists-and-forms.md): the Ask box, the view pills, the
   chips line that is the address, the add-filter row, and column heads that sort. Every colour
   is an existing token, so dark mode follows. */
.list-toolbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 0; }
.ask-box { flex: 1 1 auto; width: 100%; }
.ask-box input { width: 100%; min-height: 36px; }
.ask-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: var(--accent); transform: scaleX(0); transform-origin: left; opacity: 0; pointer-events: none; }
.ask-box.is-asking .ask-progress { opacity: 1; animation: ask-progress 1.2s ease-in-out infinite; }
@keyframes ask-progress { 0% { transform: scaleX(0); transform-origin: left; } 50% { transform: scaleX(1); transform-origin: left; } 51% { transform-origin: right; } 100% { transform: scaleX(0); transform-origin: right; } }
.ask-line { min-height: 0; margin: 0; color: var(--muted); font-size: 13px; }
.ask-line:empty { display: none; }
.ask-line.is-danger { color: var(--danger-ink); }
/* One scrolling row: the status pills, More, a dot, the period pills and the date chooser. */
.pill-row { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; position: relative; }
.pill-row::-webkit-scrollbar { display: none; }
.pill-row[hidden] { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 32px; max-width: 160px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--secondary); font-size: 12px; font-weight: 500; line-height: 20px; white-space: nowrap; box-shadow: none; }
.pill:hover { background: var(--surface-low); color: var(--ink); }
.pill.is-on, .pill[aria-pressed="true"] { background: var(--surface-high); border-color: var(--line-strong); color: var(--ink); }
.pill-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pill-count { display: inline-block; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .2s ease-out; }
.pill-count.is-known { opacity: 1; }
.pill-count.is-zero { color: var(--faint); }
.pill-row.is-counting .pill-count { color: var(--faint); }
.pill-more, .pill-chooser { color: var(--muted); }
.pill-caret { color: var(--faint); font-size: 10px; }
.pill-dot { color: var(--faint); flex: none; }
.list-menu-host { position: relative; display: inline-flex; flex: none; }
.list-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 200px; max-height: 320px; overflow: auto; padding: 4px; display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.list-menu-item { justify-content: space-between; gap: 12px; width: 100%; padding: 6px 8px; border-radius: var(--radius-sm); background: transparent; color: var(--secondary); text-align: left; box-shadow: none; }
.list-menu-item:hover, .list-menu-item:focus-visible { background: var(--surface-low); color: var(--ink); outline: none; }
.list-menu-item[aria-checked="true"] { color: var(--ink); font-weight: 500; }
.list-menu-item small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
/* The chips line: the count first, then every chip, then "+ Add filter" and "Clear all". */
.chips-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-height: 28px; }
.chips-label, .chips-count { color: var(--muted); font-size: 13px; }
.chips-dot { color: var(--faint); }
.chip.list-chip { position: relative; max-width: 240px; min-height: 28px; padding: 0 2px 0 10px; gap: 4px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 500; line-height: 20px; box-shadow: none; }
.chip.list-chip:hover { background: var(--surface-low); color: var(--ink); }
.chip.list-chip .chip-words { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.list-chip.source-ask-model { border-color: var(--line-strong); }
.chip-spark { color: var(--accent); font-size: 12px; margin-right: 2px; }
.chip-remove { display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); box-shadow: none; }
.chip-remove:hover { background: var(--surface-high); color: var(--ink); }
.chip-remove .icon { width: 12px; height: 12px; }
.chip.list-chip.is-refused { border-color: var(--danger-line); color: var(--danger-ink); }
.chip.add-filter-chip { min-height: 28px; border-style: dashed; border-color: var(--line-strong); background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; font-weight: 500; line-height: 20px; cursor: pointer; box-shadow: none; }
.chip.add-filter-chip:hover { color: var(--ink); background: var(--surface-low); }
.clear-all { min-height: 28px; padding: 0 8px; font-size: 13px; }
/* The add-filter row: field, condition, value, Apply and Cancel; stacked on a phone. */
.add-filter-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-low); }
.add-filter-row[hidden] { display: none; }
.add-filter-row select, .add-filter-row input { min-height: 36px; margin: 0; }
.add-filter-row .row-field { flex: 1 1 180px; }
.add-filter-row .row-condition { flex: 0 1 160px; }
.add-filter-row .row-value { display: flex; flex: 1 1 200px; align-items: center; gap: 6px; min-width: 0; }
.add-filter-row .row-value > * { flex: 1 1 auto; min-width: 0; }
.add-filter-row .row-value .apps-link { flex: 1 1 auto; }
.add-filter-row .row-and { flex: none; color: var(--muted); font-size: 13px; }
.add-filter-row .row-error { flex-basis: 100%; min-height: 0; color: var(--danger-ink); font-size: 13px; }
.add-filter-row .row-error:empty { display: none; }
.add-filter-row .row-buttons { display: flex; gap: 8px; margin-left: auto; }
/* The table reloads in place: rows at half opacity and a 2px line across the top of the frame. */
.list-card > .table-scroll { position: relative; }
.table-scroll.is-reloading tbody { opacity: .5; }
.table-scroll.is-reloading::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 1; }
.table-scroll .list-empty { padding: 40px 24px; border-top: 1px solid var(--line); }
.table-scroll .list-empty > p:first-child { color: var(--ink); font-size: 16px; font-weight: 600; }
.list-foot .list-cap { margin: 8px 0 0; font-size: 13px; }
.list-foot:empty { display: none; }
/* Column heads are buttons; the sorted one carries aria-sort and its arrow. */
th[aria-sort] .sort-button { color: var(--ink); }
.sort-button { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-size: 12px; font-weight: 500; box-shadow: none; }
.sort-button:hover { background: none; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.sort-mark { color: var(--muted); font-size: 11px; }
.list-card td.is-number { font-variant-numeric: tabular-nums; }
.list-card td.is-title { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.list-card td.is-status { color: var(--ink); }

/* ---- The record form from the server's layout: outline tabs under the page header, sections in
   columns, folded sections with their values on the fold line, inline errors. */
.form-tabs { display: flex; align-items: flex-end; gap: 4px; margin: 0 -16px 16px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.form-tabs::-webkit-scrollbar { display: none; }
.form-tabs[hidden] { display: none; }
.form-tab { position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 40px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 500; box-shadow: none; }
.form-tab:hover { background: none; color: var(--ink); }
.form-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.form-tab .tab-dot { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.form-tab.needs-attention .tab-dot { display: inline-block; }
.form-tabpanel[hidden] { display: none; }
.record-amounts { color: var(--ink); font-size: 14px; font-weight: 500; }
.has-layout .field-grid { grid-template-columns: repeat(var(--columns, 1), minmax(0, 1fr)); gap: 0 24px; }
.has-layout .field-column { display: flex; flex-direction: column; min-width: 0; }
.has-layout .field-column > label, .has-layout .field-column > .file-field, .has-layout .field-column > .table-field, .has-layout .field-column > [role="group"] { display: block; }
.has-layout [data-field][hidden] { display: none; }
.has-layout .form-section.is-collapsible { padding: 0; }
.has-layout .form-section.is-collapsible > .fold-line { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 8px 24px; border: 0; border-radius: 0; background: none; color: var(--ink); text-align: left; box-shadow: none; cursor: pointer; }
.has-layout .form-section.is-collapsible > .fold-line:hover { background: var(--surface-low); }
.has-layout .form-section.is-collapsible > .fold-line > .icon { width: 14px; height: 14px; color: var(--muted); transition: transform 160ms ease-out; transform: rotate(90deg); }
.has-layout .form-section.is-folded > .fold-line > .icon { transform: rotate(0deg); }
.has-layout .form-section.is-collapsible > .fold-line > h3 { margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; }
.fold-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; font-weight: 400; }
.fold-summary:empty { display: none; }
.has-layout .fold-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 160ms ease-out; }
.has-layout .fold-inner { min-height: 0; overflow: hidden; }
.has-layout .form-section.is-collapsible .fold-inner { padding: 0 24px 20px; }
.has-layout .form-section.is-folded > .fold-body { grid-template-rows: 0fr; }
.has-layout .form-section.is-folded .fold-inner { padding-bottom: 0; }
.has-layout .form-section.no-motion .fold-body, .has-layout .form-section.no-motion .fold-line > .icon { transition: none; }
.field-error { display: block; margin-top: 6px; color: var(--danger-ink); font-size: 13px; font-weight: 400; }
@media (prefers-reduced-motion: reduce) {
  .has-layout .fold-body, .has-layout .fold-line > .icon, .pill-count { transition: none; }
  .ask-box.is-asking .ask-progress { animation: none; transform: none; }
}
@media (hover: none) and (pointer: coarse) {
  .pill, .chip.list-chip, .chip.add-filter-chip { min-height: 44px; }
  .chip-remove { width: 44px; height: 44px; }
  .sort-button { min-height: 44px; }
  .has-layout .form-section.is-collapsible > .fold-line { min-height: 44px; }
}
@media (max-width: 760px) {
  .form-tabs { margin: 0 -16px 12px; }
  .has-layout .form-section.is-collapsible > .fold-line { padding: 8px 18px; }
  .has-layout .form-section.is-collapsible .fold-inner { padding: 0 18px 18px; }
}
@media (max-width: 480px) {
  .list-toolbar { flex-wrap: nowrap; }
  .pill-row { mask-image: linear-gradient(to right, var(--surface) calc(100% - 24px), transparent); -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .form-tabs { mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .add-filter-row > .row-field, .add-filter-row > .row-condition, .add-filter-row > .row-value { flex: 1 1 100%; }
  .add-filter-row .row-buttons { display: flex; width: 100%; margin: 0; }
  .add-filter-row .row-buttons .row-apply { flex: 1 1 auto; }
  .has-layout .field-grid { grid-template-columns: 1fr; }
  .list-card th:first-child, .list-card td:first-child { position: sticky; left: 0; z-index: 1; min-width: 120px; max-width: 160px; background: var(--surface); }
  .list-card th:first-child { background: var(--table-head-bg); }
  .list-foot .form-footer button { width: 100%; }
  #status { right: 16px; left: 16px; bottom: 72px; max-width: none; }
}
/* A section the page gives no column breaks keeps the two-up field grid Builder-made pages had. */
.has-layout .field-grid.is-single > .field-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; align-items: start; }
.has-layout .field-grid.is-single > .field-column > label.wide, .has-layout .field-grid.is-single > .field-column > .table-field, .has-layout .field-grid.is-single > .field-column > .change-wide { grid-column: 1 / -1; }
@media (max-width: 480px) { .has-layout .field-grid.is-single > .field-column { grid-template-columns: 1fr; } }
