/* po.css — purchase orders (po.js, po_form.js): the Status | PO switch, the
 * summary, the PO as it prints (an A4 sheet like the workbook's FORMAT), the
 * form laid out the same way, and the print rules. */

/* ---------- Status | PO, under the stage tabs ---------- */
.ad-modes { margin: 0 0 12px; }
.ad-modes .subtab { min-width: 92px; }
.po-tabs { margin: 4px 0 12px; }
.po-tab { display: inline-flex; align-items: center; gap: 6px; }
.po-tab-new:not(.is-on) { color: var(--accent-ink); }
.po-signin { margin-top: 24px; }

/* ---------- summary ---------- */
.po-link {
  border: 0; background: none; padding: 0; font: inherit; font-weight: 700;
  color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.po-link:hover { color: var(--ink); }
.po-cat {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--fill); color: var(--ink-2); white-space: nowrap;
}
.po-cat-adda-job-work     { background: color-mix(in srgb, var(--adda) 16%, #fff); color: color-mix(in srgb, var(--adda) 75%, #000); }
.po-cat-adda-accessories  { background: color-mix(in srgb, var(--adda) 8%, #fff); color: color-mix(in srgb, var(--adda) 65%, #000); }
.po-cat-accessories       { background: color-mix(in srgb, var(--planning) 12%, #fff); color: color-mix(in srgb, var(--planning) 70%, #000); }
.po-cat-fabric            { background: color-mix(in srgb, var(--fabric) 14%, #fff); color: color-mix(in srgb, var(--fabric) 70%, #000); }
.po-cat-printing-job      { background: color-mix(in srgb, var(--images) 14%, #fff); color: color-mix(in srgb, var(--images) 70%, #000); }

/* ---------- the PO, as it prints ---------- */
.po-doc-wrap { display: flex; flex-direction: column; gap: 12px; }
.po-doc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.po-doc-actions .is-danger { margin-left: auto; color: var(--red); }
.po-doc-note {
  margin: 0; padding: 8px 12px; border-radius: var(--r-sm); font-size: 13px;
  background: color-mix(in srgb, var(--adda) 10%, #fff); color: color-mix(in srgb, var(--adda) 70%, #000);
}
.po-paper {
  width: 100%; max-width: 960px; margin: 0 auto; padding: 28px 32px 32px; box-sizing: border-box;
  background: var(--surface); border: 1px solid var(--sheet-edge); border-radius: var(--r-md); box-shadow: var(--sh-sm);
}
.po-paper-head { text-align: center; padding-bottom: 14px; border-bottom: 2px solid var(--ink); margin-bottom: 14px; }
.po-paper-title { margin: 0 0 4px; font-family: var(--display); font-size: 22px; letter-spacing: .14em; }
.po-paper-co { margin: 0; font-weight: 800; font-size: 16px; letter-spacing: .04em; }
.po-paper-sub { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.po-paper-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0 0 14px;
  border: 1px solid var(--sheet-edge); }
.po-paper-meta > div { padding: 7px 10px; border-right: 1px solid var(--sheet-line); border-bottom: 1px solid var(--sheet-line); min-width: 0; }
.po-paper-meta > div.is-wide { grid-column: span 2; }
.po-paper-meta > div.is-full { grid-column: 1 / -1; }
.po-paper-meta dt { font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.po-paper-meta dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.po-paper-lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.po-paper-lines th {
  text-align: left; padding: 7px 8px; background: var(--fill); border: 1px solid var(--sheet-edge);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2);
}
.po-paper-lines td { padding: 6px 8px; border: 1px solid var(--sheet-line); vertical-align: top; }
.po-paper-lines .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.po-paper-lines tr.is-note td { color: var(--ink-2); font-style: italic; }
.po-paper-totals { margin: 12px 0 0 auto; width: min(320px, 100%); }
.po-paper-totals > div { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 6px 10px; border-bottom: 1px solid var(--sheet-line); }
.po-paper-totals dt { color: var(--ink-2); }
.po-paper-totals dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.po-paper-totals .is-total { border-top: 2px solid var(--ink); border-bottom: 0; font-size: 16px; }
.po-paper-totals .is-total dt, .po-paper-totals .is-total dd { color: var(--ink); font-weight: 800; }
.po-paper-hint { margin: 4px 10px 0; font-size: 12px; color: var(--ink-3); text-align: right; }
.po-paper-foot { margin-top: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.po-paper-notes { margin: 12px 0 0; padding: 8px 10px; background: var(--fill); border-radius: var(--r-sm); font-size: 13px; }
.po-paper-h { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.po-paper-terms { margin: 0; padding-left: 18px; font-size: 12px; color: var(--ink-2); columns: 2 320px; column-gap: 28px; }
.po-paper-terms li { margin: 0 0 4px; break-inside: avoid; }

/* ---------- the form: the same sheet, to fill in ---------- */
.po-form { display: flex; flex-direction: column; gap: 12px; }
.po-form-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; max-width: 960px; width: 100%; margin: 0 auto; }
.po-form-title { margin: 0; font-size: 18px; }
.po-form-kept { font-size: 12.5px; color: var(--ink-3); }
.po-form-bar .tb-btn { margin-left: auto; }
.po-paper.is-form { padding-top: 22px; }
.pf-notice { max-width: 960px; width: 100%; box-sizing: border-box; margin: 0 auto; padding: 9px 12px;
  border-radius: var(--r-sm); font-size: 13.5px; background: var(--fill); color: var(--ink-2); }
.pf-notice.is-warn { background: var(--yellow-soft, #fff7d6); color: var(--ink); border: 1px solid var(--yellow-line, #f0d27a); }
.pf-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; margin-bottom: 16px; }
.pf-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pf-label { font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.pf-party { grid-column: span 2; }
.pf-addr { grid-column: 1 / -1; }
.pf-phone[hidden] { display: none; }
.pf-no { padding: 9px 0; font-weight: 800; font-size: 16px; }
.pf-input {
  font: inherit; font-size: 14px; width: 100%; box-sizing: border-box; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
}
textarea.pf-input { resize: vertical; min-height: 40px; }
.pf-input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
.pf-input.is-bad { border-color: var(--red); background: var(--red-soft); }
.pf-hint { font-size: 12px; color: var(--ink-3); min-height: 16px; }
.pf-hint.ok { color: var(--green); }
.pf-hint.warn { color: var(--amber); }
.pf-hint.bad { color: var(--red); }
.pf-linkbtn { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--accent-ink);
  text-decoration: underline; cursor: pointer; }

.pf-lines-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.pf-lines { min-width: 860px; }
.pf-lines td { padding: 0; vertical-align: top; }
.pf-lines .pf-input { border: 0; border-radius: 0; padding: 8px 8px; background: transparent; }
.pf-lines .pf-input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
.pf-lines .pf-input.is-bad { background: var(--red-soft); }
.pf-lines td.num .pf-input { text-align: right; font-variant-numeric: tabular-nums; }
.pf-lines .pf-no-cell { width: 28px; text-align: center; color: var(--ink-3); padding: 8px 4px; font-size: 12px; }
.pf-lines .pf-c-art { width: 150px; }
.pf-lines .pf-c-jc { width: 80px; }
.pf-lines .pf-c-w { width: 70px; }
.pf-lines .pf-c-qty { width: 80px; }
.pf-lines .pf-c-uom { width: 86px; }
.pf-lines .pf-c-price { width: 90px; }
.pf-lines .pf-c-tot { width: 110px; padding: 8px; color: var(--ink-2); }
.pf-lines .pf-c-x { width: 34px; text-align: center; }
.pf-art-hint { display: block; padding: 0 8px 5px; font-size: 11px; line-height: 1.25; color: var(--ink-3); }
.pf-art-hint:empty { display: none; }
.pf-art-hint.ok { color: var(--green); }
.pf-art-hint.warn { color: var(--amber); }
.pf-art-hint.bad { color: var(--red); }
.pf-tag { display: inline-block; margin: 0 8px 5px; padding: 1px 6px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  background: color-mix(in srgb, var(--adda) 14%, #fff); color: color-mix(in srgb, var(--adda) 75%, #000); }
.pf-rm { border: 0; background: none; padding: 8px 6px; color: var(--ink-3); cursor: pointer; border-radius: var(--r-sm); }
.pf-rm:hover { color: var(--red); background: var(--red-soft); }
.pf-add { margin-top: 8px; }

.pf-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: 18px; margin-top: 16px; align-items: start; }
.pf-bottom-left { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.pf-notes { grid-column: 1 / -1; }
.pf-totals { margin: 0; width: 100%; }
.pf-gst-label { display: inline-flex; align-items: center; gap: 4px; }
.pf-totals input.pf-rate { width: 64px; flex: 0 0 64px; padding: 4px 6px; font-size: 14px; text-align: right; }
.pf-adda-note {
  margin: 16px 0 0; padding: 9px 12px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--adda) 12%, #fff); color: color-mix(in srgb, var(--adda) 72%, #000);
}
.pf-adda-note[hidden] { display: none; }
.po-form-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  max-width: 960px; width: 100%; margin: 0 auto; padding: 10px 0;
  background: linear-gradient(to top, var(--page, #f6f7f9) 70%, transparent);
}
.pf-msg { margin: 0 auto 0 0; font-size: 13.5px; min-width: 0; }
.pf-msg .msg { margin: 0; }
.pf-save { min-width: 132px; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .po-paper { padding: 16px 14px 20px; }
  .po-paper-meta, .pf-head, .pf-bottom, .pf-bottom-left { grid-template-columns: minmax(0, 1fr); }
  .po-paper-meta > div.is-wide, .pf-party { grid-column: auto; }
  .po-paper-terms { columns: 1; }
  .po-form-actions { flex-wrap: wrap; }
  .pf-msg { flex: 1 1 100%; }
}

/* ---------- printing one PO: just the sheet ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body.print-po { background: #fff !important; }
  body.print-po * { visibility: hidden; }
  body.print-po .po-paper, body.print-po .po-paper * { visibility: visible; }
  body.print-po .po-paper {
    position: absolute; left: 0; top: 0; max-width: none; margin: 0; padding: 0;
    border: 0; border-radius: 0; box-shadow: none; font-size: 12px;
  }
  body.print-po .po-paper-lines th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
