* { box-sizing: border-box; }
body { color: #203329; background: #fbfcfa; line-height: 1.55; }
a { color: #1d6647; text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, .button { border: 1px solid #35664b; border-radius: 5px; padding: .6rem 1rem; background: #216146; color: white; cursor: pointer; display: inline-block; }
button:disabled { cursor: not-allowed; background: #e7eae7; color: #576359; border-color: #b5bdb7; }
input:not([type=checkbox]), select, textarea { padding: .55rem; border: 1px solid #82978a; border-radius: 4px; max-width: 100%; background: white; color: #203329; }
:focus-visible { outline: 3px solid #ad720a; outline-offset: 2px; }
.language-switch { display: flex; align-items: center; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.page-heading, .actions, .filters { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 1.2rem 0; }
.page-heading { justify-content: space-between; }
.filters label { display: grid; gap: .3rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field small { color: #4e6456; }
.field label { font-weight: 600; }
.field.invalid input, .field.invalid select { border: 2px solid #b32624; }
.errorlist, .error-summary { color: #8d2421; }
.error-summary { padding: 1rem; border: 1px solid #b32624; background: #fff1f0; margin-bottom: 1rem; }
.notice { background: #fff5d8; border-left: 4px solid #b17c1b; padding: .8rem 1rem; }
.receipt-line { border: 1px solid #b7c8bb; background: white; border-radius: 6px; margin: 1rem 0; padding: 1rem; min-width: 0; }
.receipt-line legend { font-weight: bold; }
#receipt-review-form fieldset { min-width: 0; margin-inline: 0; }
.table-scroll { width: 100%; overflow-x: auto; margin: 1rem 0; }
.table-scroll table { max-width: none; min-width: 700px; }
.status { display: inline-block; padding: .25rem .7rem; border-radius: 6px; background: #e6eaf2; white-space: nowrap; }
.status-posted, .status-verified { background: #d8eedf; }
.status-reversed { background: #f6dfdd; }
.document-meta { display: grid; grid-template-columns: minmax(110px, 200px) 1fr; gap: .5rem 1rem; overflow-wrap: anywhere; }
.document-meta dt { font-weight: 600; }.document-meta dd { margin: 0; }
.total, #document-total { font-size: 1.15rem; font-weight: bold; }
.pagination { margin: 1rem 0; }.search-options { width: 100%; }
[hidden] { display: none !important; }
@media (max-width: 600px) { .document-meta { grid-template-columns: 1fr; }.document-meta dd { margin-bottom: .7rem; }.actions > * { width: 100%; text-align: center; } }

/* Give wrapped document references one continuous tablet tap target. */
.receipt-number { display: block; overflow-wrap: anywhere; }

.error-summary a { color: inherit; text-decoration: underline; }
.field input, .field select, .field textarea { scroll-margin-block: 2rem; }
.search-feedback { padding: .5rem; background: #fff5d8; }
.table-scroll-hint { font-weight: 600; margin-bottom: .25rem; color: #355e46; }
.table-scroll.more-right { border-right: 4px solid #b17c1b; }
.table-scroll.more-left { border-left: 4px solid #b17c1b; }

/* Nine receipt columns need readable widths rather than tightly wrapped Thai. */
.table-scroll .receipt-lines-table { min-width: 1100px; }
.receipt-lines-table td:nth-child(3), .receipt-lines-table td:nth-child(4),
.receipt-lines-table td:nth-child(6), .receipt-lines-table td:nth-child(7),
.receipt-lines-table td:nth-child(8), .receipt-lines-table td:nth-child(9) { white-space: nowrap; }

.transfer-lines-table td:first-child { width: 3rem; }
.transfer-lines-table td:last-child { min-width: 9rem; }

/* Navigation and common document controls */
.site-header, .site-brand, .site-navigation, .home-links {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
}
.site-header { justify-content: space-between; margin-bottom: .75rem; }
.site-brand > a { font-size: 1.35rem; font-weight: 750; }
.environment-badge { background: #fff1c5; border-radius: 4px; padding: .2rem .45rem; font-size: .72rem; font-weight: 650; }
.site-header .language-switch { margin: 0; gap: .25rem; }
.language-switch button { min-height: 44px; padding: .35rem .55rem; background: transparent; color: #205b41; }
.language-switch [aria-pressed="true"] { background: #216146; color: white; }
.site-navigation { margin-bottom: 1rem; padding-bottom: .65rem; border-bottom: 1px solid #c9d9cf; gap: .35rem; }
.site-navigation a { padding: .55rem .7rem; min-height: 44px; border-radius: 5px; }
.site-navigation a[aria-current] { background: #d8eedf; color: #174533; font-weight: 700; }
#menu-toggle { display: none; margin-bottom: .6rem; }
.home-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; margin-top: 1.15rem; }
.home-card { padding: 1rem; border: 1px solid #bed3c6; border-radius: 7px; background: white; }
.home-card h2 { margin: 0 0 .65rem; font-size: 1.2rem; }
.home-links { gap: .6rem 1rem; }
.home-links > a { padding-block: .6rem; }
button.button-secondary:not(:disabled), .button.button-secondary { background: white; color: #205b41; }
button.remove-line { background: white; color: #8d2421; border-color: #c18d89; }
.receipt-line > button.remove-line { display: block; margin-inline-start: auto; margin-bottom: .65rem; }
#receipt-review-form label:has(input[type="checkbox"]), #receipt-review-form label:has(input[type="radio"]) {
    display: flex; width: fit-content; align-items: center; gap: .6rem; min-height: 44px; cursor: pointer;
}
#receipt-review-form input:is([type="checkbox"], [type="radio"]) { width: 1.3rem; height: 1.3rem; flex-shrink: 0; }
.searchable-picker { position: relative; }
.searchable-picker input { width: 100%; }
.picker-popup { position: absolute; inset-inline: 0; top: 100%; z-index: 2; background: white; border: 1px solid #82978a; border-radius: 4px; box-shadow: 0 4px 10px #183c2526; }
.picker-options { max-height: 13rem; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.picker-options li { min-height: 44px; padding: .55rem; cursor: pointer; overflow-wrap: anywhere; }
.picker-options li:hover, .picker-options li[aria-selected="true"] { background: #d8eedf; }
.picker-popup .search-feedback { display: block; }
.stock-on-hand { color: #355e46; font-weight: 600; margin-block: .4rem; }
@media (max-width: 850px) {
    #menu-toggle:not([hidden]) { display: block; }
    #menu-toggle[aria-expanded="false"] + .site-navigation { display: none; }
    .site-navigation a { border: 1px solid #c9d9cf; }
}
@media (min-width: 601px) and (max-width: 1100px) {
    .draft-actions { position: sticky; bottom: 0; z-index: 1; background: #fbfcfa; border-top: 1px solid #bed3c6; padding: .65rem 0; }
}

/* Keep stock and editable receiving quantities in the same visual group. */
.stock-filters select { width: 100%; }
.document-reference, .stack-table, .delivery-line { overflow-wrap: anywhere; }
.stack-table { table-layout: fixed; }
.stack-table small { color: #4e6456; }
.stack-label { display: none; }
.stock-quantity { background: #edf6ef; }
.stock-impact { display: grid; gap: .2rem; background: #edf6ef; padding: .55rem; border-radius: 4px; }
.stock-impact-negative { background: #fff1da; }
.delivery-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr)); gap: 1rem; margin: 1rem 0; }
.delivery-line { min-width: 0; border: 1px solid #b7c8bb; border-radius: 6px; padding: 1rem; background: white; }
.delivery-line legend { font-weight: 700; }
.delivery-line dl { display: grid; gap: .35rem; margin: 0 0 1rem; }
.delivery-line dl > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: .15rem .55rem; }
.delivery-line dd { margin: 0; }
.delivery-line output { display: grid; gap: .25rem; margin-top: .6rem; padding: .65rem; background: #edf6ef; border-radius: 4px; font-weight: 600; }
.delivery-line output.warning { background: #fff1da; }

@media (max-width: 950px) {
    .stack-table, .stack-table tbody { display: block; }
    .stack-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .stack-table tbody { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: .8rem; }
    .stack-table tbody tr { display: grid; align-content: start; min-width: 0; background: white; border: 1px solid #b7c8bb; border-radius: 6px; padding: .65rem; }
    .stack-table td { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: .55rem; border: 0; padding: .35rem .45rem; }
    .stack-table .stack-heading { display: block; }
    .stack-table .stack-label { display: inline; color: #355e46; }
}
