/* Shared field geometry. Keep native choice widgets and hidden controls separate. */
:root { --control-height: 48px; --control-radius: 10px; --field-gap: 8px; }
body :is(input:not([type="hidden"],[type="checkbox"],[type="radio"],[type="range"],[type="color"],[type="submit"],[type="button"],[type="reset"],[type="image"]),select,textarea) {
  box-sizing:border-box; min-width:0; max-width:100%; width:100%; margin:0;
  min-height:var(--control-height); padding:10px 12px;
  border:1px solid var(--line,#d4d4d4); border-radius:var(--control-radius);
  background:var(--surface,#fff); color:var(--ink,#111); font:inherit; line-height:1.4;
}
body :is(input:not([type="hidden"],[type="checkbox"],[type="radio"],[type="range"],[type="color"],[type="file"],[type="submit"],[type="button"],[type="reset"],[type="image"]),select:not([multiple])) {
  height:var(--control-height)!important; min-height:var(--control-height)!important;
}
body textarea { height:auto; min-height:112px; resize:vertical; }
body select[multiple] { height:auto; min-height:144px; }
body input[type="file"] { height:auto; padding:6px; overflow:hidden; }
body input[type="file"]::file-selector-button { min-height:34px; margin-right:8px; padding:6px 12px; border:1px solid var(--line); border-radius:6px; background:var(--surface-soft); color:var(--ink); font:inherit; cursor:pointer; }
body :is(input,select,textarea):focus-visible { outline:2px solid var(--product); outline-offset:2px; }
body :is(input,select,textarea):disabled { color:var(--muted); background:var(--surface-soft); cursor:not-allowed; opacity:1; }
body :is(input,textarea)[readonly] { background:var(--surface-soft); }
body :is(input,select,textarea)[aria-invalid="true"] { border-color:var(--danger)!important; }
body :is(input[type="checkbox"],input[type="radio"]) { flex:none; accent-color:var(--product); }
body input[type="range"] { width:100%; min-width:0; accent-color:var(--product); }
body input[type="color"] { width:64px; min-height:44px; padding:4px; border:1px solid var(--line); border-radius:8px; }
body input[type="hidden"],body [hidden] { display:none!important; }
/* Enhanced selects retain their hidden native control for form submission. */
body .searchable-select { width:100%; min-width:0; margin:0; }
body .searchable-select>select { width:1px!important; height:1px!important; min-height:0!important; padding:0; border:0; opacity:0!important; pointer-events:none; }
body .searchable-select-input { height:var(--control-height); min-height:var(--control-height); }
body .searchable-select-options { max-width:100%; }
body .searchable-select-option { white-space:normal; overflow-wrap:anywhere; }

/* Field wrappers always stack label, control, then feedback. */
body .field:not(:has(>input[type="checkbox"],>input[type="radio"])),
body .stack-form>:is(div,p):has(>label),
body :is(.offline-form,.audit-filter-grid) label:not(:has(input[type="checkbox"],input[type="radio"])) {
  min-width:0; max-width:100%; display:flex; flex-direction:column; align-items:stretch;
  gap:var(--field-gap); margin:0; overflow:visible;
}
body :is(.field,.stack-form)>label:not(.icon-delete-control),
body .field>.field-label { margin:0; line-height:1.4; font-weight:750; overflow-wrap:anywhere; }
body .field :is(.helptext,.errorlist,small),body .stack-form .helptext { min-height:0; margin:0; white-space:normal; overflow-wrap:anywhere; }
body .field .errorlist { padding-left:20px; }
body form> .field + .field { margin-top:16px; }
body :is(.form-grid,.settings-form-grid,.line-grid,.quick-line-fields,.offline-form-grid,.purchase-unit-create-grid,.offline-new-pack-grid,.audit-filter-grid)>* { min-width:0; }
body .stack-form>div.form-actions { display:flex; flex-direction:row; grid-template-rows:none; flex-wrap:wrap; }
body :is(.form-actions,.offline-form-actions,.sync-review-actions) { flex-wrap:wrap; align-items:center; }
body :is(.form-actions,.offline-form-actions,.sync-review-actions)>* { max-width:100%; white-space:normal; }
body .field:has(>input[type="checkbox"]) { grid-template-columns:24px minmax(0,1fr); }
body .field:has(>input[type="checkbox"])>label { min-height:24px; }

/* Containers, not only the viewport, decide when controls wrap. */
.panel:has(form),form.panel,.offline-form,.sale-line,.offline-sale-line { container-type:inline-size; container-name:form-box; }
body :is(.filter-bar,.list-filter-form,.report-period-form,.transfer-filters,.offline-report-period,.offline-register-filters,.offline-catalog-filters) {
  display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr)); align-items:end; gap:16px;
}
body :is(.filter-bar,.list-filter-form,.report-period-form,.transfer-filters,.offline-report-period,.offline-register-filters,.offline-catalog-filters)>button {
  height:var(--control-height); min-height:var(--control-height); align-self:end; margin:0; display:flex; align-items:center; justify-content:center;
}
body :is(.form-grid,.settings-form-grid) { gap:20px 16px; }
body :is(.line-grid-purchase,.offline-transaction-line) { grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr)); align-items:start; }
body .quick-line-fields { grid-template-columns:minmax(0,2fr) minmax(0,1.2fr) minmax(0,1fr); align-items:start; }
body .purchase-line-total strong,body .checkout-total>strong { min-height:var(--control-height); height:var(--control-height); display:flex; align-items:center; margin:0; }
body :is(.icon-delete-control,.icon-delete-button,.offline-line-remove) { min-height:var(--control-height); height:var(--control-height); display:inline-flex; align-items:center; justify-content:center; }
body .sale-line>.remove-line { grid-column:3; grid-row:1; align-self:start; margin-top:var(--form-row-label-height,26px); }
body .checkout-summary>.field { display:flex; align-content:start; }
body .checkout-summary>.field>small { white-space:normal; }
body .purchase-unit-create-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr)); align-items:start; }
body .inline-create-form { grid-template-columns:minmax(0,1fr) auto; }
body .inline-create-form>button { min-height:var(--control-height); align-self:end; }
body :is(.inline-unit-grid,.offline-new-pack-grid) { grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr)); }
body .offline-form-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr)); align-items:start; }
body .offline-form[data-offline-transfer-form] .offline-transaction-line { grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr)); }
body .transfer-form { --control-height:52px; }
body .transfer-filters { --control-height:52px; }
body .transfer-form .transfer-item-fields>.field { display:flex; }
body .transfer-form .transfer-context { grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr)); }
body .product-auth-form { --control-height:52px; }
body .password-control input { padding-right:5rem; }
body .pagination-jump { --control-height:40px; }
body .pagination-jump input { width:72px; }
@container form-box (min-width:961px) {
  body .line-grid-purchase { grid-template-columns:minmax(0,2fr) minmax(0,1.2fr) minmax(0,.8fr) minmax(0,1fr) minmax(0,.9fr) 48px; }
}
@container form-box (min-width:481px) and (max-width:960px) {
  body .line-grid-purchase { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@container form-box (max-width:640px) {
  body .quick-line-fields { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body .quick-line-fields>.product-field { grid-column:1/-1; }
  body .checkout-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body .transfer-form .transfer-item-fields { grid-template-columns:minmax(0,1fr) minmax(0,1fr) 48px; }
  body .transfer-form .transfer-item-fields>.field:first-child { grid-column:1/-1; }
}
@container form-box (max-width:480px) {
  body :is(.form-grid,.settings-form-grid,.quick-line-fields,.checkout-summary,.inline-create-form,.line-grid-purchase,.offline-transaction-line,.offline-form-grid,.transfer-context) { grid-template-columns:minmax(0,1fr); }
  body .field-span-2 { grid-column:1/-1; }
  body .transfer-form .transfer-item-fields { grid-template-columns:minmax(0,1fr) 48px; }
  body .transfer-form .transfer-item-fields>.field { grid-column:1/-1; }
  body .transfer-form .transfer-item-fields>.field:nth-child(3) { grid-column:1; }
}
@media(max-width:680px) {
  body :is(input,select,textarea) { font-size:16px; }
  body :is(.form-grid,.settings-form-grid,.quick-line-fields,.checkout-summary,.line-grid-purchase,.inline-create-form,.offline-form-grid) { grid-template-columns:minmax(0,1fr); }
  body .form-actions>* { flex:1 1 140px; }
}
