/* Ledger grid (LedgerGrid.razor, LG1): "Option A · Ledger", approved 2026-10-29. A dense, ruled, keyboard-first table with a
   query box. Built on the portal tokens (uw-tokens.css): Inter, the portal blues and status tints. Ledger's own character is
   kept where it does not fight the kit: square-cornered tags, ruled columns, a pinned Next step column.
   The portal has no dark-mode switch yet. The dark block at the bottom is inert until <html data-theme="dark"> is set, so the
   grid (and the shell tokens it reads) are ready when one is added. */

.lg {
    --lg-surface: var(--uw-surface);
    --lg-raised: #f8fafc;
    --lg-hover: #f5f7fa;
    --lg-active: #eef1f5;
    --lg-sel: #eef3fe;
    --lg-sel-strong: #dfe8fd;
    --lg-border: var(--uw-border);
    --lg-rule: #edf0f4;
    --lg-control: var(--uw-border-strong);
    --lg-text: var(--uw-text);
    --lg-text-2: var(--uw-text-2);
    --lg-muted: var(--uw-muted);
    --lg-faint: var(--uw-faint);
    --lg-accent: var(--uw-primary);
    --lg-accent-tint: var(--uw-primary-tint);
    --lg-primary: var(--uw-text);
    --lg-on-primary: #ffffff;
    --lg-pos-bg: var(--uw-success-bg); --lg-pos-ink: var(--uw-success-ink);
    --lg-warn-bg: var(--uw-warning-bg); --lg-warn-ink: var(--uw-warning-ink); --lg-warn-dot: var(--uw-warning);
    --lg-org-bg: var(--uw-orange-bg); --lg-org-ink: var(--uw-orange-ink);
    --lg-neg-bg: var(--uw-danger-bg); --lg-neg-ink: var(--uw-danger-ink);
    --lg-info-bg: #e2f0fa; --lg-info-ink: #0b5585;
    --lg-prog-bg: var(--uw-indigo-bg); --lg-prog-ink: var(--uw-indigo-ink);
    --lg-neu-bg: var(--lg-active); --lg-neu-ink: var(--uw-text-2);
    --lg-shadow-pop: var(--uw-shadow-pop);
    --lg-scrim: rgba(15, 23, 42, .38);
    --lg-row: 38px;
    --lg-pad-x: 12px;
    --lg-r-ctl: 6px;
    --lg-r-card: 10px;
    --lg-r-tag: 3px;
    --lg-fs-1: var(--uw-fs-xs);
    --lg-fs-2: var(--uw-fs-md);
    --lg-fs-3: var(--uw-fs-lg);
    color: var(--lg-text);
    font-size: var(--lg-fs-2);
    min-width: 0;
}
.lg--comfy { --lg-row: 54px; --lg-pad-x: 14px; }

.uw-page--ledger { gap: 14px; padding-top: var(--uw-s5); }
.uw-page--ledger .uw-page-header__sub { font-size: var(--uw-fs-md); color: var(--uw-text-2); max-width: none; }

.lg *, .lg *::before, .lg *::after { box-sizing: border-box; }
.lg [hidden] { display: none !important; }
.lg :where(button, input, select) { font: inherit; color: inherit; }
.lg :where(button) { cursor: pointer; }
.lg :focus-visible { outline: 2px solid var(--lg-accent); outline-offset: 1px; border-radius: 4px; }
.lg-i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.lg-num { font-variant-numeric: tabular-nums; }
.lg-muted { color: var(--lg-muted); }
.lg-strong { font-weight: 600; }
.lg-ell { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-faint { color: var(--lg-faint); }
.lg-dash { color: var(--lg-faint); }
.lg-id { font-variant-numeric: tabular-nums; color: var(--lg-text); }
.lg-grow { flex: 1; }
.lg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lg kbd, .lg-menu__kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; background: var(--lg-active); color: var(--lg-text-2); font: 500 var(--lg-fs-1)/1 var(--uw-font); }
.lg-notice { margin: 0; padding: 10px 12px; border-radius: var(--lg-r-ctl); background: var(--lg-warn-bg); color: var(--lg-warn-ink); font-size: var(--lg-fs-2); }

/* ---- controls */
.lg-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--lg-r-ctl); border: 1px solid var(--lg-control); background: var(--lg-surface); color: var(--lg-text); font-weight: 500; font-size: var(--lg-fs-2); white-space: nowrap; transition: background .12s, border-color .12s; }
.lg-btn:hover { background: var(--lg-hover); }
.lg-btn:disabled { opacity: .45; cursor: default; background: transparent; }
.lg-btn--primary { background: var(--lg-primary); border-color: var(--lg-primary); color: var(--lg-on-primary); }
.lg-btn--primary:hover { background: var(--lg-primary); opacity: .9; }
.lg-btn--primary:disabled { opacity: 1; background: var(--lg-active); border-color: var(--lg-active); color: var(--lg-muted); }
.lg-btn--ghost { border-color: transparent; background: transparent; }
.lg-btn--sm { height: 28px; padding: 0 9px; font-size: var(--lg-fs-1); }
.lg-btn.is-on { background: var(--lg-active); }
.lg-btn .lg-i { width: 15px; height: 15px; }
.lg-ibtn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--lg-r-ctl); border: 0; background: transparent; color: var(--lg-muted); flex: none; transition: background .12s, color .12s; }
.lg-ibtn:hover { background: var(--lg-active); color: var(--lg-text); }
.lg-ibtn:disabled { opacity: .35; cursor: default; background: none; }
.lg-ibtn--sm { width: 24px; height: 24px; }
.lg-ibtn--sm .lg-i { width: 14px; height: 14px; }
.lg-link { border: 0; background: none; padding: 0; color: var(--lg-accent); font-weight: 500; font-size: var(--lg-fs-2); text-decoration: none; }
.lg-link:hover { text-decoration: underline; }
.lg-link--quiet { color: var(--lg-muted); font-size: var(--lg-fs-1); }
a.lg-link.lg-id { color: var(--lg-accent); }
a.lg-rowlink { color: inherit; text-decoration: none; }
a.lg-rowlink:hover { text-decoration: underline; color: var(--lg-accent); }
.lg-input, .lg-select { height: 32px; padding: 0 10px; border: 1px solid var(--lg-control); border-radius: var(--lg-r-ctl); background: var(--lg-surface); color: var(--lg-text); font-size: var(--lg-fs-2); min-width: 0; }
.lg-input::placeholder { color: var(--lg-faint); }
.lg-field { display: grid; gap: 5px; font-size: var(--lg-fs-1); color: var(--lg-muted); }
.lg-field .lg-input { width: 100%; }
.lg-check { display: flex; align-items: center; gap: 9px; min-height: 30px; cursor: pointer; font-size: var(--lg-fs-2); color: var(--lg-text); }
.lg-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--lg-accent); flex: none; }
.lg-check__l { flex: 1; min-width: 0; }
.lg-check__n { color: var(--lg-muted); font-size: var(--lg-fs-1); }
.lg-seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--lg-active); gap: 2px; }
.lg-seg--wrap { flex-wrap: wrap; }
.lg-seg__b { height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--lg-muted); font-size: var(--lg-fs-1); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.lg-seg__b:hover { color: var(--lg-text); }
.lg-seg__b[aria-pressed="true"] { background: var(--lg-surface); color: var(--lg-text); box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.lg-cb { width: 16px; height: 16px; margin: 0; accent-color: var(--lg-accent); vertical-align: middle; cursor: pointer; }

/* ---- cells: tags, people, two-part cells */
.lg .uw-chip.lg-tag { height: 20px; padding: 0 6px; border-radius: var(--lg-r-tag); font-weight: 500; font-size: var(--lg-fs-1); }
.lg-tbl .lg-inline .uw-chip.lg-tag { margin-left: 2px; }
.lg-tagx { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: var(--lg-r-tag); font-size: var(--lg-fs-1); font-weight: 500; white-space: nowrap; background: var(--lg-neu-bg); color: var(--lg-neu-ink); }
.lg-tagx--info { background: var(--lg-info-bg); color: var(--lg-info-ink); }
.lg-tagx--warn { background: var(--lg-warn-bg); color: var(--lg-warn-ink); }
.lg-tagx--org { background: var(--lg-org-bg); color: var(--lg-org-ink); }
.lg-tagx--neg { background: var(--lg-neg-bg); color: var(--lg-neg-ink); }
.lg-tagx--prog { background: var(--lg-prog-bg); color: var(--lg-prog-ink); }
.lg-inline { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; min-width: 0; }
.lg-two { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; gap: 1px; }
.lg-two > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-two .lg-muted, .lg-pair .lg-muted, .lg-sub { font-size: var(--lg-fs-1); }
.lg-pair { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-code { font-variant-numeric: tabular-nums; }
/* compact rows: one line per row, the sub line runs on after the name */
.lg--compact .lg-tbl .lg-two { flex-direction: row; align-items: baseline; gap: 8px; overflow: hidden; }
.lg--compact .lg-tbl .lg-two > * { flex: 0 1 auto; min-width: 0; }
.lg--compact .lg-tbl .lg-two > :first-child { flex-shrink: 0; max-width: 100%; }
.lg--compact .lg-tbl .lg-two > .lg-pair + .lg-pair::before { content: "· "; color: var(--lg-faint); }
.lg-person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; }
.lg-person__n { overflow: hidden; text-overflow: ellipsis; }
.lg-ava { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: hsl(var(--h) 70% 92%); color: hsl(var(--h) 45% 28%); }

/* ---- the card: tabs, query bar */
.lg-card { background: var(--lg-surface); border: 1px solid var(--lg-border); border-radius: var(--lg-r-card); display: flex; flex-direction: column; min-width: 0; overflow: clip; }
.lg-bar1 { display: flex; align-items: center; gap: 12px; padding: 8px 10px 0; min-width: 0; }
.lg-tabs { flex: 1; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.lg-tabs::-webkit-scrollbar { display: none; }
.lg-tab { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; border: 0; border-radius: var(--lg-r-ctl); background: transparent; color: var(--lg-muted); font-size: var(--lg-fs-2); font-weight: 500; white-space: nowrap; transition: background .12s, color .12s; }
.lg-tab:hover { color: var(--lg-text); background: var(--lg-hover); }
.lg-tab.is-on { color: var(--lg-text); background: var(--lg-active); font-weight: 600; }
.lg-tab__n { font-size: var(--lg-fs-1); color: var(--lg-faint); font-weight: 500; min-width: 1ch; font-variant-numeric: tabular-nums; }
.lg-tab.is-on .lg-tab__n { color: var(--lg-text-2); }
.lg-tab .lg-i { width: 14px; height: 14px; }
.lg-tab__dirty { width: 6px; height: 6px; border-radius: 50%; background: var(--lg-warn-dot); }
.lg-tabs__sep { width: 1px; height: 18px; background: var(--lg-border); margin: 0 6px; flex: none; }
.lg-tabv { display: inline-flex; align-items: center; }
.lg-tabv__x { opacity: 0; margin-left: -4px; }
.lg-tabv:hover .lg-tabv__x, .lg-tabv.is-on .lg-tabv__x, .lg-tabv__x:focus-visible { opacity: 1; }
.lg-tabs__save { display: flex; gap: 4px; flex: none; }
.lg-bar2 { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--lg-border); flex-wrap: wrap; }
.lg-bar2__r { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.lg-q { position: relative; flex: 1 1 360px; min-width: 240px; max-width: 520px; display: flex; align-items: center; }
.lg-q > .lg-i { position: absolute; left: 10px; color: var(--lg-faint); pointer-events: none; }
.lg-q .lg-input { height: 34px; width: 100%; padding-left: 32px; padding-right: 34px; }
.lg-q .lg-input[aria-invalid="true"] { border-color: var(--lg-neg-ink); }
.lg-q__hint { position: absolute; right: 8px; pointer-events: none; display: flex; }
.lg-q__err { position: absolute; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 6px 10px; border-radius: var(--lg-r-ctl); background: var(--lg-neg-bg); color: var(--lg-neg-ink); font-size: var(--lg-fs-1); z-index: 6; }
.lg-q__err--static { position: static; }
.lg-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1 1 auto; min-width: 0; }
.lg-chip { display: inline-flex; align-items: stretch; height: 28px; border-radius: var(--lg-r-ctl); background: var(--lg-accent-tint); color: var(--lg-text); font-size: var(--lg-fs-1); overflow: hidden; }
.lg-chip--live { background: transparent; box-shadow: inset 0 0 0 1px var(--lg-accent); border-style: dashed; }
.lg-chip__b { border: 0; background: none; padding: 0 4px 0 10px; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.lg-chip__x { border: 0; background: none; width: 26px; display: grid; place-items: center; color: var(--lg-muted); }
.lg-chip__x:hover, .lg-chip__b:hover { background: var(--lg-sel-strong); }
.lg-chip__x .lg-i { width: 13px; height: 13px; }
.lg-toolbar-extra { display: inline-flex; align-items: center; }
.lg-toolbar-extra .mud-switch { margin: 0; }
.lg-toolbar-extra .mud-switch { font-size: var(--lg-fs-1); color: var(--lg-text-2); font-weight: 500; }
.lg .lg-toolbar-extra p.mud-switch { font-size: 13px !important; color: var(--lg-text-2); font-weight: 500; margin: 0; }
.lg-toolbar-extra .mud-input-control { margin: 0; }
.lg-same { display: flex; gap: 6px; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--lg-rule); background: var(--lg-raised); font-size: var(--lg-fs-1); }
.lg-same .lg-link { font-size: var(--lg-fs-1); }

/* ---- the table */
.lg-wrap { position: relative; overflow: auto; overscroll-behavior: contain; background: var(--lg-surface); max-height: calc(100vh - 300px); min-height: 360px; }
.lg-tbl { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: var(--lg-fs-2); }
.lg-tbl th, .lg-tbl td { padding: 0 var(--lg-pad-x); text-align: left; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--lg-rule); background: var(--lg-surface); }
.lg-tbl td:not(.lg-c-sel):not(.lg-c-act):not(.lg-filler), .lg-tbl th.lg-th { border-right: 1px solid var(--lg-rule); }
.lg-tbl tr.lg-tr td { height: var(--lg-row); }
.lg-tbl .lg-num { text-align: right; }
.lg-tbl thead th { position: sticky; top: 0; z-index: 3; height: 38px; background: var(--lg-surface); border-bottom: 1px solid var(--lg-border); font-size: var(--lg-fs-1); font-weight: 500; color: var(--lg-muted); }
.lg-tbl .lg-sticky-l { position: sticky; left: 0; z-index: 2; }
.lg-tbl .lg-pin { position: sticky; left: 40px; z-index: 2; box-shadow: inset -1px 0 0 var(--lg-border); }
.lg-tbl .lg-sticky-r { position: sticky; right: 0; z-index: 2; overflow: visible; box-shadow: inset 1px 0 0 var(--lg-border); }
.lg-tbl thead .lg-sticky-l, .lg-tbl thead .lg-pin, .lg-tbl thead .lg-sticky-r { z-index: 4; }
.lg-tbl .lg-c-sel { padding: 0 0 0 14px; }
.lg-tbl .lg-c-act { padding: 0 6px 0 0; }
.lg-tbl .lg-filler { padding: 0; }
.lg-th { user-select: none; }
.lg-th__in { display: flex; align-items: center; gap: 2px; min-width: 0; }
.lg-th.lg-num .lg-th__sort { margin-left: auto; }
.lg-th__sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 4px 2px; color: inherit; font-weight: 500; font-size: var(--lg-fs-1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 5px; }
.lg-th__sort:hover, .lg-th[aria-sort="ascending"] .lg-th__sort, .lg-th[aria-sort="descending"] .lg-th__sort { color: var(--lg-text); }
.lg-th__dir { display: inline-flex; align-items: center; color: var(--lg-accent); }
.lg-th__dir .lg-i { width: 13px; height: 13px; stroke-width: 2; }
.lg-th__pri { font-size: var(--lg-fs-1); font-weight: 600; margin-left: 1px; }
.lg-th__menu { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: var(--lg-surface); border-radius: 5px; color: var(--lg-faint); opacity: 0; transition: opacity .12s; }
.lg-th:hover .lg-th__menu, .lg-th__menu:focus-visible, .lg-th__menu.is-on { opacity: 1; }
.lg-th:not(:hover) .lg-th__menu:not(.is-on):not(:focus-visible) { pointer-events: none; }
.lg-th.lg-num .lg-th__menu { right: auto; left: 4px; }
.lg-th__menu.is-on { color: var(--lg-accent); }
.lg-th__menu:hover { background: var(--lg-active); color: var(--lg-text); }
.lg-th__menu .lg-i { width: 14px; height: 14px; }
.lg-th__next { color: var(--lg-muted); font-weight: 500; display: block; padding-left: 10px; }
.lg-rs { position: absolute; top: 6px; bottom: 6px; right: 0; width: 9px; cursor: col-resize; z-index: 5; touch-action: none; }
.lg-rs::after { content: ""; position: absolute; right: 3px; top: 0; bottom: 0; width: 2px; border-radius: 2px; background: transparent; transition: background .12s; }
.lg-th:hover .lg-rs::after { background: var(--lg-border); }
.lg-rs:hover::after, .lg-rs.is-on::after, .lg-rs:focus-visible::after { background: var(--lg-accent); }
.lg-th.is-drag { opacity: .45; }
.lg-th.drop-a { box-shadow: inset 2px 0 0 var(--lg-accent); }
.lg-th.drop-b { box-shadow: inset -2px 0 0 var(--lg-accent); }
body.lg-resizing { cursor: col-resize; user-select: none; }
.lg-tr { cursor: pointer; }
.lg-tr:hover td { background: var(--lg-hover); }
.lg-tr.is-sel td { background: var(--lg-sel); }
.lg-tr.is-sel:hover td { background: var(--lg-sel-strong); }
.lg-tr.is-cursor td:first-child { box-shadow: inset 2px 0 0 var(--lg-accent); }
.lg-tr:focus { outline: none; }
.lg-tr--sk td { cursor: default; }
/* Make-up POs: an urgent row carries a red rule on its left edge (desktop and phone). */
.lg-tr.lg-tr--urgent td:first-child { box-shadow: inset 3px 0 0 var(--lg-neg-ink); }
.lg-lrow.lg-tr--urgent { box-shadow: inset 3px 0 0 var(--lg-neg-ink); }
.lg-chip-urgent { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; background: var(--lg-neg-bg); color: var(--lg-neg-ink); font-size: var(--lg-fs-1); font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.lg-actcell { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding-left: 8px; }
.lg-actcell > .lg-kebab:only-child { margin-left: auto; }
.lg-nextcell { display: inline-flex; min-width: 0; max-width: 100%; }
.lg-kebab { width: 30px; height: 30px; }
.lg-skb { display: inline-block; height: 10px; border-radius: 5px; background: var(--lg-active); vertical-align: middle; animation: lg-skp 1.4s ease-in-out infinite; }
.lg-skb--2 { display: block; height: 8px; margin-top: 7px; opacity: .7; }
.lg-skb--cb { width: 16px; height: 16px; border-radius: 4px; }
@keyframes lg-skp { 50% { opacity: .55; } }

/* ---- next step */
.lg-next { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--lg-r-tag); border: 1px solid var(--lg-control); background: var(--lg-surface); color: var(--lg-text); font-size: var(--lg-fs-1); font-weight: 600; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
button.lg-next:hover { filter: brightness(.97); }
.lg-next--info, .lg-next--warn, .lg-next--org, .lg-next--prog, .lg-next--neg { border-color: transparent; }
.lg-next--info { background: var(--lg-info-bg); color: var(--lg-info-ink); }
.lg-next--warn { background: var(--lg-warn-bg); color: var(--lg-warn-ink); }
.lg-next--org { background: var(--lg-org-bg); color: var(--lg-org-ink); }
.lg-next--neg { background: var(--lg-neg-bg); color: var(--lg-neg-ink); }
.lg-next--prog { background: var(--lg-prog-bg); color: var(--lg-prog-ink); }
.lg-next--text { border: 0; background: none; padding: 0; height: auto; font-weight: 400; }

/* ---- states, pager, bulk */
.lg-state { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 64px 24px 72px; min-height: 360px; align-content: center; }
.lg-state__art { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--lg-active); color: var(--lg-muted); }
.lg-state__art .lg-i { width: 22px; height: 22px; }
.lg-state__t { margin: 0; font-size: var(--lg-fs-3); font-weight: 600; }
.lg-state__p { margin: 0 0 6px; color: var(--lg-muted); max-width: 44ch; }
.lg-pager { display: flex; align-items: center; gap: 16px; padding: 10px 16px; font-size: var(--lg-fs-2); color: var(--lg-muted); border-top: 1px solid var(--lg-border); }
.lg-pager__count { margin-right: auto; }
.lg-pager__count .lg-num { color: var(--lg-text); }
.lg-pager__size { display: flex; align-items: center; gap: 8px; }
.lg-pager__size .lg-select { height: 30px; padding-right: 6px; }
.lg-pager__nav { display: flex; align-items: center; gap: 2px; }
.lg-pager__n { min-width: 30px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--lg-text-2); font-variant-numeric: tabular-nums; font-size: var(--lg-fs-2); }
.lg-pager__n:hover { background: var(--lg-active); }
.lg-pager__n.is-on { background: var(--lg-active); color: var(--lg-text); font-weight: 600; }
.lg-pager__gap { padding: 0 4px; }
.lg-bulk { position: fixed; left: 50%; bottom: 20px; z-index: 1300; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-radius: 12px; background: var(--lg-surface); color: var(--lg-text); box-shadow: var(--lg-shadow-pop); transform: translateX(-50%); max-width: calc(100vw - 24px); animation: lg-up .18s var(--uw-ease); }
@keyframes lg-up { from { opacity: 0; transform: translate(-50%, 12px); } }
.lg-bulk__n { font-weight: 600; font-size: var(--lg-fs-2); white-space: nowrap; }
.lg-bulk__sp { width: 8px; }

/* ---- popovers, menus, dialogs */
.lg-scrim { position: fixed; inset: 0; z-index: 1390; background: transparent; }
.lg-scrim--dim { background: var(--lg-scrim); }
.lg-pop { position: fixed; z-index: 1400; top: -9999px; left: -9999px; min-width: 220px; max-width: min(360px, calc(100vw - 16px)); max-height: min(70vh, 560px); overflow: auto; padding: 8px; border-radius: 12px; background: var(--lg-surface); color: var(--lg-text); box-shadow: var(--lg-shadow-pop); animation: lg-pin .14s var(--uw-ease); }
@keyframes lg-pin { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.lg-pop--sugg { min-width: 300px; z-index: 1380; }
.lg-pop--chooser { max-width: 320px; }
.lg-sugg { display: grid; }
.lg-sugg__item { display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: none; text-align: left; font-size: var(--lg-fs-2); }
.lg-sugg__item.is-on, .lg-sugg__item:hover { background: var(--lg-active); }
.lg-sugg__k { font-weight: 600; min-width: 64px; }
.lg-sugg__d { color: var(--lg-muted); font-size: var(--lg-fs-1); margin-left: auto; }
.lg-sugg__help { padding: 8px 10px 4px; font-size: var(--lg-fs-1); color: var(--lg-muted); border-top: 1px solid var(--lg-rule); margin-top: 4px; line-height: 1.7; }
.lg-sugg__help code { font: 500 var(--lg-fs-1)/1 var(--uw-font); background: var(--lg-active); padding: 2px 5px; border-radius: 4px; color: var(--lg-text-2); margin-right: 4px; }
.lg-menu { display: grid; min-width: 200px; }
.lg-menu__item { display: flex; align-items: center; justify-content: flex-start; width: 100%; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: none; text-align: left; font-size: var(--lg-fs-2); color: var(--lg-text); white-space: nowrap; }
.lg-menu__item .lg-i { color: var(--lg-muted); }
.lg-menu__item:hover, .lg-menu__item:focus-visible { background: var(--lg-active); outline: none; }
.lg-menu__item .lg-menu__kbd { margin-left: auto; }
.lg-menu__sep { height: 1px; background: var(--lg-rule); margin: 4px 6px; }
.lg-fw { display: grid; gap: 10px; padding: 4px; }
.lg-fw + .lg-fw { border-top: 1px solid var(--lg-rule); margin-top: 6px; padding-top: 12px; }
.lg-fw__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--lg-fs-2); font-weight: 600; }
.lg-fw__head .lg-muted { font-weight: 400; font-size: var(--lg-fs-1); }
.lg-fw__links { display: flex; gap: 12px; }
.lg-fw__clear { justify-self: start; }
.lg-checklist { display: grid; max-height: 280px; overflow: auto; }
.lg-checklist .lg-check { padding: 0 4px; border-radius: 6px; }
.lg-checklist .lg-check:hover { background: var(--lg-hover); }
.lg-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lg-colpop { display: grid; gap: 6px; min-width: 260px; }
.lg-colpop__sorts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; }
.lg-colpop__sorts .lg-btn { justify-content: center; }
.lg-colpop__foot { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--lg-rule); padding-top: 6px; margin-top: 2px; }
.lg-chooser { display: grid; gap: 6px; min-width: 280px; padding: 4px; }
.lg-chooser__list { list-style: none; margin: 0; padding: 0; display: grid; }
.lg-chooser__item { display: flex; align-items: center; gap: 4px; padding: 0 2px; border-radius: 6px; position: relative; }
.lg-chooser__item:hover { background: var(--lg-hover); }
.lg-chooser__item.is-drag { opacity: .4; }
.lg-chooser__item.drop-a { box-shadow: inset 0 2px 0 var(--lg-accent); }
.lg-chooser__item.drop-b { box-shadow: inset 0 -2px 0 var(--lg-accent); }
.lg-chooser__grip { color: var(--lg-faint); cursor: grab; display: grid; }
.lg-chooser__item .lg-check { flex: 1; }
.lg-chooser__mv { display: flex; opacity: 0; }
.lg-chooser__item:hover .lg-chooser__mv, .lg-chooser__mv:focus-within { opacity: 1; }
.lg-chooser__pin { border-top: 1px solid var(--lg-rule); padding-top: 8px; margin-top: 2px; }
.lg-fsheet { display: flex; flex-direction: column; min-width: 300px; max-height: inherit; }
.lg-fsheet__head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 8px; border-bottom: 1px solid var(--lg-rule); }
.lg-fsheet__body { overflow: auto; padding: 4px 0 8px; flex: 1; min-height: 0; }
.lg-fsheet__foot { display: flex; padding: 10px 0 4px; border-top: 1px solid var(--lg-border); }
.lg-fsheet__foot .lg-btn { height: 44px; justify-content: center; }
.lg-dialog { position: fixed; z-index: 1400; left: 50%; top: 12vh; transform: translateX(-50%); width: min(460px, calc(100vw - 32px)); max-height: 76vh; overflow: auto; padding: 16px 20px 18px; border-radius: 14px; background: var(--lg-surface); color: var(--lg-text); box-shadow: var(--lg-shadow-pop); display: grid; gap: 12px; }
.lg-dialog--wide { width: min(680px, calc(100vw - 32px)); }
.lg-dialog form { display: grid; gap: 12px; }
.lg-dialog p { margin: 0; }
.lg-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lg-dialog__head h2 { margin: 0; font-size: var(--lg-fs-3); font-weight: 600; }
.lg-dialog__foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.lg-keys { margin: 0; display: grid; gap: 2px; }
.lg-keys div { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--lg-rule); }
.lg-keys dd { margin: 0; color: var(--lg-text-2); }
.lg-keys dt { display: flex; gap: 4px; align-items: center; color: var(--lg-muted); font-size: var(--lg-fs-1); }
.lg-paylist { display: grid; }
.lg-paylist__row { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 40px; border-bottom: 1px solid var(--lg-rule); font-size: var(--lg-fs-2); }
.lg-paylist__who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-paylist__in { width: 120px; }
.lg-paylist--skip .lg-paylist__row { color: var(--lg-muted); }
.lg-paylist__skiphead { font-size: var(--lg-fs-1); color: var(--lg-muted); margin-top: 6px !important; }

/* ---- phone: a two-line row per item, the next step on its own line, long-press to select */
.lg-mlist { display: block; }
.lg-lrow { display: grid; gap: 4px; padding: 12px 14px; border-bottom: 1px solid var(--lg-rule); background: var(--lg-surface); position: relative; cursor: pointer; }
.lg-lrow:focus { outline: none; }
.lg-lrow.is-sel { background: var(--lg-sel); box-shadow: inset 3px 0 0 var(--lg-accent); }
.lg-lrow.is-cursor { box-shadow: inset 3px 0 0 var(--lg-accent); }
.lg-lrow__1 { display: flex; align-items: baseline; gap: 10px; }
.lg-lrow__t { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-lrow__amt { font-weight: 600; }
.lg-lrow__1.has-kebab { align-items: center; }
.lg-lrow__menu { flex: none; margin: -6px -6px -6px 0; }
.lg-lrow__2 { display: flex; gap: 8px; font-size: var(--lg-fs-1); min-width: 0; }
.lg-lrow__2 .lg-id { flex: none; }
.lg-lrow__sub { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-lrow__when { flex: none; }
.lg-lrow__3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.lg-lrow__3 .lg-next { height: 32px; }
.lg-lrow--sk { gap: 8px; cursor: default; }

@media (max-width: 1100px) {
    .lg-wrap { max-height: calc(100vh - 320px); }
}
@media (max-width: 700px) {
    .uw-page--ledger { padding-top: var(--uw-s3); }
    .lg-card { margin: 0 -4px; }
    .lg-bar1 { padding: 6px 6px 0; }
    .lg-bar2 { padding: 8px; gap: 6px; }
    .lg-q { flex: 1 1 100%; max-width: none; min-width: 0; }
    .lg-q__err { position: static; margin-top: 6px; }
    .lg-bar2__r { margin-left: 0; width: 100%; }
    .lg-toolbar-extra { order: 3; }
    .lg-pager { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
    .lg-pager__size, .lg-pager__gap { display: none; }
    .lg-pager__nav .lg-pager__n:not(.is-on) { display: none; }
    .lg-bulk { left: 8px; right: 8px; transform: none; bottom: 8px; flex-wrap: wrap; padding: 8px 8px 8px 12px; animation: none; }
    .lg-bulk .lg-btn { flex: 1; justify-content: center; }
    .lg-bulk__sp { display: none; }
    .lg-pop--sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; max-width: none; max-height: 82vh; border-radius: 16px 16px 0 0; padding: 12px 16px 20px; }
    .lg-dialog { top: auto; bottom: 0; left: 0; right: 0; transform: none; width: 100%; border-radius: 16px 16px 0 0; max-height: 88vh; }
    .lg-paylist__row { grid-template-columns: 110px minmax(0, 1fr); }
    .lg-paylist__in { grid-column: 1 / -1; width: 100%; }
}

/* ---- dark. The portal has no switch for it yet: these apply only under <html data-theme="dark">. The shell tokens are
   redefined here too, so a dark grid never sits in a light page. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --uw-bg: #0c0d0f;
    --uw-surface: #141518;
    --uw-surface-2: #1c1e23;
    --uw-border: #262930;
    --uw-border-strong: #3a3e47;
    --uw-text: #f2f4f7;
    --uw-text-2: #c9ced6;
    --uw-muted: #a3a9b4;
    --uw-faint: #8a919d;
    --uw-primary: #7ea4ff;
    --uw-primary-hover: #9bb8ff;
    --uw-primary-tint: #18233a;
    --uw-success-bg: #13291c; --uw-success-ink: #6fd69a;
    --uw-danger-bg: #321618;  --uw-danger-ink: #f58f8f;
    --uw-warning-bg: #2d2410; --uw-warning-ink: #f2c75c; --uw-warning: #e0a92a;
    --uw-orange-bg: #301c10;  --uw-orange-ink: #f7a26b;
    --uw-indigo-bg: #17213d;  --uw-indigo-ink: #9db6ff;
    --uw-sky-bg: #10263a;     --uw-sky-ink: #7cc3f2;
    --uw-shadow-pop: 0 0 0 1px #2c3038, 0 16px 40px rgba(0, 0, 0, .55);
    --mud-palette-primary: #7ea4ff;
    --mud-palette-background: var(--uw-bg);
    --mud-palette-surface: var(--uw-surface);
    --mud-palette-text-primary: var(--uw-text);
    --mud-palette-text-secondary: var(--uw-text-2);
    --mud-palette-lines-default: var(--uw-border);
    --mud-palette-lines-inputs: var(--uw-border-strong);
    --mud-palette-divider: var(--uw-border);
    --mud-palette-appbar-background: var(--uw-surface);
    --mud-palette-drawer-background: var(--uw-surface);
}
:root[data-theme="dark"] body { background: var(--uw-bg); color: var(--uw-text); }
:root[data-theme="dark"] .uw-topbar { background: var(--uw-surface); }
:root[data-theme="dark"] .lg {
    --lg-raised: #191b1f;
    --lg-hover: #1c1e23;
    --lg-active: #23262c;
    --lg-sel: #172238;
    --lg-sel-strong: #1d2c49;
    --lg-rule: #1f2227;
    --lg-primary: #f2f4f7;
    --lg-on-primary: #0c0d0f;
    --lg-info-bg: #10263a; --lg-info-ink: #7cc3f2;
    --lg-scrim: rgba(0, 0, 0, .6);
}
:root[data-theme="dark"] .lg-ava { background: hsl(var(--h) 30% 22%); color: hsl(var(--h) 60% 82%); }
:root[data-theme="dark"] .lg .uw-chip { background: var(--lg-active); color: var(--lg-text-2); }
:root[data-theme="dark"] .lg .uw-chip--success { background: var(--uw-success-bg); color: var(--uw-success-ink); }
:root[data-theme="dark"] .lg .uw-chip--warning { background: var(--uw-warning-bg); color: var(--uw-warning-ink); }
:root[data-theme="dark"] .lg .uw-chip--danger { background: var(--uw-danger-bg); color: var(--uw-danger-ink); }
:root[data-theme="dark"] .lg .uw-chip--indigo { background: var(--uw-indigo-bg); color: var(--uw-indigo-ink); }
:root[data-theme="dark"] .lg .uw-chip--info { background: var(--uw-sky-bg); color: var(--uw-sky-ink); }
