/* Invoice maker: editor layout, the four invoice templates and the A4 print rules. */
.inv-page { padding-top: 32px; padding-bottom: 56px; display: flex; flex-direction: column; gap: 18px; }
.inv-title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.inv-title-row > div:first-child { display: flex; flex-direction: column; gap: 8px; }
.inv-h1 { font-size: 42px; }
.inv-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.inv-form { flex: 1 1 460px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.inv-preview-col { flex: 1 1 460px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.preview-head { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--sub); letter-spacing: 0.06em; }
.sheet-host { position: relative; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 18px 40px -26px rgba(26,27,58,0.45); background: #fff; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Template picker */
.tpl-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tpl-card { display: flex; flex-direction: column; gap: 6px; align-items: center; cursor: pointer; font-size: 14px; }
.tpl-card input { position: absolute; opacity: 0; }
.tpl-thumb { width: 100%; aspect-ratio: 210 / 297; border: 1.5px solid var(--line); border-radius: 4px; background: #fff; padding: 10%; display: flex; flex-direction: column; gap: 10%; }
.tpl-card input:checked + .tpl-thumb { border-color: var(--brand); box-shadow: 0 0 0 3px var(--tint); }
.tpl-card input:focus-visible + .tpl-thumb { outline: 2px solid var(--brand); outline-offset: 2px; }
.tpl-thumb i { display: block; height: 8%; background: var(--soft); }
.t-classic i:first-child { height: 6%; width: 60%; background: var(--ink); }
.t-modern { padding: 0 0 10%; } .t-modern i:first-child { height: 22%; background: var(--brand); } .t-modern i { margin: 0 10%; }
.t-minimal i:first-child { height: 4%; width: 40%; background: var(--line); } .t-minimal i { height: 3%; }
.t-compact { gap: 5%; } .t-compact i:first-child { height: 14%; background: none; border: 1.5px solid var(--ink); } .t-compact i { border: 1px solid var(--line); background: none; }

.swatches { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sw { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--sub); min-height: 44px; }
.sw input[type="radio"] { position: absolute; opacity: 0; }
.sw span { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); }
.sw input:checked + span { box-shadow: 0 0 0 2.5px var(--ink); }
.sw input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 3px; }
.sw.custom input { width: 36px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.more > summary { cursor: pointer; font-size: 14px; color: var(--brand); padding: 4px 0 12px; }
.checks-grid label { display: inline-flex; align-items: center; gap: 6px; margin: 4px 16px 4px 0; font-size: 14px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.checks-grid input { width: auto; min-height: 0; margin: 0; }
.grid input[type="file"] { font-size: 13px; }

/* Invoice lines editor */
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2fr) auto; gap: 8px; align-items: end; }
.line label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sub); }
.line input { border: 1px solid var(--line); border-radius: 4px; padding: 8px; font: 15px var(--sans); min-height: 40px; width: 100%; color: var(--ink); background: #fff; }
.line input.mono { font-family: var(--mono); font-size: 14px; }
.line .link { min-height: 40px; }

/* ---------- The invoice sheet (A4 at 96 dpi: 794 x 1123 px) ---------- */
.inv-sheet { --accent: #4B3FC4; width: 794px; min-height: 1123px; box-sizing: border-box; padding: 56px 60px 44px; background: #fff; color: #1A1B3A; font: 15px/1.5 var(--sans); display: flex; flex-direction: column; gap: 24px; transform-origin: top left; }
.inv-sheet .s-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.inv-sheet .s-head.logo-right .s-from { order: 2; text-align: right; flex-direction: row-reverse; }
.inv-sheet .s-from { display: flex; gap: 14px; align-items: flex-start; }
.inv-sheet .s-logo { max-width: 120px; max-height: 64px; object-fit: contain; }
.inv-sheet .s-firm { display: flex; flex-direction: column; }
.inv-sheet .s-firm b { font-size: 19px; }
.inv-sheet .s-ids { font: 12px var(--mono); color: #4D4B66; }
.inv-sheet .s-title { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.inv-sheet .s-title h2 { margin: 0; font: 600 34px/1.05 var(--serif); }
.inv-sheet .s-title span { font: 14px var(--mono); }
.inv-sheet .s-rule { height: 2px; background: #1A1B3A; }
.inv-sheet .s-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.inv-sheet .s-meta div { display: flex; flex-direction: column; }
.inv-sheet .lbl { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #4D4B66; }
.inv-sheet table { border-collapse: collapse; width: 100%; font-size: 15px; }
.inv-sheet th { text-align: left; padding: 9px 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: #4D4B66; white-space: normal; }
.inv-sheet td { padding: 11px 8px; vertical-align: top; }
.inv-sheet th:first-child, .inv-sheet td:first-child { padding-left: 0; }
.inv-sheet th:last-child, .inv-sheet td:last-child { padding-right: 0; text-align: right; }
.inv-sheet thead tr { border-top: 1.5px solid #1A1B3A; border-bottom: 1.5px solid #1A1B3A; }
.inv-sheet tbody tr { border-bottom: 1px solid #ECEAF6; }
.inv-sheet .n { font-family: var(--mono); white-space: nowrap; }
.inv-sheet .s-totals { align-self: flex-end; width: 340px; display: flex; flex-direction: column; gap: 6px; }
.inv-sheet .s-totals > div { display: flex; justify-content: space-between; gap: 12px; }
.inv-sheet .s-grand { border-top: 1.5px solid #1A1B3A; padding-top: 8px; font-size: 18px; font-weight: 700; }
.inv-sheet .s-words { font-size: 13px; color: #4D4B66; }
.inv-sheet .s-gst { border: 1px solid #D9D6EE; border-radius: 4px; padding: 12px 14px; font-size: 13px; background: #F8F7FD; }
.inv-sheet .s-notes { font-size: 14px; color: #4D4B66; white-space: pre-line; }
.inv-sheet .s-foot { margin-top: auto; display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; }
.inv-sheet .s-bank { display: flex; flex-direction: column; font-size: 13px; }
.inv-sheet .s-sign { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; }
.inv-sheet .s-sign img { max-width: 170px; max-height: 60px; object-fit: contain; }
.inv-sheet .s-sign .gap { width: 170px; height: 50px; }
.inv-sheet .s-sign .line-sig { border-top: 1px solid #1A1B3A; padding-top: 4px; width: 170px; text-align: center; color: #4D4B66; }
.inv-sheet .s-footer { font-size: 11px; color: #7A7894; border-top: 1px solid #ECEAF6; padding-top: 8px; display: flex; justify-content: space-between; gap: 12px; }
.inv-sheet .placeholder { color: #A5A2C0; }

/* Classic: ink rules, serif title (default above), accent on the title */
.tpl-classic .s-title h2 { color: var(--accent); }

/* Modern: accent band header */
.tpl-modern { padding-top: 0; }
.tpl-modern .s-head { margin: 0 -60px; padding: 40px 60px 32px; background: var(--accent); color: #fff; }
.tpl-modern .s-head .s-ids, .tpl-modern .s-head .s-firm span { color: rgba(255,255,255,0.85); }
.tpl-modern .s-title h2 { font-family: var(--sans); font-weight: 600; letter-spacing: -0.01em; }
.tpl-modern .s-rule { display: none; }
.tpl-modern thead tr { border: 0; background: color-mix(in srgb, var(--accent) 10%, #fff); }
.tpl-modern th:first-child { padding-left: 10px; } .tpl-modern td:first-child { padding-left: 10px; }
.tpl-modern th:last-child, .tpl-modern td:last-child { padding-right: 10px; }
.tpl-modern .s-grand { border-top-color: var(--accent); color: var(--accent); }

/* Minimal: hairlines, light title, lots of air */
.tpl-minimal { gap: 30px; padding: 72px 72px 52px; }
.tpl-minimal .s-title h2 { font: 300 30px var(--sans); letter-spacing: 0.02em; text-transform: uppercase; color: #1A1B3A; }
.tpl-minimal .s-rule { height: 1px; background: #D9D6EE; }
.tpl-minimal thead tr { border-top: 0; border-bottom: 1px solid #D9D6EE; }
.tpl-minimal .s-grand { border-top: 1px solid #D9D6EE; color: var(--accent); }
.tpl-minimal .s-gst { background: none; border: 0; border-left: 2px solid var(--accent); border-radius: 0; }

/* Compact: boxed header, gridded table, smaller type for long invoices */
.tpl-compact { font-size: 13px; gap: 16px; padding: 40px 44px 32px; }
.tpl-compact .s-head { border: 1.5px solid #1A1B3A; padding: 14px 16px; }
.tpl-compact .s-title h2 { font: 600 24px var(--sans); color: var(--accent); }
.tpl-compact .s-rule { display: none; }
.tpl-compact .s-meta { border: 1px solid #D9D6EE; padding: 10px 12px; gap: 12px; }
.tpl-compact table { font-size: 13px; }
.tpl-compact th, .tpl-compact td { border: 1px solid #D9D6EE; padding: 6px 8px !important; }
.tpl-compact thead tr { background: #F4F3FA; }
.tpl-compact .s-totals { width: 300px; }

@media (max-width: 720px) {
  .tpl-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .line label:first-child { grid-column: 1 / -1; }
}

/* Print: only the invoice, at real A4 size */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .no-print, .skip { display: none !important; }
  .inv-page { display: block; padding: 0; max-width: none; }
  .inv-layout { display: block; }
  .inv-preview-col { display: block; }
  .sheet-host { border: 0; box-shadow: none; overflow: visible; height: auto !important; }
  .inv-sheet { transform: none !important; width: 210mm; min-height: 297mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
