/*! invoice.css — the invoice generator: hero, editor, A4 sheet, print.
    Loaded only on /invoice-generator/ so other pages stay light. */

/* =============================== hero =============================== */
.hero { padding: 34px 0 26px; }
.hero-inner { display: grid; gap: 22px; align-items: start; }
@media (min-width: 1024px) {
  .hero-inner { grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 40px; }
}
.hero h1 { margin-bottom: 12px; }
.hero-lead { font-size: 1.05rem; color: var(--ink-2); max-width: 60ch; margin-bottom: 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.trust-list {
  list-style: none; margin: 20px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-size: .85rem; color: var(--muted);
}
.trust-list li { display: flex; align-items: center; gap: 7px; }
.trust-list li::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--brand); flex: none;
}

.hero-note {
  padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: var(--radius); font-size: .89rem; color: var(--ink-2);
}
.hero-note strong { display: block; margin-bottom: 4px; color: var(--ink); }
.hero-note p:last-child { margin-bottom: 0; }

/* =============================== tool =============================== */
.tool { padding-bottom: 20px; scroll-margin-top: 70px; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  position: sticky; top: var(--header-h); z-index: 30;
}
.toolbar-status {
  display: flex; align-items: center; gap: 7px; margin-right: auto;
  font-family: var(--font-mono); font-size: .72rem; color: var(--muted);
  letter-spacing: .02em;
}
.toolbar-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand); flex: none;
}
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.count-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  padding: 0 5px; margin-left: 2px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand-ink);
  font-family: var(--font-mono); font-size: .68rem;
}

.view-toggle { display: none; gap: 4px; padding: 4px; background: var(--desk-deep); border-radius: var(--radius-sm); }
.view-toggle .btn { min-height: 34px; border: 0; background: transparent; font-size: .87rem; }
.view-toggle .btn.is-active { background: var(--surface); box-shadow: var(--shadow-sm); }
@media (max-width: 1023px) { .view-toggle { display: flex; } }

#tool-grid { display: grid; gap: var(--gap); align-items: start; }
@media (min-width: 1024px) {
  #tool-grid { grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr); }
}
@media (min-width: 1440px) {
  #tool-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
}

@media (max-width: 1023px) {
  #tool-grid.is-preview .editor-pane { display: none; }
  #tool-grid:not(.is-preview) .preview-pane { display: none; }
}

/* ============================== notices ============================= */
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 12px;
  border-radius: var(--radius); font-size: .88rem;
}
.notice--sample { background: var(--brand-soft); color: var(--brand-ink); }
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.notice p { margin: 0; }
.notice .btn { margin-left: auto; }

/* ============================== editor ============================== */
.editor-pane { display: grid; gap: 12px; min-width: 0; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; cursor: pointer; list-style: none;
  font-weight: 650; letter-spacing: -.01em;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after {
  content: ""; margin-left: auto; flex: none;
  width: 8px; height: 8px; border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .16s ease;
}
.panel[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.panel > summary:hover { background: var(--surface-2); }
.panel-step {
  font-family: var(--font-mono); font-size: .7rem; color: var(--muted);
  background: var(--desk); border-radius: 4px; padding: 3px 6px; flex: none;
}
.panel-hint { font-weight: 400; font-size: .82rem; color: var(--muted); }
.panel-body { padding: 4px 16px 18px; border-top: 1px solid var(--line); }
.panel-body > * + * { margin-top: 14px; }

.grid-2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid-3 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.span-2 { grid-column: 1 / -1; }

/* logo control */
.logo-control { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo-drop {
  width: 96px; height: 72px; flex: none;
  display: grid; place-items: center; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--muted);
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: .06em;
  text-transform: uppercase; padding: 6px;
}
#logo-preview { width: 96px; height: 72px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; background: var(--surface); }
#logo-preview img { max-height: 60px; max-width: 84px; object-fit: contain; }
.logo-meta { min-width: 0; }
.logo-meta p { margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
.file-btn { position: relative; overflow: hidden; }
.file-btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.file-btn input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0;
}

/* item rows */
.items { display: grid; gap: 10px; }
.item-row {
  display: grid; gap: 8px 10px; align-items: end;
  padding: 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "idx    actions"
    "desc   desc"
    "qty    rate"
    "amount amount";
}
.items--with-tax .item-row {
  grid-template-areas:
    "idx    actions"
    "desc   desc"
    "qty    rate"
    "tax    amount";
}
.item-row-index {
  grid-area: idx; font-family: var(--font-mono); font-size: .7rem;
  color: var(--muted); letter-spacing: .08em;
}
.item-row-index::before { content: "ITEM "; }
.field--desc { grid-area: desc; }
.field--qty { grid-area: qty; }
.field--rate { grid-area: rate; }
.field--tax { grid-area: tax; }
.field--amount { grid-area: amount; align-items: flex-end; text-align: right; }
.item-actions { grid-area: actions; display: flex; gap: 2px; justify-content: flex-end; }

.item-amount {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 1rem; font-weight: 600; padding: 8px 0 0;
}

@media (min-width: 700px) {
  .item-row {
    grid-template-columns: 22px minmax(0, 1fr) 84px 110px minmax(96px, auto) 76px;
    grid-template-areas: "idx desc qty rate amount actions";
    align-items: end; gap: 8px;
  }
  .items--with-tax .item-row {
    grid-template-columns: 22px minmax(0, 1fr) 72px 100px 74px minmax(90px, auto) 76px;
    grid-template-areas: "idx desc qty rate tax amount actions";
  }
  .item-row-index { padding-bottom: 11px; }
  .item-row-index::before { content: ""; }
  .item-actions { padding-bottom: 4px; }
  .field--amount { padding-bottom: 0; }
  .item-amount { padding-top: 0; padding-bottom: 8px; }
  /* Only the first row needs visible column headings. */
  .item-row:not(:first-child) .field-label:not(.sr-only) { display: none; }
  .item-row:not(:first-child) .field--amount .field-label { display: none; }
}

.charge-row {
  display: grid; gap: 8px; align-items: end;
  grid-template-columns: minmax(0, 1fr) 130px 32px;
  margin-bottom: 8px;
}

/* totals recap inside the editor */
.recap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; background: var(--ink); color: #fff;
  border-radius: var(--radius);
}
.recap-label {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; opacity: .7;
}
.recap-total {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em;
}
.recap-meta { font-family: var(--font-mono); font-size: .72rem; opacity: .65; }

/* template + colour pickers */
.template-picker { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 520px) { .template-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1440px) { .template-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.toggle-list { display: grid; gap: 10px; }
.input.is-readonly, .is-readonly { background: var(--surface-2); color: var(--ink-2); }
.template-option {
  display: grid; gap: 4px; padding: 10px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font: inherit; color: var(--ink);
}
.template-option:hover { border-color: #a9b7c4; }
.template-option.is-active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(11, 107, 91, .16); }
.template-option-name { font-weight: 600; font-size: .9rem; }
.template-option-hint { font-size: .74rem; color: var(--muted); line-height: 1.35; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: var(--swatch); border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line-strong) inset;
}
.swatch.is-active { border-color: var(--surface); box-shadow: 0 0 0 2px var(--ink); }
.color-custom { display: flex; align-items: center; gap: 8px; }
.color-custom input[type="color"] {
  width: 40px; height: 32px; padding: 2px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}

/* ============================== preview ============================= */
.preview-pane { min-width: 0; }
@media (min-width: 1024px) {
  .preview-pane { position: sticky; top: calc(var(--header-h) + 76px); }
}

.preview-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.preview-title {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.preview-actions { margin-left: auto; display: flex; gap: 8px; }

#sheet-viewport { overflow: hidden; }
#sheet-scaler { width: 794px; transform-origin: top left; }

.sheet {
  width: 794px; min-height: 1123px; /* A4 at 96dpi */
  padding: 46px 52px 56px;
  background: #fff; color: #141A21;
  font-size: 13px; line-height: 1.55;
  box-shadow: var(--shadow-lg); border-radius: 2px;
}

/* --------------------------- sheet shared --------------------------
   Type scale is set in px because the sheet is a fixed 794px A4 canvas.
   Base is 15px = 11.25pt printed, which is normal invoice body size —
   the earlier 13px was legible on screen but small on paper. */
.sheet-placeholder { color: #b3bcc6; }
.sheet-lines { color: #47525e; font-size: 14px; }
.sheet-lines div { margin-bottom: 2px; }
.sheet-lines--center { text-align: center; }

.sheet-block-title {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .11em; text-transform: uppercase; color: #6d7885;
  margin: 0 0 8px;
}
.sheet-biz-name { font-size: 21px; font-weight: 700; letter-spacing: -.015em; margin-bottom: 8px; }
.sheet-party-name { font-size: 16px; font-weight: 650; margin-bottom: 4px; }

/* Logo. Large by default — it is the first thing a client recognises. */
.sheet-logo { margin-bottom: 14px; }
.sheet-logo img { object-fit: contain; }
.logo--small  img { max-height: 52px;  max-width: 170px; }
.logo--medium img { max-height: 78px;  max-width: 230px; }
.logo--large  img { max-height: 110px; max-width: 300px; }
.logo--xlarge img { max-height: 145px; max-width: 380px; }
.sheet-logo--center { display: flex; justify-content: center; }
.sheet-logo--min img { max-height: 84px; }

.sheet-doctype {
  font-size: 34px; font-weight: 700; letter-spacing: -.03em;
  text-transform: uppercase; color: var(--accent); line-height: 1; margin-bottom: 16px;
}

.sheet-meta { margin: 0; display: grid; gap: 5px; }
.sheet-meta > div { display: flex; justify-content: space-between; gap: 20px; }
.sheet-meta dt { color: #6d7885; font-size: 13px; }
.sheet-meta dd {
  margin: 0; font-family: var(--font-mono); font-size: 13px;
  font-variant-numeric: tabular-nums; text-align: right;
}
.sheet-meta--stack > div { justify-content: flex-start; gap: 10px; }
.sheet-meta--stack dd { text-align: left; }

.sheet-head { display: flex; gap: 32px; justify-content: space-between; align-items: flex-start; }
.sheet-head-left { max-width: 58%; }
.sheet-head-right { min-width: 240px; text-align: right; }
.sheet-head-right .sheet-doctype { text-align: right; }

.sheet-rule { height: 2px; background: var(--accent); margin: 24px 0 22px; }

.sheet-parties {
  display: flex; gap: 28px; justify-content: space-between;
  align-items: flex-start; margin-bottom: 26px;
}
.sheet-party { min-width: 0; flex: 1; }
.sheet-party--right { text-align: right; flex: none; min-width: 230px; }

.sheet-amount-due {
  min-width: 210px; flex: none; text-align: right; padding: 14px 16px;
  background: #f5f8f9; border-left: 3px solid var(--accent); border-radius: 2px;
}
.sheet-amount-due-label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: #6d7885;
}
.sheet-amount-due-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 3px;
  color: var(--accent);
}
.sheet-amount-due-date { font-size: 12.5px; color: #6d7885; }

/* items table */
.sheet-items { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.sheet-items th {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase; color: #6d7885;
  text-align: left; padding: 10px 9px; border-bottom: 1.5px solid #d7dee5;
}
.sheet-items td {
  padding: 11px 9px; border-bottom: 1px solid #edf1f4; vertical-align: top;
  font-size: 14px;
}
.sheet-items .col-idx { width: 28px; color: #97a2ad; font-family: var(--font-mono); font-size: 12px; }
.sheet-items .col-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sheet-items th.col-num { text-align: right; }
.sheet-items .col-amount { font-weight: 600; }
.sheet-items .col-desc { word-break: break-word; }
.w-idx { width: 32px; } .w-qty { width: 68px; } .w-rate { width: 100px; }
.w-tax { width: 68px; } .w-amount { width: 116px; }

/* totals */
.sheet-summary { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.sheet-summary-inner { width: 330px; max-width: 100%; }
.sheet-total-row {
  display: flex; justify-content: space-between; gap: 18px;
  padding: 6px 0; font-size: 14px; color: #47525e;
}
.sheet-total-row span:last-child {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: #141A21;
}
.sheet-total-row.is-negative span:last-child { color: #7c6a2a; }

.sheet-grand {
  display: flex; justify-content: space-between; gap: 18px; align-items: baseline;
  margin-top: 9px; padding-top: 11px; border-top: 1.5px solid var(--accent);
  font-weight: 700;
}
.sheet-grand span:first-child { font-size: 14px; letter-spacing: -.01em; }
.sheet-grand span:last-child {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 23px; letter-spacing: -.02em; color: var(--accent);
}

/* amount in words */
.sheet-words {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  padding: 10px 0 14px; margin-bottom: 14px; border-bottom: 1px solid #edf1f4;
}
.sheet-words-label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .11em;
  text-transform: uppercase; color: #6d7885; flex: none;
}
.sheet-words-value { font-size: 13.5px; font-style: italic; color: #2e3a46; }

/* blocks below the totals */
.sheet-foot { display: flex; gap: 32px; justify-content: space-between; align-items: flex-start; }
.sheet-foot-main { flex: 1; min-width: 0; }
.sheet-block { margin-bottom: 20px; max-width: 520px; }
.sheet-para { margin: 0; font-size: 13.5px; color: #47525e; line-height: 1.6; }
.sheet-para--muted { color: #6d7885; font-size: 13px; }
.sheet-pay-list { margin: 0 0 10px; display: grid; gap: 4px; }
.sheet-pay-list > div { display: flex; gap: 12px; font-size: 13.5px; }
.sheet-pay-list dt { color: #6d7885; min-width: 118px; }
.sheet-pay-list dd { margin: 0; font-family: var(--font-mono); font-size: 13px; word-break: break-word; }

/* signature */
.sheet-signature { flex: none; width: 200px; text-align: center; padding-top: 34px; }
.sheet-signature-line { border-bottom: 1px solid #8a95a1; margin-bottom: 7px; }
.sheet-signature-label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: #6d7885;
}
.sheet-signature-org { font-size: 12.5px; color: #47525e; margin-top: 3px; }

/* paid stamp */
.sheet { position: relative; }
.sheet-stamp {
  position: absolute; top: 150px; right: 60px; z-index: 2;
  padding: 8px 22px; border: 4px double var(--accent); border-radius: 6px;
  color: var(--accent); opacity: .28;
  font-family: var(--font-mono); font-size: 34px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  transform: rotate(-14deg); pointer-events: none;
}
[dir="rtl"] .sheet-stamp { right: auto; left: 60px; transform: rotate(14deg); }

/* ------------------------------- RTL ------------------------------- */
.sheet[dir="rtl"] { text-align: right; }
.sheet[dir="rtl"] .sheet-items th,
.sheet[dir="rtl"] .sheet-items td { text-align: right; }
.sheet[dir="rtl"] .sheet-items th.col-num,
.sheet[dir="rtl"] .sheet-items .col-num { text-align: left; }
.sheet[dir="rtl"] .sheet-head-right,
.sheet[dir="rtl"] .sheet-amount-due,
.sheet[dir="rtl"] .sheet-party--right { text-align: left; }
.sheet[dir="rtl"] .sheet-head-right .sheet-doctype { text-align: left; }
.sheet[dir="rtl"] .sheet-amount-due { border-left: 0; border-right: 3px solid var(--accent); }
.sheet[dir="rtl"] .sheet-meta dd { text-align: left; }
.sheet[dir="rtl"] .sheet-meta--stack dd { text-align: right; }
.sheet[dir="rtl"] .sheet-summary { justify-content: flex-start; }
.sheet[dir="rtl"] .sheet-rail { left: auto; right: 0; }
.sheet[dir="rtl"] .sheet--ledger { padding-left: 52px; padding-right: 64px; }

/* ----------------------------- modern ----------------------------- */
.sheet--modern { padding-top: 0; }
.sheet-band {
  display: flex; gap: 32px; justify-content: space-between; align-items: flex-start;
  margin: 0 -48px 28px; padding: 42px 48px 36px;
  background: var(--accent); color: #fff;
}
.sheet-band .sheet-biz-name { color: #fff; }
.sheet-band-left { max-width: 58%; }
.sheet-lines--band { color: rgba(255, 255, 255, .84); }
.sheet-band-right { text-align: right; min-width: 220px; }
.sheet-doctype--band {
  color: rgba(255, 255, 255, .8); font-size: 17px; letter-spacing: .18em; margin-bottom: 8px;
}
.sheet-band-number { font-family: var(--font-mono); font-size: 13.5px; color: rgba(255, 255, 255, .84); margin-bottom: 16px; }
.sheet-band-total {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 30px; font-weight: 700; letter-spacing: -.02em;
}
.sheet-band-due { font-size: 12.5px; color: rgba(255, 255, 255, .84); margin-top: 3px; }
.sheet[dir="rtl"] .sheet-band-right { text-align: left; }
.sheet-parties--modern { gap: 40px; }
.sheet--modern .sheet-items th { background: #f4f7f8; border-bottom: 1px solid #e2e8ed; }
.sheet-summary-inner--card { padding: 16px 18px; background: #f5f8f9; border-radius: 6px; }
.sheet-grand--filled {
  margin: 12px -18px -16px; padding: 14px 18px;
  background: var(--accent); color: #fff; border-top: 0; border-radius: 0 0 6px 6px;
}
.sheet-grand--filled span:last-child { color: #fff; }

/* ----------------------------- minimal ---------------------------- */
.sheet--minimal { padding: 58px 56px; }
.sheet-min-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 26px; padding-bottom: 20px; border-bottom: 1px solid #e6ebef;
}
.sheet--minimal .sheet-biz-name { font-size: 18px; font-weight: 600; margin: 0; }
.sheet-min-doc { text-align: right; }
.sheet[dir="rtl"] .sheet-min-doc { text-align: left; }
.sheet-eyebrow {
  display: block; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--accent);
}
.sheet-min-number { font-family: var(--font-mono); font-size: 13.5px; color: #6d7885; }
.sheet-min-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px; margin: 26px 0 32px;
}
.sheet--minimal .sheet-items th { border-bottom: 1px solid #d7dee5; color: #8a95a1; }
.sheet--minimal .sheet-items td { border-bottom: 1px solid #f1f4f6; }
.sheet-summary--min .sheet-summary-inner { width: 290px; }
.sheet--minimal .sheet-grand { border-top: 1px solid #141A21; }
.sheet--minimal .sheet-grand span:last-child { color: #141A21; font-size: 20px; }

/* ------------------------------- bold ----------------------------- */
.sheet--bold { padding-top: 0; }
.sheet-bold-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 30px;
  margin: 0 -48px 30px; padding: 48px 48px 30px;
  background: #14181f; color: #fff;
}
.sheet-bold-type {
  font-size: 52px; font-weight: 800; letter-spacing: -.045em; line-height: .9;
  text-transform: uppercase; color: #fff;
}
.sheet-bold-total { text-align: right; }
.sheet[dir="rtl"] .sheet-bold-total { text-align: left; }
.sheet-bold-total-label {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .6);
  margin-bottom: 4px;
}
.sheet-bold-total-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 34px; font-weight: 700; letter-spacing: -.03em; color: var(--accent);
  filter: brightness(1.9);
}
.sheet-bold-cols {
  display: flex; gap: 28px; justify-content: space-between;
  align-items: flex-start; margin-bottom: 30px;
}
.sheet--bold .sheet-items th {
  background: #14181f; color: rgba(255, 255, 255, .75); border-bottom: 0;
}
.sheet--bold .sheet-items tbody tr:nth-child(even) { background: #f6f8f9; }
.sheet--bold .sheet-items td { border-bottom: 0; }
.sheet-grand--bold {
  border-top: 3px solid #14181f; padding-top: 12px;
}
.sheet-grand--bold span:last-child { font-size: 26px; color: #14181f; }

/* ----------------------------- elegant ---------------------------- */
.sheet--elegant {
  padding: 60px 62px;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
}
.sheet--elegant .sheet-block-title,
.sheet--elegant .sheet-items th,
.sheet--elegant .sheet-words-label,
.sheet--elegant .sheet-signature-label { font-family: var(--font-mono); }
.sheet-eleg-head { text-align: center; margin-bottom: 30px; }
.sheet--elegant .sheet-biz-name {
  font-size: 26px; font-weight: 400; letter-spacing: .04em; margin-bottom: 8px;
}
.sheet-eleg-rule {
  position: relative; margin-top: 26px; border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent); padding: 9px 0;
}
.sheet-eleg-rule span {
  font-family: var(--font-mono); font-size: 15px; letter-spacing: .3em;
  text-transform: uppercase; color: var(--accent);
}
.sheet-parties--eleg { margin-bottom: 30px; }
.sheet--elegant .sheet-items th { border-bottom: 1px solid var(--accent); color: #47525e; }
.sheet--elegant .sheet-grand span:last-child { font-size: 22px; }

/* ----------------------------- compact ---------------------------- */
.sheet--compact { padding: 40px 46px; font-size: 13.5px; }
.sheet-compact-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 26px; padding-bottom: 16px; border-bottom: 2px solid var(--accent); margin-bottom: 18px;
}
.sheet-compact-brand { display: flex; gap: 16px; align-items: flex-start; }
.sheet-compact-brand .sheet-logo { margin-bottom: 0; }
.sheet--compact .sheet-biz-name { font-size: 18px; margin-bottom: 5px; }
.sheet--compact .sheet-lines { font-size: 12.5px; }
.sheet-compact-meta { text-align: right; min-width: 220px; }
.sheet[dir="rtl"] .sheet-compact-meta { text-align: left; }
.sheet--compact .sheet-doctype { font-size: 24px; margin-bottom: 10px; }
.sheet--compact .sheet-block-title { font-size: 10px; margin-bottom: 5px; }
.sheet-parties--compact { margin-bottom: 18px; }
.sheet--compact .sheet-items th { padding: 7px 8px; font-size: 10px; }
.sheet--compact .sheet-items td { padding: 7px 8px; font-size: 13px; }
.sheet--compact .sheet-party-name { font-size: 15px; }
.sheet--compact .sheet-amount-due { padding: 10px 13px; min-width: 180px; }
.sheet--compact .sheet-amount-due-value { font-size: 21px; }
.sheet--compact .sheet-block { margin-bottom: 14px; }

/* ------------------------------ ledger ---------------------------- */
.sheet--ledger { padding-left: 64px; }
.sheet-rail {
  position: absolute; left: 0; top: 0; bottom: 0; width: 14px;
  background: var(--accent);
}
.sheet-ledger-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 30px; margin-bottom: 26px;
}
.sheet-ledger-right { text-align: right; }
.sheet[dir="rtl"] .sheet-ledger-right { text-align: left; }
.sheet-ledger-number {
  font-family: var(--font-mono); font-size: 14px; color: #47525e;
  padding: 5px 11px; background: #f2f6f7; border-radius: 3px; display: inline-block;
}
.sheet-ledger-grid {
  display: flex; gap: 30px; justify-content: space-between;
  align-items: flex-start; margin-bottom: 26px;
}
.sheet--ledger .sheet-items th {
  border-top: 1.5px solid var(--accent); border-bottom: 1.5px solid var(--accent);
  color: #47525e;
}
.sheet--ledger .sheet-items tbody tr:nth-child(odd) { background: #f7fafa; }
.sheet--ledger .sheet-items td { border-bottom: 1px solid #e8eef0; }
.sheet-grand--rule { border-top: 3px double var(--accent); }

/* ========================= saved invoices ========================== */
.saved-grid { display: grid; gap: 8px; }
.saved-row {
  display: grid; gap: 8px 12px; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.saved-row:hover { border-color: var(--line-strong); background: var(--surface-2); }
.saved-main { display: grid; gap: 2px; min-width: 0; }
.saved-number { font-family: var(--font-mono); font-size: .82rem; color: var(--brand-ink); }
.saved-customer { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-dates { font-size: .78rem; color: var(--muted); }
.saved-total {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-weight: 700; text-align: right;
}
.saved-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
@media (min-width: 620px) {
  .saved-row { grid-template-columns: minmax(0, 1fr) 120px auto; }
  .saved-actions { grid-column: auto; }
}

/* ========================== mobile action bar ====================== */
.mobile-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: none; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.mobile-bar .btn { flex: 1; }
@media (max-width: 1023px) {
  .mobile-bar { display: flex; }
  body { padding-bottom: 68px; }
}

/* =============================== print ============================= */
@media print {
  @page { size: A4; margin: 12mm; }

  html, body { background: #fff !important; padding: 0 !important; margin: 0 !important; }

  /* Everything that is not the invoice is removed from the page. */
  .site-header, .site-footer, .hero, .toolbar, .editor-pane, .mobile-bar,
  .ad-slot, .content-section, .breadcrumbs, .toasts, .modal, .preview-head,
  .notice, .skip-link, #tool-grid > .editor-pane {
    display: none !important;
  }

  /* Belt and braces: hide anything left, then reveal only the sheet. */
  body * { visibility: hidden !important; }
  #invoice-sheet, #invoice-sheet * { visibility: visible !important; }

  .wrap { padding: 0 !important; max-width: none !important; }
  .tool { padding: 0 !important; }
  #tool-grid { display: block !important; }
  .preview-pane { position: static !important; display: block !important; width: 100% !important; }
  #sheet-viewport { overflow: visible !important; height: auto !important; }
  /* Stay in normal flow — absolutely positioned content does not paginate
     reliably, and a long invoice must be able to break across pages. */
  #sheet-scaler { transform: none !important; width: 100% !important; margin: 0 !important; }
  #invoice-sheet { position: static !important; width: 100% !important; }

  .sheet {
    width: 100% !important; min-height: 0 !important;
    padding: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    font-size: 11pt; color: #000;
  }
  .sheet--minimal, .sheet--elegant, .sheet--compact { padding: 0 !important; }
  .sheet--ledger { padding: 0 0 0 12mm !important; }
  .sheet-band, .sheet-bold-head { margin: 0 0 8mm !important; padding: 8mm !important; }
  .sheet--modern, .sheet--bold { padding-top: 0 !important; }
  .sheet-rail { position: absolute; height: 100%; }

  /* Multi-page behaviour */
  .sheet-items thead { display: table-header-group; }
  .sheet-items tr { break-inside: avoid; page-break-inside: avoid; }
  .sheet-summary, .sheet-block, .sheet-amount-due, .sheet-words,
  .sheet-signature, .sheet-foot { break-inside: avoid; page-break-inside: avoid; }
  .sheet-grand { break-inside: avoid; }

  /* Keep accent fills in the PDF where the browser allows it. */
  .sheet-band, .sheet-grand--filled, .sheet-rule, .sheet-amount-due,
  .sheet--modern .sheet-items th, .sheet-summary-inner--card,
  .sheet-bold-head, .sheet--bold .sheet-items th, .sheet--bold .sheet-items tbody tr,
  .sheet-rail, .sheet--ledger .sheet-items tbody tr, .sheet-stamp, .sheet-ledger-number {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
