/* ==========================================================================
   Purchase Order document editor + printable A4 preview
   ========================================================================== */

.po-section-title { font-size: 13px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.03em; margin: var(--sp-5) 0 var(--sp-3); }
.po-section-title:first-child { margin-top: 0; }

/* Workflow bar above the document — status/expected date/tax mode are CRM
   metadata, not part of the printed PO, so they're deliberately styled as
   normal app UI (not document text) to signal that distinction. */
/* 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. */
.po-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); }
.po-meta-bar .field { margin-bottom: 0; min-width: 180px; }

.po-tax-mode-row { display: flex; gap: var(--sp-4); flex-wrap: wrap; margin-top: 27px; }
.po-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 preview ----------
   Modern corporate Purchase Order redesign — same navy/maroon design
   language as the Quotations/Documents (.qd-doc) and Invoice (.inv-doc)
   sheets, with the PO's traditional navy "masthead" band kept as its own
   identity (appropriate per-category layout, shared design system). */
.po-doc {
  --po-navy: #173a63;
  --po-maroon: #9c1d2e;
  --po-muted: #667085;
  --po-line: #d7dbe3;
  --po-line-strong: #aeb4c4;
  --po-band: #f4f6fb;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 12px; line-height: 1.5; color: #1e2230; background: #fff;
  padding: 22px; border: 1px solid var(--po-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;
}
.po-doc > .doc-brand-logo { max-height: 44px; margin: 0 auto 8px; }
.po-doc-company-name { font-size: 17px; font-weight: 800; color: var(--po-navy); text-align: center; padding: 6px 10px 12px; margin-bottom: 12px; border-bottom: 2.5px solid var(--po-navy); }
.po-doc-title-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.po-doc-address-box { flex: 1; border: 1px solid var(--po-line); border-radius: 4px; padding: 10px 12px; }
.po-doc-meta-box { width: 260px; border: 1px solid var(--po-line); border-radius: 4px; overflow: hidden; }
.po-doc-meta-row { display: flex; justify-content: space-between; gap: 8px; padding: 7px 11px; border-top: 1px solid var(--po-line); font-weight: 700; color: var(--po-navy); font-size: 11.5px; }
.po-doc-meta-row:first-child { border-top: none; }
.po-doc-title-badge { text-align: center; font-weight: 800; font-size: 19px; color: var(--po-navy); background: transparent; padding: 4px 6px 10px; letter-spacing: 0.06em; text-transform: uppercase; position: relative; }
.po-doc-title-badge::after { content: ""; display: block; width: 52px; height: 3px; background: var(--po-maroon); margin: 8px auto 0; border-radius: 2px; }

.po-doc-info-table, .po-doc-items-table, .po-doc-terms-table, .po-doc-totals-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.po-doc-info-table td, .po-doc-info-table th { border: 1px solid var(--po-line); padding: 7px 10px; vertical-align: top; }
.po-doc-info-table th { background: var(--po-navy); color: #fff; text-align: left; font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.02em; border-color: var(--po-navy); }

.po-doc-greeting { margin: 12px 0; }
.po-doc-greeting p { margin: 0 0 6px; }

.po-doc-items-table th, .po-doc-items-table td { border: 1px solid var(--po-line); padding: 7px 10px; }
.po-doc-items-table th { background: var(--po-navy); color: #fff; font-weight: 700; text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.02em; border-color: var(--po-navy); }
.po-doc-items-table td.num, .po-doc-items-table th.num { text-align: right; white-space: nowrap; }
.po-doc-items-table td.desc { max-width: 320px; }
.po-doc-items-table tbody tr:nth-child(even) td { background: var(--po-band); }

.po-doc-bottom-grid { display: flex; gap: 10px; align-items: flex-start; }
.po-doc-terms-table { flex: 1.3; }
.po-doc-terms-table td, .po-doc-terms-table th { border: 1px solid var(--po-line); padding: 7px 10px; }
.po-doc-terms-table th { background: var(--po-navy); color: #fff; text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.02em; border-color: var(--po-navy); }
.po-doc-terms-table td:first-child { font-weight: 700; width: 40%; color: var(--po-navy); background: var(--po-band); }

.po-doc-totals-table { flex: 1; }
.po-doc-totals-table td { border: 1px solid var(--po-line); padding: 7px 10px; }
.po-doc-totals-table td:first-child { font-weight: 600; }
.po-doc-totals-table td:last-child { text-align: right; white-space: nowrap; font-weight: 700; }
.po-doc-totals-table tr.grand td { font-weight: 800; background: var(--po-navy); color: #fff; font-size: 13px; }

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

.po-doc-auth { margin-top: 30px; display: flex; justify-content: flex-end; break-inside: avoid; }
.po-doc-auth-box { text-align: center; width: 220px; }
.po-doc-sig-line { height: 50px; border-bottom: 1px solid var(--po-line-strong); margin-bottom: 6px; }
.po-doc-auth-box input { text-align: center; font-weight: 700; margin-bottom: 2px; }

/* ---------- Editable fields inside the live document editor ---------- */
.po-doc input, .po-doc textarea, .po-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, background 0.15s ease;
}
.po-doc input::placeholder, .po-doc textarea::placeholder {
  color: #94a3b8;
  font-style: italic;
  opacity: 1;
}
.po-doc input:hover, .po-doc textarea:hover, .po-doc select:hover {
  border-color: #64748b;
  background: #fff;
}
.po-doc input:focus, .po-doc textarea:focus, .po-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;
}
.po-doc input[type="number"], .po-doc td.num input {
  text-align: right;
}
.po-doc input[type="date"] {
  min-width: 130px;
}
.po-doc-company-name {
  padding: 8px;
}
.po-doc-address-box textarea {
  min-height: 64px;
}
.po-doc-items-table input, .po-doc-terms-table input {
  padding: 6px 8px;
  border: 1px solid var(--border-strong, #cbd5e1);
  background: #ffffff;
  border-radius: 4px;
}
.po-doc-totals-table input[type="number"] {
  width: 60px;
  display: inline-block;
  margin: 0 2px;
}
.po-doc-items-table .remove-row-btn, .po-doc-terms-table .remove-row-btn {
  background: none; border: none; color: var(--po-muted); opacity: 0.7; cursor: pointer; padding: 4px;
}
.po-doc-items-table .remove-row-btn:hover, .po-doc-terms-table .remove-row-btn:hover { opacity: 1; color: #b91c1c; }
.po-doc-items-table td, .po-doc-terms-table td { vertical-align: middle; }
.po-doc-error { color: #b91c1c; font-size: 12px; font-weight: 600; margin: -6px 0 10px; }

/* 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 {
  #poPreviewBody { padding: 0; }
  .po-doc { border: none; box-shadow: none; border-radius: 0; padding: 0; }
  .po-doc input, .po-doc textarea, .po-doc select {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .po-doc-items-table thead { display: table-header-group; }
  .po-doc-items-table tr { break-inside: avoid; }
  .po-doc-title-row, .po-doc-bottom-grid, .po-doc-words, .po-doc-auth { break-inside: avoid; }
}
