/* ส่งห้าง (PO) — สไตล์หน้าทีมคลัง/รายละเอียดใบ (po.js) + แถบทางเข้าในหน้าคิวแพ็ค (queue.js) · โทเค็นสีใช้ของ app.css
   ใช้ซ้ำของเดิมให้มากที่สุด: .tabs/.tab/.queue-card/.queue-card-lines (ทั้งชุด), .badge, .so-chip, .so-row, .step-bar, .btn-primary/.btn-secondary, .so-chip-btn,
   .modal-card-form, .photo-list, .history-list — ที่นี่มีแค่ของที่ PO ต้องการเพิ่มจริง ๆ
   คู่สีใหม่ทุกคู่อยู่ใน test/ui-contrast.test.js */

/* ---------- แถบทางเข้า "งานส่งห้าง" ใต้แถวแท็บของหน้าคิว (และแถบ "กลับไปคิวแพ็ค" ในหน้างานส่งห้าง) ----------
   geometry เดียวกับ .claims-strip (เต็มความกว้าง สูงขั้นต่ำ 48px แตะได้ทั้งแถบ) แต่สีจาง = ทางเข้า ไม่ใช่การแจ้งเตือน */
.po-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.po-strip:hover { color: var(--text); }
.po-strip-arrow { font-size: 20px; line-height: 1; }
.po-strip-back { justify-content: flex-start; gap: 8px; }

/* ---------- ป้ายบนการ์ด/หัวใบ ---------- */
/* LOT ครบ = เขียวทึบ (ขาวบน --success) · LOT k/n = จาง ไม่แย่งสายตา (--text-muted บน --surface-muted) */
.badge-lot-ok { background: var(--success); }
.badge-lot-part { background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border-strong); }
/* ป้ายสถานะใบ PO ในหัวหน้ารายละเอียด (ตัวหนังสือขาวบนสีทึบ) */
.po-st-open { background: var(--primary); }
.po-st-picked { background: var(--case); }
.po-st-shipping { background: var(--warning); }
.po-st-shipped { background: var(--success); }
.po-st-cancelled { background: var(--danger); }

/* ---------- การ์ดในรายการ ---------- */
.po-card-place { font-size: 15px; font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.po-card-refs { font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--text-muted); }
.po-card-ponum { font-weight: 600; }
.po-card-refs .so-chip { margin-left: 0; }
.po-card-meta {
  display: flex;
  gap: 6px;
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
}
/* note ยาวตัดเหลือบรรทัดเดียว (การ์ดต้องไม่ยาวเกิน) — อ่านเต็มในหน้ารายละเอียด */
.po-card-note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- หัวหน้ารายละเอียด ---------- */
.po-page { max-width: 640px; margin: 0 auto; padding: 16px 16px 160px; }
.po-title { font-size: 21px; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.po-head-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 8px; font-size: 14px; }
.po-head-meta .badge { margin-left: 0; }
.po-code { font-weight: 700; }
.po-due { color: var(--text-muted); font-weight: 600; }
.po-head-po { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.po-head-extra { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.po-page .so-row { margin: 0 0 8px; }
.po-page .step-bar { margin: 4px 0 12px; }
/* note เน้น (เช่น "ติดสติ๊กเกอร์บาร์โค้ด") — ทีมคลังต้องเห็นก่อนลงมือจัด · พื้น/ขอบสีเตือนเดียวกับ .admin-hint */
.po-note {
  background: var(--warning-soft);
  color: var(--text);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.po-note-label { display: block; font-size: 12px; font-weight: 700; color: var(--warning); margin-bottom: 2px; }
.po-cancelled { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; font-size: 14px; color: var(--text-muted); }
.po-cancelled .badge { margin-left: 0; }

/* ---------- รายการ + LOT ---------- */
.po-lines h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.po-lines-total { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.po-lines-total-ok { color: var(--success); }
.po-line { padding: 12px 0; border-top: 1px solid var(--border); }
.po-line:first-of-type { border-top: none; padding-top: 0; }
.po-line-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.po-line-name { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; min-width: 0; }
.po-line-qty { font-size: 14px; color: var(--text-muted); white-space: nowrap; flex: 0 0 auto; }
.po-lots { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto; }
.po-lots th { text-align: left; font-size: 12px; font-weight: 700; color: var(--text-muted); padding: 4px 6px; background: var(--surface-muted); }
.po-lots td { padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.po-lots .po-lot-no { font-weight: 700; overflow-wrap: anywhere; }
.po-lots .po-lot-qty { text-align: right; font-variant-numeric: tabular-nums; }
.po-lots .po-lot-del { width: 1%; text-align: right; padding-right: 0; }
.po-lots .btn-del { min-width: 48px; padding: 6px 8px; }
.po-lots-empty { font-size: 13px; color: var(--text-faint); padding: 6px 0; }
.po-line-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.po-lot-sum { font-size: 14px; font-weight: 700; }
.po-lot-sum-ok { color: var(--success); }
.po-lot-sum-part { color: var(--warning); }
.po-add-lot { width: auto; padding-left: 16px; padding-right: 16px; }

/* ---------- ปุ่มรอง (ชิป) + ปุ่มหลักล่างจอ ---------- */
.po-tools { margin-bottom: 12px; }
.po-tools-row { display: flex; flex-wrap: wrap; gap: 8px; }
/* ชิปของ PO สูง 48px (ชิป SO เดิม 44px) — ทีมคลังสวมถุงมือแตะ */
.po-tools .so-chip-btn { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; }
.po-chip-file { position: relative; }
/* แถบปุ่มหลักตรึงขอบล่างจอ — หน้าตาเดียวกับ .actions-primary ของหน้าออเดอร์ (ไม่ใช้คลาสนั้นเพราะผูก padding ท้ายหน้าของ .order-page) */
.po-primary-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.12);
}
.po-primary-bar > * { max-width: 608px; width: 100%; margin-left: auto; margin-right: auto; }

/* ---------- กล่อง popup ---------- */
.po-modal-line { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.po-modal-text { margin: 0; font-size: 15px; line-height: 1.5; }
.modal-card-form .field-row { gap: 10px; }
