.purchase-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 16px;
}

/* Purchase metadata editor: compact PC width, scrollable body and visible actions. */
#purchaseInfoDialog { width: min(560px, calc(100vw - 28px)); max-width: min(560px, calc(100vw - 28px)); min-width: 0; height: fit-content; max-height: calc(100dvh - 28px); padding: 0; overflow: hidden; box-sizing: border-box; border-radius: 14px; }
#purchaseInfoDialog > form { display: flex; flex-direction: column; max-height: calc(100dvh - 28px); min-height: 0; }
#purchaseInfoDialog .purchase-dialog-body { min-height: 0; overflow-y: auto; }
#purchaseInfoDialog footer { flex-wrap: wrap; }
#purchaseInfoDialog input { min-width: 0; max-width: 100%; box-sizing: border-box; }


.purchase-hero {
  align-items: center;
  background: linear-gradient(135deg, #f8fbff 0%, #edf5ff 100%);
  border: 1px solid #c9dcf4;
  border-radius: 20px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 22px;
}

.purchase-hero-copy {
  align-items: center;
  display: flex;
  gap: 14px;
}

.purchase-hero-icon {
  align-items: center;
  background: #fff;
  border: 1px solid #d9e7f8;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(13, 87, 200, .09);
  display: inline-flex;
  font-size: 27px;
  height: 58px;
  justify-content: center;
  width: 58px;
}

.purchase-hero-copy p,
.purchase-dialog header p {
  color: #1769d5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  margin: 0 0 4px;
}

.purchase-hero-copy h2,
.purchase-dialog header h3 {
  color: #10243f;
  font-size: 21px;
  margin: 0;
}

.purchase-hero-copy div > span {
  color: #71829a;
  display: block;
  font-size: 12px;
  margin-top: 5px;
}

.purchase-create { min-width: 136px; }

.purchase-metrics {
  background: rgba(255, 255, 255, .8);
  border: 1px solid #dbe7f5;
  border-radius: 14px;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
}

.purchase-metrics > button {
  background: transparent;
  border: 0;
  border-radius: 0;
  min-width: 0;
  padding: 8px;
  cursor: pointer;
  align-items: center;
  border-right: 1px solid #e2eaf3;
  display: flex;
  gap: 7px;
  justify-content: center;
  min-height: 57px;
}

.purchase-metrics > button:last-child { border-right: 0; }
.purchase-metrics > button:hover { background: #edf5ff; }
.purchase-metrics > button.is-active { background: #dcecff; box-shadow: inset 0 -3px #1769d5; }
.purchase-metrics > button.is-active span { color: #164f91; }
.purchase-metrics > button:focus-visible { outline: 2px solid #1769d5; outline-offset: -4px; }
.purchase-metrics strong { color: #0d57c8; font-size: 19px; }
.purchase-metrics span { color: #71829a; font-size: 11px; font-weight: 700; }

.purchase-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.purchase-search {
  align-items: center;
  background: #fff;
  border: 1px solid #dce5ef;
  border-radius: 11px;
  display: flex;
  min-width: min(360px, 100%);
  padding: 0 12px;
}

.purchase-search span { color: #7b899d; font-size: 20px; }
.purchase-search input { border: 0; box-shadow: none; flex: 1; min-height: 43px; outline: 0; padding: 0 8px; }

.purchase-filter-row { display: flex; flex-wrap: wrap; gap: 7px; }
.purchase-filter-row button {
  background: #fff;
  border: 1px solid #dce5ef;
  border-radius: 20px;
  color: #64758a;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  min-height: 36px;
  padding: 0 13px;
}
.purchase-filter-row button b { color: inherit; }
.purchase-filter-row button.is-active { background: #1769d5; border-color: #1769d5; color: #fff; }

.purchase-list {
  display: grid;
  min-width: 0;
  gap: 11px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.purchase-card {
  align-items: center;
  background: #fff;
  border: 1px solid #dfe7f0;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(19, 48, 79, .05);
  color: inherit;
  cursor: pointer;
  display: flex;
  min-height: 132px;
  min-width: 0;
  padding: 13px;
  text-align: left;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  width: 100%;
}
.purchase-card:hover { border-color: #a9c7ec; box-shadow: 0 12px 30px rgba(13, 87, 200, .1); transform: translateY(-1px); }
.purchase-card.is-urgent { border-color: #efb8c0; }
.purchase-card-media { flex: 0 0 96px; height: 96px; margin-right: 13px; }
.purchase-card-media img,
.purchase-card-placeholder { border-radius: 12px; height: 100%; object-fit: cover; width: 100%; }
.purchase-card-placeholder { align-items: center; background: #edf5ff; display: flex; font-size: 28px; justify-content: center; }
.purchase-card-content { display: block; flex: 1; min-width: 0; }
.purchase-card-head { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; }
.purchase-card-content > strong { color: #10243f; display: block; font-size: 14px; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purchase-card-content > small { color: #71829a; display: block; font-size: 10px; margin-top: 5px; }
.purchase-card-foot { align-items: center; display: flex; gap: 8px; margin-top: 11px; }
.purchase-card-foot em { color: #344b65; flex: 1; font-size: 10px; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purchase-card-foot time { color: #98a4b4; font-size: 9px; }
.purchase-card-arrow { color: #a1afc0; font-size: 25px; margin-left: 8px; }

.purchase-status,
.purchase-urgent {
  border-radius: 12px;
  display: inline-flex;
  font-size: 9px;
  font-weight: 800;
  padding: 5px 8px;
}
.purchase-status.is-orange { background: #fff5ea; color: #d96d0e; }
.purchase-status.is-blue { background: #edf5ff; color: #1769d5; }
.purchase-status.is-purple { background: #f2f1ff; color: #625dd0; }
.purchase-card .purchase-status.has-location { max-width: 100%; min-width: 0; box-sizing: border-box; }
.purchase-status.has-location > span:first-child { flex-shrink: 0; }
.purchase-status-location { min-width: 0; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.purchase-status.is-teal { background: #eaf8fa; color: #12829a; }
.purchase-status.is-green { background: #eef9f5; color: #16945c; }
.purchase-status.is-yellow { background: #fff8e7; color: #8a6b26; }
.purchase-status.is-red { background: #fff0f1; color: #d9485a; }
.purchase-status.is-gray { background: #f1f4f7; color: #718096; }
.purchase-urgent { background: #fff0f1; color: #d9485a; }

.purchase-loading,
.purchase-empty {
  align-items: center;
  background: #fff;
  border: 1px solid #dfe7f0;
  border-radius: 16px;
  color: #71829a;
  display: flex;
  flex-direction: column;
  grid-column: 1 / -1;
  justify-content: center;
  min-height: 260px;
  padding: 32px;
  text-align: center;
}
.purchase-loading span { animation: purchase-spin .8s linear infinite; border: 3px solid #d9e6f6; border-radius: 50%; border-top-color: #1769d5; height: 28px; width: 28px; }
.purchase-empty > span { font-size: 30px; }
.purchase-empty strong { color: #10243f; font-size: 14px; margin-top: 10px; }
.purchase-empty p { font-size: 11px; margin: 6px 0 14px; }
.purchase-empty.is-error > span { align-items: center; background: #fff0f1; border-radius: 50%; color: #d9485a; display: flex; font-weight: 900; height: 42px; justify-content: center; width: 42px; }
@keyframes purchase-spin { to { transform: rotate(360deg); } }

.purchase-dialog {
  background: #f5f7fb;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 25px 80px rgba(7, 29, 53, .28);
  color: #344b65;
  max-height: min(880px, calc(100vh - 36px));
  max-width: min(720px, calc(100vw - 36px));
  padding: 0;
  width: 100%;
}
.purchase-dialog::backdrop { background: rgba(7, 24, 43, .5); backdrop-filter: blur(2px); }
/* Explicit IDs avoid shared modal sizing making small purchase forms full-width. */
#purchaseCreateDialog, #purchaseDetailDialog, #purchaseHandlersDialog, #purchaseShippingDialog {
  width: min(580px, calc(100vw - 28px));
  min-width: 0;
  max-width: min(580px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  box-sizing: border-box;
}
#purchaseDetailDialog { width: min(640px, calc(100vw - 28px)); max-width: min(640px, calc(100vw - 28px)); }
#purchaseCreateDialog > form, #purchaseHandlersDialog > form, #purchaseShippingDialog > form,
#purchaseDetailDialog[open] { display: flex; flex-direction: column; max-height: calc(100dvh - 28px); margin: 0; }
#purchaseCreateDialog .purchase-dialog-body, #purchaseDetailDialog .purchase-dialog-body,
#purchaseHandlersDialog .purchase-dialog-body, #purchaseShippingDialog .purchase-dialog-body {
  min-height: 0; flex: 1 1 auto; overflow-y: auto; max-height: none;
}
#purchaseDetailDialog[open] { margin: auto; }
.purchase-dialog > header, .purchase-dialog form > header, .purchase-dialog footer { flex-shrink: 0; }
.purchase-dialog header > div { min-width: 0; }
.purchase-dialog header h3 { overflow-wrap: anywhere; }
.purchase-dialog .purchase-dialog-close { flex: 0 0 36px; }
.purchase-dialog footer button { width: auto; min-width: 72px; white-space: nowrap; }
.purchase-dialog footer .danger-action { margin-right: auto; }
.purchase-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.purchase-hero-actions button { white-space: nowrap; flex: 0 0 auto; }
.purchase-handler-list { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; margin: 12px 0; }
.purchase-handler-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #fff; border: 1px solid #d6e2ef; border-radius: 10px; cursor: pointer; }
.purchase-handler-row[hidden] { display: none; }
#purchaseHandlersDialog .purchase-handler-row input { flex: 0 0 18px; width: 18px; height: 18px; margin: 0; padding: 0; accent-color: #166bb9; }
.purchase-handler-row span { display: grid; gap: 3px; }
.purchase-handler-row strong { font-size: 14px; color: #153d64; }
.purchase-handler-row small { font-size: 12px; color: #536c86; }
.purchase-handler-count { color: #155e9b; font-weight: 700; }
.purchase-handler-search { width: 100%; min-width: 0; box-sizing: border-box; }
.purchase-dialog .purchase-helper { font-size: 12px; line-height: 1.6; color: #506984; }
.purchase-dialog .purchase-form-grid select { min-height: 40px; width: 100%; }
.purchase-shipping-info dl { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; font-size: 13px; }
.purchase-shipping-info dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; }
.purchase-shipping-info button { margin-top: 10px; }
#purchaseDetailDialog .purchase-detail-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Mobile summary cards already provide the same filters. */
@media (max-width: 820px) {
  .purchase-toolbar .purchase-filter-row { display: none; }
}

@media (max-width: 640px) {
  #purchaseCreateDialog, #purchaseDetailDialog, #purchaseHandlersDialog, #purchaseShippingDialog { height: auto; border-radius: 14px; }
  .purchase-hero-actions { justify-content: flex-start; }
  .purchase-hero-actions .purchase-create { width: auto; }
}
.purchase-dialog > form,
.purchase-detail-dialog { overflow: hidden; }
.purchase-dialog header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #dfe7f0;
  display: flex;
  justify-content: space-between;
  padding: 17px 20px;
}
.purchase-dialog header h3 { font-size: 18px; }
.purchase-dialog-close { background: #f3f6fa; border: 0; border-radius: 50%; color: #344b65; cursor: pointer; font-size: 22px; height: 36px; width: 36px; }
.purchase-dialog-body { max-height: calc(100vh - 190px); overflow: auto; padding: 20px; }
.purchase-dialog footer { background: #fff; border-top: 1px solid #dfe7f0; display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; }

.purchase-requester-auto { align-items: center; background: #edf5ff; border: 1px solid #cfe0f7; border-radius: 13px; display: flex; gap: 10px; margin-bottom: 18px; padding: 12px; }
.purchase-requester-auto > span { align-items: center; background: #fff; border-radius: 10px; display: flex; height: 38px; justify-content: center; width: 38px; }
.purchase-requester-auto div { display: flex; flex: 1; flex-direction: column; }
.purchase-requester-auto small { color: #71829a; font-size: 9px; }
.purchase-requester-auto strong { color: #10243f; font-size: 12px; margin-top: 2px; }
.purchase-requester-auto > b { color: #16945c; }

.purchase-form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.purchase-form-grid label { display: flex; flex-direction: column; gap: 6px; }
.purchase-form-grid > .is-wide { grid-column: 1 / -1; min-width: 0; }
.purchase-form-grid label > span { color: #344b65; font-size: 11px; font-weight: 800; }
.purchase-form-grid label > span b { color: #d9485a; font-size: 9px; }
.purchase-form-grid label > span em { color: #98a4b4; font-size: 9px; font-style: normal; }
.purchase-form-grid input:not([type="checkbox"]) { background: #fff; border: 1px solid #dce5ef; border-radius: 10px; min-height: 44px; padding: 0 11px; }
.purchase-file-field { background: #fff; border: 1px dashed #b7cee9; border-radius: 11px; padding: 12px; }
.purchase-file-field input { border: 0 !important; min-height: 34px !important; padding: 0 !important; }
.purchase-file-field small { color: #71829a; font-size: 9px; }
.purchase-dialog .purchase-photo-preview { display: flex; align-items: center; gap: 12px; padding: 10px; margin: 8px 0; background: #f0f6ff; border: 1px solid #d0e1f4; border-radius: 10px; min-width: 0; }
.purchase-dialog .purchase-photo-preview[hidden] { display: none; }
.purchase-photo-preview img { width: 88px; height: 74px; object-fit: contain; border-radius: 6px; background: #fff; flex: 0 0 88px; }
.purchase-photo-preview > div { display: grid; gap: 7px; min-width: 0; justify-items: start; }
.purchase-photo-preview strong { font-size: 12px; color: #234c73; overflow-wrap: anywhere; }
.purchase-dialog .purchase-photo-preview button { width: auto; min-height: 30px; padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.purchase-dialog .purchase-photo-help { display: block; color: #4e6881; font-size: 11px; line-height: 1.6; margin-top: 6px; }
.purchase-dialog .purchase-photo-error:not([hidden]) { display: block; color: #b32632; font-size: 12px; margin-top: 6px; }
.purchase-detail-options { padding: 0 0 12px; margin-bottom: 12px; border-bottom: 1px solid #e1e9f3; }
.purchase-detail-options span { color: #456683; font-weight: 700; font-size: 12px; }
.purchase-detail-options p { margin: 4px 0 0; font-size: 14px; color: #193d5f; overflow-wrap: anywhere; white-space: pre-wrap; }
#purchaseDetailDialog footer { flex-wrap: wrap; }
#purchaseCreateDialog input, #purchaseCreateDialog .purchase-file-field { max-width: 100%; min-width: 0; box-sizing: border-box; }
.purchase-urgent-check { align-items: center; background: #fff0f1; border: 1px solid #f0c8ce; border-radius: 10px; flex-direction: row !important; grid-column: 1 / -1; padding: 11px; }
.purchase-urgent-check input { accent-color: #d9485a; height: 16px; width: 16px; }
.purchase-form-error { background: #fff0f1; border: 1px solid #f0c8ce; border-radius: 9px; color: #d9485a; font-size: 10px; margin: 14px 0 0; padding: 10px; }

.purchase-detail-dialog { max-width: min(820px, calc(100vw - 36px)); }
.purchase-detail-loading { align-items: center; display: flex; justify-content: center; min-height: 280px; }
.purchase-detail-body { display: grid; gap: 12px; }
.purchase-detail-summary,
.purchase-detail-links,
.purchase-detail-section { background: #fff; border: 1px solid #dfe7f0; border-radius: 14px; padding: 15px; }
.purchase-detail-status-line { align-items: center; display: flex; gap: 7px; }
.purchase-detail-facts { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); margin-top: 14px; }
.purchase-detail-facts div { background: #f7f9fc; border-radius: 9px; display: flex; flex-direction: column; padding: 10px; }
.purchase-detail-facts span { color: #8996a8; font-size: 9px; }
.purchase-detail-facts strong { color: #10243f; font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purchase-photo-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 40px; width: 40px; height: 40px; min-width: 40px; padding: 0; margin-left: auto; border: 1px solid #c8dcf0; border-radius: 10px; background: #edf5ff; color: #1769d5; cursor: pointer; }
.purchase-photo-icon:hover { background: #dcecff; border-color: #89b5e5; }
.purchase-photo-icon:focus-visible { outline: 2px solid #1769d5; outline-offset: 3px; }
#purchasePhotoDialog { width: min(860px, calc(100vw - 28px)); min-width: 0; max-width: min(860px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 0; box-sizing: border-box; overflow: hidden; }
#purchasePhotoDialog[open] { display: flex; flex-direction: column; margin: auto; }
#purchasePhotoDialog > header h3 { font-size: 17px; }
#purchasePhotoDialog .purchase-photo-viewer-body { flex: 1 1 auto; min-height: 0; overflow: auto; display: grid; place-items: center; background: #eef3f8; padding: 12px; }
#purchasePhotoDialog .purchase-photo-viewer-body img { display: block; width: auto; height: auto; max-width: 100%; max-height: max(100px, calc(100dvh - 205px)); object-fit: contain; }
#purchasePhotoDialog .purchase-photo-viewer-body p { margin: 20px 8px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
#purchasePhotoDialog .purchase-photo-viewer-body [hidden] { display: none; }
#purchasePhotoDialog footer { justify-content: flex-end; }
.purchase-detail-links { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; }
.purchase-detail-links > span { color: #71829a; font-size: 10px; }
.purchase-detail-links a { background: #edf5ff; border-radius: 9px; color: #1769d5; font-size: 10px; font-weight: 800; padding: 9px 11px; text-decoration: none; }
.purchase-detail-links p { background: #f7f9fc; border-radius: 9px; display: flex; flex: 1 0 100%; flex-direction: column; font-size: 10px; margin: 0; padding: 10px; }
.purchase-detail-links p strong { color: #8996a8; font-size: 9px; margin-bottom: 4px; }
.purchase-detail-section h4 { color: #10243f; font-size: 13px; margin: 0; }
.purchase-detail-section > p { color: #71829a; font-size: 9px; margin: 4px 0 0; }
.purchase-action-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.purchase-action-row button { background: #fff; border: 1px solid; border-radius: 9px; cursor: pointer; font-size: 10px; font-weight: 800; min-height: 37px; padding: 0 11px; }
.purchase-action-row .is-blue { border-color: #9fc0e8; color: #1769d5; }
.purchase-action-row .is-purple { border-color: #c7c3ef; color: #625dd0; }
.purchase-action-row .is-teal { border-color: #a6d7df; color: #12829a; }
.purchase-action-row .is-green { border-color: #9ed5be; color: #16945c; }
.purchase-action-row .is-yellow { border-color: #dacb9b; color: #8a6b26; }
.purchase-action-row .is-red { border-color: #edb2ba; color: #d9485a; }

.purchase-timeline { list-style: none; margin: 15px 0 0; padding: 0; }
.purchase-timeline li { display: grid; grid-template-columns: 16px 1fr; min-height: 58px; position: relative; }
.purchase-timeline li > i { background: #1769d5; border: 3px solid #dcecff; border-radius: 50%; height: 12px; margin-top: 2px; width: 12px; z-index: 1; }
.purchase-timeline li.is-comment > i { background: #16945c; border-color: #d9f2e8; }
.purchase-timeline li:not(:last-child)::before { background: #dce5ef; content: ""; height: calc(100% - 8px); left: 5px; position: absolute; top: 12px; width: 1px; }
.purchase-timeline li > div { padding: 0 0 14px 8px; }
.purchase-timeline header { border: 0; padding: 0; }
.purchase-timeline header strong { color: #344b65; font-size: 10px; }
.purchase-timeline header time { color: #98a4b4; font-size: 8px; }
.purchase-timeline small { color: #71829a; display: block; font-size: 9px; margin-top: 2px; }
.purchase-timeline p { background: #f7f9fc; border-radius: 8px; font-size: 10px; line-height: 1.5; margin: 6px 0 0; padding: 8px; }
.purchase-no-history { padding: 22px !important; text-align: center; }
/* Automatic tracking stays within its shipping/waybill history entry. */
#purchaseDetailDialog .purchase-timeline li { grid-template-columns: 16px minmax(0, 1fr); }
#purchaseDetailDialog .purchase-timeline li > div { min-width: 0; }
#purchaseDetailDialog .purchase-shipping-events { background: #f4f8fc; border: 1px solid #e2eaf3; border-radius: 8px; margin-top: 6px; padding: 5px 10px; }
#purchaseDetailDialog .purchase-shipping-event { color: #344b65; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; padding: 5px 0; }
#purchaseDetailDialog .purchase-shipping-event time { color: inherit; display: inline-block; font: inherit; white-space: nowrap; }
#purchaseDetailDialog .purchase-shipping-event + .purchase-shipping-event { border-top: 1px solid #e2eaf3; }
#purchaseDetailDialog .purchase-shipping-event.is-delivered { color: #128154; font-weight: 700; }
#purchaseDetailDialog .purchase-shipping-completed { background: #e4f5eb; border-radius: 5px; color: #128154; display: inline-block; font-size: 11px; margin-left: 8px; padding: 2px 6px; vertical-align: middle; }
.purchase-comment-compose { align-items: flex-end; display: flex; gap: 8px; margin-top: 11px; }
.purchase-comment-compose textarea { border: 1px solid #dce5ef; border-radius: 10px; flex: 1; min-height: 70px; padding: 10px; resize: vertical; }
.purchase-comment-compose button { background: #1769d5; border: 0; border-radius: 9px; color: #fff; cursor: pointer; font-weight: 800; min-height: 40px; padding: 0 14px; }

@media (max-width: 900px) {
  .purchase-list { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .purchase-hero { grid-template-columns: 1fr; padding: 16px; }
  .purchase-create { width: 100%; }
  .purchase-metrics { grid-template-columns: repeat(2, 1fr); }
  .purchase-metrics > button:nth-child(2) { border-right: 0; }
  .purchase-metrics > button:nth-child(-n+2) { border-bottom: 1px solid #e2eaf3; }
  .purchase-toolbar, .purchase-filter-row { align-items: stretch; flex-direction: column; }
  .purchase-search { min-width: 100%; }
  .purchase-card-media { flex-basis: 72px; height: 72px; }
  .purchase-card { min-height: 108px; }
  .purchase-dialog { border-radius: 0; height: 100dvh; max-height: none; max-width: none; width: 100vw; }
  .purchase-dialog-body { max-height: calc(100dvh - 145px); }
  .purchase-form-grid, .purchase-detail-facts { grid-template-columns: 1fr; }
  .purchase-detail-facts { grid-template-columns: repeat(2, 1fr); }
}

/* 2026-08-24 purchase comment attachments */
.purchase-comment-compose { align-items: stretch; display: grid; gap: 8px; grid-template-columns: minmax(0,1fr) auto; }
.purchase-comment-compose textarea { grid-column: 1 / -1; }
.purchase-comment-compose > .purchase-comment-extra, #purchaseCommentPhotoAttachment { grid-column: 1 / -1; min-width: 0; }
.purchase-comment-compose > [data-purchase-comment-send] { grid-column: 1 / -1; justify-self: end; width: auto; min-width: 72px; }
.purchase-comment-extra { display: grid; gap: 7px; grid-template-columns: minmax(0,1fr) auto; }
.purchase-comment-extra > input { background: #fff; border: 1px solid #d8e2ec; border-radius: 10px; color: #25415f; font: inherit; font-size: 10px; min-width: 0; padding: 10px 11px; }
.purchase-comment-extra label { align-items: center; background: #edf5ff; border: 1px solid #bed7f2; border-radius: 10px; color: #1769d5; cursor: pointer; display: flex; font-size: 9px; font-weight: 900; justify-content: center; padding: 0 13px; white-space: nowrap; }
.purchase-comment-extra label input { display: none; }
.purchase-comment-photo { align-items: center; color: #1769d5; display: inline-flex; flex-direction: column; font-size: 8px; font-weight: 800; gap: 4px; margin-top: 8px; text-decoration: none; }
.purchase-comment-photo img { border: 1px solid #d8e3ee; border-radius: 10px; height: 82px; object-fit: cover; width: 118px; }
.purchase-comment-link { color: #1769d5; display: block; font-size: 9px; font-weight: 900; margin-top: 7px; text-decoration: none; }
.purchase-comment-link:hover { text-decoration: underline; }

/* Detail reading size: labels 12px, content 13-14px; keep the compact dialog width. */
#purchaseDetailDialog { font-size: 14px; }
#purchaseDetailDialog > header h3 { font-size: 21px; }
#purchaseDetailDialog > header p { font-size: 12px; }
#purchaseDetailDialog .purchase-status, #purchaseDetailDialog .purchase-urgent { font-size: 12px; }
#purchaseDetailDialog .purchase-detail-facts span { font-size: 12px; color: #526c84; }
#purchaseDetailDialog .purchase-detail-facts strong { font-size: 14px; white-space: normal; overflow-wrap: anywhere; }
#purchaseDetailDialog .purchase-detail-links > span, #purchaseDetailDialog .purchase-detail-links a,
#purchaseDetailDialog .purchase-detail-links p, #purchaseDetailDialog .purchase-shipping-info p { font-size: 13px; }
#purchaseDetailDialog .purchase-detail-links p strong, #purchaseDetailDialog .purchase-shipping-info small { font-size: 12px; color: #526c84; }
#purchaseDetailDialog .purchase-detail-section h4 { font-size: 15px; }
#purchaseDetailDialog .purchase-detail-section > p { font-size: 13px; line-height: 1.65; color: #526c84; }
#purchaseDetailDialog .purchase-action-row button { font-size: 13px; min-height: 40px; }
#purchaseDetailDialog .purchase-timeline header strong { font-size: 13px; }
#purchaseDetailDialog .purchase-timeline time, #purchaseDetailDialog .purchase-timeline small { font-size: 12px; color: #526c84; }
#purchaseDetailDialog .purchase-timeline p, #purchaseDetailDialog .purchase-no-history { font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
#purchaseDetailDialog .purchase-comment-compose textarea, #purchaseDetailDialog .purchase-comment-extra > input { font-size: 14px; }
#purchaseDetailDialog .purchase-comment-extra label, #purchaseDetailDialog .purchase-comment-photo,
#purchaseDetailDialog .purchase-comment-link { font-size: 12px; }
#purchaseDetailDialog .purchase-comment-compose > button, #purchaseDetailDialog footer button { font-size: 14px; }
#purchaseDetailDialog .purchase-lookup-result { background: #f0f7ff; border-color: #bfd8f2; }
@media (max-width: 640px) {
  .purchase-comment-compose { grid-template-columns: 1fr; }
  .purchase-comment-extra { grid-template-columns: 1fr; }
  .purchase-comment-extra label { min-height: 39px; }
}
