/* The editor owns its scrolling; available workspace width includes the sidebar state. */
@media screen {
 .editor-view{container:document-editor / inline-size;height:calc(100dvh - var(--shellbar-height));min-height:0;overflow:auto;padding:0 14px 8px;gap:8px;scroll-padding-block:106px 55px}
 .editor-view .editor-commandbar{position:sticky;top:0;z-index:40;flex-wrap:wrap;min-height:50px;padding:7px 0;gap:7px;background:var(--bg)}
 .editor-view .editor-commandbar .command-spacer{display:block;min-width:0}
 .editor-view .editor-commandbar .record-nav{order:0;margin-left:0}
 .editor-view .editor-bottom{position:sticky;bottom:-8px;z-index:30;flex-wrap:wrap;min-height:39px;padding:6px 0;background:var(--bg)}
 .editor-view .document-fields{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:7px 14px}
 .editor-view .basic-fields,.editor-view .common-fields{display:contents}
 .editor-view .document-fields>.header-fields>label{min-width:0;gap:6px}
 .editor-view .document-options{grid-column:1/-1;margin:0;gap:9px}
 .editor-view .editor-detail-layout,.editor-view[data-direction=in] .editor-detail-layout,.editor-view[data-direction=out] .editor-detail-layout{flex:1 0 410px;min-height:410px;grid-template-columns:minmax(0,1.55fr) minmax(0,1fr);grid-template-rows:minmax(260px,1fr) 140px;grid-template-areas:'goods accounts' 'summary customer';gap:8px}
 .editor-view[data-direction=out] .editor-detail-layout{grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}
 .editor-view .goods-panel{grid-area:goods}
 .editor-view .accounts-panel{grid-area:accounts}
 .editor-view .goods-summary-panel{grid-area:summary}
 .editor-view .customer-panel{grid-area:customer}
 .editor-view .grid-panel>.tabulator{display:flex;flex-direction:column}
 .editor-view .tabulator .tabulator-header{flex-shrink:0}
 .editor-view .tabulator .tabulator-header .tabulator-headers{display:inline-flex;align-items:stretch;height:auto!important}
 .editor-view .tabulator .tabulator-header .tabulator-col{height:auto!important}
 .editor-view .tabulator .tabulator-header .tabulator-col .tabulator-col-content{padding:7px 5px}
 .editor-view .tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title{white-space:normal;overflow-wrap:anywhere;text-overflow:clip;line-height:1.4}
 .editor-view .tabulator .tabulator-tableholder{flex:1;min-height:0;height:auto!important}
 .editor-view .tabulator-row{min-height:36px}
 .editor-view .tabulator-row .tabulator-cell{white-space:normal;overflow-wrap:anywhere;word-break:normal;text-overflow:clip;padding:7px 5px;line-height:20px}
 .editor-view .tabulator-row .tabulator-cell.numeric-cell{white-space:nowrap;overflow-wrap:normal;word-break:normal}
 .editor-view .tabulator-row .tabulator-cell.tabulator-editing{overflow:visible}
 .editor-view .tabulator-cell.tabulator-editing input{min-width:0;font:inherit}
 .editor-view .document-finance{grid-template-columns:minmax(0,1.3fr) minmax(0,1.15fr) minmax(0,.6fr)}
 .editor-view .document-finance .finance-summary{grid-column:auto;flex-direction:row;flex-wrap:wrap;gap:4px 10px}
 .editor-view .finance-summary>div{width:100%;min-width:0}
 .editor-view .finance-summary>span{margin:0}
 .editor-view .totals-fields label{white-space:normal;flex-wrap:wrap}
 .editor-view .total-value{white-space:normal;overflow-wrap:anywhere}
 @container document-editor (max-width:1450px){
  .editor-view .document-fields{grid-template-columns:repeat(4,minmax(0,1fr))}
  .editor-view .document-finance{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
  .editor-view .document-finance .finance-summary{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr 2fr;align-items:center}
 }
 @container document-editor (max-width:1950px){
  .editor-view .editor-detail-layout,.editor-view[data-direction=in] .editor-detail-layout,.editor-view[data-direction=out] .editor-detail-layout{flex:none;min-height:0;grid-template-columns:minmax(0,1fr);grid-template-rows:340px 140px 280px 160px;grid-template-areas:'goods' 'summary' 'accounts' 'customer'}
 }
 @container document-editor (max-width:1050px){
  .editor-view .document-fields{grid-template-columns:repeat(3,minmax(0,1fr))}
  .editor-view .document-fields>.header-fields>label{flex-direction:column;align-items:stretch;gap:4px}
  .editor-view .document-fields>.header-fields>label>span{flex:0 0 auto}
  .editor-view .document-fields>.header-fields>label>input,.editor-view .document-fields>.header-fields>label>select{width:100%;flex:auto}
  .editor-view .document-fields>.header-fields>label>.ts-wrapper{width:100%;flex:auto}
  .editor-view .editor-commandbar .record-nav span{display:none}
  .editor-view .editor-bottom>span{flex-basis:100%}
 }
 @container document-editor (max-width:750px){
  .editor-view .document-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
  .editor-view .document-finance{grid-template-columns:minmax(0,1fr)}
  .editor-view .document-finance .finance-summary{grid-template-columns:1fr 1fr}
  .editor-view .finance-summary>span{grid-column:1/-1}
  .editor-view .totals-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
  .editor-view .payment-fields{grid-template-columns:minmax(0,1fr)}
  .editor-view .document-options .note-field{flex-basis:100%;min-width:0}
  .editor-view .document-options .note-field input{min-width:0}
 }
}

/* Tabulator generates the complete HTML tables; paper layout must not inherit
   the viewport heights, screen column widths or scrolling-panel spacing. */
@media print {
 html:has(body.printing-document){height:auto;min-height:0;background:#fff}
 body.printing-document{height:auto!important;min-height:0!important;overflow:visible!important;background:#fff!important}
 body.printing-document .editor-view{display:block!important;position:static!important;width:100%;height:auto!important;min-height:0!important;margin:0;padding:0;background:#fff!important;color:#111}
 body.printing-document .editor-commandbar{display:block!important;min-height:0;padding:0 0 6px;margin:0;background:#fff}
 body.printing-document .editor-commandbar>.editor-heading{display:block!important;margin:0;padding:0;border:0}
 body.printing-document .editor-heading strong{font-size:17px;color:#111}
 body.printing-document .document-form{padding:0 6px 6px;margin:0;border-radius:0;break-inside:avoid}
 body.printing-document .document-meta{min-height:0;padding:4px 0;font-size:9px}
 body.printing-document .document-header-grid,body.printing-document .document-fields{display:block}
 body.printing-document .basic-fields,body.printing-document .common-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:3px 8px}
 body.printing-document .header-fields>label{min-width:0;gap:3px;font-size:10px}
 body.printing-document .header-fields>label>span{flex:0 0 58px;font-size:10px}
 body.printing-document input,body.printing-document select{min-width:0;min-height:0;height:auto;padding:2px;border:0;box-shadow:none;font-size:10px;background:transparent}
 body.printing-document .document-options{gap:5px;margin-top:4px;font-size:10px}
 body.printing-document .document-options .note-field{flex-basis:100%;min-width:0}
 body.printing-document .document-header-tools{display:contents}
 body.printing-document .extra-fields{position:static;width:100%}
 body.printing-document .extra-fields .advanced-fields{position:static;display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));width:auto;padding:3px 0 0;border:0;box-shadow:none}
 body.printing-document .editor-detail-layout,body.printing-document .editor-view[data-direction=out] .editor-detail-layout{display:block!important;height:auto;min-height:0;grid-template-rows:none}
 body.printing-document .grid-panel{display:block;height:auto;min-height:0;overflow:visible;margin:6px 0;border-radius:0;break-inside:auto}
 body.printing-document .grid-caption{min-height:0;padding:3px 6px;font-size:10px;background:#f2f3f1;color:#111;break-after:avoid}
 body.printing-document .grid-caption .panel-name{font-size:10px}
 body.printing-document .grid-caption .lucide{width:12px;height:12px}
 body.printing-document div.tabulator-print-table{width:100%;margin:0;padding:0}
 body.printing-document table.tabulator-print-table{table-layout:auto;width:100%;border-collapse:collapse;font:10px/1.35 var(--sans);color:#111}
 body.printing-document .tabulator-print-table th,body.printing-document .tabulator-print-table td{height:auto;width:auto;padding:3px 4px;border:1px solid #aeb5af;white-space:normal;overflow-wrap:anywhere;vertical-align:top}
 body.printing-document .tabulator-print-table th{background:#f2f3f1;font-weight:600}
 body.printing-document .tabulator-print-table td.numeric-cell{white-space:nowrap;overflow-wrap:normal;text-align:right;font-variant-numeric:tabular-nums}
 body.printing-document .goods-panel .tabulator-print-table tr>:first-child{white-space:nowrap;min-width:2em}
 body.printing-document .tabulator-print-table thead{display:table-header-group}
 body.printing-document .tabulator-print-table tr{break-inside:avoid}
 body.printing-document .document-finance{display:grid;grid-template-columns:1.3fr 1.1fr .8fr;gap:5px;min-height:0;margin:6px 0 0;break-inside:avoid}
 body.printing-document .document-finance fieldset{min-width:0;min-height:0;margin:0;padding:4px 6px;border-radius:0;font-size:10px}
 body.printing-document .document-finance legend{font-size:10px}
 body.printing-document .totals-fields,body.printing-document .payment-fields{gap:3px;font-size:9px}
 body.printing-document .totals-fields label{flex-wrap:wrap;white-space:normal;font-size:9px}
 body.printing-document .document-finance input{font-size:9px}
 body.printing-document .document-finance .finance-summary{display:block;grid-column:auto}
 body.printing-document .finance-summary>div{display:flex;justify-content:space-between;gap:4px;margin-bottom:3px;font-size:10px}
 body.printing-document .finance-summary>span{display:block;margin:0;font-size:8px}
 body.printing-document .total-value{font-size:10px;white-space:normal;overflow-wrap:anywhere}
 body.printing-document #total-amount{font-size:16px}
}
