/* AR invoice entry as a full page (ตั้งลูกหนี้การค้า / ลูกหนี้อื่น).
   The Bootstrap modal is kept for its open/close/save flow; here it is laid over the content area only,
   so the topbar and sidebar stay visible, and styled as a page: header with status/progress, cards below. */

#modalAROther.aro-page {
  --arp-gap: 18px;
  --arp-card-border: #E6E9EC;
  --arp-shadow: 0 1px 2px rgb(16 24 40 / 4%), 0 8px 24px -10px rgb(16 24 40 / 10%);
  --arp-tile: linear-gradient(150deg, #FAFBFB 0%, #EEF1F3 55%, #E1E6E9 100%);
  --arp-ink: #2B3238;
  position: fixed; inset: var(--arp-top, var(--topbar-height)) 0 0 var(--arp-left, 0);
  width: auto; height: auto; padding: 0 !important; overflow: hidden;
  z-index: 950; /* above page content + sidebar, below the topbar menus and every real modal */
}
#modalAROther.aro-page.fade { transition: opacity .16s ease; }
#modalAROther.aro-page .modal-dialog { max-width: none; width: 100%; height: 100%; margin: 0; transform: none !important; }
#modalAROther.aro-page .modal-content {
  height: 100%; display: flex; flex-direction: column;
  border: 0; border-radius: 0; background: var(--bg-main); box-shadow: none; overflow: hidden;
}

/* Fields */
#modalAROther .form-label-custom { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: #3A4248; }
#modalAROther .form-label-custom .aro-opt { font-weight: 400; }
#modalAROther .input-custom {
  min-height: 42px; border: 1px solid #E1E5E8; border-radius: 9px; background: var(--bg-card);
  box-shadow: 0 1px 1px rgb(16 24 40 / 3%); transition: border-color .15s, box-shadow .15s;
}
#modalAROther .input-custom:hover:not(:disabled):not(:focus) { border-color: #CDD3D8; }
#modalAROther .input-custom:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
#modalAROther .input-custom::placeholder { color: #9AA3AA; }
#modalAROther .input-custom:disabled { background: #F6F7F8; }
#modalAROther .select2-container .select2-selection--single { min-height: 42px; border-color: #E1E5E8; border-radius: 9px; box-shadow: 0 1px 1px rgb(16 24 40 / 3%); }

/* ── Page header ── */
.arp-head {
  position: relative; display: block; flex-shrink: 0; padding: 12px 28px 16px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--bg-card) 0%, color-mix(in srgb, var(--bg-card) 70%, var(--bg-main)) 100%);
  overflow: hidden;
}
.arp-head-art { position: absolute; right: 34%; top: 8px; width: 230px; opacity: .55; pointer-events: none; user-select: none; }
.arp-crumb { position: relative; display: flex; align-items: center; gap: 14px; margin-bottom: 10px; font-size: 12.5px; color: var(--text-muted); }
.arp-crumb nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.arp-crumb nav b { font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.arp-crumb nav .ti { font-size: 14px; }
.arp-crumb-sep { font-size: 12px !important; opacity: .7; }
.arp-back {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px;
  border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card);
  color: var(--text-secondary); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 1px rgb(16 24 40 / 4%); transition: background .15s, color .15s, border-color .15s;
}
.arp-back:hover { background: var(--bg-main); color: var(--text-primary); border-color: #c9cdd2; }
.arp-back .ti { font-size: 15px; }
.arp-back:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.arp-titlebar { position: relative; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.arp-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.arp-title-icon {
  flex-shrink: 0; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px;
  background: var(--arp-tile); border: 1px solid var(--arp-card-border); color: var(--arp-ink); font-size: 22px;
  box-shadow: inset 0 1px 0 #fff, 0 6px 14px -8px rgb(30 42 51 / 35%);
}
.arp-title h1 { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; color: var(--text-primary); }
.arp-title small { display: block; margin-top: 2px; font-size: 13px; color: var(--text-muted); }

.arp-head-side { margin-left: auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.arp-stats {
  display: flex; align-items: stretch; border: 1px solid var(--arp-card-border); border-radius: 12px;
  background: var(--bg-card); box-shadow: var(--arp-shadow);
}
.arp-stat { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 8px 16px; min-width: 0; }
.arp-stat + .arp-stat { border-left: 1px solid var(--arp-card-border); }
.arp-stat-label { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.arp-stat-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 7px;
  background: var(--bg-main); font-size: 13px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.arp-status { font-weight: 600; }
.arp-status i { width: 8px; height: 8px; border-radius: 50%; background: #E8A33D; box-shadow: 0 0 0 3px rgb(232 163 61 / 18%); }
.arp-status[data-tone="edit"] i { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.arp-status[data-tone="wait"] i { background: #7C5CC4; box-shadow: 0 0 0 3px rgb(124 92 196 / 18%); }
.arp-status[data-tone="done"] i { background: var(--success); box-shadow: 0 0 0 3px rgb(46 125 50 / 15%); }
.arp-progress { flex-direction: row; align-items: center; gap: 10px; }
.arp-progress svg { width: 34px; height: 34px; flex-shrink: 0; transform: rotate(-90deg); }
.arp-progress circle { fill: none; stroke-width: 4; }
.arp-ring-bg { stroke: var(--border-color); }
.arp-ring { stroke: #E8A33D; stroke-linecap: round; transition: stroke-dasharray .3s ease; }
.arp-progress.is-ready .arp-ring { stroke: var(--success); }
.arp-progress b { display: block; font-size: 13px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }

.arp-actions { display: flex; align-items: center; gap: 10px; padding: 0; margin: 0; border: 0; background: none; flex-wrap: nowrap; }
.arp-actions > * { margin: 0 !important; }
.arp-actions .btn-solid { height: 44px; padding: 0 20px; border-radius: 10px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.arp-actions .btn-dark { box-shadow: 0 6px 14px -6px rgb(17 24 39 / 55%); }

/* ── Page body ── */
.arp-body {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 22px 28px 28px !important;
  display: flex; flex-direction: column; gap: var(--arp-gap) !important; background: var(--bg-main);
  container-type: inline-size; container-name: arpbody;
}
.arp-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--arp-gap); }
.arp-main {
  display: grid; gap: var(--arp-gap); align-items: stretch;
  grid-template-columns: minmax(0, 1fr) 290px;
  grid-template-areas: "pay sum" "lines sum";
  grid-template-rows: auto 1fr;
}
.arp-pay { grid-area: pay; } .arp-summary { grid-area: sum; } .arp-lines { grid-area: lines; }
.arp-bottom { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--arp-gap); }

/* Cards */
.arp-card {
  position: relative; min-width: 0; border: 1px solid var(--arp-card-border); border-radius: 16px;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card) 70%, color-mix(in srgb, var(--bg-card) 82%, var(--bg-main)) 100%);
  box-shadow: var(--arp-shadow);
}
.arp-card-head { position: relative; display: flex; align-items: center; gap: 16px; min-height: 92px; padding: 20px 24px 10px; }
.arp-card-icon {
  position: relative; z-index: 1; flex-shrink: 0; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 15px;
  background: var(--arp-tile); border: 1px solid var(--arp-card-border); color: #4A5A66; font-size: 25px;
  box-shadow: inset 0 1px 0 #fff, 0 8px 16px -10px rgb(30 42 51 / 45%);
}
.arp-card-icon-img { padding: 0; overflow: hidden; }
.arp-card-icon-img img { width: 100%; height: 100%; display: block; }
.arp-card-titles { position: relative; z-index: 1; min-width: 0; }
.arp-card-titles h2 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; color: var(--text-primary); letter-spacing: -.005em; }
.arp-card-titles p { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }
.arp-card-tools { position: relative; z-index: 1; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.arp-card-art { position: absolute; pointer-events: none; user-select: none; z-index: 0; }
.arp-art-customer { right: 230px; top: 6px; height: 92px; }
.arp-art-document { right: 14px; top: -4px; height: 116px; }
.arp-art-payment { right: 18px; top: -8px; height: 112px; }
.arp-art-summary { right: 12px; top: 8px; height: 76px; opacity: .9; }
.arp-art-percent { position: absolute; right: 14px; bottom: 12px; height: 92px; pointer-events: none; user-select: none; }
.arp-card-body { position: relative; display: flex; flex-direction: column; gap: 16px; padding: 8px 24px 22px; }
.arp-card.is-complete .arp-card-icon::after {
  content: ""; position: absolute; right: -5px; bottom: -5px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.2 2.2 4.8-4.8' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat;
  border: 2px solid var(--bg-card); box-shadow: 0 2px 4px rgb(0 0 0 / 15%);
}
.arp-card-icon-img { overflow: visible; }

.arp-row-3 { display: grid; grid-template-columns: minmax(0, 1fr) 128px minmax(0, 1fr); gap: 12px; }
.arp-rates { width: min(100%, 64%); }
.arp-icon-left > input { padding-left: 38px !important; padding-right: 12px !important; }
.arp-icon-left > i { left: 13px; right: auto !important; color: #6B7680 !important; }
.arp-address { position: relative; }
.arp-address > i { position: absolute; left: 13px; top: 12px; color: #6B7680; font-size: 17px; pointer-events: none; }
.arp-address > textarea { padding-left: 40px !important; }
.arp-money > input { font-size: 18px !important; font-weight: 700; padding-right: 66px !important; }
.arp-money > span {
  top: 1px; bottom: 1px; right: 1px; transform: none; width: 54px; display: grid; place-items: center;
  border-left: 1px solid #E1E5E8; border-radius: 0 8px 8px 0; background: #F7F8F9; font-size: 12.5px; color: var(--text-secondary);
}

/* Segmented controls (customer type, payment type, payment method) */
#modalAROther .aro-seg, #modalAROther .aro-term-toggle {
  display: inline-flex; gap: 2px; padding: 3px; border: 1px solid #E1E5E8; border-radius: 10px;
  background: var(--bg-card); box-shadow: 0 1px 1px rgb(16 24 40 / 3%);
}
#modalAROther .aro-seg .aro-term-pill, #modalAROther .aro-term-toggle .aro-term-pill {
  padding: 7px 13px; border-radius: 7px; font-size: 13px; font-weight: 600; gap: 7px; color: #4A545C; border: 0;
}
#modalAROther .aro-term-pill i { color: #6B7680; font-size: 16px; }
#modalAROther .aro-term-pill.active, #modalAROther .aro-term-pill:has(input:checked) {
  background: linear-gradient(180deg, #2E353B 0%, #1F2428 100%); color: #fff;
  box-shadow: 0 4px 10px -4px rgb(17 24 39 / 55%);
}
#modalAROther .aro-term-pill.active i, #modalAROther .aro-term-pill:has(input:checked) i { color: #fff !important; }
.arp-card-tools .aro-seg .aro-term-pill { padding: 6px 12px; font-size: 12.5px; }

/* Payment card */
.arp-pay-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px 18px; align-items: end; }
.arp-refs-grid { display: grid; grid-template-columns: minmax(0, .9fr) repeat(3, minmax(0, 1fr)); gap: 16px 14px; }
.arp-terms-pay .aro-inline { flex-wrap: wrap; }
#modalAROther .aro-credit-days { height: 42px; border-radius: 9px; border-color: #E1E5E8; }
#modalAROther .aro-readonly { min-height: 42px; border-radius: 9px; background: #F7F8F9; border: 1px solid #E1E5E8; }
#modalAROther .aro-readonly i { color: #6B7680; }
#modalAROther .aro-seg-wide { display: flex; width: 100%; }
#modalAROther .aro-seg-wide .aro-term-pill { flex: 1; justify-content: center; }

/* Summary card — runs alongside the payment and lines cards */
.arp-summary { display: flex; flex-direction: column; }
.arp-summary .arp-card-body.aro-summary {
  flex: 1; display: flex; flex-direction: column; gap: 0; padding: 4px 24px 22px; border: 0; background: none; border-radius: 0;
}
.arp-summary .aro-sum-row { padding: 8px 0; font-size: 14px; color: #4A545C; }
.arp-summary .aro-sum-row b { font-weight: 600; }
.arp-summary .aro-sum-row:nth-child(3) { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--arp-card-border); }
.arp-summary .aro-sum-row.is-total {
  margin-top: auto; flex-direction: column; align-items: stretch; gap: 6px; padding: 18px 20px; border: 1px solid var(--arp-card-border);
  border-radius: 14px; background: linear-gradient(150deg, #F7F8F9 0%, #EBEFF1 100%);
  box-shadow: inset 0 1px 0 #fff; color: var(--text-primary); font-size: 14px; font-weight: 700;
}
.arp-summary .aro-sum-row.is-total b { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 30px; letter-spacing: -.02em; line-height: 1.1; }
.arp-summary .aro-sum-row.is-total b small { align-self: flex-end; margin-bottom: 4px; font-size: 12px; }
.arp-coin {
  flex-shrink: 0; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%;
  font-style: normal; font-size: 16px; font-weight: 700; color: var(--brand);
  background: linear-gradient(150deg, #FFFFFF, #DDE4E9); border: 1px solid #D6DDE2; box-shadow: 0 3px 8px -4px rgb(30 42 51 / 40%);
}
.arp-summary .aro-sum-row.is-wht { margin-top: 10px; }
.arp-summary .aro-sum-row.is-net { margin-top: 0; }

/* Lines card */
.arp-lines .arp-card-head { padding-bottom: 14px; min-height: 0; }
.arp-lines-body { padding: 0 14px 14px; container-type: inline-size; container-name: arplines; }
#modalAROther .aro-lines-scroll { border: 1px solid var(--arp-card-border); border-radius: 12px; }
#modalAROther .aro-grid-head { background: #F7F8F9; font-size: 12px; color: #5B656D; padding-top: 11px; padding-bottom: 11px; }
#modalAROther .aro-line-wrap:hover { background: color-mix(in srgb, var(--bg-main) 45%, transparent); }
#modalAROther .aro-add-line {
  height: 40px; border-radius: 9px; padding: 0 16px !important; font-size: 13px !important; font-weight: 600;
  box-shadow: 0 1px 1px rgb(16 24 40 / 4%);
}

/* Narrow lines card (summary alongside): tighter columns — widths only, same columns */
@container arplines (max-width: 900px) {
  #modalAROther .aro-grid-head, #modalAROther .aro-line-grid {
    grid-template-columns: 22px minmax(150px, 1fr) 70px 96px 88px 66px 76px 92px 30px !important;
    gap: 6px; min-width: 0; padding-left: 8px; padding-right: 8px;
  }
  #modalAROther:has(#aro-disc-baht-header[style*="none"]) .aro-grid-head,
  #modalAROther:has(#aro-disc-baht-header[style*="none"]) .aro-line-grid {
    grid-template-columns: 22px minmax(160px, 1fr) 76px 104px 92px 70px 100px 30px !important;
  }
  #modalAROther .aro-line-num { font-size: 13px !important; padding-left: 8px; padding-right: 8px; }
  #modalAROther .aro-grid-head { font-size: 11.5px; }
}

/* Bottom: attachments + remark */
.arp-files, .arp-remark { padding: 18px 22px 20px; display: flex; flex-direction: column; gap: 12px; }
.arp-mini-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.arp-mini-head > .ti { align-self: center; font-size: 18px; color: #4A5A66; }
.arp-mini-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text-primary); }
.arp-mini-head h2 label { margin: 0; cursor: pointer; }
.arp-mini-head .aro-opt { font-size: 12px; }
#modalAROther #aro-attach-zone {
  justify-content: flex-start; gap: 14px; min-height: 72px; padding: 12px 16px; border-radius: 12px;
  border: 1.5px dashed #D3D9DE; background: linear-gradient(180deg, #FAFBFB, #F3F5F6); color: var(--text-secondary); text-align: left;
}
#modalAROther #aro-attach-zone > .ti { font-size: 26px; color: #6B7680; }
#modalAROther #aro-attach-zone > span:not(.arp-pick-btn) { flex: 1; font-size: 13px; font-weight: 500; }
#modalAROther #aro-attach-zone small { color: var(--text-muted); font-weight: 400; }
.arp-pick-btn {
  flex-shrink: 0; height: 36px; padding: 0 16px; display: inline-flex; align-items: center; border-radius: 9px;
  border: 1px solid #DCE1E5; background: var(--bg-card); font-size: 13px; font-weight: 600; color: var(--text-primary);
  box-shadow: 0 1px 2px rgb(16 24 40 / 6%);
}
#modalAROther #aro-attach-zone:hover .arp-pick-btn { border-color: var(--brand); }
#modalAROther #aro-remark { min-height: 72px; }

/* Recorder line appended by _docRecorderRender */
.arp-body > .doc-recorder { margin-top: 0; }

/* Dark theme: keep the soft tiles readable */
[data-theme="dark"] #modalAROther.aro-page { --arp-tile: linear-gradient(150deg, #2A2F33, #202428); --arp-card-border: var(--border-color); }
[data-theme="dark"] #modalAROther .arp-summary .aro-sum-row.is-total,
[data-theme="dark"] #modalAROther #aro-attach-zone,
[data-theme="dark"] #modalAROther .aro-readonly,
[data-theme="dark"] #modalAROther .aro-grid-head,
[data-theme="dark"] .arp-money > span { background: var(--bg-main); }
[data-theme="dark"] .arp-coin { background: var(--bg-card); }

/* ── Responsive (by the page's own width) ── */
@container arpbody (max-width: 1240px) {
  .arp-art-customer { display: none; }
}
@container arpbody (max-width: 1060px) {
  .arp-main { grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "pay sum" "lines lines"; grid-template-rows: auto auto; }
  .arp-refs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arp-summary .aro-sum-row.is-total { margin-top: 14px; }
}
@container arpbody (max-width: 900px) {
  .arp-top { grid-template-columns: 1fr; }
  .arp-main { grid-template-columns: 1fr; grid-template-areas: "pay" "sum" "lines"; }
  .arp-bottom { grid-template-columns: 1fr; }
  .arp-art-customer { display: block; }
}
@container arpbody (max-width: 560px) {
  .arp-row-3, .arp-pay-grid, .arp-refs-grid, #modalAROther .aro-row-2 { grid-template-columns: 1fr; }
  .arp-rates { width: 100%; }
  .arp-card-art, .arp-art-percent { display: none !important; }
  .arp-card-head { flex-wrap: wrap; min-height: 0; padding: 16px 16px 8px; }
  .arp-card-body { padding: 8px 16px 18px; }
  .arp-card-tools { margin-left: 0; width: 100%; }
  .arp-card-icon { width: 46px; height: 46px; font-size: 21px; border-radius: 13px; }
  #modalAROther #aro-attach-zone { flex-wrap: wrap; }
}
@media (max-width: 1280px) {
  .arp-head-art { display: none; }
  .arp-head-side { width: 100%; margin-left: 0; justify-content: space-between; }
}
@media (max-width: 767.98px) {
  .arp-head { padding: 10px 16px 12px; }
  .arp-body { padding: 14px 16px 20px !important; }
  .arp-title h1 { font-size: 18px; }
  .arp-stats { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .arp-stat { padding: 8px 12px; }
  .arp-stat-chip { white-space: normal; }
  .arp-progress { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--arp-card-border); }
  .arp-actions { width: 100%; }
  .arp-actions .btn-solid { flex: 1; justify-content: center; }
  .arp-crumb nav span, .arp-crumb nav .arp-crumb-sep:first-of-type { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #modalAROther.aro-page.fade, .arp-ring { transition: none; }
}

/* Lines card: the table runs edge to edge inside the card */
.arp-lines .arp-card-head { padding-left: 24px; padding-right: 20px; }
@container arplines (max-width: 900px) {
  #modalAROther .aro-line-add-pcc { width: 26px !important; height: 26px !important; }
  #modalAROther .aro-line-disc input { padding-left: 4px; }
}
#modalAROther .aro-readonly { font-size: 14px; }

/* Page header background: soft grey gradient like the reference (light at the edges, deeper grey behind the art) */
.arp-head {
  background:
    radial-gradient(ellipse 38% 120% at 42% 40%, rgb(255 255 255 / 55%) 0%, rgb(255 255 255 / 0%) 70%),
    linear-gradient(90deg, #F3F4F6 0%, #E7EAED 32%, #DFE3E7 50%, #E9ECEF 72%, #F5F6F8 100%);
  border-bottom-color: #DCE0E4;
}
.arp-head-art { opacity: .7; }
[data-theme="dark"] .arp-head {
  background: linear-gradient(90deg, #1E2226 0%, #262B30 45%, #20252A 75%, #1B1F23 100%);
}
/* Header background — owner-picked colours (2026-10-03) */
.arp-head {
  background:
    radial-gradient(ellipse 38% 120% at 42% 40%, rgb(255 255 255 / 55%) 0%, rgb(255 255 255 / 0%) 70%),
    linear-gradient(90deg, #ffffff 0%, #ffffff 32%, #e4e4e4 50%, #d4d4d4 72%, #F5F6F8 100%);
}

/* ── Opened from AI Scan: type switches + the scanned document beside the form ── */
.arp-ai-bar {
  flex-shrink: 0; display: flex; align-items: center; gap: 14px 22px; flex-wrap: wrap; padding: 10px 28px;
  background: linear-gradient(90deg, #F3F5FE, #F7F8FB); border-bottom: 1px solid #E1E6F8;
}
.arp-ai-bar[hidden] { display: none; }
.arp-ai-badge { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 14px; background: #4F6BED; color: #fff; font-size: 12.5px; font-weight: 700; }
.arp-ai-field { display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
#modalAROther .arp-ai-field .aro-seg .aro-term-pill { padding: 5px 11px; font-size: 12.5px; }
.arp-ai-src-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 9px;
  border: 1px solid #D6DCF5; background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.arp-ai-src-btn:hover { border-color: #4F6BED; color: #4F6BED; }
.arp-split { flex: 1; min-height: 0; display: flex; position: relative; }
.arp-split > .arp-body { flex: 1; min-width: 0; }
.arp-source { display: none; }
#modalAROther.has-source:not(.source-collapsed) .arp-source {
  display: flex; flex-direction: column; width: clamp(340px, 36%, 600px); flex-shrink: 0;
  border-right: 1px solid var(--border-color); background: #EEF1F4;
}
.arp-source .ais-source-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg-card); border-bottom: 1px solid var(--border-color); font-size: 13px; }
.arp-source .ais-source-head b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arp-source .ais-source-open { flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid #DCE1E5; background: var(--bg-card); color: var(--text-primary); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.arp-source .ais-source-body { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 14px; }
.arp-source .ais-source-img { max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 6px 18px -8px rgb(16 24 40 / 35%); background: #fff; cursor: zoom-in; }
.arp-source .ais-source-img.is-zoom { max-width: none; width: 180%; cursor: zoom-out; }
.arp-source .ais-source-pdf { width: 100%; height: 100%; border: 0; background: #fff; }
.arp-source .ais-source-empty { margin: auto; display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }
@media (max-width: 1199.98px) {
  #modalAROther.has-source:not(.source-collapsed) .arp-source { position: absolute; inset: 0 auto 0 0; z-index: 6; width: min(520px, 92%); box-shadow: 12px 0 32px -12px rgb(16 24 40 / 35%); }
}
@media (max-width: 767.98px) { .arp-ai-bar { padding: 10px 16px; } .arp-ai-src-btn { margin-left: 0; } }

/* ── AI review session (several scanned documents): toolbar under the header, like the reference ── */
.arp-head-tag, .arp-sess-sum { display: none; }
#modalAROther.ai-session .arp-stats, #modalAROther.ai-session .arp-actions { display: none; }
#modalAROther.ai-session .arp-head-tag { display: block; margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); text-align: right; }
#modalAROther.ai-session .arp-sess-sum {
  display: flex; align-items: stretch; gap: 0; border: 1px solid var(--arp-card-border); border-radius: 12px; background: var(--bg-card); box-shadow: var(--arp-shadow);
}
.arp-sess-sum > div { display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 9px 16px; }
.arp-sess-sum > div + div { border-left: 1px solid var(--arp-card-border); }
.arp-sess-sum-chips { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.arp-sess-sum-chips span { display: inline-flex; align-items: center; gap: 6px; }
.arp-sess-sum-chips b { color: var(--text-primary); }
.arp-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.arp-dot.is-pending { background: #E8A33D; }
.arp-dot.is-edited { background: #4F6BED; }
.arp-dot.is-saved { background: var(--success); }
.arp-sess-sum-total b { font-size: 18px; font-weight: 800; color: var(--text-primary); white-space: nowrap; }

.arp-sess { flex-shrink: 0; background: var(--bg-card); border-bottom: 1px solid var(--border-color); }
.arp-sess[hidden] { display: none; }
.arp-sess-row { display: flex; align-items: center; gap: 14px 22px; flex-wrap: wrap; padding: 12px 28px; }
.arp-sess-nav { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-secondary); white-space: nowrap; }
.arp-sess-nav b { font-size: 19px; color: var(--text-primary); }
.arp-sess-navbtn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); font-size: 18px; cursor: pointer; }
.arp-sess-navbtn:hover:not(:disabled) { border-color: var(--text-primary); }
.arp-sess-navbtn:disabled { opacity: .35; cursor: default; }
.arp-sess-file { display: flex; align-items: center; gap: 10px; min-width: 0; padding-left: 18px; border-left: 1px solid var(--border-color); }
.arp-sess-file-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--bg-main); color: #4A5A66; font-size: 19px; flex-shrink: 0; }
.arp-sess-file b { display: block; max-width: 220px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arp-sess-file small, .arp-sess-amt small, .arp-sess-ready small { display: block; font-size: 11.5px; color: var(--text-muted); }
.arp-sess-amt { padding-left: 18px; border-left: 1px solid var(--border-color); }
.arp-sess-amt b { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.arp-sess-amt b small { display: inline; font-size: 12px; font-weight: 500; }
.arp-sess-ready { display: flex; align-items: center; gap: 8px; }
.arp-sess-ready svg { width: 34px; height: 34px; transform: rotate(-90deg); }
.arp-sess-ready circle { fill: none; stroke-width: 4; }
.arp-sess-ready.is-ready .arp-ring { stroke: var(--success); }
.arp-sess-ready b { font-size: 13px; white-space: nowrap; }
.arp-sess-ready.is-ready b { color: var(--success); }
.arp-sess-status { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: #FEF5E7; color: #B45309; }
.arp-sess-status[data-tone="edited"] { background: #EEF1FE; color: #4F6BED; }
.arp-sess-status[data-tone="saved"], .arp-sess-status[data-tone="receipt"] { background: #E8F7EE; color: var(--success); }
.arp-sess-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.arp-sess-actions .btn-solid { height: 42px; padding: 0 16px; border-radius: 10px; font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.arp-sess-actions .btn-solid:disabled { opacity: .45; cursor: not-allowed; }
.arp-sess-listwrap { position: relative; }
.arp-sess-listbtn { height: 42px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 0; background: none; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-primary); cursor: pointer; border-radius: 10px; }
.arp-sess-listbtn:hover { background: var(--bg-main); }
.arp-sess-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 380px; max-height: 420px; overflow: auto;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 14px; box-shadow: 0 18px 40px -16px rgb(16 24 40 / 35%); padding: 6px;
}
.arp-sess-list[hidden] { display: none; }
.arp-sess-list-head { padding: 8px 10px; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }
.arp-sess-list-head span { margin-left: 4px; padding: 1px 7px; border-radius: 9px; background: var(--bg-main); }
.arp-sess-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 10px; background: none; text-align: left; font: inherit; cursor: pointer; }
.arp-sess-item:hover { background: var(--bg-main); }
.arp-sess-item.is-current { background: #F3F5FE; }
.arp-sess-item-no { width: 24px; height: 24px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--bg-main); font-size: 12px; font-weight: 700; }
.arp-sess-item.is-current .arp-sess-item-no { background: var(--text-primary); color: #fff; }
.arp-sess-item-main { flex: 1; min-width: 0; }
.arp-sess-item-main b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arp-sess-item-main small { display: block; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arp-sess-chip { flex-shrink: 0; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 700; background: #FEF5E7; color: #B45309; }
.arp-sess-chip[data-tone="edited"] { background: #EEF1FE; color: #4F6BED; }
.arp-sess-chip[data-tone="saved"], .arp-sess-chip[data-tone="receipt"] { background: #E8F7EE; color: var(--success); }
.arp-sess-list-foot { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px 4px; margin-top: 4px; border-top: 1px solid var(--border-color); }
.arp-sess-link { border: 0; background: none; padding: 2px; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--text-primary); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.arp-sess-saveall { display: flex; align-items: center; gap: 12px; padding: 8px 28px; background: #F3F5FE; border-top: 1px solid #E1E6F8; font-size: 13px; color: #33408F; }
.arp-sess-saveall[hidden] { display: none; }
.arp-sess-types { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding: 10px 28px; background: linear-gradient(90deg, #F3F5FE, #F7F8FB); border-top: 1px solid #E1E6F8; }
.arp-type-tabs { display: inline-flex; gap: 8px; }
#modalAROther .arp-type-tabs .aro-term-pill { padding: 7px 16px; border: 1px solid #DCE1E5; border-radius: 10px; background: var(--bg-card); font-size: 13px; font-weight: 600; }
#modalAROther .arp-type-tabs .aro-term-pill:has(input:checked) { background: linear-gradient(180deg, #2E353B, #1F2428); border-color: #1F2428; color: #fff; }
@media (max-width: 1399.98px) {
  #modalAROther.ai-session .arp-head-tag { display: none; }
  .arp-sess-actions { margin-left: 0; width: 100%; }
}
@media (max-width: 767.98px) {
  .arp-sess-row, .arp-sess-types, .arp-sess-saveall { padding-left: 16px; padding-right: 16px; }
  .arp-sess-file, .arp-sess-amt { border-left: 0; padding-left: 0; }
  .arp-sess-list { width: min(380px, 92vw); }
}

/* แถววันที่เอกสาร + เวลา (เอาช่องวันที่บันทึกบัญชีออกแล้ว — ลงบัญชีตามวันที่เอกสาร) */
.arp-row-3.arp-row-date { grid-template-columns: minmax(0, 1fr) 180px; }
@media (max-width: 760px) { .arp-row-3.arp-row-date { grid-template-columns: 1fr; } }

/* ── หักเงินมัดจำ (ใบตั้งหนี้) ── */
.arp-deposit { grid-column: 1 / -1; padding: 18px 22px 20px; display: flex; flex-direction: column; gap: 12px; }
.aro-dep-chip {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px dashed var(--border-color);
  background: var(--bg-card); color: var(--text-muted); font-size: 13px; text-align: left; cursor: pointer;
}
.aro-dep-chip.is-on { border-style: solid; border-color: #ce93d8; color: #7b1fa2; font-weight: 600; background: #faf5fc; }
.aro-dep-empty { font-size: 13px; color: var(--text-muted); padding: 6px 2px; }
.aro-dep-table { border: 1px solid var(--border-color); border-radius: 10px; overflow: hidden; }
.aro-dep-row {
  display: grid; grid-template-columns: 34px minmax(150px, 1.6fr) 1fr 1.1fr 1fr 1.2fr; gap: 8px; align-items: center;
  padding: 8px 12px; border-top: 1px solid var(--border-color); font-size: 13px;
}
.aro-dep-row:first-child { border-top: 0; }
.aro-dep-row.is-head { background: var(--bg-main, #f6f7f8); font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.aro-dep-row.is-on { background: #faf5fc; }
.aro-dep-row.is-over { background: #fff4f4; }
.aro-dep-row b { display: block; font-weight: 700; }
.aro-dep-row small { display: block; font-size: 11px; color: var(--text-muted); }
.aro-dep-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.aro-dep-row input[type="number"] { height: 32px; text-align: right; font-size: 13px; }
.aro-dep-warn { padding: 4px 12px 8px 54px; font-size: 12px; color: var(--danger, #c62828); background: #fff4f4; }
.aro-dep-note { font-size: 12px; color: var(--text-muted); }
.aro-dep-note .ti { margin-right: 4px; }
.arp-deposit.is-over .aro-dep-table { border-color: var(--danger, #c62828); }
.aro-sum-row.is-dep b { color: #7b1fa2; }
@media (max-width: 760px) {
  .aro-dep-row { grid-template-columns: 30px 1fr 1fr; }
  .aro-dep-row.is-head { display: none; }
  .aro-dep-row > span:nth-child(n+3) { grid-column: span 1; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .aro-dep-chip.is-on, :root:not([data-theme="light"]) .aro-dep-row.is-on { background: rgba(206, 147, 216, .12); }
  :root:not([data-theme="light"]) .aro-dep-row.is-over, :root:not([data-theme="light"]) .aro-dep-warn { background: rgba(198, 40, 40, .12); }
}
:root[data-theme="dark"] .aro-dep-chip.is-on, :root[data-theme="dark"] .aro-dep-row.is-on { background: rgba(206, 147, 216, .12); }
:root[data-theme="dark"] .aro-dep-row.is-over, :root[data-theme="dark"] .aro-dep-warn { background: rgba(198, 40, 40, .12); }

/* ── หัก ณ ที่จ่าย AR หลายแถว (ใบเสร็จ / หน้ารับชำระ) ── */
.ar-wht-host { padding: 12px 14px; }
.ar-wht-table { border: 1px solid var(--border-color); border-radius: 10px; overflow-x: auto; }
.ar-wht-row {
  display: grid; grid-template-columns: minmax(120px, 1.3fr) minmax(120px, 1.3fr) minmax(90px, .9fr) 64px minmax(90px, .9fr) 30px;
  gap: 6px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border-color); min-width: 560px; font-size: 12px;
}
.ar-wht-row:first-child { border-top: 0; }
.ar-wht-row.is-head { background: var(--bg-main, #f6f7f8); font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.ar-wht-row .num { text-align: right; }
.ar-wht-row .ar-wht-l2 { display: flex; align-items: center; gap: 6px; }
.ar-wht-row .ar-wht-l2.span3 { grid-column: span 3; }
.ar-wht-row .ar-wht-l2 small { flex-shrink: 0; font-size: 11px; color: var(--text-muted); min-width: 34px; }
.ar-wht-row .input-custom { height: 32px; font-size: 12px; padding: 4px 8px; }
.ar-wht-row .num .input-custom { text-align: right; font-variant-numeric: tabular-nums; }
.ar-wht-row .input-custom.is-off { border-color: #f59e0b; }
.ar-wht-empty { padding: 10px 12px; font-size: 12px; color: var(--text-muted); }
.ar-wht-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; }
.ar-wht-hint { color: var(--text-muted); flex: 1; min-width: 200px; }
.ar-wht-total { margin-left: auto; color: var(--text-secondary); }
.ar-wht-total b { color: #c62828; font-size: 14px; margin-left: 6px; }
.ar-wht-cert { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 10.5px; font-weight: 700; border: 1px solid transparent; }
.ar-wht-cert.is-pending { background: #fff8e1; color: #8a5a00; border-color: #ffe082; }
.ar-wht-cert.is-received { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }
.ar-wht-cert.is-mismatch { background: #fdecea; color: #b71c1c; border-color: #f5c2c0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ar-wht-cert.is-pending { background: rgba(255, 193, 7, .14); color: #ffd36b; }
  :root:not([data-theme="light"]) .ar-wht-cert.is-received { background: rgba(76, 175, 80, .14); color: #8fd694; }
  :root:not([data-theme="light"]) .ar-wht-cert.is-mismatch { background: rgba(244, 67, 54, .14); color: #ff9b91; }
}
:root[data-theme="dark"] .ar-wht-cert.is-pending { background: rgba(255, 193, 7, .14); color: #ffd36b; }
:root[data-theme="dark"] .ar-wht-cert.is-received { background: rgba(76, 175, 80, .14); color: #8fd694; }
:root[data-theme="dark"] .ar-wht-cert.is-mismatch { background: rgba(244, 67, 54, .14); color: #ff9b91; }

/* ใบเสร็จ: หัวส่วน (หัก ณ ที่จ่าย / รายการในใบเสร็จ / ช่องทาง) เยื้องเท่ากับส่วนข้อมูลเอกสาร ไม่ชิดขอบซ้าย */
.rcp-doc-body > section.aro-lines { padding-left: 22px; padding-right: 22px; }
.rcp-doc-body > section.aro-lines .aro-lines-head .aro-sec-title { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
#modalDeposit #dep-doc-amount.is-auto { background: var(--bg-main); border-style: dashed; }

/* Breadcrumb กดย้อนไปเมนูได้ */
a.crumb-link { color: inherit; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; }
a.crumb-link:hover, a.crumb-link:focus-visible { color: var(--text-primary); text-decoration: underline; text-underline-offset: 3px; }

/* ══ จอเล็ก / จอเตี้ย: หัวหน้าเอกสารแบบกะทัดรัด — ซ่อนชื่อขั้นตอนใหญ่ + คำอธิบาย (แถบ Step บอกอยู่แล้ว) ══ */
@media (max-height: 880px), (max-width: 1440px) {
  body .ais-head { padding: 8px 18px; }
  body .ais-head-title { display: none !important; }
  body .rcw-head { padding: 8px 20px 10px; }
  body .rcw-title-row, .rcw-head-art { display: none; }
  .arp-head-art { display: none; }
  #modalAROther.aro-page .arp-head { padding-top: 10px; padding-bottom: 10px; }
  #modalAROther.aro-page .arp-title small, #modalAROther.aro-page .arp-title-icon { display: none; }
  #modalAROther.aro-page .arp-title h1 { font-size: 18px; }
  body .ais-steps .ais-step-label, .rcw-steps li > span:last-child { font-size: 11.5px; }
  /* ตรวจเอกสารจาก AI Scan: แถบเอกสาร n / N บอกเอกสาร / สถานะอยู่แล้ว → ซ่อนแถวชื่อหน้า + สรุปสถานะ (เหลือหัวไม่ถึงหนึ่งในสี่ของจอ) */
  #modalAROther.ai-session .arp-titlebar { display: none; }
  #modalAROther.ai-session .arp-head { padding-top: 6px; padding-bottom: 6px; }
  .arp-sess-row { padding-top: 8px; padding-bottom: 8px; gap: 8px 16px; }
  .arp-sess-types { padding-top: 6px; padding-bottom: 6px; }
  /* ปุ่มบันทึกอยู่แถวเดียวกับข้อมูลเอกสาร (เดิมขึ้นบรรทัดใหม่ทุกจอที่แคบกว่า 1400px) */
  .arp-sess-actions { margin-left: auto; width: auto; gap: 8px; }
  .arp-sess-actions .btn-solid { height: 36px; padding: 0 12px; font-size: 13px; }
  .arp-sess-file b { max-width: 150px; }
  .arp-sess-file-icon { width: 32px; height: 32px; font-size: 17px; }
}

/* ไม่มี VAT / ไม่มีหัก ณ ที่จ่าย → สีเทาจาง (คลิกเลือกหรือพิมพ์อัตราได้ตามปกติ) */
select.input-custom.is-none, .select2-container.is-none .select2-selection__rendered { color: var(--text-muted) !important; opacity: .7; }
.select2-container.is-none .select2-selection { background: var(--bg-main); }

/* ส่วนลด: ระบบเปลี่ยนหน่วย % → บาท / ปรับค่า — ไฮไลต์ให้เห็นชัด */
.aro-line-disc.is-unit-changed .input-custom, .aro-line-disc.is-unit-changed .aro-disc-type-btn { border-color: #d97706 !important; box-shadow: 0 0 0 3px rgb(217 119 6 / 20%); }
.aro-line-disc.is-unit-changed .aro-disc-type-btn { background: #fef3e2; color: #b45309; font-weight: 700; }
.aro-price-mode-seg { display: flex; gap: 6px; }
.aro-price-mode-seg .aro-term-pill { flex: 1 1 140px; justify-content: center; }

/* ══ เฟส A: ตรวจประเภทเอกสาร / ไฟล์แนบ / WHT ช่องเดียว / กลุ่มแนะนำใบลดหนี้ ══ */
.aro-doccheck { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; border: 1px solid #F3D19C; background: #FEF5E7; color: #8A4B08; font-size: 13px; }
.aro-doccheck > .ti { font-size: 18px; }
.aro-doccheck > span { flex: 1; min-width: 200px; }
.aro-doccheck .btn-solid { font-size: 12px; padding: 5px 12px; }
.ar-doccheck-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; background: #FEF5E7; color: #8A4B08; border: 1px solid #F3D19C; font-size: 10.5px; font-weight: 700; vertical-align: 1px; white-space: nowrap; }
.doc-attach-zone { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; border: 1.5px dashed var(--border-color); border-radius: 10px; color: var(--text-muted); font-size: 12.5px; cursor: pointer; background: var(--bg-main); }
.doc-attach-zone:hover { border-color: var(--text-muted); color: var(--text-secondary); }
.doc-attach-zone .ti { font-size: 18px; }
.doc-attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.doc-attach-item { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 3px 6px 3px 8px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); font-size: 11.5px; }
.doc-attach-item .doc-attach-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-attach-item button { border: 0; background: none; padding: 0 2px; color: var(--text-secondary); cursor: pointer; }
.doc-attach-item button.is-del { color: #c62828; }
.ar-wht-slot { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 12px; border: 1.5px dashed var(--border-color); border-radius: 10px; color: var(--text-muted); font-size: 12.5px; cursor: pointer; background: var(--bg-main); }
.ar-wht-slot:hover { color: var(--text-secondary); border-color: var(--text-muted); }
.pay-wht-single { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 12px 14px; }
.pay-wht-single .aro-field { min-width: 180px; flex: 0 1 240px; margin: 0; }
.pay-wht-total { margin-left: auto; font-size: 12.5px; color: var(--text-secondary); padding-bottom: 8px; }
.pay-wht-total b { color: #c62828; font-size: 14px; margin-left: 6px; }
.dcn-ref-grp { font-weight: 700; color: var(--text-secondary); }
.dcn-ref-grp.is-rec { color: #1d4ed8; }
.select2-results__group:has(.dcn-ref-grp.is-rec) { background: #EFF6FF; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .aro-doccheck, :root:not([data-theme="light"]) .ar-doccheck-badge { background: rgba(245, 158, 11, .14); color: #F6C177; border-color: rgba(245, 158, 11, .35); }
  :root:not([data-theme="light"]) .dcn-ref-grp.is-rec { color: #93C5FD; }
  :root:not([data-theme="light"]) .select2-results__group:has(.dcn-ref-grp.is-rec) { background: rgba(59, 130, 246, .12); }
}
:root[data-theme="dark"] .aro-doccheck, :root[data-theme="dark"] .ar-doccheck-badge { background: rgba(245, 158, 11, .14); color: #F6C177; border-color: rgba(245, 158, 11, .35); }
:root[data-theme="dark"] .dcn-ref-grp.is-rec { color: #93C5FD; }
:root[data-theme="dark"] .select2-results__group:has(.dcn-ref-grp.is-rec) { background: rgba(59, 130, 246, .12); }

/* ══ เฟส B: ลบ / ยกเลิกหลายใบ ══ */
.arbulk-filters { display: grid; grid-template-columns: 150px 150px 170px minmax(180px, 1fr); gap: 10px; margin-bottom: 12px; }
.arbulk-filters .aro-field { margin: 0; }
@media (max-width: 760px) { .arbulk-filters { grid-template-columns: 1fr 1fr; } }
.arbulk-table-wrap { border: 1px solid var(--border-color); border-radius: 10px; overflow: auto; max-height: 52vh; }
.arbulk-table { margin: 0; }
.arbulk-table thead th { position: sticky; top: 0; background: var(--bg-main); z-index: 1; }
.arbulk-sub { font-size: 11px; color: var(--text-muted); }
.arbulk-row.is-block .arbulk-act { color: #b42318; }
.arbulk-row.is-cancel .arbulk-act { color: #8a4b08; }
.arbulk-row.is-delete .arbulk-act { color: var(--text-secondary); }
.arbulk-count { margin-right: auto; font-size: 13px; color: var(--text-secondary); }
.arbulk-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 10px; }
.arbulk-stat { border: 1px solid var(--border-color); border-radius: 10px; padding: 10px 8px; text-align: center; }
.arbulk-stat b { display: block; font-size: 22px; }
.arbulk-stat span { font-size: 12px; color: var(--text-secondary); }
.arbulk-stat.is-cancel b { color: #8a4b08; }
.arbulk-stat.is-block b { color: #b42318; }
.arbulk-list { text-align: left; font-size: 12px; color: var(--text-secondary); margin: 0; padding-left: 18px; max-height: 140px; overflow: auto; }
.show-cancelled-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; margin: 0; cursor: pointer; }

/* Preview กลาง (R-017): ปุ่มมุมขวาบนหน้าตั้งหนี้ */
.arp-pv-slot { display: flex; align-items: center; }
.arp-pv-slot .ar-pv-head-btn { height: 44px; padding: 0 16px; border-radius: 10px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.aro-head-meta .ar-pv-head-btn { height: 34px; padding: 0 12px; font-size: 13px; white-space: nowrap; }

/* ── โหมดตรวจเอกสาร (Fast Scan AR / AP): ขยายเต็มจอ / ย่อกลับ ── */
.rvf-btn {
  height: 42px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary);
  font: inherit; font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.rvf-btn:hover { border-color: var(--text-primary); }
.rvf-btn i { font-size: 17px; }
#modalAddARReceipt .rcw-head-top .rvf-btn { height: 36px; flex-shrink: 0; }
#modalAROther.aro-page.is-focus, #modalAddARReceipt.rcw-page.is-focus { inset: 0 !important; z-index: 1045 !important; } /* ทับแถบเมนู (1000) · หน้าต่างย่อยที่เปิดจากหน้านี้ซ้อนที่ 1075+ */
#modalAROther.is-focus .arp-head { display: none; }
#modalAROther.is-focus .arp-sess { display: flex; align-items: center; flex-wrap: wrap; }
#modalAROther.is-focus .arp-sess-row { flex: 1 1 760px; padding: 8px 16px; gap: 10px 18px; }
#modalAROther.is-focus .arp-sess-types { flex: 1 1 auto; padding: 6px 16px; border-top: 0; }
#modalAROther.is-focus .arp-sess-actions .btn-solid, #modalAROther.is-focus .arp-sess-listbtn, #modalAROther.is-focus .rvf-btn { height: 36px; }
#modalAddARReceipt.is-focus .rcw-head-art, #modalAddARReceipt.is-focus .rcw-title-row, #modalAddARReceipt.is-focus .rcw-hero { display: none; }
/* เส้นแบ่งต้นฉบับ | ข้อมูล (ลากปรับขนาด) */
#modalAROther.has-source:not(.source-collapsed) .arp-source { width: var(--arp-src-w, clamp(340px, 36%, 600px)); }
.arp-src-handle { display: none; }
#modalAROther.has-source:not(.source-collapsed) .arp-src-handle {
  display: block; flex-shrink: 0; width: 8px; margin: 0 -4px; position: relative; z-index: 5; cursor: col-resize; background: transparent;
}
#modalAROther.has-source:not(.source-collapsed) .arp-src-handle::after { content: ''; position: absolute; inset: 0 3px; background: var(--border-color); transition: background .15s; }
#modalAROther .arp-src-handle:hover::after, #modalAROther .arp-split.is-resizing .arp-src-handle::after { background: var(--brand, #1F2428); }
#modalAROther .arp-split.is-resizing { cursor: col-resize; user-select: none; }
#modalAROther .arp-split.is-resizing iframe { pointer-events: none; }
@media (max-width: 1199.98px) {
  #modalAROther.has-source:not(.source-collapsed) .arp-source { width: min(520px, 92%); }
  #modalAROther.has-source:not(.source-collapsed) .arp-src-handle { display: none; }
}
@media (max-width: 767.98px) { .rvf-btn span { display: none; } }

/* R-035 #43: ช่องการชำระเงินแคบ (เปิดเอกสารต้นฉบับ) → ปุ่มไม่ตกช่อง: ถ้ากว้างไม่พอเรียงลงทีละแถว */
#modalAROther .arp-card-body:has(> .arp-pay-grid) { container-type: inline-size; }
#modalAROther .aro-term-pill span { white-space: nowrap; }
@container (max-width: 760px) { .arp-pay-grid { grid-template-columns: minmax(0, 1fr); } }
#modalAROther .aro-term-toggle { flex-wrap: wrap; max-width: 100%; }

/* R-042 (2026-10-10): กฎของหน้าแอปที่เดิมอยู่ใน template หน้าพิมพ์รายงานสมุดรายวัน (จึงไม่เคยมีผลกับหน้าแอป) — ย้ายมาไว้ที่นี่
   รวม: แถวสินทรัพย์ในใบตั้งเจ้าหนี้ · ช่องรับเงินคืนใบลดหนี้ AP · หน้า Fast Scan บิลซื้อแสดงเฉพาะรายการใหม่ · แดชบอร์ด AP แสดงเฉพาะแบบ AR · ป้ายรอตรวจ AI */
.aro-line-asset{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;padding:8px 12px 10px;background:var(--bg-main,#F5F5F2);border-top:1px dashed var(--border-color)}
@media (max-width:767px){.aro-line-asset{grid-template-columns:1fr 1fr}}
.cn-refund-check{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:600;cursor:pointer}
#page-ap-payment > :not(.page-header):not(#apfs-root){display:none!important}
.apfs-gl-ok{font-size:11px;color:#1b5e20;font-weight:600}
#page-dashboard-ap > :not(.apd2-wrap){display:none!important}
.ai-review-chip{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:600;color:#b45309;background:#fff7ed;border:1px solid #fed7aa;border-radius:999px;padding:1px 8px;cursor:pointer;margin-left:4px}

/* R-044: ปุ่มลัดช่วงเดือน (เดือนก่อน / เดือนนี้ / เดือนก่อน–เดือนนี้) ต่อท้ายช่องวันที่ — หน้า AR / AP */
.acc-range { display: inline-flex; align-items: stretch; flex-shrink: 0; height: 32px; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; background: var(--bg-card); }
.acc-range-btn { border: 0; background: transparent; color: var(--text-secondary); font-family: 'Noto Sans Thai', sans-serif; font-size: 12px; font-weight: 500; padding: 0 11px; cursor: pointer; white-space: nowrap; line-height: 1; transition: background .15s, color .15s; }
.acc-range-btn + .acc-range-btn { border-left: 1px solid var(--border-color); }
.acc-range-btn:hover { background: var(--bg-main); color: var(--text-primary); }
.acc-range-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.acc-range-btn.is-active { background: var(--text-primary); color: var(--bg-card); font-weight: 600; }
.acc-range--col { align-self: flex-end; height: 38px; }
.acc-range--tall { height: 38px; }
@media (max-width: 575.98px) {
  .acc-range { width: 100%; height: 34px; }
  .acc-range-btn { flex: 1 1 0; padding: 0 6px; }
}

/* R-046 (#85): ตัวนับเอกสารบนแท็บ AP เป็นสีแบบเดียวกับ AR (ใบกำกับ / ใบเสร็จ = ฟ้า · ยกเลิก = แดง) */
.acc-tab-cnt { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; line-height: 1.5; }
.acc-tab-cnt.is-blue { background: #e3f2fd; color: #1565c0; }
.acc-tab-cnt.is-red { background: #fce4ec; color: #c62828; }

/* #92 (R-054): Group บัญชีประเภทอื่นที่ค้นหาเจอ — ป้ายประเภทเล็ก ๆ ท้ายชื่อ (ไม่รก) */
.apg-opt-x { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.apg-opt-tag { flex-shrink: 0; padding: 1px 7px; border-radius: 99px; background: var(--bg-main); border: 1px solid var(--border-color); color: var(--text-muted); font-size: 10.5px; font-weight: 600; }
.select2-results__option--highlighted .apg-opt-tag { background: rgba(255,255,255,.18); border-color: transparent; color: inherit; }

/* R-059 (#104): หน้าต่างสร้างรายงาน */
.rpt-b-row { margin-bottom: 12px; }
.rpt-b-row > .input-custom, .rpt-b-row select { width: 100%; }
.rpt-b-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; margin-top: 4px; }
.rpt-b-type { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border-color); border-radius: 9px; cursor: pointer; font-size: 13px; }
.rpt-b-type[hidden] { display: none; }
.rpt-b-type input { accent-color: var(--text-primary); width: 15px; height: 15px; }
.rpt-b-note { margin-top: 6px; padding: 8px 10px; border-radius: 9px; background: var(--bg-main); color: var(--text-muted); font-size: 12px; line-height: 1.6; }
