:root {
  --bg: #f4f3f0;
  --card: #ffffff;
  --ink: #1d232b;
  --muted: #6b7480;
  --faint: #a3aab3;
  --line: #e6e3de;
  --soft: #f7f6f3;
  --accent: #2c5d4f;
  --accent-soft: #e6f0eb;
  --accent-ink: #ffffff;
  --warn: #8f5400;
  --warn-soft: #fbf2e3;

  /* one grid for every row: switch · content · amount · action */
  --c-switch: 36px;
  --c-amount: 120px;
  --c-action: 24px;
  --gap: 12px;

  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171b; --card: #1c2026; --ink: #e8eaed; --muted: #9aa3ad; --faint: #66707b; --line: #2c323a; --soft: #222830;
    --accent: #7fc4ac; --accent-soft: #1f3a32; --accent-ink: #0f1a16; --warn: #f0b45c; --warn-soft: #3a2c16;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171b; --card: #1c2026; --ink: #e8eaed; --muted: #9aa3ad; --faint: #66707b; --line: #2c323a; --soft: #222830;
  --accent: #7fc4ac; --accent-soft: #1f3a32; --accent-ink: #0f1a16; --warn: #f0b45c; --warn-soft: #3a2c16;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 10px 24px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand strong { font-size: 15px; }
.brand span { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 2px; margin-left: auto; background: var(--soft); padding: 3px; border-radius: 8px; }
.tabs button { border: 0; background: none; padding: 6px 16px; border-radius: 6px; color: var(--muted); }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- page ---------- */
/* defined on #layout (not :root) so they pick up a --c-switch set on #layout */
#layout { --rows: var(--c-switch) minmax(0, 1fr) var(--c-amount) var(--c-action);
  --sub: minmax(0, 1fr) var(--c-amount) var(--c-action);
  --lead: calc(var(--c-switch) + var(--gap)); }
#layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start;
  max-width: 1200px; margin: 0 auto; padding: 24px 24px 96px; }
#layout.wide { grid-template-columns: minmax(0, 1fr); max-width: 880px; }
#layout.wide #rail { display: none; }
#rail { position: sticky; top: 80px; display: grid; gap: 16px; max-height: calc(100vh - 96px); overflow-y: auto;
  scrollbar-width: thin; padding-bottom: 2px; }
.paper { display: grid; gap: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.card h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; }

/* section header uses the row grid so the total sits in the amount column */
.sec-head { display: grid; grid-template-columns: var(--rows); column-gap: var(--gap); align-items: baseline; padding-bottom: 12px; }
.sec-head .roman { color: var(--faint); font-weight: 600; font-size: 14px; }
.sec-head h2 { font-size: 16px; font-weight: 650; }
.sec-head h2 small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.sec-total { text-align: right; padding-right: 9px; font-weight: 650; font-variant-numeric: tabular-nums; }
.note { margin: -4px 0 8px var(--lead); font-size: 13px; color: var(--muted); }
.heading { padding: 16px 0 6px var(--lead); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- rows ---------- */
.row { display: grid; grid-template-columns: var(--rows); column-gap: var(--gap); row-gap: 8px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line); }
.heading + .row { border-top: 0; }
.lbl { min-width: 0; }
.lbl .name { display: block; }
.lbl small { display: block; margin-top: 1px; color: var(--muted); font-size: 12.5px; }
.row:not(.on) .lbl .name { color: var(--muted); }
.row.indent .lbl, .row.indent > .sub { padding-left: 16px; }
.row > .sub { grid-column: 2 / -1; }
.sub.line { display: grid; grid-template-columns: var(--sub); column-gap: var(--gap); align-items: center; }
.sub.detail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 12px; grid-column: 2 / 4; }
.ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
/* casket / vault: product picker and typed-in product */
.pick { flex: 1; min-width: 0; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  color: var(--ink); padding: 0 10px; font: inherit; font-size: 14px; }
.pick, .item-fields { margin-right: calc(var(--c-action) + var(--gap)); width: auto; }
.item-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px 12px; margin-top: 8px; align-items: end; }
.item-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.item-actions .hint { margin: 0; flex: 1; }
.chip:disabled { opacity: .5; cursor: default; }
/* price list: name + SKU side by side */
.two { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 8px; }
.cat-head { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cat-head .r { text-align: right; padding-right: 9px; }
.act { display: flex; justify-content: center; }

/* switch */
.switch { position: relative; width: 34px; height: 20px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 20px; transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* inputs */
input { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; min-width: 0; height: 32px; }
input:hover { border-color: var(--line); }
input:focus { outline: none; border-color: var(--accent); background: var(--card); }
.amt { width: 100%; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.amt::placeholder { color: var(--faint); font-weight: 400; }
.row:not(.on) .amt { color: var(--faint); font-weight: 400; }
.amt.edited { background: var(--warn-soft); }
.x-label, .qty, .each, .fld input, .note-in, #layout.wide .amt { border-color: var(--line); background: var(--card); }
.x-label { width: 100%; }
.qty { width: 64px; text-align: right; }
.each { width: 96px; text-align: right; }
.hint { font-size: 12.5px; margin-left: 4px; }
.note-in { width: 100%; margin-top: 6px; height: 28px; font-size: 12.5px; color: var(--muted); }

.fld { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.fld input, .fld select { width: 100%; color: var(--ink); font-size: 14px; }
.fld.inline { display: flex; align-items: center; gap: 8px; }
.fld.inline input { width: 160px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid + .grid { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.grid .span2 { grid-column: span 2; }
.grid .wide { grid-column: 1 / -1; }

/* buttons */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; max-width: 100%; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; line-height: 1.3; text-align: left; }
.chip span { white-space: nowrap; }
.chip span { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--faint); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); }
.chip.on span { color: inherit; }
.chip.ghost { border-style: dashed; color: var(--muted); }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper b { min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.step { width: 28px; height: 28px; border: 1px solid var(--line); background: var(--card); border-radius: 6px; line-height: 1; }
.icon { width: 24px; height: 24px; border: 0; background: none; border-radius: 6px; color: var(--muted); font-size: 16px; line-height: 1; }
.icon:hover { background: var(--soft); color: var(--ink); }
.link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; font-size: inherit; white-space: nowrap; }
.primary { width: 100%; margin-top: 16px; height: 40px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segs { display: inline-flex; background: var(--soft); padding: 3px; border-radius: 8px; }
.seg { border: 0; background: none; padding: 6px 14px; border-radius: 6px; color: var(--muted); }
.seg.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* header cards */
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; }
.head-row h2 { font-size: 16px; font-weight: 650; }
.head-row p { margin: 2px 0 0; }
.head .grid { margin-top: 16px; }
.people { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.people summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.people[open] summary { margin-bottom: 16px; }
.people .grid { margin-top: 0; }
.people p { margin: 12px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* checkbox rows (requirements) */
.check-row { cursor: pointer; }
.tick { display: flex; justify-content: center; }
.tick input, .doc input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check-row .lbl { grid-column: 2 / -1; }

/* ---------- rail ---------- */
.tot { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tot span:last-child { color: var(--ink); }
.tot.sub { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; color: var(--ink); font-weight: 600; }
.tot.grand { border-top: 2px solid var(--ink); margin-top: 8px; padding-top: 10px; color: var(--ink); font-size: 18px; font-weight: 700; }
.checks { display: grid; gap: 8px; }
.checks h3 { margin-bottom: 4px; }
.chk { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--soft); }
.chk.warn { background: var(--warn-soft); color: var(--warn); }
.docs { display: grid; gap: 8px; }
.inv-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.inv-fields .amt { width: 100%; }
.inv-fields .grand-sm { grid-column: 1 / -1; color: var(--ink); font-weight: 650; font-size: 14px; }
.doc { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.included { display: inline-flex; width: 16px; justify-content: center; color: var(--accent); font-weight: 700; }
.suggest { margin-left: auto; font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 0 6px; }
#forms > p.muted { margin: -4px 0 12px; }
.form-doc { align-items: flex-start; }
.form-doc input { margin-top: 2px; flex: none; }
.form-doc > span:not(.suggest) { display: grid; gap: 1px; }
.form-doc small { font-size: 12px; line-height: 1.35; }
.form-doc .suggest { flex: none; }
#forms .disp { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
#forms .disp + p, #forms .docs + p { margin-top: 12px; }
.form-missing { margin-top: 8px; color: var(--warn, #9a5b00); }

/* ---------- price list ---------- */
.hdr-edit { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; margin-top: 14px; align-items: start; }
.logo-box { display: grid; gap: 10px; justify-items: start; }
.logo-box > img, .logo-box > .muted:first-child { width: 200px; height: 90px; object-fit: contain; border: 1px dashed var(--line);
  border-radius: 8px; background: #fff; padding: 8px; display: grid; place-items: center; }
.logo-actions { display: flex; gap: 8px; }
.hdr-preview-wrap { margin-top: 16px; display: grid; gap: 6px; }
.hdr-preview { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 16px; display: flex; justify-content: center; }

.pick:disabled { opacity: .55; }
.fld .pick { margin-right: 0; width: 100%; }
.out-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.out-actions .primary { grid-column: 1 / -1; margin-top: 0; }
.out-actions .chip { justify-content: center; height: 36px; }
.one-doc { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 12px; font-size: 13px; }
.link:disabled { opacity: .5; }
.out-note { margin-top: 10px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.prow .pl-left { font-size: 13.5px; color: var(--muted); }
.prow .pl-left .x-label { color: var(--ink); }
/* the price list has no switches: collapse that column, keep every other column identical */
#layout.wide { --c-switch: 0px; --lead: 0px; }
#layout.wide .sec-head .roman { display: none; }
#layout.wide .sec-head h2 { grid-column: 2; }
/* pull content over the empty switch column's gap so it lines up with the card's fields */
#layout.wide .row > .lbl, #layout.wide .row > .sub, #layout.wide .sec-head h2 { margin-left: calc(-1 * var(--gap)); }

/* ---------- pinned totals (single-column layout only) ---------- */
.totalbar { display: none; }
@media (max-width: 900px) {
  .totalbar { display: flex; align-items: center; gap: 16px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 10px 24px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line);
    box-shadow: 0 -2px 8px rgba(0,0,0,.06); }
  .totalbar .primary { width: auto; margin: 0; padding: 8px 20px; }
  .tb-figures { flex: 1; display: flex; align-items: center; gap: 28px; border: 0; background: none; padding: 0;
    text-align: left; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
  .tb-item small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
  .tb-item.grand { font-size: 18px; font-weight: 700; }
  .tb-checks { margin-left: auto; font-size: 12.5px; font-weight: 500; color: var(--warn); background: var(--warn-soft);
    border-radius: 999px; padding: 3px 10px; }
  #totals { scroll-margin-top: 140px; }
}

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  #layout { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 104px; }
  #rail { position: static; max-height: none; overflow: visible; }
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
}
@media (max-width: 560px) {
  :root { --c-switch: 34px; --c-amount: 96px; --c-action: 22px; --gap: 8px; }
  .card { padding: 14px 14px; }
  .sub.detail, .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid .span2 { grid-column: 1 / -1; }
  .sub.detail { grid-column: 2 / -1; }
  .segs { width: 100%; }
  .seg { flex: 1; padding: 6px 8px; }
  .hint { flex-basis: 100%; margin-left: 0; }
}

/* Accounts: the sign-in screen, the account bar and the Team view (src/account.js). */
[hidden] { display: none !important; }
.account { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); }
.account .who { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state.saving { color: var(--muted); }
.save-state.error { color: #b42318; font-weight: 600; }
body.signed-out .tabs, body.signed-out [data-act="new"], body.signed-out .account, body.signed-out #rail { display: none; }
.signin { max-width: 420px; margin: 48px auto; display: grid; gap: 14px; }
.signin form { display: grid; gap: 12px; justify-items: start; }
.signin .fld { width: 100%; }
.signin input[name="code"] { font-size: 22px; letter-spacing: .3em; }
.dev-code { background: #fff7d6; border: 1px dashed #c9a400; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; margin: 0; }
.signin-error { color: #b42318; font-size: 13.5px; margin: 0; }
.chip.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.team-row { display: grid; grid-template-columns: 1fr 150px 170px 24px; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.team-email { overflow-wrap: anywhere; }
.team-add { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 14px; }
.team-add .fld:first-child { flex: 1 1 240px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--soft); color: var(--muted); }
.team-search { width: 100%; margin-top: 14px; padding: 10px 12px; font-size: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.team-notice { color: var(--accent); font-size: 13.5px; margin: 10px 0 0; }
.team-crumbs { font-size: 13px; color: var(--muted); margin: 0 0 12px 4px; }
.team-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 4px; }
.team-sub:first-child { margin-top: 0; }
.team-hit, .team-tr { display: grid; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 6px; font: inherit; color: inherit; cursor: pointer; }
.team-hit { grid-template-columns: 1fr auto; align-items: baseline; gap: 12px; }
.team-tr { grid-template-columns: 1fr 80px 170px; gap: 12px; align-items: center; }
.team-hit:hover, button.team-tr:hover { background: var(--soft); }
.team-tr.head { cursor: default; font-size: 12px; color: var(--muted); padding-top: 4px; }
.team-facts { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; align-items: center; margin-top: 12px; }
.team-facts .team-role { max-width: 200px; }
.team-delete { display: grid; gap: 10px; justify-items: start; }
.team-delete .fld { width: min(100%, 420px); }
.team-row .team-role { max-width: 200px; }
.card.danger { border-color: #f3c7c3; }
.chip.danger { color: #b42318; border-color: #f3c7c3; }
.chip.danger:hover { background: #fdf0ef; }
select.team-role, .team-add select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: inherit; font-size: 13.5px; }
@media (max-width: 700px) { .team-row { grid-template-columns: 1fr 24px; } .team-row .team-role, .team-row .muted { grid-column: 1; } .team-tr { grid-template-columns: 1fr 50px; } .team-tr > :last-child { display: none; } .team-facts { grid-template-columns: 1fr; } }

/* ---------- print: the NJ form ---------- */
#print { display: none; }
/* ---------- documents: the printed pages ----------
   Scoped to .sheet and not inside @media print, so the same styles render the print-out, the
   PDF (src/pdf.js) and the header preview on the Price list tab. A sheet is the printable area
   of a US letter page (8.5in less 0.35in margins = 7.8in wide). */
.sheet { width: 7.8in; background: #fff; color: #000; font: 8.6px/1.3 "Times New Roman", serif; }
.sheet * { box-sizing: border-box; }

/* funeral home header (src/documents/header.js) */
.sheet .dh { display: flex; align-items: center; gap: 14px; padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1.5px solid #000; }
.sheet .dh-center, .sheet .dh-logo { flex-direction: column; justify-content: center; text-align: center; gap: 6px; }
.sheet img.dh-img { display: block; max-height: 64px; max-width: 2.6in; object-fit: contain; }
.sheet .dh-name { font-size: 15px; font-weight: 700; }
.sheet .dh-tag { font-style: italic; }

/* NJ statement: the State Board's sample traced exactly (src/documents/sgs.js), one 8.5 × 14 in
   page with no margin. The form itself is an SVG; only the funeral home header is HTML. */
.sheet.fixed { width: 8.5in; }
.sgs-page { position: relative; width: 8.5in; height: 14in; overflow: hidden; background: #fff; }
.sgs-svg { position: absolute; left: 0; top: 0; display: block; }
.sgs-head { position: absolute; left: 22.5pt; top: 17pt; width: 276pt; height: 63pt; display: flex; align-items: center; justify-content: center;
  text-align: center; font: 10pt/1.2 "Times New Roman", Times, serif; }
.sheet .sgs-head .dh { border: 0; padding: 0; margin: 0; gap: 3pt; }
.sheet .sgs-head .dh-left { text-align: left; }
.sheet .sgs-head .dh-name { font-size: 12pt; }
.sheet .sgs-head img.dh-img { max-height: 40pt; max-width: 1.5in; }
.sgs-attached { font: 10pt/1.35 "Times New Roman", Times, serif; padding: 1.25in 0.5in 0.5in; }
.sgs-attached h2 { font-size: 11pt; margin: 0 0 6pt; }
.sgs-attached p { margin: 0 0 10pt; }
.sgs-attached table { width: 100%; border-collapse: collapse; }
.sgs-attached th, .sgs-attached td { text-align: left; border-bottom: 0.5pt solid #000; padding: 3pt 6pt 3pt 0; vertical-align: top; }
.sgs-attached .n { text-align: right; white-space: nowrap; padding-right: 0; }

/* invoice */
.sheet .inv { font: 11px/1.45 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
.sheet .inv .dh { border-bottom: 0; margin-bottom: 0; padding-bottom: 12px; }
.sheet .inv .dh-name { font-size: 17px; }
.sheet .inv-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 10px 0 10px; border-top: 2px solid #000; border-bottom: 1px solid #000; }
.sheet .inv-head h1 { font-size: 22px; letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.sheet .inv-meta { border-collapse: collapse; text-align: right; }
.sheet .inv-meta td { padding: 1px 0 1px 16px; }
.sheet .inv-meta td:first-child { color: #555; }
.sheet .inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 12px 0 14px; }
.sheet .inv-parties h2, .sheet .inv-lines th { font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #555; margin: 0 0 4px; }
.sheet .inv-lines, .sheet .inv-totals { width: 100%; border-collapse: collapse; }
.sheet .inv-lines th { text-align: left; border-bottom: 1px solid #000; padding: 4px 0; }
.sheet .inv-lines td { padding: 3px 0; border-bottom: 1px solid #ddd; vertical-align: top; }
.sheet .inv-lines tr { break-inside: avoid; }
.sheet .inv-group td { padding-top: 9px; font-weight: 700; border-bottom: 1px solid #999; }
.sheet .inv-group em { font-weight: 400; color: #555; }
.sheet .inv-detail { color: #555; font-size: 10px; }
/* No tabular-nums: html2canvas (Save PDF) ignores it, which pushes wide amounts off the right edge. */
.sheet .inv-amt { text-align: right; width: 110px; white-space: nowrap; }
.sheet .inv-lines th.inv-amt { text-align: right; }
.sheet .inv-totals { width: 320px; margin: 14px 0 0 auto; break-inside: avoid; }
.sheet .inv-totals td { padding: 3px 0; }
.sheet .inv-total td { border-top: 1px solid #000; padding-top: 6px; font-weight: 700; }
.sheet .inv-balance td { border-top: 2px solid #000; padding-top: 6px; font-size: 14px; font-weight: 700; }
.sheet .inv-terms { margin-top: 20px; }
.sheet .inv-note { margin-top: 10px; font-size: 9.5px; color: #555; }

@media print {
  @page { size: letter; margin: 0.35in; }
  body { background: #fff; color: #000; }
  .topbar, #layout { display: none !important; }
  #print { display: block !important; }
  .print-doc + .print-doc { break-before: page; }
  /* The NJ statement: its exact-size pages, no margin. */
  @page doc-legal { size: 8.5in 14in; margin: 0; }
  .print-doc.legal { page: doc-legal; }
  .print-doc .sgs-page + .sgs-page { break-before: page; }
  /* Consent forms: each page full size on its own sheet (legal or letter, as the form is). */
  @page form-legal { size: 8.5in 14in; margin: 0; }
  @page form-letter { size: letter; margin: 0; }
  .print-form { break-before: page; display: flex; justify-content: center; }
  .print-form.legal { page: form-legal; }
  .print-form.letter { page: form-letter; }
  .print-form img { display: block; height: calc(100vh - 1px); width: auto; max-width: 100%; }
}
