/* Invoice Template Lab — online invoice generator. Uses the site variables from styles.css. */
.ed-page { padding-bottom: 3rem; }
.ed-intro { padding: 2.2rem 0 1rem; }
.ed-intro h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 3.6vw, 2.7rem); letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 0.6rem; }
.ed-intro .lede { max-width: 62ch; margin-bottom: 0.5rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.step-num { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--teal); color: var(--white); font: 700 0.95rem/1 var(--sans); margin-right: 0.45rem; vertical-align: 0.2em; }

/* Step 1: type picker */
.tp { background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.4rem 1.4rem 0.6rem; box-shadow: var(--shadow); margin-bottom: 1.6rem; scroll-margin-top: calc(var(--header-h) + 0.8rem); }
.tp-head h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.35rem, 2.6vw, 1.75rem); margin: 0 0 0.35rem; letter-spacing: -0.02em; }
.tp-head p { margin: 0 0 1rem; color: var(--ink-soft); }
.tp-group h3 { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0.4rem 0 0.55rem; }
.tp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.65rem; margin-bottom: 0.9rem; }
.tp-card { display: grid; grid-template-columns: 2.2rem 1fr; grid-template-rows: auto auto; column-gap: 0.65rem; align-items: center; text-align: left;
  background: var(--white); border: 1px solid var(--rule); border-radius: 12px; padding: 0.75rem 0.8rem; cursor: pointer; font: inherit; color: var(--ink); transition: border-color .15s, box-shadow .15s, transform .15s; }
.tp-card:hover { border-color: var(--teal); box-shadow: 0 6px 18px rgba(14,107,102,.12); transform: translateY(-1px); }
.tp-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tp-card[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.tp-icon { grid-row: 1 / span 2; width: 2.2rem; height: 2.2rem; border-radius: 9px; background: var(--teal-soft); color: var(--teal-dark); display: grid; place-items: center; font-size: 1.1rem; font-weight: 700; }
.tp-card[aria-pressed="true"] .tp-icon { background: var(--teal); color: var(--white); }
.tp-name { font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.tp-blurb { font-size: 0.8rem; color: var(--muted); line-height: 1.3; }
.tp.is-compact .tp-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.45rem; }
.tp.is-compact .tp-card { padding: 0.5rem 0.6rem; }
.tp.is-compact .tp-blurb { display: none; }
.tp.is-compact .tp-icon { width: 1.8rem; height: 1.8rem; font-size: 0.95rem; grid-row: auto; }
.tp.is-compact .tp-card { grid-template-columns: 1.8rem 1fr; }

/* Step 2: editor */
.ed { scroll-margin-top: calc(var(--header-h) + 0.8rem); }
.ed-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.6rem 1rem; }
.ed-bar h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.35rem, 2.6vw, 1.75rem); margin: 0; letter-spacing: -0.02em; }
.ed-bar-actions { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; }
.ed-switch { font-size: 0.8rem; font-weight: 650; color: var(--muted); display: flex; flex-direction: column; gap: 0.2rem; }
.ed-files { font-size: 0.88rem; color: var(--muted); margin: 0.4rem 0 1rem; }
.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 1.4rem; align-items: start; }
.ed-form { display: grid; gap: 1rem; min-width: 0; }
.ed-card { border: 1px solid var(--rule); background: var(--paper-2); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; margin: 0; min-width: 0; display: grid; gap: 0.7rem; }
.ed-card legend { font-weight: 700; font-size: 0.95rem; padding: 0 0.4rem; margin-left: -0.4rem; }
.ed-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.84rem; font-weight: 650; color: var(--ink); min-width: 0; }
.ed-field[hidden], [data-key][hidden], [data-only][hidden] { display: none !important; }
.ed input:not([type=checkbox]):not([type=file]), .ed select, .ed textarea {
  width: 100%; padding: 0.55rem 0.65rem; border: 1px solid var(--rule-dark); border-radius: 8px; background: var(--white); color: var(--ink); font: 400 0.95rem/1.35 var(--sans); min-width: 0; }
.ed textarea { resize: vertical; }
.ed input:focus, .ed select:focus, .ed textarea:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--teal); }
.ed select:disabled { background: var(--paper); color: var(--muted); }
.ed-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.ed-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.ed-inline { display: grid; grid-template-columns: 1fr 5rem; gap: 0.4rem; }
.ed-logo { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; font-weight: 400; }
.ed-check { display: flex; gap: 0.5rem; align-items: center; font-size: 0.9rem; }
.ed-hint { font-size: 0.84rem; color: var(--muted); margin: 0; }
.ed-total-line { margin: 0; text-align: right; font-size: 1rem; }
.ed-total-line strong { font-size: 1.15rem; color: var(--teal-dark); }
.ed-items-wrap { overflow: visible; }
/* Item rows are laid out as small cards at every width: description on top, numbers below. */
.ed-items { width: 100%; border-collapse: collapse; font-size: 0.85rem; display: block; }
.ed-items thead { display: none; }
.ed-items tbody { display: grid; gap: 0.55rem; }
.ed-items tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr) minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1.1fr) 2.2rem; gap: 0.4rem;
  align-items: end; border: 1px solid var(--rule); border-radius: 10px; padding: 0.55rem; background: var(--white); }
.ed-items td { display: block; padding: 0; min-width: 0; }
.ed-items td:first-child { grid-column: 1 / -2; }
.ed-items td:last-child { grid-column: -2 / -1; grid-row: 1; align-self: end; }
.ed-items td .sr { position: static; width: auto; height: auto; clip: auto; white-space: normal; display: block; font-size: 0.72rem; color: var(--muted); font-weight: 650; margin-bottom: 0.15rem; }
.ed-items .amt { text-align: right; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; padding-bottom: 0.55rem; overflow: hidden; text-overflow: ellipsis; }
.ed-items textarea { min-height: 2.4rem; }
.row-del { border: 1px solid var(--rule-dark); background: var(--white); border-radius: 8px; width: 2rem; height: 2.3rem; cursor: pointer; font-size: 1.1rem; color: var(--ink-soft); }
.row-del:hover:not(:disabled) { background: #fdecea; color: #7a1f16; border-color: #f0c4be; }
.row-del:disabled { opacity: 0.35; cursor: default; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.ed-clear { margin-left: auto; color: #7a1f16; }

/* Preview */
.ed-preview { position: sticky; top: calc(var(--header-h) + 0.8rem); min-width: 0; }
.ed-preview-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.82rem; font-weight: 650; color: var(--muted); margin-bottom: 0.5rem; }
.inv-doc { background: #fff; color: #15232e; border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow); padding: 22px 24px; font: 400 11.5px/1.45 var(--sans); max-height: calc(100vh - var(--header-h) - 4rem); overflow: auto; }
.inv-doc .ph { color: #9aa6ad; font-style: italic; }
.inv-doc-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid #15232e; padding-bottom: 10px; margin-bottom: 12px; }
.inv-brand { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.inv-logo { max-width: 90px; max-height: 60px; object-fit: contain; }
.inv-seller-name { font: 700 15px/1.25 var(--serif); }
.inv-small { font-size: 10.5px; color: #3d4f5c; overflow-wrap: anywhere; }
.inv-titlebox { text-align: right; flex: none; max-width: 48%; }
.inv-title { font: 700 17px/1.2 var(--serif); letter-spacing: 0.03em; color: #0e6b66; }
.inv-kicker { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: #4a5a64; margin-top: 3px; }
.inv-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.inv-party { border: 1px solid #d9d1c3; border-radius: 4px; padding: 7px 9px; min-width: 0; }
.inv-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #4a5a64; margin: 0 0 2px; }
.inv-strong { font-weight: 700; font-size: 11.5px; }
.inv-meta-t { border-collapse: collapse; width: 100%; font-size: 10.5px; }
.inv-meta-t th { text-align: left; font-weight: 600; color: #4a5a64; padding: 1px 6px 1px 0; vertical-align: top; white-space: nowrap; }
.inv-meta-t td { padding: 1px 0; font-weight: 600; overflow-wrap: anywhere; }
.inv-items { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-bottom: 10px; }
.inv-items th { background: #15232e; color: #fff; font-weight: 600; text-align: left; padding: 5px 6px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.inv-items td { padding: 5px 6px; border-bottom: 1px solid #e4ddd0; vertical-align: top; overflow-wrap: anywhere; }
.inv-items .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-items .c-n { width: 22px; }
.inv-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: 14px; align-items: start; margin-bottom: 10px; }
.inv-words { display: grid; gap: 4px; align-content: start; }
.inv-endorse { border: 1px dashed #0e6b66; color: #0a524e; font-weight: 700; font-size: 10px; padding: 5px 7px; border-radius: 4px; margin: 4px 0; }
.inv-totals { border-collapse: collapse; width: 100%; font-size: 10.5px; }
.inv-totals th { text-align: left; font-weight: 500; color: #3d4f5c; padding: 3px 6px; }
.inv-totals td { text-align: right; padding: 3px 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-totals tr.grand th, .inv-totals tr.grand td { background: #0e6b66; color: #fff; font-weight: 700; font-size: 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.inv-block { margin-bottom: 8px; }
.inv-foot { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 16px; align-items: end; margin-top: 14px; padding-top: 10px; border-top: 1px solid #d9d1c3; }
.inv-decl { font-size: 9.5px; color: #4a5a64; }
.inv-sign { text-align: right; }
.inv-sign-line { border-bottom: 1px solid #15232e; height: 38px; margin: 2px 0 4px; }

@media (max-width: 1000px) {
  .tp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tp.is-compact .tp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ed-grid { grid-template-columns: 1fr; }
  .ed-preview { position: static; }
  .inv-doc { max-height: none; }
}
@media (max-width: 640px) {
  .tp { padding: 1rem 0.9rem 0.3rem; }
  .tp-grid, .tp.is-compact .tp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tp-blurb { display: none; }
  .tp-card { grid-template-columns: 1.9rem 1fr; padding: 0.6rem; }
  .tp-icon { width: 1.9rem; height: 1.9rem; grid-row: auto; }
  .ed-row, .ed-extra { grid-template-columns: 1fr; }
  .ed-items tr { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ed-items td:last-child { justify-self: end; }
  .ed-items .amt { text-align: left; grid-column: 1 / -1; padding-bottom: 0; }
  .ed-items td:first-child { grid-column: 1 / -2; }
  .inv-doc { padding: 14px; font-size: 10.5px; }
  .inv-doc-head { flex-direction: column; }
  .inv-titlebox { text-align: left; max-width: none; }
  .inv-bottom, .inv-foot { grid-template-columns: 1fr; }
  .ed-clear { margin-left: 0; }
}

/* Print: only the invoice, on A4 */
@page { size: A4; margin: 8mm 6mm; }
/* Reserve space for the type grid until JS fills it (prevents layout shift of the content below) */
#type-grid:empty { min-height: 660px; }
/* Skip layout of the below-the-fold help section until it is near the viewport */
#about-generator { content-visibility: auto; contain-intrinsic-size: auto 900px; }
@media (max-width: 1000px) { #type-grid:empty { min-height: 820px; } }
@media (max-width: 640px) { #type-grid:empty { min-height: 900px; } }

@media print {
  html, body { background: #fff !important; }
  .skip, .site-header, .site-footer, .ed-intro, .tp, .ed-bar, .ed-files, .ed-form, .ed-preview-bar, #about-generator { display: none !important; }
  .ed-page, .ed, .wrap { width: auto !important; max-width: none !important; margin: 0 auto !important; padding: 0 !important; }
  .ed-grid { display: block !important; }
  .ed-preview { position: static !important; }
  .inv-doc { box-sizing: border-box !important; width: 100% !important; max-width: 100% !important; margin: 0 auto !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important; padding: 6mm 8mm !important; max-height: none !important; overflow: visible !important; font-size: 10.5pt; }
  .inv-doc .ph { color: #9aa6ad; }
  .inv-items tr, .inv-bottom, .inv-foot { break-inside: avoid; }
}
