/* ==========================================================================
   Tax Invoice document editor + printable A4 preview
   Modeled on the same "live document" approach as purchase-order.css —
   maroon/blue GST tax-invoice look with black grid lines.
   ========================================================================== */

/* flex-start (not flex-end): fields in this row can have different natural
   heights (e.g. the lead picker's manual-entry toggle makes it taller than
   a plain label+input field) — aligning by the top edge means one taller
   field never throws off every other field's label/input position, the
   way bottom-alignment would. */
.inv-meta-bar { display: flex; gap: var(--sp-5); flex-wrap: wrap; align-items: flex-start; margin-bottom: var(--sp-5); padding-bottom: var(--sp-4); border-bottom: 1px dashed var(--border-strong); }
.inv-meta-bar .field { margin-bottom: 0; min-width: 180px; }
.inv-tax-mode-row { display: flex; gap: var(--sp-4); flex-wrap: wrap; margin-top: 27px; }
.inv-tax-mode-row label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; white-space: nowrap; }

/* ---------- Printable document ----------
   Modern corporate tax-invoice redesign: navy for structure/headings, a
   restrained maroon accent for identity/emphasis, light gray rules
   instead of a heavy all-black grid, and a clear grand-total callout —
   same design language as the Quotations/Documents (.qd-doc) and
   Purchase Order (.po-doc) sheets, sized appropriately for an invoice. */
.inv-doc {
  --inv-ink: #1e2230;
  --inv-navy: #173a63;
  --inv-maroon: #9c1d2e;
  --inv-muted: #667085;
  --inv-line: #d7dbe3;
  --inv-line-strong: #aeb4c4;
  --inv-band: #f4f6fb;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 11.5px; line-height: 1.5; color: var(--inv-ink); background: #fff;
  padding: 22px; border: 1px solid var(--inv-line-strong); border-radius: 6px; box-shadow: 0 1px 3px rgba(23, 58, 99, 0.08);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.inv-doc-brand { text-align: center; margin-bottom: 6px; }
.inv-doc-brand .doc-brand-logo { max-height: 46px; margin: 0 auto 6px; }
.inv-doc-company-name { font-size: 17px; font-weight: 800; color: var(--inv-navy); font-style: normal; }
.inv-doc-iso { font-size: 9.5px; color: var(--inv-muted); letter-spacing: 0.06em; margin-top: 1px; text-transform: uppercase; }
.inv-doc-addrline { text-align: center; color: var(--inv-muted); font-weight: 500; font-size: 11px; }
.inv-doc-addrline2 { text-align: center; color: var(--inv-muted); font-weight: 500; font-size: 11px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 2.5px solid var(--inv-navy); }

.inv-doc-title-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px 12px; }
.inv-doc-title { font-size: 21px; font-weight: 800; color: var(--inv-navy); letter-spacing: 0.04em; text-transform: uppercase; }
.inv-doc-copytype select { border: 1px solid var(--inv-line-strong); border-radius: 4px; font-size: 11.5px; font-weight: 700; padding: 5px 9px; color: var(--inv-navy); background: var(--inv-band); }

.inv-doc-meta-row { display: flex; gap: 0; margin-bottom: 8px; }
.inv-doc-meta-table { width: 50%; border-collapse: collapse; }
.inv-doc-meta-table td { border: 1px solid var(--inv-line); padding: 6px 9px; color: var(--inv-ink); }
.inv-doc-meta-table td:first-child { font-weight: 700; width: 42%; background: var(--inv-band); color: var(--inv-navy); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.02em; }

.inv-doc-parties { display: flex; border: 1px solid var(--inv-line); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.inv-doc-party { flex: 1; padding: 9px 11px; border-left: 1px solid var(--inv-line); color: var(--inv-ink); font-weight: 500; background: var(--inv-band); }
.inv-doc-party:first-child { border-left: none; }
.inv-doc-party-title { font-weight: 700; color: var(--inv-navy); font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 5px; }
.inv-doc-party:last-child { color: var(--inv-ink); font-weight: 500; background: #fff; }
.inv-doc-party:last-child .inv-doc-party-title { color: var(--inv-navy); font-style: normal; }
.inv-doc-party-accent { color: var(--inv-maroon); font-weight: 700; font-style: normal; }

.inv-doc-items-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.inv-doc-items-table th, .inv-doc-items-table td { border: 1px solid var(--inv-line); padding: 7px 9px; color: var(--inv-ink); }
.inv-doc-items-table th { background: var(--inv-navy); color: #fff; font-weight: 700; text-align: center; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.02em; border-color: var(--inv-navy); }
.inv-doc-items-table td.num, .inv-doc-items-table th.num { text-align: right; white-space: nowrap; }
.inv-doc-items-table td.desc { max-width: 280px; }
.inv-doc-items-table tbody tr:nth-child(even) td { background: var(--inv-band); }

.inv-doc-bottom-grid { display: flex; gap: 0; border: 1px solid var(--inv-line); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.inv-doc-tax-table { flex: 1; border-collapse: collapse; }
.inv-doc-tax-table td, .inv-doc-tax-table th { border: 1px solid var(--inv-line); padding: 6px 8px; text-align: center; font-size: 11px; color: var(--inv-ink); }
.inv-doc-tax-table th { background: var(--inv-band); color: var(--inv-navy); font-weight: 700; }
.inv-doc-note { flex: 1.1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px; color: var(--inv-ink); font-weight: 600; font-style: normal; border-left: 1px solid var(--inv-line); border-right: 1px solid var(--inv-line); background: var(--inv-band); }
.inv-doc-summary-table { flex: 1; border-collapse: collapse; }
.inv-doc-summary-table td { border: 1px solid var(--inv-line); padding: 6px 9px; color: var(--inv-ink); }
.inv-doc-summary-table td:first-child { font-weight: 600; width: 55%; }
.inv-doc-summary-table td:last-child { text-align: right; white-space: nowrap; font-weight: 700; }
.inv-doc-summary-table tr.grand td { font-weight: 800; background: var(--inv-navy); color: #fff; border-color: var(--inv-navy); font-size: 12.5px; }

.inv-doc-words { border: 1px solid var(--inv-line); border-left: 3px solid var(--inv-maroon); padding: 7px 10px; margin-bottom: 8px; color: var(--inv-ink); font-weight: 700; background: var(--inv-band); border-radius: 0 4px 4px 0; }

.inv-doc-termscert { display: flex; border: 1px solid var(--inv-line); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.inv-doc-terms { flex: 1.3; padding: 9px 11px; border-right: 1px solid var(--inv-line); color: var(--inv-ink); font-weight: 500; font-style: normal; }
.inv-doc-cert { flex: 1; padding: 9px 11px; font-size: 11px; font-style: normal; color: var(--inv-ink); background: var(--inv-band); }
.inv-doc-terms-label { font-weight: 700; margin-bottom: 4px; color: var(--inv-navy); font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.inv-doc-cert-label { font-weight: 700; margin-bottom: 4px; color: var(--inv-navy); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; }

.inv-doc-bank-grid { display: flex; border: 1px solid var(--inv-line); border-radius: 4px; overflow: hidden; }
.inv-doc-bank-table { flex: 1.2; border-collapse: collapse; }
.inv-doc-bank-table td { border: 1px solid var(--inv-line); padding: 5px 9px; font-size: 11px; }
.inv-doc-bank-table td:first-child { font-weight: 700; width: 40%; background: var(--inv-band); color: var(--inv-navy); }
.inv-doc-bank-table td:last-child { color: var(--inv-ink); font-weight: 600; }
.inv-doc-interest { flex: 1; padding: 11px; font-size: 11px; font-style: normal; color: var(--inv-maroon); font-weight: 600; border-left: 1px solid var(--inv-line); border-right: 1px solid var(--inv-line); background: var(--inv-band); }
.inv-doc-jurisdiction { font-weight: 700; text-align: center; margin-top: 8px; color: var(--inv-muted); font-style: normal; font-size: 10.5px; }
.inv-doc-sign { flex: 1; padding: 11px; text-align: center; display: flex; flex-direction: column; justify-content: space-between; color: var(--inv-ink); font-weight: 600; }
.inv-doc-sign-line { height: 44px; border-bottom: 1px solid var(--inv-line-strong); }
.inv-doc-footer { font-size: 9.5px; font-style: normal; margin-top: 8px; color: var(--inv-muted); text-align: center; }

/* ---------- Editable fields inside the live document editor ---------- */
.inv-doc input, .inv-doc textarea, .inv-doc select {
  border: 1px solid var(--border-strong, #cbd5e1);
  background: #ffffff;
  font: inherit;
  color: var(--text, #1e293b);
  width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.inv-doc input::placeholder, .inv-doc textarea::placeholder { color: #94a3b8; font-style: italic; opacity: 1; }
.inv-doc input:hover, .inv-doc textarea:hover, .inv-doc select:hover { border-color: #64748b; background: #fff; }
.inv-doc input:focus, .inv-doc textarea:focus, .inv-doc select:focus {
  outline: none;
  border-color: var(--primary, #9c1d2e);
  box-shadow: 0 0 0 2.5px rgba(156, 29, 46, 0.15);
  background: #fff;
}
.inv-doc input[type="number"], .inv-doc td.num input { text-align: right; }
.inv-doc-company-name { padding: 4px 8px; text-align: center; }
.inv-doc-items-table input { padding: 6px 8px; border: 1px solid var(--border-strong, #cbd5e1); background: #ffffff; border-radius: 4px; }
.inv-doc-summary-table input { width: 55px; display: inline-block; margin: 0 2px; }
.inv-doc-items-table .remove-row-btn { background: none; border: none; color: var(--inv-muted); opacity: 0.7; cursor: pointer; padding: 4px; }
.inv-doc-items-table .remove-row-btn:hover { opacity: 1; color: #b91c1c; }
.inv-doc-error { color: #b91c1c; font-size: 12px; font-weight: 600; margin: -4px 0 8px; }

@media print {
  .inv-doc input, .inv-doc textarea, .inv-doc select {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
}

/* The generic "hide everything except the open modal" isolation lives once
   in components.css, shared by every document type — see the comment
   there for why it can't be duplicated per-file with an id-specific
   :not() selector (the stylesheets all load globally and the rules
   collide with each other). */
@page { size: A4; margin: 14mm 12mm; }
@media print {
  #invPreviewBody { padding: 0; }
  .inv-doc { border: none; box-shadow: none; border-radius: 0; padding: 0; }
  .inv-doc-items-table thead { display: table-header-group; }
  .inv-doc-items-table tr { break-inside: avoid; }
  .inv-doc-brand, .inv-doc-bottom-grid, .inv-doc-termscert, .inv-doc-bank-grid, .inv-doc-words { break-inside: avoid; }
}
