/* Phone layout; desktop styles remain unchanged. */
.mobile-nav-toggle,.mobile-nav-backdrop{display:none}
@media(max-width:760px){
  html{scroll-padding-top:12px}
  body{overflow-x:hidden}
  .app{display:block;min-width:0}
  .main{min-width:0;padding:12px 12px calc(26px + env(safe-area-inset-bottom))}
  .mobile-nav-toggle{display:grid;place-items:center;grid-column:1;width:44px;height:44px;border:1px solid var(--line);border-radius:10px;background:#fff;color:var(--deep);font-size:23px;cursor:pointer}
  .sidebar{display:flex!important;position:fixed;z-index:31;inset:0 auto 0 0;width:min(82vw,310px);height:100dvh;overflow-y:auto;overscroll-behavior:contain;padding:20px 14px calc(20px + env(safe-area-inset-bottom));gap:18px;transform:translateX(-105%);transition:transform .22s ease;box-shadow:12px 0 30px #12383b25}
  .sidebar .brand{justify-content:flex-start;padding:0 8px}
  .sidebar .brand b,.sidebar .brand small,.sidebar .nav-label,.sidebar .nav button span,.sidebar .nav .count,.sidebar .shift-card{display:block}
  .sidebar .nav button{justify-content:flex-start;min-height:44px;padding:9px 11px;font-size:14px}
  .sidebar .nav button:after{display:none}
  .sidebar .nav button.active:before{display:block}
  .sidebar .nav-group-toggle .group-arrow{display:block}
  .sidebar .nav-submenu{margin-left:18px;padding-left:8px;border-left:1px solid rgba(216,238,119,.22)}
  .sidebar .shift-card{margin-top:16px}
  .mobile-nav-backdrop{position:fixed;inset:0;z-index:30;border:0;background:#081f23a8;cursor:pointer}
  body.mobile-nav-open{overflow:hidden}
  body.mobile-nav-open .sidebar{transform:translateX(0)}
  body.mobile-nav-open .mobile-nav-backdrop{display:block}
  .topbar{display:grid;grid-template-columns:44px minmax(0,1fr);align-items:center;gap:9px;margin:0 0 14px}
  .topbar .crumb{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .topbar .actions{grid-column:1/-1;display:flex;flex-wrap:wrap;align-items:center;gap:7px;width:100%;margin:0}
  .topbar .account-bar{flex:0 0 100%;display:flex;justify-content:space-between;gap:5px;min-width:0;width:100%;white-space:nowrap}
  .topbar .account-bar[hidden]{display:none!important}
  .topbar #accountDisplay{min-width:0;overflow:hidden;text-overflow:ellipsis}
  .topbar .date{display:none}
  .topbar #messageButton{display:grid;flex:0 0 44px;min-height:44px;width:44px}
  .topbar #openBatch,.topbar #openModal,.topbar .audit-open-button{flex:1 1 0;width:auto;min-width:0;min-height:44px;padding:8px 4px;font-size:12px;white-space:nowrap}
  .overview,.node-metrics{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:12px}
  .overview .metric,.node-metrics .metric{min-width:0;min-height:88px;padding:11px}
  .overview .metric.primary,.node-metrics .metric.primary{grid-column:auto}
  .metric .label{font-size:12px}.metric strong{font-size:23px;margin-top:6px}.metric small{font-size:10px;line-height:1.35}
  .total-dashboard{padding:12px;margin-bottom:12px}
  .total-dashboard-head{align-items:flex-start;gap:8px}
  .total-dashboard-actions{width:100%;justify-content:flex-start;flex-wrap:wrap}
  .total-dashboard-actions .batch-btn{min-height:40px}
  .total-dashboard-filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:100%}
  .total-dashboard-filters label{display:grid;gap:4px;min-width:0;font-size:11px}
  .total-dashboard-filters .filter{width:100%;max-width:none;min-width:0}
  #totalDashboardReset{grid-column:1/-1}
  .total-dashboard-table-wrap{max-height:none;overflow:visible;border:0}
  .total-dashboard table{display:block;min-width:0;width:100%}
  .total-dashboard thead{display:none}
  .total-dashboard tbody{display:grid;gap:8px}
  .total-dashboard tbody tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;padding:10px;border:1px solid var(--line);border-radius:8px}
  .total-dashboard tbody td{display:flex;flex-direction:column;gap:3px;min-width:0;padding:0;border:0;overflow-wrap:anywhere}
  .total-dashboard tbody td:before{content:attr(data-label);font-size:10px;color:#819095}
  .total-dashboard tbody td:first-child,.total-dashboard tbody td:last-child{grid-column:1/-1}
  .total-dashboard tbody tr:has(td[colspan]){display:block}
  .total-dashboard tbody tr:has(td[colspan]) td:before{display:none}
  .workspace,.workspace.node-workspace{display:block;min-width:0}
  .table-card{overflow:visible}
  .table-head{display:grid;gap:9px;padding:12px}
  .table-title-group{justify-content:space-between}
  .table-title-group h2{font-size:15px}
  .filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;width:100%}
  .filter-actions{display:flex;gap:7px;grid-column:1/-1;width:100%}
  .filter-actions button{flex:1 1 0;min-width:0;white-space:nowrap}
  .filters .search{grid-column:1/-1;width:100%;min-width:0}
  .filters .filter{min-width:0;width:100%}
  .table-card table,.report-template-table{display:block;min-width:0!important;width:100%;table-layout:auto}
  .table-card thead{display:none}
  .table-card.mobile-select-mode thead,.table-card.mobile-split-mode thead{display:block}
  .table-card thead tr{display:flex;align-items:center;gap:12px;padding:8px 12px;background:#f8faf9}
  .table-card thead th{display:none;padding:0;border:0;background:transparent}
  .table-card.mobile-select-mode thead th.photo-select-col:not([hidden]){display:flex;align-items:center;gap:7px;width:auto;text-align:left}
  .table-card.mobile-select-mode thead th.photo-select-col:after{content:'全选当前单据';font-size:12px;color:#52646d}
  .table-card.mobile-split-mode thead th.category-col:not([hidden]){display:block}
  .table-card tbody{display:grid;gap:9px;padding:10px}
  .table-card tbody tr{position:relative;display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:10px 7px;padding:12px;border:1px solid var(--line);border-radius:10px;background:#fff;min-width:0}
  .table-card tbody tr:hover{background:#fff}
  .table-card tbody td{display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-width:0;padding:0;border:0;font-size:12px;overflow-wrap:anywhere}
  .table-card tbody td[hidden],.report-template-table td[hidden]{display:none!important}
  .table-card tbody td:before,.report-template-table tbody td:before{content:attr(data-label);font-size:10px;color:#819095;line-height:1.2}
  .table-card tbody td.photo-select-col{position:absolute;top:13px;left:12px;width:22px}
  .table-card tbody td.photo-select-col:before{display:none}
  .table-card tbody td.photo-select-col input,.report-template-table tbody td.report-template-select-col input{width:21px;height:21px}
  .table-card tbody tr:not(.mobile-history-row) td:nth-child(2){grid-column:span 4}
  .table-card tbody tr:not(.mobile-history-row) td:nth-child(3){grid-column:span 2;align-items:flex-end}
  .table-card tbody tr:not(.mobile-history-row) td:nth-child(4),.table-card tbody tr:not(.mobile-history-row) td:nth-child(5),.table-card tbody tr:not(.mobile-history-row) td:nth-child(6){grid-column:span 2}
  .table-card tbody tr:not(.mobile-history-row) td:nth-child(7),.table-card tbody tr:not(.mobile-history-row) td:nth-child(8){grid-column:span 3}
  .table-card tbody tr:not(.mobile-history-row) td:nth-child(9),.table-card tbody tr:not(.mobile-history-row) td:nth-child(10),.table-card tbody tr:not(.mobile-history-row) td:nth-child(11){grid-column:1/-1}
  .table-card tbody tr:has(td.photo-select-col:not([hidden])) td:nth-child(2){padding-left:29px}
  .table-card tbody tr.mobile-history-row td:nth-child(1){grid-column:span 4}
  .table-card tbody tr.mobile-history-row td:nth-child(2){grid-column:span 2;align-items:flex-end}
  .table-card tbody tr.mobile-history-row td:nth-child(n+3){grid-column:1/-1}
  .table-card tbody tr.mobile-empty-row{display:block;text-align:center}
  .table-card tbody tr.mobile-empty-row td{display:block;width:100%}
  .table-card tbody tr.mobile-empty-row td:before{display:none}
  .table-card .order-id,.report-template-table .order-id{font-size:14px;line-height:1.4;overflow-wrap:anywhere}
  .table-card .date-time,.table-card .node-time-btn{white-space:normal;text-align:left}
  .table-card .note-cell{max-width:none;max-height:4.5em;overflow:auto;white-space:pre-wrap}
  .table-card .node-note-btn,.report-template-table .node-note-btn{width:100%;max-width:none;min-height:44px;height:auto}
  .table-card .flow-btn,.report-template-table .flow-btn{width:100%;min-height:44px;white-space:normal}
  .table-card .split-category-check{width:22px;height:22px}
  .quick-complete,.report-template-module .quick-complete{display:grid;grid-template-columns:1fr;gap:7px;margin:0 0 10px;padding:8px;border-radius:8px}
  .quick-complete input,.quick-complete-action{width:100%;min-height:40px}
  .quick-complete .quick-pending-empty{font-size:12px;color:var(--muted);padding:2px 0}
  .report-template-module{overflow:visible;padding:12px}
  .report-template-head{display:grid;gap:7px}
  .report-template-head span{line-height:1.4}
  .report-template-head .batch-btn{justify-self:start}
  .report-template-table thead{display:block}
  .report-template-table thead tr{display:block;padding:6px 0}
  .report-template-table thead th{display:none;border:0;background:transparent;padding:0}
  .report-template-table thead th.report-template-select-col{display:block;width:auto;text-align:left}
  .report-template-table thead th.report-template-select-col:after{content:' 全选报告模板';font-size:12px;color:#52646d}
  .report-template-table tbody{display:grid;gap:9px;padding:8px 0}
  .report-template-table tbody tr{position:relative;display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:9px 7px;padding:12px;border:1px solid var(--line);border-radius:10px;background:#fff}
  .report-template-table tbody td{display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-width:0;padding:0;border:0;font-size:12px;overflow-wrap:anywhere}
  .report-template-table tbody td.report-template-select-col{position:absolute;top:14px;left:12px;width:22px}
  .report-template-table tbody td.report-template-select-col:before{display:none}
  .report-template-table tbody td:nth-child(2){grid-column:span 4;padding-left:29px}
  .report-template-table tbody td:nth-child(3){grid-column:span 2}
  .report-template-table tbody td:nth-child(4){grid-column:span 2}
  .report-template-table tbody td:nth-child(5){grid-column:span 4}
  .report-template-table tbody td:nth-child(6),.report-template-table tbody td:nth-child(7),.report-template-table tbody td:nth-child(8){grid-column:1/-1}
  .report-template-table tbody tr:has(td[colspan]){display:block}
  .report-template-table tbody tr:has(td[colspan]) td{display:block}
  .report-template-table tbody tr:has(td[colspan]) td:before{display:none}
  .report-template-table .template-copies{width:90px;min-height:44px}
  .modal{align-items:flex-end;padding:0;z-index:40}
  .modal-box,.batch-box,.weekly-report-box,.admin-account-box,.node-load-box,.message-box,.reminder-box{width:100%;max-width:none;max-height:calc(100dvh - 8px);overflow-y:auto;overscroll-behavior:contain;border-radius:17px 17px 0 0;padding:17px 15px calc(15px + env(safe-area-inset-bottom))}
  .modal-title{position:sticky;top:-17px;z-index:2;background:#fff;padding:5px 0 10px;margin-bottom:10px}
  .modal-title h2{font-size:18px}
  .close{width:40px;height:40px}
  .form-grid{grid-template-columns:1fr;gap:11px}
  .field.full{grid-column:auto}
  .form-actions{position:sticky;bottom:calc(-15px - env(safe-area-inset-bottom));z-index:2;background:#fff;border-top:1px solid var(--line);padding:10px 0 calc(8px + env(safe-area-inset-bottom));margin-top:15px}
  .form-actions button{min-height:44px}
  .form-actions .new-btn{flex:1}
  .batch-grid-wrap{overflow:visible;border:0}
  #batchModal .batch-grid,#batchRoutingModal .batch-grid{display:block;min-width:0!important;width:100%}
  #batchModal .batch-grid thead{display:none}
  #batchRoutingModal .batch-grid thead{display:block;margin-bottom:8px}
  #batchRoutingModal .batch-grid thead tr{display:flex;align-items:center;gap:8px;padding:8px;background:#f3f8f7;border:0}
  #batchRoutingModal .batch-grid thead th{border:0;background:transparent;padding:0}
  #batchRoutingModal .batch-grid thead th:first-child{display:none}
  #batchRoutingModal .batch-grid thead .flag-col{width:auto;flex:1;text-align:left}
  #batchRoutingModal .batch-grid thead .batch-routing-select-label{gap:4px;font-size:11px}
  #batchRoutingModal .batch-grid thead .batch-routing-select-label input{width:21px;height:21px}
  #batchModal .batch-grid tbody,#batchRoutingModal .batch-grid tbody{display:grid;gap:9px}
  #batchModal .batch-grid tr,#batchRoutingModal .batch-grid tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;padding:11px;border:1px solid var(--line);border-radius:9px;background:#fff}
  #batchModal .batch-grid td,#batchRoutingModal .batch-grid td{display:grid;align-content:start;gap:4px;min-width:0;padding:0;border:0}
  #batchModal .batch-grid td:before,#batchRoutingModal .batch-grid td:before{content:attr(data-label);font-size:11px;color:#71838d}
  #batchModal .batch-grid td:nth-child(1),#batchModal .batch-grid td:nth-child(2),#batchModal .batch-grid td:nth-child(8),#batchModal .batch-grid td:nth-child(9){grid-column:1/-1}
  #batchRoutingModal .batch-grid td:nth-child(1){grid-column:1/-1}
  #batchModal .batch-grid input,#batchModal .batch-grid textarea{min-width:0;width:100%}
  #batchModal .batch-grid .time-input{min-width:0}
  #batchModal .batch-grid .flag-col,#batchRoutingModal .batch-grid .flag-col{text-align:left}
  #batchModal .batch-grid .flag-col input,#batchRoutingModal .batch-grid .flag-col input{width:22px;height:22px}
  #batchModal .batch-grid .row-delete{width:100%;height:42px}
  .paste-panel{padding:10px}
  .paste-panel textarea{min-height:105px}
  .paste-action-buttons{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
  .paste-action-buttons button{min-height:42px;min-width:0;padding:7px 4px;font-size:12px}
  .weekly-report-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
  .weekly-report-toolbar label{grid-column:1/-1;display:grid;gap:5px;width:100%}
  .weekly-report-toolbar .filter{width:100%;min-width:0}
  .weekly-report-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
  .weekly-report-sections{grid-template-columns:1fr}
  .weekly-report-detail{max-height:none;overflow:visible;border:0}
  .weekly-report-detail h3{border:1px solid var(--line);border-radius:8px 8px 0 0}
  .weekly-report-detail table,.weekly-report-detail:last-of-type table{display:block;min-width:0;width:100%}
  .weekly-report-detail thead{display:none}
  .weekly-report-detail tbody{display:grid;gap:8px;padding:8px 0}
  .weekly-report-detail tbody tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;padding:10px;border:1px solid var(--line);border-radius:8px}
  .weekly-report-detail tbody td{display:flex;flex-direction:column;gap:3px;min-width:0;padding:0;border:0;overflow-wrap:anywhere}
  .weekly-report-detail tbody td:before{content:attr(data-label);font-size:10px;color:#819095}
  .weekly-report-detail tbody td:first-child{grid-column:1/-1}
  .weekly-report-detail tbody tr:has(td[colspan]){display:block}
  .weekly-report-detail tbody tr:has(td[colspan]) td:before{display:none}
  .node-load-editor-head{display:none}
  .node-load-editor-row{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;padding:10px;border:1px solid var(--line);border-radius:8px}
  .node-load-editor-row .node-load-name{grid-column:1/-1;font-weight:600}
  .node-load-editor-row .node-load-current:before{content:'实时 ';color:#829391}
  .node-load-editor-row .node-load-percent:before{content:'负荷率 ';color:#829391}
  .message-list{max-height:55dvh}
  .toast{left:12px;right:12px;bottom:calc(12px + env(safe-area-inset-bottom));text-align:center}
  input,select,textarea{font-size:16px!important}
  button{touch-action:manipulation}
  .batch-btn,.new-btn,.cancel,.filter,.search{min-height:42px}
  [hidden]{display:none!important}
}
@media(max-width:360px){
  .main{padding-left:9px;padding-right:9px}
  .topbar #openBatch,.topbar #openModal{font-size:11px}
  .metric small{font-size:9px}
}
@media(prefers-reduced-motion:reduce){.sidebar{transition:none}}
