/* ============================================================================
   Price table (.ps): an editable spreadsheet for a price (Peter, 31 Oct 2026: "a spreadsheet style input form is
   just the easiest way ... type it, drag things around, mark things as selectable, put a title on it").
   It EXTENDS the data grid (the markup carries .data-grid__wrap / .data-grid, so the frame, the header and the hairline
   rows are data-grid.css's own): every cell is a field you type in. Inline editing is approved here by Peter, unlike
   the data grid lens, which stays drawer-only. Each row's Type (In the price, An extra or As needed; for a section, Always in or A package) is a .tx-dd, like Per. A row with no price reads as
   a section (a grey band, its name in medium weight). The Per picker is the app's .tx-dd; the row menu is the
   invoice list's row menu (ask-do.css .ado-menu.inv-rowmenu). On a phone each row stacks into a small block.
   Behaviour (typing, paste from Excel, drag, menus, Undo) lives with the screen that uses it
   (preview/first-proposal/jobs/build.py, SHEET_UI). Catalogued in preview/index.html (#pricetable).
   ============================================================================ */
.ps { display: grid; gap: var(--space-3); }
.ps__t { min-width: 700px; }   /* the What column keeps room for a paragraph; past this the frame scrolls sideways */   /* past this the frame scrolls sideways, as the data grid does */
/* the columns: layout widths, one-off */
.ps__k--grip { width: 30px; } .ps__k--qty { width: 78px; } .ps__k--unit { width: 96px; } .ps__k--price { width: 96px; } .ps__k--tot { width: 86px; } .ps__k--type { width: 134px; } .ps__k--more { width: 38px; }   /* wide enough for Month and In the price whole */
.ps__t thead th.r { text-align: right; padding-right: var(--space-2); } .ps__t thead th.c { text-align: center; }   /* over the figures, which sit at the field's own padding */
.ps__t thead th.ps__h--price { text-align: left; padding-left: var(--space-3); }   /* over the euro sign, where the money starts */   /* over the figure, which sits by its euro sign */
/* a cell is a field: the grid's cell padding moves onto the field, and a name may wrap */
.data-grid.ps__t tbody td { padding: 0; white-space: normal; vertical-align: top; position: relative; border-bottom: var(--border-width) solid var(--color-border); }
.ps__row:hover td { background: var(--color-bg-subtle-light); }
.ps__row.is-title td { background: var(--color-bg-subtle); }
.ps__in { display: block; width: 100%; box-sizing: border-box; border: 0; background: transparent; font: inherit; font-size: var(--text-base); line-height: var(--leading-body); color: var(--color-text); padding: var(--space-3) var(--space-2); border-radius: 0; }
.ps__in::placeholder { color: var(--color-text-muted); }
.ps__in:focus { outline: none; }   /* no box round a field you type in: you just edit the words, as on a page (Peter, 6 Nov 2026: "why have one, just let them edit"); the caret and the row's grey band show where you are */
.ps__in.ps__num { text-align: right; }
.ps__row.is-title .ps__name { font-weight: var(--weight-medium); }
/* each line is the invoice's rich text editor (invoice-line-item.css .li-richtext; Peter, 31 Oct 2026: "each line should
   have a rich text editor built into it"), made to sit in a cell: no frame, one line high until it is written longer,
   its toolbar (bold, italic, underline, bullets, numbers) shown just under the line while it is being written, so nothing
   moves and the column heads stay in sight */
.ps__rt.li-richtext { min-height: 0; border: 0; border-radius: 0; background: transparent; position: relative; }
.ps__rt .li-richtext__area { flex: none; padding: var(--space-3) var(--space-2); overflow: visible; line-height: var(--leading-body); }
.ps__rt .li-richtext__area ul, .ps__rt .li-richtext__area ol { margin: var(--space-1) 0 0; padding-left: var(--space-6); }
.ps__rt .ps__rtbar { position: absolute; left: var(--space-1); top: calc(100% - var(--space-1)); z-index: 6; display: none; padding: var(--space-1); background: var(--color-surface); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-dropdown); }
.ps__rt:focus-within .ps__rtbar { display: flex; }
.ps__rt .li-richtext__area:focus, .ps__rt .li-richtext__area:focus-visible { outline: var(--border-width) solid var(--color-border-strong); outline-offset: calc(-1 * var(--border-width)); box-shadow: none; }   /* the line being written: a hairline, as the invoice's editor shows it */
/* an empty line is only its What until it is used, so it never reads as half filled */
.ps__row.is-blank:not(:focus-within) :is(.ps__c--qty .ps__in, .ps__unit, .ps__c--price .amt-eur, .ps__type) { visibility: hidden; }
.ps__note { resize: none; field-sizing: content; overflow: hidden; font-size: var(--text-base); color: var(--color-text-muted); padding: 0 var(--space-2) var(--space-2); margin-top: calc(-1 * var(--space-2)); }
.ps__row.is-title .ps__note { display: none; }
.ps__tag { display: block; font-size: var(--text-base); line-height: var(--leading-footnote); color: var(--color-text-muted); padding: 0 var(--space-2) var(--space-2); margin-top: calc(-1 * var(--space-2)); text-wrap: pretty; }   /* the same gap under the name as a note */
.ps__tag:empty { display: none; }
.ps__row.is-title .ps__c--qty .ps__in, .ps__row.is-title .ps__unit { visibility: hidden; }
.ps__row.is-title:focus-within .ps__c--qty .ps__in, .ps__row.is-title:focus-within .ps__unit { visibility: visible; }
.data-grid.ps__t tbody td.ps__c--tot { text-align: right; padding: var(--space-3) var(--space-2); white-space: nowrap; color: var(--color-text); }
.ps__row.is-title .ps__c--tot, .ps__row.is-pick:not(.is-title) .ps__c--tot { color: var(--color-text-muted); }
/* an As needed line (billed at its rate as the work is done): no count, and its total says it is not in the total */
.ps__row.is-need:not(:focus-within) .ps__c--qty .ps__in { visibility: hidden; }
.ps__row.is-need .ps__c--tot { color: var(--color-text-muted); }
/* the dots and the more button: icon buttons, the grid's quiet grey until used */
/* the grip and the more button sit centred on the line's name (Peter, 8 Nov 2026: "I don't think these grippers are
   centered"; "the drag bar is not center"): measured against the name's own text box, not its field (the field's 12px
   top padding fooled the first fix), so 10px puts the centres level */
.ps__grip, .ps__more { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; margin: 10px 2px 0; padding: 0; border: 0; background: none; color: var(--color-text-muted); border-radius: var(--radius-sm); cursor: pointer; }
.ps__grip { cursor: grab; }
.ps__grip svg, .ps__more svg { width: 16px; height: 16px; }
.ps__more:hover, .ps__more[aria-expanded="true"], .ps__grip:hover { background: var(--color-bg-subtle); color: var(--color-text); }   /* provisional */
/* Per: the app's .tx-dd, borderless at rest so the table reads as a sheet; its edge shows on the row's hover, and an
   open picker keeps the dropdown's own ink edge (dropdown.css) */
.ps__unit, .ps__type, .ps__vat { margin: 5px var(--space-1) 0; }   /* .ps__vat: VAT on each line, on a page that asks for it (the quick way, 6 Nov 2026) */   /* the word in the picker on the line of the What and the figures */
.ps__unit .tx-dd__btn:not([aria-expanded="true"]), .ps__type .tx-dd__btn:not([aria-expanded="true"]), .ps__vat .tx-dd__btn:not([aria-expanded="true"]) { border-color: transparent; background: transparent; }
.ps__row:hover :is(.ps__unit, .ps__type, .ps__vat) .tx-dd__btn:not([aria-expanded="true"]) { border-color: var(--color-border); background: var(--color-surface); }   /* provisional */
.ps__t tfoot td { padding: var(--space-3) var(--space-2); font-weight: var(--weight-medium); border-top: 0; }
.ps__t tfoot .ps__c--tot { text-align: right; white-space: nowrap; }
.ps__t tfoot td[colspan="4"] { text-align: right; }   /* In all sits by its figure, so the format toolbar under the last line never covers it (Signal's check, 31 Oct 2026); nothing moves when the line is left */
.ps__t tfoot .ps__c--tot.is-empty { color: var(--color-text-muted); font-weight: var(--weight-regular); }
.ps__allnote { font-weight: var(--weight-regular); color: var(--color-text-muted); font-size: var(--text-xs); margin-left: var(--space-1); }
/* a row moves as a block (Peter, 10 Nov 2026): the card that follows the mouse, and the empty slot it left */
.ps__row.is-drag { background: var(--color-bg-subtle); }
.ps__row.is-drag > * { visibility: hidden; }
.ps__dragblock { position: fixed; left: 0; top: -400px; z-index: 0; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) var(--space-6); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-dropdown); font-size: var(--text-base); color: var(--color-text); pointer-events: none; }
.ps__dragblock__n { font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps__dragblock__t { flex: none; }
.ps__row.is-drop-before td { box-shadow: inset 0 2px 0 var(--color-text); }
.ps__row.is-drop-after td { box-shadow: inset 0 -2px 0 var(--color-text); }
/* a row just read in: the app's highlighter, a 1px yellow ring that holds, then fades (rings flash, never stay; the
   same run as ui.js uiFlashCard, which this preview does not load; data-grid.css keeps its own dgFlash the same way) */
.ps__row.is-flash { animation: psFlash 5s ease both; }
@keyframes psFlash { 0%, 70% { outline: var(--border-width) solid var(--color-hilite-strong); outline-offset: calc(-1 * var(--border-width)); } 100% { outline: var(--border-width) solid transparent; outline-offset: calc(-1 * var(--border-width)); } }
.ps__acts { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ps__hint { margin: 0; font-size: var(--text-base); line-height: var(--leading-body); color: var(--color-text-muted); }
.ps__menu { z-index: 80; }
.ps__menu .inv-rowmenu__act[disabled] { opacity: .5; cursor: not-allowed; }   /* provisional */
.ps__umenu { position: absolute; z-index: 80; right: auto; min-width: 130px; }   /* the Per menu, opened on the page itself */
/* the price is a money field: the app's euro sign inside its left edge (input.css .amt-eur, ui.js "€ prefix on every
   money field", 7 Jul 2026); how many is not money, so it has none. In a section's grey band the sign waits until used. */
.ps__c--price .amt-eur > .ps__in { padding-left: var(--space-6); text-align: left; }   /* the figure sits by its euro sign, as in every money field */
.ps__row.is-title:not(:focus-within) .ps__c--price .amt-eur__sym { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .ps__row.is-flash { animation: none; } }
/* a phone: each row is a small block, the name on top, then how many and per, price and total, then They choose,
   each with its label */
@media (max-width: 640px) {
  .ps__t.data-grid { min-width: 0; }
  .ps .data-grid__wrap { overflow: visible; }
  .ps__t colgroup, .ps__t thead { display: none; }
  .ps__t, .ps__t tbody, .ps__t tfoot { display: block; }
  .ps__row { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) 34px; grid-template-areas: "grip what what more" ". qty unit ." ". price tot ." ". type type ."; border-bottom: var(--border-width) solid var(--color-border); }
  .data-grid.ps__t tbody td { display: block; border-bottom: 0; }
  .ps__c--grip { grid-area: grip; } .ps__c--what { grid-area: what; } .ps__c--more { grid-area: more; } .ps__c--qty { grid-area: qty; } .ps__c--unit { grid-area: unit; } .ps__c--price { grid-area: price; }
  .data-grid.ps__t tbody td.ps__c--tot { grid-area: tot; text-align: left; padding: 2px 6px 0; }
  .data-grid.ps__t tbody td.ps__c--type { grid-area: type; padding-bottom: var(--space-2); }
  .ps__row td[data-l]::before { content: attr(data-l); display: block; font-size: var(--text-xs); color: var(--color-text-muted); padding: 2px 6px 0; white-space: nowrap; }
  .ps__row .ps__c--tot::before { padding: 0 0 11px; }
  .ps__in.ps__num { text-align: left; }
  .ps__row .ps__in { padding-left: 6px; padding-right: 6px; }
  .ps__row.is-title .ps__c--qty, .ps__row.is-title .ps__c--unit, .ps__row.is-title .ps__c--price { display: none; }
  .ps__row.is-title { background: var(--color-bg-subtle); } .ps__row.is-title td { background: transparent; }   /* one grey band, no patches (review round 2) */
  .ps__row.is-title:focus-within .ps__c--qty, .ps__row.is-title:focus-within .ps__c--unit, .ps__row.is-title:focus-within .ps__c--price { display: block; }
  /* an empty row is just its name field until they start on it */
  .ps__row.is-blank:not(:focus-within) :is(.ps__c--qty, .ps__c--unit, .ps__c--price, .ps__c--tot, .ps__c--type) { display: none; }
  .ps__row.is-need:not(:focus-within) .ps__c--qty { visibility: hidden; }
  .ps__t tfoot tr { display: flex; justify-content: space-between; }
  .ps__t tfoot td:empty { display: none; }
}

/* EVERY WORD IN THE TABLE IS BODY SIZE (Peter, 6 Nov 2026: "I hate the fucking tiny font"): the lines, the notes, the heads.
   LIKE THE INVOICE'S LINE ITEMS (Peter, 6 Nov 2026: "Does that look like our design style"): the head is the invoice
   table's grey band in full ink, there is no frame round the table, and Type is wide enough for Optional extra */
.ps .data-grid__wrap { border: 0; border-radius: 0; }
.ps__t thead th { font-size: var(--text-base); background: var(--color-bg-subtle); color: var(--color-text); font-weight: var(--weight-medium); }
.ps__k--type { width: 150px; }
.ps__t tbody td, .ps__t tfoot td, .ps__t .tx-dd__btn, .ps .amt-eur__sym, .ps__allnote { font-size: var(--text-base); }   /* the pickers, the euro sign, the totals and the note under them too */

/* the line's name reads like a small heading over its grey note (Peter, 8 Nov 2026: "make that text a little darker...
   so that it just stands out a little more, kinda like a heading"): medium weight, same size and ink */
.ps__row:not(.is-title) .ps__name { font-weight: var(--weight-medium); color: var(--color-text); }
