/* Invoice generator — editor + live preview paper + print. */
.ig-form { display: flex; flex-direction: column; gap: 18px; }
.ig-grp { margin: 0; padding: 0 0 18px; border: 0; border-bottom: 1px solid var(--border); min-width: 0; }
.ig-grp legend { padding: 0; margin-bottom: 12px; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.ig-form .actions { margin-top: 0; }
.ig-mt { margin-top: 12px; }
.ig-form .field textarea { min-height: 72px; }
.ig-form [aria-invalid="true"] { border-color: var(--bad) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.ig-form input:focus-visible, .ig-form select:focus-visible, .ig-form textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Logo */
.ig-logo { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.ig-logo-thumb { width: 72px; height: 56px; border: 1px dashed var(--field); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--bg); overflow: hidden; }
.ig-logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ig-logo-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; flex: 1 1 200px; }
.ig-logo-ctl small { flex: 1 1 100%; color: var(--muted); font-size: 13px; }
.ig-file { position: relative; }
.ig-file:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Line items */
.ig-items-head, .ig-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 110px 112px 40px; gap: 8px; align-items: center; }
.ig-items-head { padding: 0 2px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.ig-items-head span:nth-child(n+2) { text-align: right; }
.ig-items { display: flex; flex-direction: column; gap: 8px; }
.ig-row input { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); font-size: 15px; }
.ig-row .ig-q, .ig-row .ig-p { text-align: right; }
.ig-a { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; overflow-wrap: anywhere; }
.ig-x { width: 40px; height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 20px; cursor: pointer; }
.ig-x:hover { color: var(--bad); border-color: var(--bad); }
.ig-add { margin-top: 10px; }
@media (max-width: 560px) {
  .ig-items-head { display: none; }
  .ig-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 40px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
  .ig-row .ig-d { grid-column: 1 / -1; }
  .ig-row .ig-a { grid-column: 1 / 3; grid-row: 3; text-align: left; }
  .ig-row .ig-x { grid-column: 3; grid-row: 2; }
}

/* Preview */
.ig-side { position: sticky; top: 12px; }
.ig-pv-title { margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.ig-paper { padding: clamp(18px, 3vw, 30px); font-size: 13px; line-height: 1.45; color: #1A1A1F; overflow-wrap: anywhere; }
.ig-pv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.ig-pv-brand img { max-width: 150px; max-height: 64px; display: block; object-fit: contain; }
.ig-pv-brand strong { font-family: var(--display); font-size: 18px; line-height: 1.2; }
.ig-pv-doc { text-align: right; }
.ig-pv-doc b { display: block; font-family: var(--display); font-size: 24px; letter-spacing: .02em; color: var(--primary-ink); line-height: 1; }
.ig-pv-doc span { color: var(--muted); font-size: 12px; }
.ig-pv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.ig-pv-parties small, .ig-pv-notes small { display: block; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ig-pv-parties strong { display: block; font-size: 14px; }
.ig-pv-parties span { display: block; color: var(--muted); font-size: 12px; }
.ig-pv-meta { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 0 0 14px; padding: 10px 12px; background: #F4F2EC; border-radius: 8px; }
.ig-pv-meta dt { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ig-pv-meta dd { margin: 0; font-weight: 700; }
.ig-pv-items { font-size: 12.5px; }
.ig-pv-items thead th { background: #1A1A1F; color: #FFF; font-size: 11px; font-weight: 700; padding: 7px 6px; }
.ig-pv-items td { vertical-align: top; }
.ig-pv-items td:last-child { font-weight: 700; }
.ig-pv-empty { color: var(--faint); text-align: center !important; }
.ig-pv-totals { margin: 12px 0 0 auto; max-width: 260px; }
.ig-pv-totals div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.ig-pv-totals dt { color: var(--muted); }
.ig-pv-totals dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.ig-pv-totals .ig-pv-total { margin-top: 4px; padding-top: 8px; border-top: 2px solid #1A1A1F; font-size: 15px; }
.ig-pv-totals .ig-pv-total dt { color: #1A1A1F; font-weight: 800; }
.ig-pv-notes { margin-top: 18px; padding-top: 12px; border-top: 1px solid #EEE; }
.ig-pv-notes p { margin: 4px 0 0; white-space: normal; }
.ig-actions .btn { flex: 1 1 auto; }
.ig-recent-title { margin-top: 10px; }
@media (max-width: 420px) { .ig-pv-parties { grid-template-columns: 1fr; } }

/* Print: only the paper */
@media print {
  @page { size: A4; margin: 14mm; }
  .ig-form, .ig-actions, .ig-pv-title, .ig-side .note, #status { display: none !important; }
  .tool-area { padding: 0 !important; margin: 0; max-width: none; }
  .ig.cols { display: block; }
  .ig-side { position: static; }
  .ig-paper { border: 0; border-radius: 0; box-shadow: none; padding: 0; font-size: 11pt; }
  .ig-paper, .ig-paper * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ig-pv-items tr { break-inside: avoid; }
}

/* Template button after saving: "✓ Saved as Template" (briefly), then "Update Template". */
.ig-tpl-btn.is-done { color: var(--good); border-color: var(--good); cursor: default; }
