/* Invoice Generator page — loaded only with projects-templates/invoice-generator.php */

/* Hide theme chrome for full-screen app */
body.invoice-generator-page .site-header,
body.invoice-generator-page .site-header__nav-backdrop {
  display: none !important;
}

body.invoice-generator-page {
  margin: 0;
}

body.invoice-generator-page .site-main.invoice-generator {
  max-width: none;
  margin: 0;
  padding: 0;
}

.invoice-generator {
  --ig-label-color: #6e6e6e;
  --ig-placeholder-party: #a9a9a9;
  --ig-chrome-offset: 0;
  --ig-sticky-top: 0.75rem;
  --ig-preview-pad: 1.25rem;
  /* Extra space above the invoice inside the gray preview holder */
  --ig-preview-invoice-margin-top: 1rem;
  /* Mobile scroll handoff: set by invoice-generator.js (preview grows as editor scrolls away) */
  --ig-mobile-scroll-boost: 1;
  --ig-mobile-preview-fill: 0;
}

.invoice-generator__inner {
  margin-inline: auto;
  max-width: 100%;
  box-sizing: border-box;
}

.invoice-generator__title {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  margin-bottom: 1.25rem;
  font-weight: 700;
}

.invoice-generator__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  align-items: start;
}

/* ——— Left panel (form) ——— */
.invoice-generator__panel {
  position: relative;
  z-index: 1;
  background-color: #f5f8fa;
  border-right: none;
  border-bottom: 1px solid #dedede;
  padding: 1.2rem;
}

.ig-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ig-section {
  border-bottom: 0;
  padding: 0 1rem 1.25rem;
}

.ig-section:first-of-type {
  border-radius: 4px 4px 0 0;
}

.ig-section:last-of-type {
  border-radius: 0 0 4px 4px;
}

.ig-section:only-of-type {
  border-radius: 4px;
}

/* Section headings: From, Bill to, Line items, Notes — 12px (match field labels) */
.ig-section__title {
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ig-label-color);
  margin-bottom: 0.85rem;
  line-height: 1.35;
}

/* Invoice editor: title row + reset control */
.ig-section__head--invoice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.ig-section__head--invoice .ig-section__title {
  margin-bottom: 0;
}

/* Invoice editor page title only — 16px */
.ig-section--invoice .ig-section__head .ig-section__title {
  font-size: 16px;
}

.ig-reset-editor {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.35rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ig-label-color);
  cursor: pointer;
  line-height: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ig-reset-editor:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--gray);
}

.ig-reset-editor:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.ig-reset-editor__icon-wrap {
  display: inline-flex;
  pointer-events: none;
}

.ig-reset-editor__icon {
  display: block;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  object-fit: contain;
  transform-origin: 50% 50%;
  transition: transform 0.55s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@media (prefers-reduced-motion: no-preference) {
  .ig-reset-editor:hover .ig-reset-editor__icon,
  .ig-reset-editor:focus-visible .ig-reset-editor__icon {
    transform: rotate(360deg);
  }
}

.ig-field {
  margin-bottom: 1.25rem;
}

.ig-field:last-child {
  margin-bottom: 0;
}

/* Invoice editor: invoice #, currency, issue date, due date —2×2 grid */
.ig-invoice-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 0.75rem;
  row-gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.ig-invoice-meta-grid .ig-field {
  margin-bottom: 0;
  /* Let grid/flex cells shrink below intrinsic control width (esp. WebKit date inputs) */
  min-width: 0;
  max-width: 100%;
}

/*
 * Date/time inputs have a large default min-width; without this they ignore the track
 * and overflow the 2×2 grid or the stacked dates column.
 */
.ig-invoice-meta-grid input[type='date'] {
  min-width: 0;
  max-width: 100%;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Wide screens: dates sit in the second row of the 2×2 grid (wrapper is layout-transparent) */
.ig-invoice-meta-grid__dates {
  display: contents;
}

/* Narrow viewports: issue + due dates in one row (invoice # and currency stay side by side above) */
@media (max-width: 40rem) {
  .ig-invoice-meta-grid__dates {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    grid-column: 1 / -1;
    gap: 0.75rem;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    align-items: flex-start;
  }

  .ig-invoice-meta-grid__dates .ig-field {
    flex: 1;
    min-width: 0;
    max-width: 100%;
  }
}

.ig-field--narrow {
  max-width: 8rem;
}

.ig-field--grow {
  flex: 1;
  min-width: 0;
}

.ig-label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ig-label-color);
}

/* Label + control are often siblings; gap on .ig-label only applies inside the label, not between label and input */
.ig-field > .ig-label:not(:last-child) {
  margin-bottom: 0.85rem;
}

.ig-input,
.ig-textarea {
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  padding: 0.65rem 0.85rem;
  border: 1px solid #e9e9e9;
  border-radius: 3px;
  color: var(--gray);
  background: var(--white);
  width: 100%;
  box-sizing: border-box;
}

.ig-input::placeholder,
.ig-textarea::placeholder {
  color: var(--ig-placeholder-party);
  font-size: 16px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  opacity: 1;
}

/* Invoice editor (first section): invoice #, currency, dates — placeholder = body text color */
.ig-section--invoice .ig-input::placeholder,
.ig-section--invoice .ig-textarea::placeholder {
  color: var(--gray);
}

/* First editor section: tighter label hierarchy + roomier controls */
.ig-section--invoice {
  padding: 1.2rem 1.15rem 1.25rem;
}

.ig-section--invoice .ig-input,
.ig-section--invoice .ig-textarea {
  padding: 0.78rem 0.95rem;
}

.ig-section--invoice .ig-input--select {
  padding-top: 0.78rem;
  padding-bottom: 0.78rem;
  padding-left: 0.95rem;
  padding-right: 2.25rem;
  background-position: right 0.75rem center;
}



.ig-section--invoice .ig-field:last-child {
  margin-bottom: 0;
}

.ig-input:focus,
.ig-textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: #d0d0d0;
}

.ig-input--select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23666' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 0.75rem;
  cursor: pointer;
}

/* Logo: full-area file control with centered label (no native “Choose file” UI) */
.ig-file-upload {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: 0.78rem 0.95rem;
  border: 1px solid #e9e9e9;
  border-radius: 3px;
  background: var(--white);
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}

.ig-file-upload:hover:not(:focus-within) {
  border-color: var(--blue);
}

.ig-file-upload:hover:not(:focus-within) .ig-file-upload__text {
  color: var(--blue);
}

.ig-file-upload .ig-input--file {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.ig-file-upload .ig-input--file:focus {
  outline: none;
}

.ig-file-upload:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: #d0d0d0;
}

.ig-file-upload__text {
  font-size: 16px;
  font-weight: 400;
  color: var(--ig-label-color);
  text-align: center;
  pointer-events: none;
  line-height: 1.35;
  transition: color 0.2s ease;
}

.ig-template-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ig-template-btn {
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  padding: 0.55rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid #e9e9e9;
  background: var(--white);
  color: var(--ig-label-color);
  line-height: 1.2;
  box-sizing: border-box;
}

.ig-template-btn:hover {
  border-color: #d0d0d0;
  background: #fafafa;
}

.ig-template-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.ig-template-btn--active,
.ig-template-btn[aria-pressed='true'] {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.ig-line-items {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0;
}

/* Line item row (Description, Qty, Rate) — same 12px as field labels */
.ig-line-item .ig-label {
  font-size: 12px;
  letter-spacing: 0.06em;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--ig-placeholder-party);
}

.ig-line-item__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.5rem 4rem auto;
  gap: 0.5rem;
  align-items: end;
}

@media (max-width: 30rem) {
  .ig-line-item__grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .ig-line-item__grid .ig-field--grow {
    grid-column: 1 / -1;
  }

  .ig-line-remove {
    grid-column: 1 / -1;
    justify-self: end;
  }
}

.ig-field--qty .ig-input,
.ig-field--rate .ig-input {
  text-align: right;
}

.ig-line-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  background: transparent;
  color: #8a8a8a;
  border-radius: 3px;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.ig-line-remove:not(:disabled):hover {
  background-color: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}

.ig-line-remove:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ig-line-remove:focus-visible:not(:disabled) {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.ig-line-remove svg {
  display: block;
  flex-shrink: 0;
}

.ig-btn {
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  padding: 0.55rem 1rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid #e9e9e9;
  color: var(--ig-label-color);
}

.ig-btn--secondary {
  background: var(--white);
  color: var(--ig-label-color);
  width: 100%;
}

.ig-btn--secondary:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.ig-btn--add-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  color: var(--blue);
}

.ig-btn--add-line .ig-btn__plus {
  font-size: 1.2em;
  font-weight: 600;
  line-height: 1;
}

.ig-btn--add-line .ig-btn__add-label {
  font-size: 16px;
  font-weight: 400;
}

.ig-btn--add-line:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.ig-btn--add-line:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.ig-btn--primary {
  width: 100%;
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
  padding: 0.65rem 1rem;
  margin-top: 1rem;
}

.ig-btn--primary:hover {
  filter: brightness(0.95);
}

.ig-btn--primary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ==========================================================================
   Preview column — frame, scaling holder, A4 sheet
   Holder uses container queries so the sheet fits like a “paper” image in the box
   ========================================================================== */

.invoice-generator__preview {
  position: relative;
  width: 100%;
  min-width: 0;
}

.invoice-generator__preview-frame {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  background: #606060;
  min-height: 16rem;
  max-width: 100%;
  box-sizing: border-box;
}

.invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='creative']) {
  background: #2e475b;
}

.invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='minimal']) {
  background: #f2f4f5;
}

.invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='retro']) {
  background: #5c5348;
}

.invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='cartoon']) {
  background: #4a4a4a;
}

/* Mobile-only template strip (see projects-templates/invoice-generator.php); hidden on desktop */
.invoice-generator__preview-toolbar {
  display: none;
}

/* Sizing context for cqw / cqh; no inner scroll — avoids scaled sheet drifting off-center */
.invoice-generator__preview-holder {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-height: 12rem;
  min-width: 0;
  box-sizing: border-box;
  padding: var(--ig-preview-pad);
  overflow: hidden;
  overflow-x: hidden;
  container-type: size;
}

/*
 * A4 ratio: JS sets --ig-sheet-w and --ig-sheet-h so width = height × (210/297).
 */
.invoice-generator__preview-scale {
  width: 210mm;
  min-height: 297mm;
  height: auto;
  flex-shrink: 0;
  margin-top: var(--ig-preview-invoice-margin-top, 0);
  transform-origin: top center;
  /* Never wider/taller than the holder: boost can only use “slack” when height-bound */
  transform: scale(
    calc(
      min(
        min(100cqw / var(--ig-sheet-w, 210mm), 100cqh / var(--ig-sheet-h, 297mm)) *
          var(--ig-mobile-scroll-boost, 1),
        100cqw / var(--ig-sheet-w, 210mm),
        100cqh / var(--ig-sheet-h, 297mm)
      )
    )
  );
}

/*
 * PDF export: html2canvas mis-renders content under CSS transform: scale().
 * JS toggles .ig-is-exporting-pdf on .invoice-generator during export.
 *
 * Lock the scale wrapper to A4 width during capture. Otherwise JS sets width from
 * offsetHeight×(210/297); web fonts (Montserrat on creative/cartoon) can change height
 * after that runs, leaving a too-narrow inline width → PDF bitmap letterboxed vs full bleed.
 */
.invoice-generator.ig-is-exporting-pdf .invoice-generator__preview-scale {
  transform: none !important;
  width: 210mm !important;
  min-width: 210mm !important;
  max-width: 210mm !important;
  box-sizing: border-box;
}

.invoice-generator.ig-is-exporting-pdf .invoice-generator__preview-scale > .ig-invoice-sheet--a4,
.invoice-generator.ig-is-exporting-pdf .invoice-generator__preview-scale > .ig-invoice-sheet--letter {
  width: 100% !important;
  max-width: none !important;
}

.invoice-generator.ig-is-exporting-pdf .invoice-generator__preview,
.invoice-generator.ig-is-exporting-pdf .invoice-generator__preview-frame,
.invoice-generator.ig-is-exporting-pdf .invoice-generator__preview-holder {
  overflow: visible !important;
}

/* PDF: drop preview-only padding and shadows so the capture matches a tight A4 page */
.invoice-generator.ig-is-exporting-pdf .ig-invoice-sheet {
  padding-bottom: calc(var(--ig-unit) * 4) !important;
  box-shadow: none !important;
}

/* ——— Invoice sheet (Classic, A4) ——— */
.ig-invoice-sheet {
  --ig-unit: 8px;
  --ig-line: #3a3a3a;
  --ig-party-name-color: #000000;
  --ig-party-meta-color: #757575;
  display: flex;
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--white);
  color: var(--gray);
  margin-inline: auto;
  box-shadow: 0 4px 24px rgba(44, 44, 44, 0.12);
  border: 1px solid rgba(44, 44, 44, 0.12);
  box-sizing: border-box;
  font-size: calc(var(--ig-unit) * 2);
  font-weight: 400;
  line-height: 1.5;
  padding: calc(var(--ig-unit) * 4);
  padding-bottom: 100px;
}

/*
 * A4 width; min height one A4 page — grows with content when more line items are added.
 */
.ig-invoice-sheet--a4,
.ig-invoice-sheet--letter {
  display: flex;
  flex-direction: column;
  width: min(100%, 210mm);
  max-width: 100%;
  margin-inline: auto;
  flex-shrink: 0;
  min-height: 297mm;
  height: auto;
  overflow: visible;
}

.invoice-generator__preview-scale > .ig-invoice-sheet--a4,
.invoice-generator__preview-scale > .ig-invoice-sheet--letter {
  width: 100%;
  min-height: 297mm;
  height: auto;
  margin: 0;
  max-width: none;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: calc(var(--ig-unit) * 3);
  margin-bottom: calc(var(--ig-unit) * 4);
}

.ig-invoice-sheet .ig-sheet__hero-left {
  display: flex;
  flex-direction: column;
  gap: calc(var(--ig-unit) * 3);
  min-width: 0;
}

.ig-invoice-sheet .ig-sheet__logo-row {
  position: relative;
  width: calc(var(--ig-unit) * 8);
  height: calc(var(--ig-unit) * 8);
  flex-shrink: 0;
}

.ig-invoice-sheet .ig-sheet__logo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #000;
  color: #fff;
  font-size: calc(var(--ig-unit) * 1.5);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.ig-invoice-sheet .ig-sheet__logo-placeholder.is-hidden {
  display: none;
}

.ig-invoice-sheet .ig-sheet__logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  background: #fff;
}

.ig-invoice-sheet .ig-sheet__logo[hidden] {
  display: none !important;
}

/* Uploaded logo: cover + visually centered crop; transparent behind image */
.ig-invoice-sheet .ig-sheet__logo-row:has(.ig-sheet__logo:not([hidden])) {
  border: none;
  box-shadow: none;
  outline: none;
  background: transparent;
  overflow: hidden;
}

.ig-invoice-sheet .ig-sheet__logo:not([hidden]) {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  margin: 0;
  padding: 0;
  display: block;
  object-fit: cover;
  object-position: 50% 50%;
  background: transparent;
}

/* Wrapper for cartoon layered shadow; inner .ig-sheet__dates-block unchanged for other templates */
.ig-invoice-sheet .ig-sheet__dates-stack {
  display: block;
}

.ig-invoice-sheet .ig-sheet__dates-block {
  display: flex;
  flex-direction: column;
  padding-left: 0;
  margin-top: calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet .ig-sheet__date-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: calc(var(--ig-unit) * 1);
  font-size: 12px;
}

.ig-invoice-sheet .ig-sheet__date-label {
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray);
}

.ig-invoice-sheet .ig-sheet__date-value {
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
}

/* Issue date: regular (markup uses <strong>) */
.ig-invoice-sheet #ig-preview-date.ig-sheet__date-value {
  font-weight: 400;
}

/* Only due date value is bold */
.ig-invoice-sheet #ig-preview-due.ig-sheet__date-value {
  font-weight: 700;
}

.ig-invoice-sheet .ig-sheet__hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex: 1;
  min-width: 12rem;
}

.ig-invoice-sheet .ig-sheet__invoice-title {
  margin: 0;
  font-size: calc(var(--ig-unit) * 4);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-transform: uppercase;
}

.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__invoice-title {
  font-family: Arial, Helvetica, sans-serif;
}

.ig-invoice-sheet .ig-sheet__invoice-number {
  margin: calc(var(--ig-unit) * 1) 0 0;
  font-size: calc(var(--ig-unit) * 2);
  font-weight: 400;
  color: #888;
  letter-spacing: 0.02em;
}

/* Parties table — fixed 50/50 columns so the center divider stays mid-container */
.ig-invoice-sheet .ig-sheet__table--parties {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-bottom: calc(var(--ig-unit) * 6);
  border: none;
}

.ig-invoice-sheet .ig-sheet__table--parties thead th {
  width: 50%;
  box-sizing: border-box;
  background: #cecece;
  border: none;
  padding: calc(var(--ig-unit) * 0.5) calc(var(--ig-unit) * 1);
  text-align: left;
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ig-invoice-sheet .ig-sheet__table--parties thead .ig-sheet__th-bill-to {
  border-left: none;
}

.ig-invoice-sheet .ig-sheet__table--parties tbody td {
  width: 50%;
  box-sizing: border-box;
  border: none;
  vertical-align: top;
  padding: calc(var(--ig-unit) * 1) calc(var(--ig-unit) * 1.5);
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.ig-invoice-sheet .ig-sheet__table--parties tbody .ig-sheet__party-cell--bill-to {
  border-left: none;
}

/* Classic: parties header + column rule like line items table */
.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--parties thead th {
  border-bottom: 1px solid var(--ig-line);
}

.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--parties thead .ig-sheet__th-bill-to {
  border-left: 1px solid var(--ig-line);
}

.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--parties tbody .ig-sheet__party-cell--bill-to {
  border-left: 1px solid var(--ig-line);
}

.ig-invoice-sheet .ig-sheet__party-line {
  margin: 0 0 calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet .ig-sheet__party-line:last-child {
  margin-bottom: 0;
}

.ig-invoice-sheet .ig-sheet__party-line--strong {
  font-weight: 400;
  font-size: 12px;
  color: var(--ig-party-name-color);
}

/* Email + address — lighter grey than company / client name */
.ig-invoice-sheet .ig-sheet__party-line:not(.ig-sheet__party-line--strong) {
  font-size: 12px;
  color: var(--ig-party-meta-color);
}

.ig-invoice-sheet .ig-sheet__party-line--multiline p {
  margin: 0 0 calc(var(--ig-unit) * 0.5);
}

/* Line items — wrapper carries bottom margin so templates can layer shadows on the stack */
.ig-sheet__lines-stack {
  margin-bottom: calc(var(--ig-unit) * 8);
}

.ig-sheet__lines-stack .ig-sheet__table--lines {
  margin-bottom: 0;
}

/* Line items — fixed columns so vertical rules stay aligned */
.ig-invoice-sheet .ig-sheet__table--lines {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-bottom: 0;
  border: none;
}

.ig-invoice-sheet .ig-sheet__table--lines thead th:nth-child(1),
.ig-invoice-sheet .ig-sheet__table--lines tbody td:nth-child(1) {
  width: 46%;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--lines thead th:nth-child(2),
.ig-invoice-sheet .ig-sheet__table--lines tbody td:nth-child(2) {
  width: 6%;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--lines thead th:nth-child(3),
.ig-invoice-sheet .ig-sheet__table--lines tbody td:nth-child(3),
.ig-invoice-sheet .ig-sheet__table--lines thead th:nth-child(4),
.ig-invoice-sheet .ig-sheet__table--lines tbody td:nth-child(4) {
  width: 10%;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--lines thead th {
  background: #cecece;
  border: none;
  border-right: 1px solid var(--ig-line);
  border-bottom: 1px solid var(--ig-line);
  padding: calc(var(--ig-unit) * 0.5) calc(var(--ig-unit) * 1);
  text-align: left;
  font-weight: 400;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ig-invoice-sheet .ig-sheet__table--lines thead th:last-child {
  border-right: none;
}

.ig-invoice-sheet .ig-sheet__table--lines tbody td {
  border: none;
  border-top: 0;
  border-right: 1px solid var(--ig-line);
  border-bottom: 1px solid var(--ig-line);
  padding: calc(var(--ig-unit) * 0.5) calc(var(--ig-unit) * 1);
  vertical-align: top;
  font-size: 12px;
}

.ig-invoice-sheet .ig-sheet__table--lines tbody td:nth-child(1) {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

/* Full-width placeholder row (colspan) — not the first column width */
.ig-invoice-sheet .ig-sheet__table--lines tbody td[colspan] {
  width: auto;
}

.ig-invoice-sheet .ig-sheet__table--lines tbody td:last-child {
  border-right: none;
}

.ig-invoice-sheet .ig-sheet__col-num {
  text-align: right;
  white-space: nowrap;
}

.ig-invoice-sheet .ig-sheet__empty-row {
  text-align: center;
  opacity: 0.45;
}

/* Totals block — sits after line items */
.ig-invoice-sheet .ig-sheet__footer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: calc(var(--ig-unit) * 2);
  flex-shrink: 0;
}

.ig-invoice-sheet .ig-sheet__footer-totals-wrap {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

/* Notes: sheet flex child, margin-top auto pins to bottom (above padding) when space allows */
.ig-invoice-sheet .ig-sheet__footer-notes {
  width: 100%;
  max-width: none;
  flex: 0 0 auto;
  padding-top: calc(var(--ig-unit) * 2);
  margin-top: auto;
  padding-bottom: 0;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__footer-notes[hidden] {
  margin-top: 0;
}

.ig-invoice-sheet .ig-sheet__note-label {
  display: block;
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet .ig-sheet__notes-body {
  font-size: calc(var(--ig-unit) * 1.75);
  color: #444;
}

.ig-invoice-sheet .ig-sheet__notes-body p {
  margin: 0 0 calc(var(--ig-unit) * 1);
}

/*
 * Totals: optional gutter (Retro = description column width) + merged QTY/Price/Total band.
 */
.ig-invoice-sheet .ig-sheet__table--totals {
  border-collapse: collapse;
  border: none;
  outline: none;
  margin-left: auto;
  width: auto;
  max-width: 100%;
}

.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-gutter {
  width: 0;
  padding: 0;
  border: none;
  box-sizing: border-box;
  vertical-align: top;
}

.ig-invoice-sheet .ig-sheet__table--totals td.ig-sheet__totals-merged {
  padding: 0;
  border-style: solid;
  border-color: var(--ig-line);
  border-width: 0 0 1px 0;
  vertical-align: middle;
  background: #fff;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-line-inner {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-line-label {
  flex: 1;
  margin: 0;
  min-width: 0;
  text-align: left;
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #cecece;
  padding: calc(var(--ig-unit) * 0.75) calc(var(--ig-unit) * 1.5);
  border-style: solid;
  border-color: var(--ig-line);
  border-width: 0 1px 0 0;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-line-value {
  display: block;
  flex: 0 0 auto;
  min-width: 4.3rem;
  text-align: right;
  font-size: calc(var(--ig-unit) * 2);
  font-weight: 400;
  background: #fff;
  padding: calc(var(--ig-unit) * 0.75) calc(var(--ig-unit) * 1.5);
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--totals tr:last-child .ig-sheet__totals-gutter,
.ig-invoice-sheet .ig-sheet__table--totals tr:last-child td.ig-sheet__totals-merged {
  border-bottom-width: 0;
}

/* Grand total: inner flexes label + amount (classic = row; creative = column) */
.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-grand td.ig-sheet__totals-grand-cell {
  display: table-cell;
  vertical-align: top;
  padding: 0;
  border: none;
  width: auto;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-stack {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-inner {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-label {
  flex: 1;
  margin: 0;
  background: #cecece;
  padding: calc(var(--ig-unit) * 0.75) calc(var(--ig-unit) * 1.5);
  border-style: solid;
  border-color: var(--ig-line);
  border-width: 0 1px 0 0;
  text-align: left;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ig-invoice-sheet .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-value {
  display: block;
  flex: 0 0 auto;
  min-width: 4.3rem;
  text-align: right;
  font-size: calc(var(--ig-unit) * 2.25);
  font-weight: 700;
  background: #fff;
  padding: calc(var(--ig-unit) * 0.75) calc(var(--ig-unit) * 1.5);
  border-style: solid;
  border-color: var(--ig-line);
  border-width: 0;
}

/* Classic: center label + amount vertically within each totals row (subtotal, tax, grand). */
.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--totals .ig-sheet__totals-line-label,
.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--totals .ig-sheet__totals-line-value {
  display: flex;
  align-items: center;
}

.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--totals .ig-sheet__totals-line-value {
  justify-content: flex-end;
}

.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--totals .ig-sheet__totals-grand td.ig-sheet__totals-grand-cell {
  vertical-align: middle;
}

.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-label,
.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-value {
  display: flex;
  align-items: center;
}

.ig-invoice-sheet[data-ig-template='classic'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-value {
  justify-content: flex-end;
}

/* ==========================================================================
   Minimal template — monochrome, Inter, generous whitespace
   ========================================================================== */

.ig-invoice-sheet[data-ig-template='minimal'] {
  --ig-line: #000000;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  color: #000;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
  border: none;
  padding: calc(var(--ig-unit) * 5);
  padding-bottom: 100px;
}

/* Left: logo + dates (stacked). Right: INVOICE + invoice # only */
.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: calc(var(--ig-unit) * 4);
  align-items: start;
  margin-bottom: calc(var(--ig-unit) * 5);
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__hero-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--ig-unit) * 3);
  min-width: 0;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: calc(var(--ig-unit) * 0.5);
  min-width: 0;
  justify-self: stretch;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__invoice-title {
  margin: 0;
  font-size: calc(var(--ig-unit) * 5);
  font-weight: 700;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  letter-spacing: 0.04em;
  line-height: 1.05;
  text-transform: uppercase;
  text-align: right;
  width: 100%;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__invoice-number {
  margin: 0;
  max-width: 100%;
  font-size: calc(var(--ig-unit) * 2);
  font-weight: 400;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  color: #000;
  text-align: right;
  letter-spacing: normal;
  width: 100%;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__invoice-number::before {
  content: 'Invoice #: ';
  font-weight: 400;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__dates-block {
  margin-top: calc(var(--ig-unit) * 2);
  padding-left: 0;
  width: 100%;
  text-align: left;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__logo-row {
  width: calc(var(--ig-unit) * 9);
  height: calc(var(--ig-unit) * 9);
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__logo-placeholder {
  border-radius: 0;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  font-size: calc(var(--ig-unit) * 1.25);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__logo {
  border-radius: 0;
  background: #fff;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__logo:not([hidden]) {
  background: transparent;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__date-line {
  font-size: calc(var(--ig-unit) * 1.75);
  justify-content: flex-start;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__date-label {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: #000;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__date-value,
.ig-invoice-sheet[data-ig-template='minimal'] #ig-preview-date.ig-sheet__date-value {
  font-weight: 400;
  font-size: 12px;
}

.ig-invoice-sheet[data-ig-template='minimal'] #ig-preview-due.ig-sheet__date-value {
  font-weight: 700;
  font-size: 12px;
}

/* FROM / BILL TO — small caps, no rule under labels */
.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--parties {
  margin-bottom: calc(var(--ig-unit) * 6);
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--parties thead th {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #000;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--parties tbody td {
  padding: calc(var(--ig-unit) * 2) calc(var(--ig-unit) * 2) 0 0;
  border: none;
  vertical-align: top;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__party-line--strong {
  font-weight: 400;
  font-size: 12px;
  color: var(--ig-party-name-color);
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__party-line:not(.ig-sheet__party-line--strong) {
  font-size: 12px;
  color: var(--ig-party-meta-color);
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__party-line--multiline p {
  margin: 0 0 calc(var(--ig-unit) * 0.5);
}

/* Line items — no rules above header or between rows */
.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__lines-stack {
  margin-bottom: calc(var(--ig-unit) * 6);
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--lines {
  border: none;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--lines thead th {
  background: transparent;
  border: none;
  padding: calc(var(--ig-unit) * 0.85) 0 calc(var(--ig-unit) * 0.65);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #000;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--lines thead th:nth-child(2),
.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--lines thead th:nth-child(3),
.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--lines thead th:nth-child(4) {
  text-align: right;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--lines thead th:first-child {
  text-align: left;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--lines tbody td {
  border: none;
  padding: calc(var(--ig-unit) * 0.5) 0;
  font-size: 12px;
  color: #000;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__empty-row {
  opacity: 0.35;
}

/* Notes + totals */
.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__footer {
  align-items: stretch;
}

/* Same treatment as FROM / BILL TO and Description / Qty column headers */
.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__note-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #000;
  margin-bottom: calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__notes-body {
  font-size: calc(var(--ig-unit) * 1.75);
  color: #000;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals {
  min-width: 11rem;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals .ig-sheet__totals-gutter {
  background: transparent;
  border: none;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals td.ig-sheet__totals-merged {
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--ig-line);
  padding: calc(var(--ig-unit) * 0.875) 0;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals .ig-sheet__totals-line-label {
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #000;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals .ig-sheet__totals-line-value {
  background: transparent;
  padding: 0;
  text-align: right;
  font-size: calc(var(--ig-unit) * 2);
  font-weight: 400;
  color: #000;
  min-width: 0;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals tr:nth-child(2) td.ig-sheet__totals-merged {
  border-bottom: 0.5px solid var(--ig-line);
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals tr.ig-sheet__totals-grand td.ig-sheet__totals-grand-cell {
  border-bottom: none;
  padding: calc(var(--ig-unit) * 1.25) 0 0;
  vertical-align: bottom;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-inner {
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: calc(var(--ig-unit) * 2);
  padding: 0;
  border: none;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-label {
  background: transparent;
  border: none;
  padding: 0;
  font-size: calc(var(--ig-unit) * 2.25);
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #000;
}

.ig-invoice-sheet[data-ig-template='minimal'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-value {
  background: transparent;
  border: none;
  padding: 0;
  font-size: calc(var(--ig-unit) * 2.5);
  font-weight: 700;
  color: #000;
  min-width: 0;
}

/* ==========================================================================
   Creative template — reference design (Montserrat, pink accent, light gray)
   ========================================================================== */

.ig-invoice-sheet[data-ig-template='creative'] {
  --ig-line: #2c3e50;
  --ig-creative-pink: #ff4d8d;
  --ig-creative-bg: #f5f5f5;
  --ig-creative-ink: #2c3e50;
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  background: var(--ig-creative-bg);
  color: var(--ig-creative-ink);
  border: none;
  box-shadow: none;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__hero {
  align-items: flex-start;
  margin-bottom: calc(var(--ig-unit) * 5);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__logo-placeholder {
  background: #fff;
  color: var(--ig-creative-ink);
  border: 1px solid var(--ig-creative-ink);
  font-size: calc(var(--ig-unit) * 1.1);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__dates-block {
  margin-top: calc(var(--ig-unit) * 2);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__date-label {
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--ig-creative-ink);
  font-weight: 500;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__date-value {
  font-size: 12px;
  color: var(--ig-creative-ink);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__hero-right {
  flex: 0 1 auto;
  min-width: 9rem;
  max-width: 55%;
  margin-top: calc(var(--ig-unit) * -4);
  margin-right: calc(var(--ig-unit) * -4);
  padding: calc(var(--ig-unit) * 3) calc(var(--ig-unit) * 4) calc(var(--ig-unit) * 3) calc(var(--ig-unit) * 10);
  background: var(--ig-creative-pink);
  color: #fff;
  border-radius: 0 0 0 8.25rem;
  text-align: right;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__invoice-title {
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  color: #fff;
  text-transform: none;
  font-weight: 700;
  font-size: calc(var(--ig-unit) * 5);
  letter-spacing: 0.02em;
  line-height: 1.05;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__invoice-number {
  margin-top: calc(var(--ig-unit) * 1.5);
  color: #fff;
  font-size: calc(var(--ig-unit) * 1.75);
  font-weight: 500;
  opacity: 0.95;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__invoice-number::before {
  content: 'Invoice #: ';
  font-weight: 500;
}

/* Parties: FROM / BILL TO — no rules (lines) between columns or under rows */
.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--parties {
  margin-bottom: calc(var(--ig-unit) * 5);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--parties thead th {
  background: transparent;
  color: var(--ig-creative-ink);
  border: none;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--parties thead .ig-sheet__th-bill-to {
  border-left: none;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--parties tbody td {
  border: none;
  padding-top: calc(var(--ig-unit) * 2);
  padding-bottom: calc(var(--ig-unit) * 2);
  background: transparent;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--parties tbody .ig-sheet__party-cell--bill-to {
  border-left: none;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__party-line--strong {
  font-weight: 400;
  font-size: 12px;
  color: var(--ig-party-name-color);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__party-line:not(.ig-sheet__party-line--strong) {
  font-size: 12px;
  color: var(--ig-party-meta-color);
}

/* Line items: one pill header (pink on tr — no seams between columns), body = horizontal rules only */
.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__lines-stack {
  margin-bottom: calc(var(--ig-unit) * 12);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines {
  border-collapse: collapse;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines thead {
  border-radius: 2rem;
  overflow: hidden;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines thead tr {
  background: var(--ig-creative-pink);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines thead th {
  background: transparent;
  color: #fff;
  border: none;
  padding: calc(var(--ig-unit) * 0.75) calc(var(--ig-unit) * 1.25);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  vertical-align: middle;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines thead th:first-child {
  border-radius: 2rem 0 0 2rem;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines thead th:nth-child(2),
.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines thead th:nth-child(3),
.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines thead th:nth-child(4) {
  text-align: right;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines tbody td {
  border: none;
  border-right: none;
  border-bottom: 1px solid var(--ig-creative-ink);
  background: transparent;
  font-size: 12px;
  color: var(--ig-creative-ink);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines tbody td:nth-child(1) {
  text-align: left;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines tbody td.ig-sheet__col-num {
  text-align: right;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--lines tbody tr:last-child td {
  border-bottom: 1px solid var(--ig-creative-ink);
}

/* Footer + totals */
.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__footer {
  align-items: stretch;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__note-label {
  color: var(--ig-creative-ink);
  font-weight: 600;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__notes-body {
  color: var(--ig-creative-ink);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals {
  margin-left: auto;
  width: auto;
  border-collapse: separate;
  border-spacing: 0;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals .ig-sheet__totals-gutter {
  border: none;
  background: transparent;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals td.ig-sheet__totals-merged {
  border: none;
  background: transparent;
  color: var(--ig-creative-ink);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals .ig-sheet__totals-line-label {
  background: transparent;
  border: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  font-size: 11px;
  color: var(--ig-creative-ink);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals .ig-sheet__totals-line-value {
  background: transparent;
  font-weight: 500;
  color: var(--ig-creative-ink);
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals tr:nth-child(2) td.ig-sheet__totals-merged {
  border-top: 1px solid var(--ig-creative-ink);
  padding-top: calc(var(--ig-unit) * 1.25);
}

/* Grand total: stacked label + amount, pink card, 60px gap above */
.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals tr.ig-sheet__totals-grand td.ig-sheet__totals-grand-cell {
  width: 100%;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-inner {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: calc(var(--ig-unit) * 1.25);
  margin-top: 60px;
  padding: calc(var(--ig-unit) * 2) calc(var(--ig-unit) * 2.5) calc(var(--ig-unit) * 2.5) calc(var(--ig-unit) * 6);
  background: var(--ig-creative-pink);
  color: #fff;
  border: none;
  border-radius: 0rem 0 0 5.75rem;
  width: 100%;
  max-width: 100%;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-label {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  padding: 0;
  text-align: right;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #fff;
}

.ig-invoice-sheet[data-ig-template='creative'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-value {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  padding: 0;
  text-align: right;
  font-size: calc(var(--ig-unit) * 4.25);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  min-width: 0;
}

/* ==========================================================================
   Retro template — cream paper, brick-red INVOICE, Courier Std, ruled tables
   ========================================================================== */

.ig-invoice-sheet[data-ig-template='retro'] {
  --ig-retro-bg: #ebe4d4;
  --ig-retro-ink: #1a1a1a;
  --ig-retro-accent: #c54d3b;
  --ig-line: #000000;
  font-family: 'courier-std', monospace;
  font-weight: 400;
  font-style: normal;
  background: var(--ig-retro-bg);
  color: var(--ig-retro-ink);
  border: none;
  box-shadow: 0 4px 28px rgba(44, 44, 44, 0.18);
}

/* Hero matches Classic: logo + dates (left), title + invoice # (right) */
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__hero {
  margin-bottom: calc(var(--ig-unit) * 5);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__invoice-title {
  margin: 0;
  font-family: 'courier-std', monospace;
  font-weight: 700;
  font-style: normal;
  font-size: clamp(2.5rem, 8cqw, 3.75rem);
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ig-retro-accent);
}

/*
 * English “Invoice” =7 letter spans (nth-child 1–7: I n v o i c e). Kern in Retro only, e.g.:
 * margin-right / letter-spacing on .ig-sheet__invoice-title__letter:nth-child(n)
 */

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__invoice-title__letter:nth-child(1) {
  margin-right: -0.08em;
}
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__invoice-title__letter:nth-child(4) {
  margin-right: -0.08em;
  margin-left: -0.04em;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__invoice-title__letter:nth-child(5) {
  margin-right: -0.12em;
  margin-left: -0.04em;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__invoice-title__letter:nth-child(6) {
  margin-right: -0.05em;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__invoice-number {
  margin: 0;
  font-family: 'courier-std', monospace;
  font-weight: 400;
  font-size: calc(var(--ig-unit) * 2);
  color: var(--ig-retro-ink);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__invoice-number::before {
  content: 'Invoice #: ';
  font-weight: 400;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__dates-block {
  margin-top: calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__logo-row {
  width: 5.5rem;
  height: 5.5rem;
  flex-shrink: 0;
  border: 1px solid #000;
  box-sizing: border-box;
  background: var(--ig-retro-bg);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__logo-placeholder {
  border-radius: 0;
  background: transparent;
  color: var(--ig-retro-ink);
  font-family: 'courier-std', monospace;
  font-weight: 400;
  font-size: calc(var(--ig-unit) * 1.5);
  letter-spacing: 0.08em;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__logo {
  border-radius: 0;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__date-line {
  font-size: calc(var(--ig-unit) * 1.75);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__date-label {
  font-family: 'courier-std', monospace;
  font-weight: 400;
  color: var(--ig-retro-ink);
  text-transform: none;
  letter-spacing: 0;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__date-value,
.ig-invoice-sheet[data-ig-template='retro'] #ig-preview-date.ig-sheet__date-value {
  font-family: 'courier-std', monospace;
  font-weight: 400;
  font-size: 12px;
  color: var(--ig-retro-ink);
}

.ig-invoice-sheet[data-ig-template='retro'] #ig-preview-due.ig-sheet__date-value {
  font-weight: 700;
  font-size: 12px;
}

/* FROM / BILL TO — no rules between columns or under header */
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--parties {
  margin-bottom: calc(var(--ig-unit) * 4);
  border: none;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--parties thead th {
  background: transparent;
  border: none;
  padding: 0 0 calc(var(--ig-unit) * 0.75);
  font-family: 'courier-std', monospace;
  font-weight: 700;
  font-size: calc(var(--ig-unit) * 1.75);
  letter-spacing: 0.06em;
  color: var(--ig-retro-ink);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--parties thead .ig-sheet__th-bill-to {
  border-left: none;
  padding-left: calc(var(--ig-unit) * 2);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--parties tbody td {
  border: none;
  padding: calc(var(--ig-unit) * 1.25) calc(var(--ig-unit) * 1.5) calc(var(--ig-unit) * 1.5) 0;
  vertical-align: top;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--parties tbody .ig-sheet__party-cell--bill-to {
  border-left: none;
  padding-left: calc(var(--ig-unit) * 2);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__party-line {
  font-family: 'courier-std', monospace;
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: calc(var(--ig-unit) * 1);
  min-height: 0;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__party-line:last-child {
  margin-bottom: 0;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__party-line--strong {
  font-weight: 400;
  font-size: 12px;
  color: var(--ig-party-name-color);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__party-line:not(.ig-sheet__party-line--strong) {
  font-size: 12px;
  color: var(--ig-party-meta-color);
  font-weight: 400;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__party-line--multiline p {
  margin: 0 0 calc(var(--ig-unit) * 0.5);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__party-line--multiline p:last-child {
  margin-bottom: 0;
}

/* Line items — full grid border */
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__lines-stack {
  margin-bottom: 0;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines {
  /* No bottom on table: last row td already has border-bottom (avoids 2px seam) */
  border: 1px solid #000;
  border-bottom: 2px solid #000;
  border-collapse: collapse;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines thead th:nth-child(1),
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines tbody td:nth-child(1) {
  width: 56%;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines thead th:nth-child(2),
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines tbody td:nth-child(2) {
  width: 10%;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines thead th:nth-child(3),
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines tbody td:nth-child(3),
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines thead th:nth-child(4),
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines tbody td:nth-child(4) {
  width: 17%;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines thead th {
  font-family: 'courier-std', monospace;
  font-weight: 700;
  font-size: calc(var(--ig-unit) * 1.5);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  color: var(--ig-retro-ink);
  border: 1px solid #000;
  border-bottom: 1px solid #000;
  padding: calc(var(--ig-unit) * 0.75) calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines thead th:nth-child(2),
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines thead th:nth-child(3),
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines thead th:nth-child(4) {
  text-align: right;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines tbody td {
  font-family: 'courier-std', monospace;
  font-weight: 400;
  font-size: 12px;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  border-left: 1px solid #000;
  border-top: none;
  background: transparent;
  color: var(--ig-retro-ink);
  padding: calc(var(--ig-unit) * 0.65) calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--lines tbody td.ig-sheet__col-num {
  text-align: right;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__empty-row {
  opacity: 0.5;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__footer {
  margin-top: 0;
  align-items: stretch;
}

/*
 * Outer 2px frame lives on the wrapper, not the <table>. html2canvas often mis-draws borders on
 * collapsed tables (uneven weight vs preview); a normal box on a flex child rasterizes like the
 * rest of the page. PDF export still uses border-collapse: separate + spacing 0 so inner 1px
 * rules don’t fight the collapsed border model during capture.
 */
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__footer-totals-wrap {
  width: 100%;
  justify-content: stretch;
  box-sizing: border-box;
  border: 2px solid #000;
  border-top: none;
}

/*
 * Totals — same column weights as line items (56% / 44%): gutter mirrors description;
 * merged cell spans QTY+price+total with no vertical rules inside; labels align to QTY edge.
 *
 * Inner rows: horizontal dividers only under subtotal and tax; grand row has no bottom rule.
 */
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals {
  table-layout: fixed;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  border-collapse: separate;
  border-spacing: 0;
  border: none;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals .ig-sheet__totals-gutter {
  width: 56%;
  padding: 0;
  font-family: 'courier-std', monospace;
  background: var(--ig-retro-bg);
  border: none;
  vertical-align: middle;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals td.ig-sheet__totals-merged {
  padding: 0;
  font-family: 'courier-std', monospace;
  background: var(--ig-retro-bg);
  color: var(--ig-retro-ink);
  border: none;
  vertical-align: middle;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals tr:first-child .ig-sheet__totals-gutter,
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals tr:first-child td.ig-sheet__totals-merged {
  border-bottom: 1px solid #000;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals tr:nth-child(2) .ig-sheet__totals-gutter,
.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals tr:nth-child(2) td.ig-sheet__totals-merged {
  border-bottom: 1px solid #000;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals .ig-sheet__totals-line-inner {
  align-items: center;
  min-height: calc(var(--ig-unit) * 4);
  padding: calc(var(--ig-unit) * 0.65) calc(var(--ig-unit) * 1);
  box-sizing: border-box;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals .ig-sheet__totals-line-label {
  flex: 1;
  margin: 0;
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  font-weight: 700;
  font-size: calc(var(--ig-unit) * 1.5);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ig-retro-ink);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals .ig-sheet__totals-line-value {
  flex: 0 0 auto;
  background: transparent;
  padding: 0;
  margin: 0;
  min-width: 0;
  text-align: right;
  font-weight: 400;
  font-size: calc(var(--ig-unit) * 2);
  color: var(--ig-retro-ink);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals tr.ig-sheet__totals-grand td.ig-sheet__totals-grand-cell {
  display: table-cell;
  padding: 0;
  border: none;
  vertical-align: middle;
  background: var(--ig-retro-bg);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-inner {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--ig-unit) * 2);
  width: 100%;
  margin: 0;
  padding: calc(var(--ig-unit) * 0.75) calc(var(--ig-unit) * 1);
  background: var(--ig-retro-bg);
  border: none;
  border-radius: 0;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-label {
  flex: 1;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  text-align: left;
  font-family: 'courier-std', monospace;
  font-size: calc(var(--ig-unit) * 1.5);
  font-weight: bold;
  font-synthesis: weight;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ig-retro-ink);
  -webkit-text-stroke: 0.02em var(--ig-retro-ink);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-value {
  flex: 0 0 auto;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: none;
  font-family: 'courier-std', monospace;
  font-size: calc(var(--ig-unit) * 2.25);
  font-weight: 700;
  color: var(--ig-retro-ink);
  text-align: right;
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__note-label {
  font-family: 'courier-std', monospace;
  font-weight: 700;
  color: var(--ig-retro-ink);
}

.ig-invoice-sheet[data-ig-template='retro'] .ig-sheet__notes-body {
  font-family: 'courier-std', monospace;
  font-weight: 400;
  color: var(--ig-retro-ink);
}

/* ==========================================================================
   Cartoon template — neo-brutalist, Montserrat, fixed palette
   ========================================================================== */

.ig-invoice-sheet[data-ig-template='cartoon'] {
  --ig-cartoon-bg: #f7f6f2;
  --ig-cartoon-yellow: #f2d990;
  --ig-cartoon-blue: #b4d8f4;
  --ig-cartoon-purple: #c6aed4;
  --ig-cartoon-ink: #000000;
  /* Offset “back” cards: ~88% face + 12% black (literal hex: html2canvas/pdf cannot parse color-mix) */
  --ig-cartoon-dup-yellow: #d5bf7f;
  --ig-cartoon-dup-blue: #9ebed7;
  --ig-cartoon-dup-purple: #ae99bb;
  --ig-cartoon-layer-offset: 5px;
  --ig-line: var(--ig-cartoon-ink);
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  background: var(--ig-cartoon-bg);
  color: var(--ig-cartoon-ink);
  border: none;
  box-shadow: none;
}

/* Hero matches Classic: logo + dates (left), title + invoice # (right) */
.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__hero {
  margin-bottom: calc(var(--ig-unit) * 4);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__invoice-title {
  margin: 0;
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(2.75rem, 10cqw, 4rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__invoice-number {
  margin: 0;
  font-weight: 500;
  font-size: calc(var(--ig-unit) * 2);
  color: var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__invoice-number::before {
  content: 'Invoice #: ';
  font-weight: 500;
}

/* Same geometry as line items: transparent stack + ::after, yellow face on inner block */
.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__dates-stack {
  position: relative;
  z-index: 0;
  isolation: isolate;
  margin-top: calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__dates-stack::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: var(--ig-cartoon-dup-yellow);
  border: 1px solid var(--ig-cartoon-ink);
  transform: translate(var(--ig-cartoon-layer-offset), var(--ig-cartoon-layer-offset));
  pointer-events: none;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__dates-block {
  margin-top: 0;
  padding: calc(var(--ig-unit) * 3) calc(var(--ig-unit) * 2.5) calc(var(--ig-unit) * 2);
  padding-top: calc(var(--ig-unit) * 4);
  background: var(--ig-cartoon-yellow);
  border: 1px solid var(--ig-cartoon-ink);
  position: relative;
}

/*
 * Traffic lights: real DOM nodes (not box-shadow on ::before) so html2canvas/PDF shows all three dots.
 */
.ig-sheet__cartoon-traffic {
  display: none;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__cartoon-traffic {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: calc(var(--ig-unit) * 1);
  position: absolute;
  z-index: 1;
  top: calc(var(--ig-unit) * 1.25);
  left: calc(var(--ig-unit) * 2);
  pointer-events: none;
}

.ig-sheet__cartoon-traffic-dot {
  width: calc(var(--ig-unit) * 1.25);
  height: calc(var(--ig-unit) * 1.25);
  border-radius: 50%;
  border: 0.5px solid var(--ig-cartoon-ink);
  box-sizing: border-box;
  flex-shrink: 0;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__cartoon-traffic-dot--red {
  background: #e85d8e;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__cartoon-traffic-dot--yellow {
  background: #d4a017;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__cartoon-traffic-dot--green {
  background: #3d9a5c;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__date-line {
  font-size: calc(var(--ig-unit) * 1.75);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__date-label {
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  font-weight: 600;
  color: var(--ig-cartoon-ink);
  text-transform: none;
  letter-spacing: 0;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__date-value,
.ig-invoice-sheet[data-ig-template='cartoon'] #ig-preview-date.ig-sheet__date-value {
  font-weight: 600;
  font-size: 12px;
  color: var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] #ig-preview-due.ig-sheet__date-value {
  font-weight: 800;
  font-size: 12px;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__logo-row {
  width: 5.25rem;
  height: 5.25rem;
  border: 1px solid var(--ig-cartoon-ink);
  background: var(--ig-cartoon-bg);
  box-sizing: border-box;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__logo-placeholder {
  border-radius: 0;
  background: var(--ig-cartoon-bg);
  color: var(--ig-cartoon-ink);
  font-weight: 700;
  font-size: calc(var(--ig-unit) * 1.5);
  letter-spacing: 0.06em;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__logo {
  border-radius: 0;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--parties {
  margin-bottom: calc(var(--ig-unit) * 4);
  border: none;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--parties thead th {
  background: transparent;
  border: none;
  padding: 0 0 calc(var(--ig-unit) * 1);
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  font-weight: 800;
  font-size: calc(var(--ig-unit) * 1.75);
  letter-spacing: 0.06em;
  color: var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--parties thead .ig-sheet__th-bill-to {
  border-left: none;
  text-align: left;
  padding-left: calc(var(--ig-unit) * 3);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--parties tbody td {
  border: none;
  padding: 0;
  padding-right: calc(var(--ig-unit) * 2);
  vertical-align: top;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--parties tbody .ig-sheet__party-cell--bill-to {
  border-left: none;
  padding-left: calc(var(--ig-unit) * 3);
  padding-right: 0;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__party-line--strong {
  font-weight: 400;
  font-size: 12px;
  color: var(--ig-party-name-color);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__party-line:not(.ig-sheet__party-line--strong) {
  font-size: 12px;
  color: var(--ig-party-meta-color);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__lines-stack {
  position: relative;
  z-index: 0;
  isolation: isolate;
  margin-bottom: calc(var(--ig-unit) * 3);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__lines-stack::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: var(--ig-cartoon-dup-blue);
  border: 1px solid var(--ig-cartoon-ink);
  transform: translate(var(--ig-cartoon-layer-offset), var(--ig-cartoon-layer-offset));
  pointer-events: none;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--lines {
  background: var(--ig-cartoon-blue);
  border: 1px solid var(--ig-cartoon-ink);
  border-bottom: none;
  border-collapse: separate;
  border-spacing: 0;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--lines thead th {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ig-cartoon-ink);
  border-right: 1px solid var(--ig-cartoon-ink);
  padding: calc(var(--ig-unit) * 1.25) calc(var(--ig-unit) * 1.5);
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  font-weight: 800;
  font-size: calc(var(--ig-unit) * 1.5);
  letter-spacing: 0.05em;
  color: var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--lines thead th:last-child {
  border-right: none;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--lines tbody td {
  border: none;
  border-bottom: 1px solid var(--ig-cartoon-ink);
  border-right: 1px solid var(--ig-cartoon-ink);
  background: transparent;
  padding: calc(var(--ig-unit) * 1) calc(var(--ig-unit) * 1.5);
  font-size: 12px;
  color: var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--lines tbody td:last-child {
  border-right: none;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--lines tbody tr:last-child td {
  border-bottom: 1px solid var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--lines tbody td.ig-sheet__empty-row {
  border-bottom: 1px solid var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__footer-totals-wrap {
  justify-content: flex-end;
  width: 100%;
}

/* Notes: full-width block below totals */
.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__footer-notes:not([hidden]) {
  padding-top: calc(var(--ig-unit) * 2);
  margin-top: auto;
  max-width: none;
  width: 100%;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__note-label {
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  font-weight: 800;
  font-size: calc(var(--ig-unit) * 1.75);
  color: var(--ig-cartoon-ink);
  text-transform: none;
  letter-spacing: 0.02em;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__notes-body {
  font-size: calc(var(--ig-unit) * 1.75);
  color: var(--ig-cartoon-ink);
  line-height: 1.45;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals {
  border: none;
  margin-left: 0;
  min-width: 11rem;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-gutter {
  border: none;
  background: transparent;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals td.ig-sheet__totals-merged {
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  border: none;
  background: transparent;
  color: var(--ig-cartoon-ink);
  padding: calc(var(--ig-unit) * 0.65) 0;
}

/* Subtotal / tax: stable gap between label and amount when values grow (avoid flex:1 label collapsing) */
.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-line-inner {
  justify-content: space-between;
  align-items: center;
  gap: calc(var(--ig-unit) * 2);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-line-label {
  flex: 0 0 auto;
  flex-shrink: 0;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 0;
  text-align: right;
  font-weight: 800;
  font-size: calc(var(--ig-unit) * 1.5);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-line-value {
  flex: 0 0 auto;
  flex-shrink: 0;
  background: transparent;
  padding: 0;
  text-align: right;
  font-weight: 600;
  font-size: calc(var(--ig-unit) * 2);
  white-space: nowrap;
  color: var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals tr:first-child td.ig-sheet__totals-merged {
  border-bottom: 1px solid var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals tr:nth-child(2) td.ig-sheet__totals-merged {
  border-bottom: none;
  padding-top: calc(var(--ig-unit) * 1);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals tr.ig-sheet__totals-grand td.ig-sheet__totals-grand-cell {
  padding: 0;
  border: none;
  vertical-align: middle;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-stack {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: 100%;
  margin-top: calc(var(--ig-unit) * 1.5);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-stack::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: var(--ig-cartoon-dup-purple);
  border: 1px solid var(--ig-cartoon-ink);
  transform: translate(var(--ig-cartoon-layer-offset), var(--ig-cartoon-layer-offset));
  pointer-events: none;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-inner {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--ig-unit) * 2);
  margin-top: 0;
  padding: calc(var(--ig-unit) * 1.25) calc(var(--ig-unit) * 2);
  background: var(--ig-cartoon-purple);
  border: 1px solid var(--ig-cartoon-ink);
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-label {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  font-size: calc(var(--ig-unit) * 2);
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
}

.ig-invoice-sheet[data-ig-template='cartoon'] .ig-sheet__table--totals .ig-sheet__totals-grand .ig-sheet__totals-grand-value {
  flex: 1;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: none;
  font-family: var(--font-montserrat), 'Montserrat', system-ui, sans-serif;
  font-size: calc(var(--ig-unit) * 2.25);
  font-weight: 800;
  color: #fff;
  text-align: right;
}

/* Preview links shouldn’t use global accent underline noise */
.invoice-generator .ig-invoice-sheet a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   Invoice generator — breakpoints (layout)
   Preview invoice scales as one unit via .invoice-generator__preview-scale (see above).
   ≥64rem: two columns; editor scrolls; preview column fills height.
   ========================================================================== */

/* ——— Mobile: preview frame height + padding (invoice scales via .invoice-generator__preview-scale) ——— */
@media (max-width: 63.99rem) {
  .invoice-generator {
    --ig-preview-pad: 1rem;
    --ig-preview-invoice-margin-top: 1.1rem;
  }

  #ig-download-pdf {
    border-radius: 0;
  }

  /*
   * Template pills: collapsed until JS adds .invoice-generator--preview-toolbar-revealed
   * (edit panel bottom above mid-viewport — see invoice-generator.js).
   */
  .invoice-generator__preview-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-shrink: 0;
    max-height: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    border-bottom: 0 solid transparent;
    background: rgba(0, 0, 0, 0.28);
    scrollbar-width: none;
    transition:
      max-height 0.35s ease,
      opacity 0.25s ease,
      padding-block 0.3s ease,
      border-bottom-width 0.2s ease;
  }

  .invoice-generator--preview-toolbar-revealed .invoice-generator__preview-toolbar {
    max-height: 5rem;
    padding: 0.75rem 0.65rem;
    opacity: 1;
    pointer-events: auto;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: rgba(255, 255, 255, 0.12);
  }

  .invoice-generator__panel {
    padding: 1.2rem 0 0;
  }

  .invoice-generator__preview-toolbar::-webkit-scrollbar {
    display: none;
  }

  @media (prefers-reduced-motion: reduce) {
    .invoice-generator__preview-toolbar {
      transition: none;
    }
  }

  .invoice-generator__preview-toolbar .ig-template-btn--preview {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 500;
    padding: 0.32rem 0.55rem;
    line-height: 1.2;
    border-radius: 999px;
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.92);
  }

  .invoice-generator__preview-toolbar .ig-template-btn--preview:hover {
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
  }

  .invoice-generator__preview-toolbar .ig-template-btn--preview.ig-template-btn--active,
  .invoice-generator__preview-toolbar .ig-template-btn--preview[aria-pressed='true'] {
    border-color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  }

  .invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='minimal']) .invoice-generator__preview-toolbar {
    background: rgba(0, 0, 0, 0.06);
    border-bottom-color: rgba(0, 0, 0, 0.1);
  }

  .invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='minimal'])
    .invoice-generator__preview-toolbar
    .ig-template-btn--preview {
    border-color: rgba(0, 0, 0, 0.14);
    background: rgba(255, 255, 255, 0.85);
    color: #3a3a3a;
  }

  .invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='minimal'])
    .invoice-generator__preview-toolbar
    .ig-template-btn--preview:hover {
    border-color: rgba(0, 0, 0, 0.22);
    background: #fff;
  }

  .invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='minimal'])
    .invoice-generator__preview-toolbar
    .ig-template-btn--preview.ig-template-btn--active,
  .invoice-generator__preview-frame:has(.ig-invoice-sheet[data-ig-template='minimal'])
    .invoice-generator__preview-toolbar
    .ig-template-btn--preview[aria-pressed='true'] {
    border-color: var(--blue);
    color: var(--blue);
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--blue);
  }

  /*
   * Default preview strip height; --ig-mobile-preview-fill (0→1) grows toward full viewport
   * while the user scrolls past the editor (see invoice-generator.js).
   */
  .invoice-generator__preview-frame {
    min-height: calc(
      min(70vh, 28rem) * (1 - var(--ig-mobile-preview-fill, 0)) + 100svh * var(--ig-mobile-preview-fill, 0)
    );
  }
}

/* ——— Desktop: split layout — only the editor column scrolls ——— */
@media (min-width: 64rem) {

  .invoice-generator {
    --ig-preview-invoice-margin-top: 0.55rem;
  }

  .invoice-generator .ig-input,
  .invoice-generator .ig-textarea {
    font-size: 12px;
  }

  .invoice-generator .ig-input::placeholder,
  .invoice-generator .ig-textarea::placeholder {
    font-size: 12px;
  }

  .invoice-generator .ig-file-upload__text {
    font-size: 12px;
  }

  .invoice-generator .ig-template-btn {
    font-size: 12px;
  }

  .invoice-generator .ig-btn {
    font-size: 12px;
  }

  .invoice-generator .ig-btn--add-line .ig-btn__add-label {
    font-size: 12px;
  }

  .invoice-generator__grid {
    grid-template-columns: minmax(16rem, 29rem) minmax(0, 1fr);
    align-items: stretch;
    /* One viewport row: form scrolls inside; preview does not grow page height */
    min-height: calc(100dvh - var(--ig-chrome-offset));
    height: calc(100dvh - var(--ig-chrome-offset));
    max-height: calc(100dvh - var(--ig-chrome-offset));
  }

  .invoice-generator__panel {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    border-right: 1px solid #dedede;
    border-bottom: none;
    align-self: stretch;
    -webkit-overflow-scrolling: touch;
    /* Subtle depth toward the preview column */
    box-shadow: 4px 0 18px -6px rgba(44, 44, 44, 0.08);
  }

  /*
   * Match the editor column height: stretch in the grid row (align-self:start was
   * shrinking the preview to content, leaving empty space below the gray frame).
   * height:100% follows the grid row, not raw 100dvh (avoids mismatch with inner padding).
   */
  .invoice-generator__preview {
    position: sticky;
    top: var(--ig-sticky-top);
    align-self: stretch;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .invoice-generator__preview-frame {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .invoice-generator__preview-holder {
    flex: 1 1 auto;
    min-height: 0;
  }
}

/* ——— Large desktop: wider form column ——— */
@media (min-width: 90rem) {
  .invoice-generator__grid {
    grid-template-columns: minmax(18rem, 29rem) minmax(0, 1fr);
  }
}

/* ——— Desktop + short viewport: tighter sticky offset ——— */
@media (min-width: 64rem) and (max-height: 50rem) {
  .invoice-generator {
    --ig-sticky-top: 0.5rem;
  }
}

/* ——— Ultra-wide: cap content width ——— */
@media (min-width: 100rem) {
  .invoice-generator__inner {
    margin-inline: auto;
  }
}
