
/* =====================================================================
   Design-system polish — one set of control sizes, radii and spacing
   (from the style audit: button 34/36 & 24/27/30px, inputs 34–52px,
   table corners leaking past rounded cards, detached tab bars)
   ===================================================================== */

/* Controls: one height per size, independent of icon/text content */
.btn { height: 36px; padding-top: 0; padding-bottom: 0; }
.btn-sm { height: 30px; padding: 0 10px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.field input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
.field select, select.input, input.input {
  height: 38px; min-height: 38px; padding-top: 0; padding-bottom: 0; border-radius: 7px;
}
.search-inline input, .tbl-tools select.input, .tbl-tools select { height: 36px; min-height: 36px; padding-top: 0; padding-bottom: 0; border-radius: 7px; }
.lines-editor input, .lines-editor select, .tbl input:not([type=checkbox]), .tbl select { height: 34px; min-height: 34px; padding-top: 0; padding-bottom: 0; border-radius: 6px; }
.field textarea { border-radius: 7px; }

/* Rounded containers clip their content so table headers/totals never square off the corners */
.card, .report-sheet, .modal { overflow: clip; }
.modal { overflow: hidden; }

/* Tab bars: a separate filter row with the standard 16px gap before the content it filters.
   Horizontal scroll only (no 1px vertical scroll): the active underline is drawn inside the tab, not pushed below it. */
.content .tabs { margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.content .tabs a, .content .tabs button { margin-bottom: 0; border-bottom: 0; box-shadow: inset 0 -2px 0 transparent; }
.content .tabs a:hover, .content .tabs button:hover { box-shadow: inset 0 -2px 0 var(--line); }
.content .tabs .active, .content .tabs .active:hover { box-shadow: inset 0 -2px 0 var(--blue); }

/* Vertical rhythm: 16px between blocks, 24px between groups */
.rp-libbar { margin-bottom: 16px !important; }
.rp-group { margin-bottom: 24px !important; }

/* Type scale: snap stray sizes to the scale */
.tbl th .arrow { font-size: 11px; }
.tag-beta { font-size: 11px; }
.rp-sheet p, .rp-plan li, .rp-plan span { font-size: 13.5px; }
.rp-sheet p.small, .rp-plan .small { font-size: 12.5px; }

/* Round the table's own scroll frame where it meets a card corner (reliable even with the pinned first column) */
.card > .card-body.flush:first-child > .table-wrap:first-child,
.card-body.flush > .table-wrap:first-child:only-child,
.card > .table-wrap:first-child { border-top-left-radius: calc(var(--radius) - 1px); border-top-right-radius: calc(var(--radius) - 1px); }
.card-body.flush > .table-wrap:last-child,
.card > .table-wrap:last-child,
.report-sheet > .table-wrap:last-child,
.report-sheet > :last-child .table-wrap:last-child { border-bottom-left-radius: calc(var(--radius) - 1px); border-bottom-right-radius: calc(var(--radius) - 1px); }
.card-body.flush > .pager:last-child, .card-body.flush > .tbl-tools:first-child { border-radius: 0; }

/* Approvals inbox: keep every column readable within a desktop width */
#ap-tbl .appr-ref { display: block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
#ap-tbl .appr-party { display: block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ap-tbl td.num { white-space: normal; max-width: 180px; }
#ap-tbl td .small.muted { white-space: nowrap; }
#ap-tbl td:last-child { white-space: nowrap; }
#ap-tbl td:last-child .btn { height: 30px; padding: 0 10px; font-size: 12.5px; }

/* Documents (invoice/quote/bill paper, print sheets) are not data grids: no pinned first column or column separator */
.doc-paper .table-wrap .tbl th:first-child, .doc-paper .table-wrap .tbl td:first-child,
.print-sheet .tbl th:first-child, .print-sheet .tbl td:first-child { position: static; background: transparent; }
.doc-paper .table-wrap .tbl td:first-child::after, .doc-paper .table-wrap .tbl th:first-child::after,
.print-sheet .tbl td:first-child::after, .print-sheet .tbl th:first-child::after { content: none; }

/* KPI tiles whose value is a name rather than a figure wrap instead of pushing the row wider */
.kpi .value.text { white-space: normal; overflow-wrap: anywhere; text-wrap: balance; font-size: clamp(15px, 9cqi, 20px); line-height: 1.2; }

/* Line editor: sized by its own width, not the viewport.
   Wide: one row per line (Description · Qty · Unit price · Disc · Tax · Amount).
   Medium (≤ 820px): two rows per line — the item on top, then the five fields with small labels, so every box
   has room for full amounts. Narrow (≤ 560px): the fields wrap two per row and the amount gets its own row. */
.le-scroll { container-type: inline-size; }
@container (max-width: 820px) {
  .le-table, .le-table tbody, .le-table tr, .le-table td { display: block; width: auto; }
  .le-table { min-width: 0; }
  .le-table colgroup, .le-table thead { display: none; }
  .le-table tr.le-fields { display: grid; grid-template-columns: minmax(56px, .55fr) minmax(0, 1fr) minmax(0, 1.5fr) minmax(72px, .7fr) minmax(0, 1.15fr); gap: 8px 10px; padding-top: 12px; align-items: end; }
  .le-table tr.le-fields td { padding: 0; }
  .le-table tr.le-fields td.le-item { grid-column: 1 / -1; }
  .le-table tr.le-fields td[data-label]::before { content: attr(data-label); display: block; margin: 0 0 4px 2px; font-size: 11.5px; font-weight: 600; color: var(--slate); text-align: left; }
  .le-table .le-amt { padding: 0 2px 9px !important; text-align: right; }
  .le-table tr.le-fields td.le-amt::before { text-align: right; }
  .le-table tbody.le-block + tbody.le-block tr:first-child td { border-top: 0; }
  .le-table tbody.le-block + tbody.le-block { border-top: 1px solid var(--line-soft); }
  .le-table tr.le-notes td { padding: 8px 0 0 !important; }
  .le-table tr.le-actions td { padding: 6px 0 10px; }
  .le-in { padding: 0 7px; }
}
@container (max-width: 560px) {
  .le-table tr.le-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .le-table tr.le-fields td[data-label="Disc"] { grid-column: 1 / -1; }
  .le-table .le-amt { grid-column: 1 / -1; display: flex !important; align-items: baseline; justify-content: space-between; padding: 8px 2px 0 !important; border-top: 1px dashed var(--line-soft); }
  .le-table tr.le-fields td.le-amt::before { margin: 0; }
}

/* Document tax summary: fits the paper on phones (tighter cells, figures may wrap between currency and amount) */

.kpi .label .ms { flex: none; }

/* Line items: "Add item" sits under the last line, on the left */
.le-add { display: flex; justify-content: flex-start; padding: 12px 0 0; border-top: 1px solid var(--line-soft); }
