/* ── Form controls: styled by element so plain markup looks right ───────────── */
input:not([type]), input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="email"], input[type="password"], input[type="tel"], input[type="url"], input[type="time"], input[type="datetime-local"], input[type="month"], select, textarea {
  min-height: var(--space-5);
  padding: 0 var(--space-2);
  color: var(--text-primary);
  background: var(--bg-card);
  border: var(--hairline) solid var(--border-control);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  transition: border-color var(--transition-base);
}
/* Search: magnifier drawn as a background (stroke = --text-muted of each theme), wider than a plain field. */
input[type="search"] { padding-left: 40px; background: var(--bg-card) var(--icon-search) no-repeat 12px center / 16px 16px; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
textarea { padding: var(--space-1) var(--space-2); }
input:hover, select:hover, textarea:hover { border-color: var(--color-accent-text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent); }
input::placeholder { color: var(--text-muted); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
/* Autofill: keep the card background/text instead of the browser's yellow/blue (password managers fill login fields). */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-primary);
  box-shadow: 0 0 0 100px var(--bg-card) inset;
  caret-color: var(--text-primary);
}
select option { background: var(--bg-card); color: var(--text-primary); }

.field { display: grid; gap: 4px; color: var(--text-muted); font-size: var(--font-size-xs); }

/* ── Filter bar ──────────────────────────────────────────────────────────────── */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); margin-bottom: var(--space-2); }
.filter-bar label { display: grid; gap: 4px; color: var(--text-muted); font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); letter-spacing: var(--letter-spacing-label); text-transform: uppercase; }
.filter-bar label.check { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--space-5); cursor: pointer; }
.filter-bar input[type="checkbox"] { min-width: 0; width: var(--icon-size-sm); height: var(--icon-size-sm); margin: 0; accent-color: var(--color-accent); }
.filter-bar input, .filter-bar select { min-width: 160px; text-transform: none; letter-spacing: normal; }
.filter-bar input[type="search"] { min-width: min(100%, 320px); width: 24rem; max-width: 100%; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card, .stat-card, .item-card {
  padding: var(--space-2);
  background: var(--bg-card);
  border: var(--hairline) solid var(--border-color);
  border-radius: var(--radius-lg);
}
.card__title { margin: 0 0 var(--space-2); }
.stat-card { display: grid; align-content: start; gap: 4px; container-type: inline-size; }
.stat-card > p { margin: 0; }
.stat-card__label { color: var(--text-muted); font-size: var(--font-size-xs); letter-spacing: var(--letter-spacing-label); text-transform: uppercase; }
.stat-card__value { font-family: var(--font-heading); font-size: clamp(var(--font-size-md), 11cqi, var(--font-size-xl)); font-weight: var(--font-weight-bold); color: var(--color-accent-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-card__hint { color: var(--text-secondary); font-size: var(--font-size-sm); }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-2); border-bottom: var(--hairline) solid var(--border-color); }
.tab {
  padding: var(--space-1) var(--space-2);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
}
.tab:hover { color: var(--text-primary); }
.tab.tab--active, .tab[aria-current="page"] { color: var(--color-accent-text); border-bottom-color: var(--color-accent-text); }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px var(--space-1); border-radius: var(--radius-lg); background: rgba(100, 100, 100, 0.2); color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); }
.badge.badge--accent { background: var(--color-accent-muted); color: var(--color-accent-text); }
.badge.badge--success { background: rgba(56, 175, 100, 0.15); color: var(--color-success-text); }
.badge.badge--warning { background: rgba(255, 160, 0, 0.15); color: var(--color-warning-fg); }
.badge.badge--danger { background: rgba(224, 85, 85, 0.15); color: var(--color-danger-text); }
.badge.badge--neutral { background: rgba(100, 100, 100, 0.2); color: var(--text-secondary); }

/* ── Data grid ───────────────────────────────────────────────────────────────── */
.grid-bar, .grid-pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin-bottom: var(--space-2); }
.grid-bar { justify-content: space-between; }
.grid-pager { justify-content: flex-end; margin: var(--space-2) 0 0; }
.grid-pager__gap { color: var(--text-muted); }
.grid thead th a.sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }
.grid thead th a.sort:hover, .grid thead th[aria-sort] a.sort { color: var(--color-accent); }
.grid thead th a.sort .material-icons { font-size: 1.2em; }
.grid-summary { color: var(--text-secondary); font-size: var(--font-size-sm); }

/* One scroller per page: .shell__content > .page is a flex column and the grid takes the space left under the
   header/filters/totals (flex: 1), so the page itself does not scroll and both grid scrollbars stay on screen.
   Edge cue (shadow where more columns exist): local/scroll background-attachment trick on the scroller. */
.table-wrapper {
  overflow-x: auto;
  border: var(--hairline) solid var(--border-color);
  /* Same corner as .btn: a grid is a working surface, not a floating card, and --radius-lg read as too pronounced
     against the controls above it. */
  border-radius: var(--radius-sm);
  background:
    linear-gradient(to right, var(--bg-card) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--bg-card) 30%, transparent) right center / 40px 100% no-repeat local,
    linear-gradient(to right, var(--edge-shadow), transparent) left center / 14px 100% no-repeat scroll,
    linear-gradient(to left, var(--edge-shadow), transparent) right center / 14px 100% no-repeat scroll,
    var(--bg-card);
}
.grid-scroll { overflow: auto; }
.shell__content > .page { display: flex; flex-direction: column; flex: 1 0 auto; min-height: 100%; }
.shell__content > .page > .grid-scroll { flex: 1 1 0; min-height: 200px; }
.grid-scroll:focus-visible { outline-offset: -2px; }

.grid { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.grid th, .grid td { padding: 0 var(--space-2); height: 36px; line-height: var(--line-height-base); text-align: left; white-space: nowrap; border-bottom: var(--hairline) solid var(--border-color); }
.grid thead th { position: sticky; height: 40px; top: 0; z-index: 1; background: var(--bg-grid-head); box-shadow: 0 1px 0 var(--border-control), 0 3px 6px var(--edge-shadow); color: var(--text-muted); font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); letter-spacing: var(--letter-spacing-label); text-transform: uppercase; }
/* .grid--dense is a kept no-op alias: every grid is dense (36 px rows, 40 px header). */
/* First column pinned while scrolling sideways. */
.grid--sticky-first th:first-child, .grid--sticky-first td:first-child { position: sticky; left: 0; background: var(--bg-card); box-shadow: 1px 0 0 var(--border-color); }
.grid--sticky-first thead th:first-child { z-index: 2; background: var(--bg-grid-head); box-shadow: 1px 0 0 var(--border-control), 0 3px 6px var(--edge-shadow); }
.grid--sticky-first tbody tr:hover td:first-child { background: var(--row-hover); }
.grid th.num, .grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Amounts: zero is a muted dash (the figure stays in the DOM for screen readers); negatives (credit notes) are marked. */
.grid .zero { color: var(--text-muted); }
.grid td.num--neg { color: var(--color-danger-text); }
/* Plan de cuentas: heading (type X) rows are bold; type codes are badges. */
.grid .badge { min-width: 24px; text-align: center; }
.grid tbody tr { transition: background var(--transition-base); }
.grid tbody tr:hover { background: var(--row-hover); }
.grid tbody tr:last-child td { border-bottom: 0; }
/* Journal: subdiary heading = strong band; voucher "Total" = quiet; repeated voucher numbers dimmed (text kept for AT). */
/* Journal: one-line totals; memo is Concar's fixed 28-char padded field, keep every space */
.journal-strip { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-1); margin: 0 0 var(--space-1); padding: var(--space-1) 0; font-size: var(--font-size-sm); font-variant-numeric: tabular-nums; border-bottom: var(--hairline) solid var(--border-color); }
.journal-strip strong { color: var(--color-accent-text); font-weight: var(--font-weight-semibold); }
.journal-strip__totals { margin-left: auto; }
.grid td.memo { white-space: pre; min-width: calc(28ch + 2 * var(--space-2)); font: inherit; }

.page-empty__action { display: inline-block; margin-top: var(--space-1); font-weight: var(--font-weight-semibold); }
/* KPI cards sit at the top of their cell instead of stretching to the tallest sibling. */
.card-list { align-items: start; }
.card-list__caption { margin: 0 0 var(--space-1); } /* one scope caption above the cards (Purchases) instead of a hint on a single card */
.card-list:has(> .stat-card) { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

@media (max-width: 768px) {
  .card, .stat-card, .item-card { border-radius: var(--radius-md); }
  /* .table-wrapper keeps --radius-sm at every width: the grid is the same working surface on a phone. */
  /* Phones: KPI cards two per row; a grid is one screen tall (page scrolls to it, the grid scrolls inside). */
  .card-list:has(> .stat-card) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1); }
  .stat-card { padding: 12px; }
  .shell__content > .page > .grid-scroll { flex: none; height: calc(100dvh - var(--topbar-height) - var(--space-3)); min-height: 280px; }
  .filter-bar label:not(.check), .filter-bar input:not([type="checkbox"]), .filter-bar select { width: 100%; min-width: 0; }
  .filter-bar .btn { width: 100%; }
  .journal-strip__totals { margin-left: 0; width: 100%; }
}

/* Journal tree (outline grouping). Off by default: header rows of vouchers, counts, sums and toggles only exist when .is-grouped. */
.journal-tree-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-1); }
.journal-tree-bar[hidden], .journal-tree-bar [hidden] { display: none; }
.journal-tree-bar__actions, .journal-tree-bar__levels { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.journal-tree-bar .btn[aria-pressed="true"] { background: var(--color-accent-muted); border-color: var(--color-accent-text); color: var(--color-accent-text); }
.journal-grid .tree-toggle, .journal-grid .jg-count, .journal-grid .jg-sum, .journal-grid .jg-voucher { display: none; }
.journal-grid.is-grouped .tree-toggle { display: inline-flex; }
.journal-grid.is-grouped .jg-count, .journal-grid.is-grouped .jg-sum { display: inline; }
.journal-grid.is-grouped .jg-voucher:not([hidden]) { display: table-row; }
.journal-grid.is-grouped .jg-flat-total { display: none; }
.journal-grid.is-grouped .jg-row { cursor: pointer; }
/* Grouped: a line belongs to the voucher header above it, so it does not repeat the voucher number (kept for screen readers);
   it starts at the date, indented past the header's number, with a guide line on the left. */
.journal-grid.is-grouped tr[data-level="3"] .jg-vno { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.journal-grid.is-grouped tr[data-level="3"] td.jg-line-no { border-left: 2px solid var(--color-accent-muted); }
.journal-grid .jg-date-first { display: none; }
/* Grouped: the date moves into the first cell, left-aligned with the voucher number of its header (padding + toggle + gap). */
.journal-grid.is-grouped tr[data-level="3"] td.jg-line-no { padding-left: calc(var(--space-4) + var(--space-4) + var(--space-1)); }
.journal-grid.is-grouped tr[data-level="3"] .jg-date-first { display: inline; }
.journal-grid.is-grouped tr[data-level="3"] td.jg-date { visibility: hidden; }
.journal-grid .jg-count { color: var(--text-muted); font-weight: var(--font-weight-regular, 400); }
.journal-grid.is-grouped .jg-voucher td:first-child { padding-left: var(--space-4); }
.tree-toggle { align-items: center; justify-content: center; width: var(--space-4); height: var(--space-4); margin-right: var(--space-1); padding: 0; vertical-align: middle; background: none; border: 0; border-radius: var(--radius-sm, 4px); color: var(--color-accent-text); cursor: pointer; }
.tree-toggle .material-icons { font-size: 20px; }
.tree-toggle:hover { background: var(--color-accent-muted); }
@media print {
  .journal-tree-bar { display: none; }
  .journal-grid tr[hidden] { display: table-row !important; } /* print everything, whatever is collapsed */
}

/* Grouped headers show their own total next to the name (the Debe/Haber cells can be scrolled out of view). */
.journal-grid .jg-tot { display: none; color: var(--text-muted); font-weight: var(--font-weight-regular, 400); white-space: nowrap; }
.journal-grid .jg-tot b { color: var(--text-primary); font-weight: var(--font-weight-medium); font-variant-numeric: tabular-nums; }
.journal-grid.is-grouped .jg-tot { display: inline; }
@media print { .journal-grid .jg-tot { display: none !important; } }

/* Full screen (fullscreen.js): any element with .fs-target can be the Fullscreen API target of a [data-fullscreen-target] button. Tokens apply because the element itself is promoted. */
.btn[hidden] { display: none; }
.btn[data-fullscreen-target]:focus-visible { outline: 2px solid var(--color-accent-text, currentColor); outline-offset: 2px; }
.fs-target:fullscreen { width: 100vw; height: 100vh; box-sizing: border-box; padding: var(--space-2); overflow: auto; background: var(--bg-page); color: var(--text-primary); font-family: inherit; }
.fs-target:-webkit-full-screen { width: 100vw; height: 100vh; box-sizing: border-box; padding: var(--space-2); overflow: auto; background: var(--bg-page); color: var(--text-primary); }
.fs-target.table-wrapper:fullscreen { max-height: none; border: 0; border-radius: 0; }
.fs-target:fullscreen:has(> .table-wrapper) { display: flex; flex-direction: column; overflow: hidden; }
.fs-target:fullscreen > .table-wrapper { flex: 1 1 0; min-height: 0; max-height: none; }
.fs-target:fullscreen .grid { background: var(--bg-card); }
.fs-target:fullscreen:focus-visible, .fs-target:fullscreen .table-wrapper:focus-visible { outline-offset: -2px; }
/* In-place navigation in progress (fullscreen.js): the table skeleton (skeleton.css) is the loading feedback; only the cursor changes here. */
.fs-target.is-loading { cursor: progress; }
/* Normal view: a wrapper around the table must not change the page flex layout (the .grid-scroll rules above expect a direct child of .page). */
.fs-target:has(> .table-wrapper):not(:fullscreen) { display: contents; }
.shell__content > .page > .fs-target:not(:fullscreen) > .grid-scroll { flex: 1 1 0; min-height: 200px; }
@media (max-width: 768px) { .shell__content > .page > .fs-target:not(:fullscreen) > .grid-scroll { flex: none; height: calc(100dvh - var(--topbar-height) - var(--space-3)); min-height: 280px; } }
@media print { [data-fullscreen-target] { display: none; } }

/* ── Form sections: the ONE fieldset look (docs/UI-STYLE.md). Page CSS must not style fieldset/legend; extreme cases only, with a comment. ── */
.form-section { margin: 0; padding: var(--space-2); min-width: 0; border: var(--hairline) solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-card); }
.form-section > legend { padding: 0 var(--space-1); color: var(--color-accent-text); font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); letter-spacing: var(--letter-spacing-label); text-transform: uppercase; }
.form-section:not(.form-section--bare):disabled { opacity: 0.85; }
/* --bare: no frame, for a group nested in a section (or a pure wrapper): legend becomes a small muted label above the fields. */
.form-section--bare { padding: 0; border: 0; border-radius: 0; background: none; }
.form-section--bare > legend { float: left; width: 100%; padding: 0; color: var(--text-muted); font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); line-height: 18px; }
.form-section--bare > legend + * { clear: both; }
/* Fields inside a section: responsive columns (1 column on a phone), label / hint / error stacked by .field. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: var(--space-2); }
.form-grid > .field { min-width: 0; align-content: start; }
.field__hint { color: var(--text-secondary); font-size: var(--font-size-xs); }
.field__error { color: var(--color-danger-text); font-size: var(--font-size-xs); }

/* ── Page header and actions: the ONE contract (docs/UI-STYLE.md). Pages never restyle .btn, .page-header*, .form-actions, .row-actions, .confirm-action. ──
   Header: title block on the start edge, .page-header__actions on the end edge, DOM order = visual order: secondary first, primary LAST. */
.page-header { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }
.page-header h1 { margin-bottom: 0; font-size: var(--font-size-xl); font-weight: var(--font-weight-bold); }
.page-header__title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); min-width: 0; }
.page-header__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1) var(--space-2); }
.page-header__actions form { margin: 0; }
.page-header__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-1); margin-inline-start: auto; }

/* Form footer: Cancel/hint on the start edge (.form-actions__start), then secondary, then Save draft, primary LAST.
   Logical properties only: mirrors in RTL. A form is never wider than the phone: the group stacks, full-width buttons. */
.form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-1); margin: var(--space-2) 0 0; }
.form-actions .btn:not(.btn--sm) { min-height: var(--touch-target-min); }
.form-actions form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin: 0; }
.form-actions__start { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin-inline-end: auto; }
.form-actions__hint { margin: 0; color: var(--text-muted); font-size: var(--font-size-xs); }

/* Table row actions: last column, end-aligned, small buttons in the order view/edit, state change, destructive. */
.grid td.grid__actions { text-align: end; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px var(--space-1); }
.row-actions form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin: 0; }

/* Destructive action: a closed <details> (no JS). The summary is the .btn.btn--danger-outline that opens it, the form holds
   the reason and the final .btn.btn--danger confirm. Two deliberate steps, same on every page. */
.confirm-action > summary { list-style: none; cursor: pointer; }
.confirm-action > summary::-webkit-details-marker { display: none; }
.confirm-action__form { display: grid; gap: var(--space-1); max-width: 32rem; min-width: 14rem; margin: var(--space-1) 0 0; text-align: start; white-space: normal; }
.confirm-action__form .btn { justify-self: start; }
.confirm-action__help { margin: 0; color: var(--text-secondary); font-size: var(--font-size-sm); }
.confirm-action--block { margin: var(--space-2) 0 0; }

@media (max-width: 768px) {
  .page-header__actions { width: 100%; }
  .page-header__actions .btn { flex: 1 1 auto; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions__start { margin-inline-end: 0; }
  .form-actions .btn { width: 100%; }
}
@media print { .page-header__actions, .form-actions, .row-actions { display: none; } }

/* ===== Combo (Pages/Shared/_Combo.cshtml + wwwroot/js/combo.js) =====================================================
   One set of classes for every select-like control. The list is anchored to .combo__box (the whole control, so it starts at the
   control's start edge); JS adds .combo--up when it would overflow the viewport bottom and .combo--end when it would overflow the side. */
.combo { position: relative; display: block; min-width: 0; }
.combo--sm { max-width: 9rem; } .combo--md { max-width: 16rem; } .combo--lg { max-width: 28rem; } .combo--full { max-width: none; }
.combo__box { position: relative; display: flex; align-items: center; min-width: 0; }
.combo .combo__control { width: 100%; min-width: 0; padding-inline-end: calc(var(--space-2) + var(--icon-size-md)); text-align: start; text-overflow: ellipsis; }
.combo .combo__button { display: flex; align-items: center; min-height: var(--space-5); padding-inline-start: var(--space-1); background: var(--bg-card); color: var(--text-primary); border: var(--hairline) solid var(--border-control); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: var(--font-size-sm); cursor: pointer; }
.combo__button:hover { border-color: var(--color-accent-text); }
.combo__button:focus-visible, .combo__control:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.combo__control:focus { box-shadow: none; }
.combo__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo__value--empty { color: var(--text-muted); }
.combo__chevron { position: absolute; inset-inline-end: var(--space-1); font-size: var(--icon-size-md); color: var(--text-secondary); pointer-events: none; transition: transform var(--transition-base); }
.combo--open .combo__chevron { transform: rotate(180deg); }
.combo__clear { position: absolute; inset-inline-end: calc(var(--space-1) + var(--icon-size-md)); display: inline-flex; align-items: center; justify-content: center; width: var(--icon-size-md); height: var(--icon-size-md); padding: 0; background: transparent; border: 0; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; }
.combo__clear[hidden] { display: none; }
.combo__clear:hover { color: var(--text-primary); }
.combo__clear-icon { font-size: var(--icon-size-sm); }
.combo .combo__control:has(~ .combo__clear:not([hidden])) { padding-inline-end: calc(var(--space-2) + 2 * var(--icon-size-md)); }
.combo .combo__native { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; overflow: hidden; }
.combo__list { position: absolute; inset-inline-start: 0; top: calc(100% + 4px); z-index: 400; min-width: 100%; width: max-content; max-width: min(32rem, calc(100vw - var(--space-4))); max-height: 280px; margin: 0; padding: 4px 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; background: var(--bg-card); color: var(--text-primary); border: var(--hairline) solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-md); outline: none; }
.combo__list[hidden] { display: none; }
.combo--up .combo__list { top: auto; bottom: calc(100% + 4px); }
.combo--end .combo__list { inset-inline-start: auto; inset-inline-end: 0; }
.combo__option { display: flex; align-items: baseline; gap: var(--space-1); min-height: var(--space-5); padding: 0 var(--space-2); font-family: var(--font-body); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); line-height: var(--space-5); cursor: pointer; }
.combo__option--active { background: var(--color-accent-muted); }
.combo__option[aria-selected="true"] { font-weight: var(--font-weight-bold); }
.combo__option--disabled { opacity: .5; cursor: not-allowed; }
.combo__code { flex: none; font-family: var(--font-mono); color: var(--text-secondary); }
.combo__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo__mark { background: transparent; color: inherit; font-weight: var(--font-weight-bold); text-decoration: underline; text-decoration-color: var(--color-accent); text-underline-offset: 2px; }
.combo__group { padding: var(--space-1) var(--space-2) 0; color: var(--text-secondary); font-size: var(--font-size-xs); font-weight: var(--font-weight-bold); letter-spacing: var(--letter-spacing-label); text-transform: uppercase; }
.combo__status { padding: var(--space-1) var(--space-2); color: var(--text-secondary); font-size: var(--font-size-sm); }
.combo__text { display: block; min-height: 1em; margin-top: 2px; color: var(--text-secondary); font-size: var(--font-size-xs); }
.combo__text:empty { display: none; }
.combo--invalid .combo__control, .combo .combo__control[aria-invalid="true"] { border-color: var(--color-danger); }
.combo--disabled .combo__control { opacity: .6; cursor: not-allowed; }
/* Topbar pickers: the .topbar__action wrapper draws border and focus ring, the combo only shows text and chevron. */
.topbar__action:has(.combo--bare) { position: relative; } /* the list anchors to the whole control, icon included */
.combo--bare, .combo--bare .combo__box { position: static; height: 100%; }
.combo--bare .combo__control, .combo--bare .combo__button { height: 100%; min-height: 0; padding-block: 0; padding-inline-start: 0; background: transparent; border: 0; color: inherit; box-shadow: none; max-width: 220px; }
.combo--bare .combo__control:focus-visible { outline: none; }
.topbar__action .combo--bare .combo__chevron { display: inline-block; position: static; margin-inline-start: calc(-1 * var(--space-1)); font-size: var(--icon-size-md); color: var(--text-secondary); }
.combo--bare .combo__list { inset-inline-start: calc(-1 * var(--hairline)); min-width: calc(100% + 2 * var(--hairline)); }
@media (min-width: 769px) { .topbar__company { flex-shrink: 0; } }
@media (max-width: 768px) {
  .combo__option { min-height: var(--touch-target-min); line-height: var(--touch-target-min); }
  .combo--sm, .combo--md, .combo--lg { max-width: none; }
  .combo--bare .combo__control, .combo--bare .combo__button { max-width: none; width: 100%; }
  .topbar__action .combo--bare .combo__chevron { margin-inline-end: -4px; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { .combo__chevron { transition: none; } }
/* ===== /Combo ============================================================================================================ */

/* ===== Tables: the one standard (docs/UI-STYLE.md#tables) =====================================================================
   Every tbody row of one level shares font, size, weight, line-height, padding and height. Levels are explicit modifiers on <tr>:
   .row--group-1 > .row--group-2 > (normal) ; .row--subtotal and .row--total close a group/table ; .row--note is an expansion row
   (the only multi-line row). A modifier changes weight/colour/background only, never size, so heights cannot drift. */
:root {
  --table-font-size: var(--font-size-sm);
  --table-line-height: var(--line-height-base);
  --table-cell-padding: 0 var(--space-2);
  --table-row-height: 36px;
  --table-clip-width: 22rem;
  --row-zebra: var(--bg-surface);
}
.grid { font-size: var(--table-font-size); }
.grid th, .grid td { padding: var(--table-cell-padding); height: var(--table-row-height); line-height: var(--table-line-height); }
.grid tbody td, .grid tfoot td, .grid tbody th, .grid tfoot th { font-size: var(--table-font-size); font-family: inherit; }
/* Identifier text keeps its muted colour but never its own (smaller) size. */
.grid td .text-id, .grid td.text-id { font-size: inherit; line-height: inherit; }
/* Numeric columns: right-aligned, tabular figures, same size as text cells (legacy per-page classes included). */
.grid :is(th, td):is(.num, .pe-num, .se-num, .bk-num, .fr-right) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid :is(td, th).num, .grid td.pe-num, .grid td.se-num, .grid td.bk-num, .grid td.fr-right { font-family: inherit; }
.grid tbody th[scope="row"] { text-align: left; font-weight: var(--font-weight-medium); }
/* One line, always: long text is clamped with an ellipsis and carries the full text in title="". */
.grid td.wrap { max-width: var(--table-clip-width); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Levels. */
.grid tr.row--group-1 td, .grid--sticky-first tr.row--group-1 td:first-child { background: var(--bg-grid-head); color: var(--color-accent-text); font-weight: var(--font-weight-bold); border-top: 2px solid var(--border-control); }
.grid tr.row--group-2 td, .grid--sticky-first tr.row--group-2 td:first-child { background: var(--bg-card); font-weight: var(--font-weight-medium); }
.grid tr.row--subtotal td, .grid--sticky-first tr.row--subtotal td:first-child { font-weight: var(--font-weight-medium); color: var(--text-secondary); }
.grid tfoot td, .grid tfoot th, .grid tr.row--total td, .grid--sticky-first tr.row--total td:first-child, .grid--sticky-first tfoot td:first-child { background: var(--bg-surface); font-weight: var(--font-weight-semibold); border-top: var(--hairline) solid var(--border-color); }
/* Expansion row (details, import issues): the only row allowed to grow. */
.grid tr.row--note td { height: auto; white-space: normal; max-width: none; overflow: visible; padding: var(--space-1) var(--space-2); background: var(--bg-surface); }
.grid--zebra tbody tr:nth-child(even):not([class*="row--"]) td { background: var(--row-zebra); }
/* Phones: a list table becomes stacked cards (td[data-label]); card rows are all alike. */
@media (max-width: 720px) {
  .grid--stack thead { display: none; }
  .grid--stack tr { display: block; padding: var(--space-1) 0; border-bottom: var(--hairline) solid var(--border-color); }
  .grid--stack td { display: flex; justify-content: space-between; gap: var(--space-2); height: auto; border: 0; white-space: normal; max-width: none; }
  .grid--stack td::before { content: attr(data-label); color: var(--text-muted); font-size: var(--font-size-xs); }
}
@media print { .grid td, .grid th { height: auto; } }
/* ===== /Tables ============================================================================================================ */
