/* Shared phone layout. Print styles and desktop dimensions remain in their source stylesheets. */
@media screen and (max-width:768px) {
  html#wkModulePage { width:100%; min-width:0; scroll-padding-top:12px; }
  html#wkModulePage body { width:100%; min-width:0; margin:0; overflow-wrap:anywhere; }
  html#wkModulePage[data-wk-module="planning"] body { padding:10px; }
  html#wkModulePage body :is(.app,.main,.content,.page,.box,.card,.raw-section,fieldset,dialog,.modal) { min-width:0; max-width:100%; }
  html#wkModulePage body .app { flex-direction:column; min-height:100dvh; }
  html#wkModulePage body .main { margin-left:0!important; width:100%!important; }
  html#wkModulePage body .content { padding:12px!important; }
  html#wkModulePage body .side { position:static; width:100%; max-height:none; padding:10px 12px; overflow:visible; }
  html#wkModulePage body .side .brand { font-size:18px; padding:4px 0 10px; margin-bottom:8px; }
  html#wkModulePage body .side .brand small { font-size:11px; }
  html#wkModulePage body .side .nav { max-height:55dvh; overflow:auto; overscroll-behavior:contain; }
  html#wkModulePage body .side.wk-module-nav-collapsed .nav { display:none; }
  html#wkModulePage body .wk-module-nav-toggle { width:100%; margin:0 0 6px; border:1px solid #64748b; background:#1e293b; color:#fff; text-align:left; }
  html#wkModulePage body .top { position:static; height:auto; min-height:48px; padding:10px 12px; gap:8px; flex-wrap:wrap; }
  html#wkModulePage body .top input { width:100%; flex:1 1 100%; }
  html#wkModulePage body :is(.online,.role-badge,.userbar) { margin-left:0; max-width:100%; flex-wrap:wrap; }
  html#wkModulePage body h1 { font-size:21px; line-height:1.4; }
  html#wkModulePage body :is(.sub,.hint,.note,.warn,.raw-status) { white-space:normal; line-height:1.6; }
  html#wkModulePage body :is(.cards,.plan-stage-kpis,.req-detail-stocks,.preview) { grid-template-columns:repeat(2,minmax(0,1fr)); }
  html#wkModulePage body :is(.cards,.plan-stage-kpis) { gap:8px; }
  html#wkModulePage body :is(.card,.box,.raw-section) { padding:12px; }
  html#wkModulePage body :is(.page,dialog,.modal) :is(.form,.grid,.raw-grid) { grid-template-columns:minmax(0,1fr)!important; gap:10px; align-items:start; }
  html#wkModulePage body :is(.form,.grid,.raw-grid)>* { min-width:0; max-width:100%; grid-column:auto!important; }
  html#wkModulePage body :is(.grid2,.spc-layout,.oi-files,.photo-pair,.checks,.instruction-detail-grid,.pw-fields,.pw-output-fields,.plan-product-field,.receipt-content,.receipt-box-content,.receipt-unknown,.pvc-certificate-grid,.subassembly-grid,.shipping-fields,.shipping-scan-row,.outsourcing-print-parties,.outsourcing-print-fields,.wk-transport-fields) { grid-template-columns:minmax(0,1fr)!important; }
  html#wkModulePage body :is(.page,dialog,.modal) [style*="grid-template-columns"] { grid-template-columns:minmax(0,1fr)!important; }
  html#wkModulePage body :is(.page,dialog,.modal) [style*="grid-column"] { grid-column:auto!important; }
  html#wkModulePage body #raw .raw-receipt-grid,
  html#wkModulePage body #outsourcing .form.subassembly-receipt-fields,
  html#wkModulePage body #outsourceReceiptEntry :is(.receipt-metadata,.wk-transport-fields),
  html#wkModulePage body #postProductionEntry .post-component-grid,
  html#wkModulePage body #plans .plan-product-field { grid-template-columns:minmax(0,1fr)!important; max-width:100%; }
  html#wkModulePage body :is(.shipping-selected-details,.qr-meta,.mold-standard-grid) { grid-template-columns:repeat(2,minmax(0,1fr)); }
  html#wkModulePage body :is(.form,.grid,.raw-grid,.grid2,.spc-layout,.receipt-metadata,.shipping-fields,.shipping-selected-details,.wk-transport-fields)>* { min-width:0; max-width:100%; }
  html#wkModulePage body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),select,textarea) { width:100%!important; min-width:0!important; max-width:100%!important; min-height:44px!important; height:auto!important; padding:10px!important; font-size:16px!important; line-height:1.4; box-sizing:border-box; }
  html#wkModulePage body :is(input,select,textarea) { scroll-margin-block:18px; }
  html#wkModulePage body :is(input[type="checkbox"],input[type="radio"]) { width:20px!important; height:20px!important; min-height:20px!important; flex:0 0 20px; }
  html#wkModulePage body textarea { min-height:90px!important; resize:vertical; }
  html#wkModulePage body :is(button,.btn,.actionbtn,.btn-link) { min-height:44px!important; height:auto!important; max-width:100%; padding:10px 12px!important; font-size:14px!important; line-height:1.4; white-space:normal; }
  html#wkModulePage body :is(button,a,input,select,textarea,summary):focus-visible { outline:3px solid #60a5fa; outline-offset:2px; }
  html#wkModulePage body :is(.head,.section-title,.toolbar,.tools,.tabs,.raw-actions,.raw-nas-filter-bar,.raw-nas-filter-bar .controls,.line-controls,.import-row,.modal-actions,.qr-actions,.login-actions,.receipt-scan,.receipt-pack-tools,.receipt-pending-search,.plan-order-select,.order-page-heading,.order-heading-actions,.order-filter-row,.order-list-toolbar,.order-list-actions,.req-heading,.req-heading-actions,.req-filter-row,.req-extra-filters,.req-list-toolbar,.req-list-footer,.plan-list-heading,.plan-list-filters,.shipping-entry-heading,.shipping-form-actions,.shipping-order-filter-row,.shipping-history-filters,.pw-filters,.instruction-filters,.pw-dialog-actions,.pw-entry-actions,.press-box-toolbar,.press-box-pager,.pw-pager,.mold-workflow-pager,.outsourcing-qr-filters,.outsourcing-qr-actions,.outsourcing-qr-foot,.outsourcing-print-filters,.outsourcing-print-actions,.outsourcing-print-extra,.outsourcing-print-foot) { gap:8px; flex-wrap:wrap; max-width:100%; min-width:0; }
  html#wkModulePage body :is(.page,dialog,.modal) [style*="display:flex"] { flex-wrap:wrap; gap:8px; }
  html#wkModulePage body :is(.head,.toolbar,.tools,.raw-actions,.line-controls,.import-row,.receipt-scan,.receipt-pack-tools,.receipt-pending-search,.plan-order-select,.order-filter-row,.order-heading-actions,.order-list-actions,.req-filter-row,.req-extra-filters,.plan-list-filters,.shipping-scan-row,.shipping-order-filter-row,.shipping-history-filters,.pw-filters,.instruction-filters,.outsourcing-filters,.outsourcing-qr-filters,.outsourcing-print-filters)>:is(div,label,input:not([type="checkbox"]):not([type="radio"]),select,textarea) { flex:1 1 100%!important; min-width:0!important; width:100%!important; max-width:100%!important; }
  html#wkModulePage body :is(.toolbar,.tools,.raw-actions,.modal-actions,.login-actions,.qr-actions,.receipt-actions,.receipt-scan,.receipt-pending-search,.plan-order-select,.order-heading-actions,.shipping-form-actions,.pw-dialog-actions,.pw-entry-actions,.wk-qr-print-actions)>:is(button,.btn) { flex:1 1 100%; width:100%; }
  html#wkModulePage body :is(.tabs,.outsourcing-tabs,.receipt-mode-buttons,.inventory-view-tabs,.mold-workflow-bar)>button { flex:1 1 44%; }
  html#wkModulePage body :is(.order-period-buttons,.req-period-actions,.compact-row-actions) { display:flex; flex-wrap:wrap; gap:6px; max-width:100%; white-space:normal; }
  html#wkModulePage body :is(.order-period-buttons,.req-period-actions)>button { flex:1 1 44%; }
  html#wkModulePage body :is(.pmpt-values-wrap,.our-values-wrap) { min-width:0; }
  html#wkModulePage body .check { align-items:flex-start; flex-direction:column; gap:8px; }
  html#wkModulePage body :is(.chart-wrap,.chartbox,.measure-grid,.spc-summary,.raw-results,.material-scroll,.scroll,.spc-history-table,.press-box-scroll,.mold-workflow-table,.pw-table-scroll,.outsourcing-qr-table,.outsourcing-print-table,.shipping-order-scroll,.pvc-receipt-scroll,.receipt-box-list) { min-width:0; max-width:100%; overflow:auto; -webkit-overflow-scrolling:touch; }
  html#wkModulePage body :is(.chartbox,.chart-wrap) { height:auto; min-height:240px; }
  html#wkModulePage body :is(canvas,svg,video,img) { max-width:100%; }
  html#wkModulePage body .chartbox canvas { max-height:360px; }
  html#wkModulePage body .wk-mobile-table-scroll { display:block!important; width:100%; min-width:0; max-width:100%; overflow:auto; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; }
  html#wkModulePage body .wk-mobile-table-region { min-width:0; max-width:100%; overflow:auto; -webkit-overflow-scrolling:touch; }
  :where(html#wkModulePage) table:where(.wk-mobile-data-table) { min-width:640px; }
  html#wkModulePage body :is(.mode-bg,.modal-bg,.login-layer) { box-sizing:border-box; padding:10px; max-height:var(--wk-module-viewport,100dvh); overflow:auto; align-items:flex-start; }
  html#wkModulePage body :is(.mode-box,.login-box,.login-card,.modal) { box-sizing:border-box; width:100%!important; max-width:100%!important; min-width:0; max-height:calc(var(--wk-module-viewport,100dvh) - 20px)!important; overflow:auto; padding:16px; margin:auto; }
  html#wkModulePage body .mode-buttons { grid-template-columns:minmax(0,1fr); }
  html#wkModulePage body dialog { box-sizing:border-box; width:calc(100% - 16px)!important; min-width:0!important; max-width:calc(100% - 16px)!important; max-height:calc(var(--wk-module-viewport,100dvh) - 16px)!important; overflow:auto!important; margin:auto; }
  html#wkModulePage body dialog[open] { overscroll-behavior:contain; }
  html#wkModulePage body :is(dialog.order-drawer,#planOrderDialog,.plan-list-dialog,.plan-stage-dialog,.shipping-order-dialog,#pressInstructionListDialog) { height:auto!important; max-height:calc(var(--wk-module-viewport,100dvh) - 16px)!important; inset:0; }
  html#wkModulePage body :is(.order-drawer-body,.plan-list-dialog-body,.plan-stage-body,.outsourcing-qr-main,.outsourcing-print-main,.shipping-order-results,.pw-entry-body) { min-height:0; min-width:0; overflow:visible; flex:0 0 auto; }
  html#wkModulePage body .plan-list-dialog-body>.plan-list-panel { min-height:0; overflow:visible; }
  html#wkModulePage body :is(#planList,#resultsList,#planOrderList,#pressInstructionList,#shipOrderResults) { height:auto; min-height:0; max-height:55dvh; flex:0 0 auto; overflow:auto; }
  html#wkModulePage body :is(.order-drawer-heading,.plan-view-head,.shipping-dialog-head,.pw-dialog-head,.instruction-dialog-head,.pvc-certificate-head,.receipt-dialog-head,.outsourcing-qr-head,.outsourcing-print-head,dialog>header) { position:static; gap:8px; flex-wrap:wrap; min-width:0; }
  html#wkModulePage body :is(.pw-dialog-actions,.pw-entry-actions,.modal-actions,.outsourcing-qr-foot,.outsourcing-print-foot) { position:static!important; }
  html#wkModulePage body :is(.qr-code,.qr-code img,.qr-code canvas) { max-width:100%; }
  html#wkModulePage body .toast { right:10px; left:10px; bottom:10px; max-width:calc(100% - 20px); }
}

/* Plant 2 keeps the original controls and handlers; only phone presentation changes. */
@media screen and (max-width:768px){
 html#wkModulePage body :is(#postproduction,#pvc) .wk-factory2-table{display:block;min-width:0!important;width:100%;border-collapse:separate}
 html#wkModulePage body :is(#postproduction,#pvc) .wk-factory2-table>tbody{display:grid;gap:10px}
 html#wkModulePage body :is(#postproduction,#pvc) .wk-factory2-table .wk-factory2-table-head{display:none}
 html#wkModulePage body :is(#postproduction,#pvc) .wk-factory2-table tr:not(.wk-factory2-table-head){display:block;border:1px solid #cbdcec;border-radius:7px;background:white;overflow:hidden}
 html#wkModulePage body :is(#postproduction,#pvc) .wk-factory2-table td{display:block;min-width:0;max-width:100%;padding:9px 11px;border-bottom:1px solid #e4ecf4;text-align:left;white-space:normal;overflow-wrap:anywhere}
 html#wkModulePage body :is(#postproduction,#pvc) .wk-factory2-table td[data-mobile-label]::before{content:attr(data-mobile-label);display:block;font-size:11px;font-weight:700;color:#71859b;margin-bottom:4px}
 html#wkModulePage body :is(#postproduction,#pvc) .wk-factory2-table :is(button,input,select){max-width:100%;min-width:0}
 html#wkModulePage body :is(#postproduction,#pvc) .material-pager{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
 html#wkModulePage body :is(#postproduction,#pvc) details.material-entry{scroll-margin-top:12px}
 html#wkModulePage body :is(#postproduction,#pvc) :is(.pvc-source-lots,.post-component-footer){min-width:0;max-width:100%}
 html#wkModulePage body #pvc .pvc-source-lots label{display:flex;gap:9px;align-items:flex-start;overflow-wrap:anywhere}
 html#wkModulePage body #pvc .pvc-source-lots label>span{min-width:0;flex:1}
 html#wkModulePage body :is(#postProductionEntry,#pvc>details:first-of-type)>button.btn{width:100%;margin-top:12px}
}

@media screen and (max-width:768px){html#wkModulePage body :is(#postproduction,#pvc) .material-scroll:has(.wk-factory2-table){max-height:none!important;overflow:visible!important}}
