/* Shared screen layout. Wide ledgers scroll inside their own panels. */
:root{--erp-table-font:Tahoma,'Segoe UI',Arial,sans-serif;--erp-row:30px;--erp-table-size:12px}
html[data-erp-theme=easy]{--erp-row:38px;--erp-table-size:14px}
@media screen {
 .shell,.workspace,main,#content,.card,.split,.split>div,.supply-workspace,.settings-primary,.settings-aside{min-width:0;max-width:100%;box-sizing:border-box}
 .workspace,main,#content{width:100%}
 main{padding:12px}
 .sidebar{gap:16px;flex-wrap:wrap;position:relative}
 .sidebar .nav{min-width:0;flex:1 1 600px;overflow-x:auto;max-width:100%;align-items:center}
 .sidebar .user-nav{display:flex;align-items:center;gap:8px;margin-left:auto;flex:none;font-size:11px;white-space:nowrap}
 .sidebar .user-nav .avatar{display:none}
 .heading{gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
 .heading>button{flex:none}
 .toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;max-width:100%;margin-bottom:10px}
 .toolbar label{min-width:0;margin:0;max-width:100%}
 .toolbar input,.toolbar select{max-width:100%}
 .order-filters label,.reserve-toolbar label{display:flex;align-items:center;gap:6px}
 .order-filters input[type=date],.reserve-toolbar input[type=date]{width:145px;min-width:0;flex:none}
 .card{width:100%;min-width:0;margin-bottom:12px;overflow:hidden}
 .card-head{min-height:36px;padding:8px 10px;flex-wrap:wrap}
 .card-head h2{font-size:13px;line-height:1.3}
 #content>.card,#content>.split,#content>.toolbar{width:100%;max-width:none;margin-left:0;margin-right:0}
 .split{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;align-items:start}
 .procurement-columns{display:grid;grid-template-columns:minmax(0,1fr);gap:14px;width:100%;align-items:start}
 .procurement-columns>.card{order:initial;margin:0;min-width:0;width:100%}
 .procurement-columns .pager{margin:0;padding:10px;border-top:1px solid var(--line);background:var(--erp-surface,#faf9e9)}
 .supply-rate{display:inline;margin-left:6px;font-size:10px;color:var(--muted);white-space:nowrap}
 .supply-workspace,.orders-compact-workspace,.reports-workspace{width:100%;max-width:none;margin:0}
 .orders-compact-workspace{display:block}
 .orders-compact-workspace>.card{width:100%}
 #content #reserveReport{width:100%;max-width:none;margin:0}
 .closed-claims{width:100%;box-sizing:border-box}

 /* Auto layout preserves readable columns; no global clipping or fixed table heights. */
 #content .table-wrap,#dialog .table-wrap{width:100%;max-width:100%;overflow:auto;max-height:65dvh;overscroll-behavior-x:contain;scrollbar-width:thin}
 #content table.numbered-table,#content table.material-table,#dialog table.numbered-table,#dialog table.material-table{display:table;table-layout:auto;width:100%;min-width:100%;max-width:none;border-collapse:separate;border-spacing:0;height:auto;font-family:var(--erp-table-font)!important;font-size:var(--erp-table-size)!important}
 #content table>thead,#dialog table.numbered-table>thead{display:table-header-group;height:auto}
 #content table>tbody,#dialog table.numbered-table>tbody{display:table-row-group;height:auto}
 #content table>thead>tr,#content table>tbody>tr,#dialog table.numbered-table tr{display:table-row;height:auto}
 #content table.numbered-table th,#content table.numbered-table td,#content table.material-table th,#content table.material-table td,
 #dialog table.numbered-table th,#dialog table.numbered-table td,#dialog table.material-table th,#dialog table.material-table td{display:table-cell;width:auto!important;min-width:76px!important;max-width:none!important;height:auto!important;padding:7px 9px!important;line-height:1.35!important;font-size:var(--erp-table-size)!important;font-family:var(--erp-table-font)!important;vertical-align:middle;word-break:normal;overflow-wrap:normal;white-space:nowrap;overflow:visible;text-overflow:clip}
 #content table.numbered-table th,#content table.material-table th,#dialog table.numbered-table th,#dialog table.material-table th{position:sticky!important;top:0!important;z-index:2;background:var(--erp-head,#eeeacd);white-space:normal;min-width:85px!important;text-align:center;padding-right:15px!important;line-height:1.4!important}
 #content table.numbered-table td,#content table.material-table td,#dialog table.numbered-table td,#dialog table.material-table td{min-height:var(--erp-row)}
 #content table.numbered-table th:first-child,#content table.numbered-table td.row-number,#content table.material-table th:first-child,#content table.material-table td:first-child,
 #dialog table.numbered-table th:first-child,#dialog table.numbered-table td.row-number{width:40px!important;min-width:40px!important;text-align:center!important}
 #content table [data-column-width=name],#dialog table [data-column-width=name],#content .material-table th:nth-child(3),#content .material-table td:nth-child(3){min-width:240px!important;max-width:420px!important;text-align:left!important;white-space:normal!important;overflow-wrap:break-word}
 #content table [data-column-width=compact],#dialog table [data-column-width=compact]{min-width:90px!important;text-align:right}
 #content table td.empty,#dialog table td.empty{height:auto!important;min-height:0;padding:22px 12px!important;text-align:center!important;white-space:normal;color:var(--muted)}
 #content table td small,#dialog table td small{font-size:10px;line-height:1.35}
 #content table td::before,#dialog table.numbered-table td::before{display:none!important}
 #content .pill,#dialog .pill{display:inline-block;max-width:none;white-space:normal;line-height:1.35;vertical-align:middle}
 #content .orders-ledger th:nth-child(2),#content .orders-ledger td:nth-child(2){min-width:180px!important;white-space:normal!important;text-align:left!important}
 #content .orders-ledger th:nth-child(3),#content .orders-ledger td:nth-child(3){min-width:145px!important;text-align:left!important}
 #content .orders-ledger th:nth-child(4),#content .orders-ledger td:nth-child(4){min-width:240px!important;max-width:420px!important;white-space:normal!important;text-align:left!important}
 #content .orders-ledger th:nth-child(5),#content .orders-ledger td:nth-child(5){min-width:125px!important;text-align:right!important}
 #content .orders-ledger th:nth-child(6),#content .orders-ledger td:nth-child(6){min-width:175px!important;white-space:normal!important;text-align:center!important}
 #content .procurement-supplies th:nth-child(2),#content .procurement-supplies td:nth-child(2){min-width:110px!important}
 #content .procurement-supplies th:nth-child(3),#content .procurement-supplies td:nth-child(3){min-width:150px!important;white-space:normal}
 #content .procurement-supplies th:nth-child(4),#content .procurement-supplies td:nth-child(4){min-width:110px!important;white-space:nowrap}
 #content .procurement-supplies th:last-child,#content .procurement-supplies td:last-child{min-width:200px!important;white-space:normal}
 #content .procurement-demand th:nth-child(3),#content .procurement-demand td:nth-child(3){min-width:250px!important;max-width:420px!important;white-space:normal;text-align:left}
 #content .reserve-report th:nth-child(2),#content .reserve-report td:nth-child(2){min-width:190px!important;max-width:320px!important;white-space:normal;text-align:left}
 #content .reserve-report th:nth-child(5),#content .reserve-report td:nth-child(5){min-width:250px!important;white-space:normal;text-align:left}
 #content .material-table th:nth-child(n+5),#content .material-table td:nth-child(n+5){min-width:95px!important}
 #content .reserve-report table th:nth-child(n+7){min-width:140px!important}
 #content .reserve-matrix td{display:table-cell!important}
 #content #stockTable.stock-ledger{overflow:auto!important;max-height:65dvh!important;height:auto!important}
 #content>.card:has(#stockTable){overflow:hidden}
 .table-filter{position:relative;margin:0;padding:8px 10px;border-width:0 0 1px;border-radius:0;min-height:32px;background:#fff}
 .table-resizable{position:relative}
 .table-resize-handle{position:absolute;top:0;right:0;bottom:0;display:block;width:8px;height:auto;margin:0;cursor:col-resize;border-right:1px solid transparent;touch-action:none}
 .table-resize-handle:hover{border-right-color:#59836a;background:#59836a20}
 .table-resizing,.table-resizing *{user-select:none!important;cursor:col-resize!important}

 /* Dialogs keep their own scrolling area and a reachable action footer. */
 #dialog{max-width:calc(100vw - 24px)!important;max-height:calc(100dvh - 24px)!important}
 #dialogBody{max-height:calc(100dvh - 40px);min-width:0;min-height:0}
 #modalForm{min-width:0;min-height:0}
 .modal-scroll-content{min-width:0;overflow:auto}
 #dialog:has(.order-picker,.supplier-order,.order-fulfillment,.client-analytics-toolbar){width:min(1280px,calc(100vw - 24px))!important}
 #dialog .purchase-product-name,#dialog .claim-product{min-width:220px;white-space:normal}
 #dialog .order-picker .picker-layout{grid-template-columns:220px minmax(0,1fr)}
 #dialog .order-picker table.numbered-table{table-layout:auto}
 #dialog .order-picker table.numbered-table thead{display:table-header-group}
 #dialog .order-picker table.numbered-table tr{display:table-row}
 #dialog .order-picker table.numbered-table td{display:table-cell!important}
 #dialog .order-picker .table-wrap{overflow:auto;max-height:36dvh}
 #dialog .order-picker table.numbered-table th:nth-child(3),#dialog .order-picker table.numbered-table td:nth-child(3){min-width:250px!important;white-space:normal}
 #dialog .order-picker input[type=number]{min-width:65px;width:80px;height:28px}
 #dialog .order-picker .toolbar input,#dialog .order-picker .toolbar select{min-height:30px;font-size:12px}
 #dialog .client-analytics-table table{table-layout:auto;width:100%;min-width:1450px;max-width:none;font-family:var(--erp-table-font);font-size:var(--erp-table-size)}
 #dialog .client-analytics-table th,#dialog .client-analytics-table td{width:auto;min-width:95px;padding:7px 9px;font-size:var(--erp-table-size);line-height:1.35;white-space:nowrap;overflow:visible;text-overflow:clip}
 #dialog .client-analytics-table th{position:sticky;top:0;z-index:2;white-space:normal;background:var(--erp-head,#eeeacd)}
 #dialog .client-analytics-table th:first-child,#dialog .client-analytics-table td:first-child{min-width:40px}
 #dialog .client-analytics-table th:nth-child(2),#dialog .client-analytics-table td:nth-child(2){min-width:250px;max-width:360px;white-space:normal;text-align:left}
 .settings-workspace{width:100%;max-width:none;margin:0}
 .settings-layout{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(300px,1fr);gap:14px;align-items:start}
 .settings-primary .theme-options{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
 .settings-primary .theme-option{min-width:0;align-items:flex-start;flex-direction:column;padding:10px}
 .settings-primary .theme-option small{font-size:11px;line-height:1.4}
 .settings-primary .theme-sample{width:54px;height:42px}
 #tablePreferencesForm{padding:12px;grid-template-columns:minmax(150px,1fr) minmax(200px,1.5fr);align-items:start}
 #tablePreferencesForm>div:last-child{grid-column:1/-1}
 .settings-layout .card{width:100%}
 .system-status{display:grid;grid-template-columns:auto 1fr;gap:10px;padding:12px}
 .system-status b,.system-status small{display:block}
 .system-check{align-self:start;color:#2c7044}
 .role-description{padding:10px;border:1px solid var(--line)}
 .reports-workspace .report-info{max-width:100%}
 .stats{grid-template-columns:repeat(4,minmax(0,1fr))}
}
@media screen and (min-width:1600px){
 .procurement-columns{grid-template-columns:minmax(0,1fr) minmax(0,1.15fr)}
}
@media screen and (max-width:1050px){
 .settings-layout,.split{grid-template-columns:minmax(0,1fr)}
 .settings-primary .theme-options{grid-template-columns:repeat(3,minmax(0,1fr))}
 .stats{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media screen and (max-width:640px){
 main{padding:10px 8px}
 .sidebar{display:flex;flex-wrap:wrap;gap:8px;padding:8px}
 .sidebar .nav{order:3;flex-basis:100%;width:100%;gap:3px;white-space:nowrap}
 .sidebar .user-nav{font-size:11px;gap:5px}
 .sidebar .user-nav .muted{display:none}
 .sidebar .nav button,.sidebar .nav a{min-height:34px;flex:none}
 .heading h1{font-size:18px}
 .heading>button{min-height:32px}
 .toolbar{gap:6px}
 .toolbar>input,.toolbar>select{flex:1 1 160px;width:100%;min-width:0}
 .toolbar label{flex:1 1 140px;flex-wrap:wrap}
 .toolbar label input{max-width:100%}
 .toolbar button{min-height:32px}
 .form-grid,.purchase-general{grid-template-columns:minmax(0,1fr)}
 .purchase-tabs{flex-wrap:wrap}
 .purchase-tabs button{min-height:32px}
 .settings-primary .theme-options{grid-template-columns:minmax(0,1fr)}
 .settings-primary .theme-option{flex-direction:row}
 #tablePreferencesForm{grid-template-columns:minmax(0,1fr)}
 #dialog .order-picker .picker-layout{display:block}
 #dialog .order-picker .picker-groups{max-height:130px;margin-bottom:10px}
 #dialog{max-width:calc(100vw - 12px)!important;max-height:calc(100dvh - 12px)!important}
 #dialogBody{max-height:calc(100dvh - 28px)}
 .stats{grid-template-columns:minmax(0,1fr)}
 .login{margin:6vh 12px;max-width:calc(100% - 24px)}
 .actions,.receipt-footer{flex-wrap:wrap}
}

/* Compact order workspace: one scrollable list and a footer at the bottom. */
@media screen{
 html[data-erp-theme=soft]{--erp-canvas:#eceef1;--erp-surface:#f8f9fa;--erp-head:#e3e6ea;--erp-stripe:#f0f2f4;--erp-border:#c3c9d0;--erp-ink:#29323d;--erp-muted:#5c6673;--erp-active:#53667c;--erp-hover:#e4e9ef}
 html[data-erp-theme=soft] :is(.brand,.nav button span,.nav a,.number,details summary){color:#43536a}
 html[data-erp-theme=soft] :is(.stat,.stat.highlight,.group-count,.stock-section>summary,.stock-subgroup>summary,.receipt-footer,.receipt-help){background:var(--erp-surface);border-color:var(--erp-border);color:var(--erp-ink)}
 .heading-title{display:flex;align-items:center;gap:14px;flex-wrap:wrap}.heading-title h1{margin:0}.heading-title button{flex:none}
 body:has(.orders-workspace) .shell{height:100dvh;min-height:0;display:flex;flex-direction:column;overflow:hidden}
 body:has(.orders-workspace) .sidebar{flex:none}
 body:has(.orders-workspace) .workspace{flex:1;min-height:0;display:flex;flex-direction:column}
 main:has(.orders-workspace){flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;padding:6px 10px}
 main:has(.orders-workspace) .heading{flex:none;margin:0 0 6px;min-height:31px}
 main:has(.orders-workspace) .heading .eyebrow,main:has(.orders-workspace) .heading .subtitle{display:none}
 main:has(.orders-workspace) h1{font-size:18px}
 #content:has(.orders-workspace){flex:1;min-height:0;display:flex;flex-direction:column}
 .orders-workspace{flex:1;min-height:0;display:flex;flex-direction:column;width:100%;gap:6px}
 .orders-workspace .purchase-tabs{flex:none;margin:0;gap:4px;border-bottom:1px solid var(--erp-border,#c3c9d0)}
 .orders-workspace .purchase-tabs button{padding:5px 18px;min-height:28px}
 .orders-workspace .order-filters{flex:none;margin:0;gap:7px;padding:4px 0}
 .orders-workspace .order-filters label{display:flex;align-items:center;gap:5px;margin:0;min-width:0}
 .orders-workspace .order-filters :is(input,select){margin:0;min-height:28px;height:28px;padding:3px 6px;border-radius:4px}
 .orders-workspace .client-filter select{width:195px}
 .orders-workspace .quick-client-search{flex:1;max-width:260px;min-width:170px!important}
 .orders-workspace .quick-client-search>span{display:none}
 .orders-workspace .quick-client-search input{min-width:0;width:100%;max-width:none}
 .orders-workspace .date-range{display:flex;align-items:center;gap:6px;padding:3px 7px;background:var(--erp-surface,#f8f9fa);border:1px solid var(--erp-border,#c3c9d0);border-radius:5px}
 .orders-workspace .date-range input[type=date]{width:126px;border:0;background:transparent;padding:1px 2px;min-height:24px;height:24px}
 .orders-workspace .quick-search-help{color:var(--erp-muted,#5c6673);font-size:11px;margin-left:auto}
 .orders-workspace .order-workarea{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--erp-border,#c3c9d0);background:var(--erp-surface,#f8f9fa);border-radius:4px}
 .orders-workspace :is(.orders-ledger,.reserve-matrix){flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
 #content .orders-workspace .order-workarea .table-wrap{flex:1;min-height:0;max-height:none;overflow:auto}
 #content .orders-workspace table.numbered-table :is(th,td),#dialog .order-fulfillment table.numbered-table :is(th,td){padding:3px 6px!important;min-height:0!important;line-height:1.3!important;font-size:12px!important;vertical-align:middle;text-align:center!important}
 #content .orders-workspace table.numbered-table th{padding-right:12px!important;font-weight:600}
 #content .orders-workspace table.numbered-table :is(th,td).row-number{width:64px!important;min-width:64px!important;max-width:85px!important}
 #content .orders-workspace .orders-ledger table.numbered-table{table-layout:fixed;min-width:760px}
 #content .orders-workspace .orders-ledger :is(th,td):nth-child(2){width:145px!important;min-width:135px!important;max-width:160px!important;white-space:nowrap!important;text-align:center!important}
 #content .orders-workspace :is(.orders-ledger,.reserve-matrix) :is(th,td):nth-child(3){width:23%!important;min-width:170px!important;max-width:300px!important;white-space:normal!important;text-align:left!important;overflow-wrap:anywhere}
 #content .orders-workspace :is(.orders-ledger,.reserve-matrix) :is(th,td):nth-child(4){width:auto!important;min-width:140px!important;max-width:280px!important;white-space:normal!important;text-align:left!important;overflow-wrap:anywhere}
 #content .orders-workspace :is(.orders-ledger,.reserve-matrix) :is(th,td):nth-child(5){width:125px!important;min-width:110px!important;max-width:150px!important;text-align:center!important;white-space:nowrap!important}
 #content .orders-workspace :is(.orders-ledger,.reserve-matrix) :is(th,td):nth-child(6){width:145px!important;min-width:120px!important;max-width:170px!important;text-align:center!important;white-space:normal!important}
 #content .orders-workspace .reserve-matrix table.numbered-table{table-layout:auto;min-width:1500px}
 #content .orders-workspace .reserve-matrix :is(th,td):nth-child(2){min-width:135px!important;max-width:160px!important;text-align:center!important;white-space:nowrap!important}
 #content .orders-workspace .reserve-matrix :is(th,td):nth-child(7){width:110px!important;min-width:95px!important;max-width:135px!important;text-align:left!important;white-space:normal!important;overflow-wrap:anywhere}
 #content .orders-workspace .reserve-matrix :is(th,td):nth-child(8){min-width:200px!important;max-width:310px!important;text-align:left!important;white-space:normal!important;overflow-wrap:anywhere}
 #content .orders-workspace .reserve-matrix :is(th,td):nth-child(n+9){min-width:65px!important;max-width:130px!important;text-align:center!important;white-space:normal!important}
 .orders-workspace :is(.pager,.reserve-totals){flex:none;display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:0;padding:6px 8px;border-top:1px solid var(--erp-border,#c3c9d0);background:var(--erp-head,#e3e6ea);font-size:11px}
 .orders-workspace .pager-count{margin-left:auto}.orders-workspace .pager small{color:var(--erp-muted,#5c6673)}
 .orders-workspace .reserve-help{flex:none;font-size:11px;line-height:1.45;color:var(--erp-muted,#5c6673);margin:0;padding:2px 1px}
 .orders-workspace th[aria-sort=ascending]::after{content:' ↑'}.orders-workspace th[aria-sort=descending]::after{content:' ↓'}
 #dialog .order-fulfillment table.numbered-table :is(th,td):nth-child(2){min-width:95px!important;max-width:135px!important;text-align:left!important;white-space:normal!important;overflow-wrap:anywhere}
 #dialog .order-fulfillment table.numbered-table :is(th,td):nth-child(3){min-width:200px!important;max-width:330px!important;text-align:left!important;white-space:normal!important;overflow-wrap:anywhere}
 #dialog .order-fulfillment table.numbered-table :is(th,td):nth-child(n+4){min-width:72px!important;text-align:center!important;white-space:normal!important}
 #dialog .order-fulfillment table.numbered-table input[type=number]{width:76px;min-height:25px;text-align:center}
 .order-help{background:var(--erp-head,#e3e6ea);padding:8px 10px;border-radius:4px;color:var(--erp-ink,#29323d)}
 .order-actions{display:grid;grid-template-columns:repeat(auto-fit,minmax(185px,1fr));gap:10px;margin:12px 0}
 .order-action{display:flex;flex-direction:column;gap:5px;padding:9px;border:1px solid var(--erp-border,#c3c9d0);border-radius:4px}
 .order-action button{min-height:29px}.order-action small{font-size:11px;line-height:1.45;color:var(--erp-muted,#5c6673)}
 #content .procurement-demand :is(th,td):nth-child(2),#dialog .purchase-receipt :is(th,td):nth-child(2){min-width:100px!important;max-width:140px!important;text-align:left!important;white-space:normal!important}
 #content .procurement-demand :is(th,td):nth-child(n+4),.purchase-receipt :is(th,td):nth-child(n+4){text-align:center!important}
}
@media screen and (max-width:720px){
 body:has(.orders-workspace) .shell{height:auto;min-height:100dvh;overflow:visible}
 .orders-workspace .order-filters{gap:5px}.orders-workspace .quick-search-help{width:100%;margin-left:0}
 .orders-workspace .client-filter{flex:1}.orders-workspace .client-filter select{width:100%}
 .orders-workspace .order-workarea{min-height:55dvh}.orders-workspace .orders-ledger,.orders-workspace .reserve-matrix{min-height:40dvh}
 #content .orders-workspace .order-workarea .table-wrap{max-height:65dvh}
 .orders-workspace .pager-count{margin-left:0}.orders-workspace .pager small{width:100%}
}

/* Size order and reserve columns to their text, without filling spare space. */
@media screen{
 #content .orders-workspace :is(.orders-ledger,.reserve-matrix) table.numbered-table{width:max-content!important;min-width:0!important;max-width:none!important;table-layout:auto!important;align-self:flex-start}
 #content .orders-workspace :is(.orders-ledger,.reserve-matrix) table.numbered-table :is(th,td){width:auto!important;min-width:0!important;max-width:none!important;white-space:nowrap!important;overflow-wrap:normal!important}
 #content .orders-workspace .orders-ledger table.numbered-table.orders-fixed-columns{table-layout:fixed!important;width:var(--orders-table-width,1416px)!important;min-width:0!important;max-width:none!important}
 #content .orders-workspace .orders-ledger table.numbered-table.orders-fixed-columns :is(th,td){white-space:normal!important;overflow-wrap:anywhere!important}
 #content .orders-workspace .orders-ledger table.numbered-table.orders-fixed-columns :is(th,td):nth-child(2),#content .orders-workspace .orders-ledger table.numbered-table.orders-fixed-columns :is(th,td):nth-child(5){white-space:nowrap!important;overflow-wrap:normal!important}
 #content .orders-workspace .orders-ledger .onec-status{color:var(--erp-muted,#5c6673);font-size:11px!important;text-align:center!important}
}
