/* Final mobile pass: loaded after every module stylesheet. */
@media (max-width:760px){
  :root{font-size:15px}
  html,body{width:100%;max-width:100%;overflow-x:hidden}
  body{background:#f5f9fd}
  .workspace{display:block;width:100%;overflow-x:hidden}
  .main,.content,#view{width:100%;max-width:100%;min-width:0;overflow-x:clip}
  .content{padding:14px 12px calc(82px + env(safe-area-inset-bottom))}
  .topbar{position:sticky;top:0;z-index:30;min-height:58px;padding:8px 10px;background:#fff;box-shadow:0 4px 18px #1f568514}
  .top-start{gap:6px;min-width:42px}.top-actions{gap:5px;min-width:0}
  .top-actions .user-chip{max-width:120px;overflow:hidden}.top-actions .user-chip small,.top-actions .user-chip strong{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .topbar :is(.top-icon,.icon-btn){width:42px;height:42px;min-width:42px;padding:0}
  .date-label,.crumb{display:none!important}
  .sidebar{width:min(300px,88vw);padding:20px 13px calc(18px + env(safe-area-inset-bottom));box-shadow:-16px 0 38px #102b4230}
  .sidebar .brand{padding:0 9px 20px;font-size:18px}.side-caption{padding:10px 14px}
  nav button{min-height:48px;padding:12px 14px;font-size:13px}
  .page-heading{margin-bottom:14px}.page-heading h1{font-size:24px}.page-heading p{font-size:11px;line-height:1.8}
  .heading-actions{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px}.heading-actions select{min-width:0;width:100%}
  .section-title{margin-block:16px 10px}.section-title h2{font-size:18px;line-height:1.6}
  .pill-tabs{border-radius:14px;background:#edf5fb;border:1px solid #d7e6f1}.pill-tabs button{font-size:12px}
  .metrics,.dashboard-module-grid,.dashboard-lower,.split,.cbs-summary,.schedule-import-form,.org-role-grid,.org-mapping,.org-board-body,.policy-row,.letter-card-grid,.grn-review-grid,.contract-statement-list{grid-template-columns:minmax(0,1fr)!important}
  .metrics{gap:9px}.metric{min-height:92px;padding:14px}.metric strong{font-size:25px}
  .card,.notice,.dashboard-hero,.dashboard-module,.inventory-hero,.finance-flow-hero{border-radius:16px;padding:14px;min-width:0;max-width:100%}
  .dashboard-hero,.inventory-hero,.finance-flow-hero{display:flex;gap:12px;align-items:stretch}
  .dashboard-module h2,.dashboard-module h3{font-size:16px;line-height:1.6}.dashboard-module p{font-size:11px;line-height:1.8}
  .quick-actions{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.quick-actions button{font-size:11px;min-height:54px;padding:10px}
  .toolbar,.section-title .toolbar,.inline-actions,.modal-actions{display:flex;flex-wrap:wrap;gap:8px;min-width:0}.toolbar>*{max-width:100%;min-width:0}
  .btn{min-height:44px;padding:10px 13px;font-size:12px}.tiny{min-height:40px}
  .table-wrap,.priority-table-scroll,.edms-table-wrap,.monthly-budget-table-scroll,.gantt-scroll{width:100%;max-width:100%;overflow-x:auto}
  .mobile-card-table tbody tr{padding:7px 12px;border-radius:15px;background:linear-gradient(145deg,#fff,#f7fbff);box-shadow:0 5px 16px #173f6014}
  .mobile-card-table td{grid-template-columns:minmax(0,38%) minmax(0,1fr);font-size:12px;line-height:1.8}
  .mobile-card-table td::before{font-size:10px;color:#4c7897}.mobile-card-table .mobile-cell-value{font-size:12px}
  .form-grid{grid-template-columns:minmax(0,1fr)!important;gap:12px}.form-grid label{font-size:12px;min-width:0}.form-grid label.full{grid-column:auto}
  :is(#view,#dialog,#gateway) :is(input:not([type=checkbox]):not([type=radio]),select,textarea){min-height:46px;font-size:16px}
  .chart{width:100%;overflow-x:auto}.chart svg,.chart canvas{max-width:none}
  .gantt-card{overflow:hidden}.gantt-scroll{max-height:58dvh}.gantt-name{width:112px}.gantt-bar{min-height:26px}
  dialog,#dialog{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important;max-height:calc(100dvh - 10px)!important;border-radius:19px!important}
  dialog #entity-form,#dialog #entity-form{max-height:calc(100dvh - 10px);padding:0;overflow:hidden}
  dialog .modal-head{padding:17px 16px 14px;margin:0}.modal-head h2{font-size:19px}
  dialog #form-fields,#dialog #form-fields{padding:16px;overflow:auto;min-height:0}.modal-actions{padding:12px 16px 16px;background:#fff}.modal-actions .btn{flex:1 1 130px}
  #dialog.purchase-request-dialog{max-height:calc(100dvh - 10px)!important}.purchase-request-dialog #entity-form{max-height:calc(100dvh - 10px)}.purchase-request-dialog #form-fields{padding:14px}.purchase-request-dialog .purchase-request-mode{grid-template-columns:1fr}.purchase-request-dialog .purchase-mode-option{min-height:66px}.purchase-request-dialog .purchase-source-card{padding:14px}.purchase-request-dialog .purchase-source-head h3{font-size:16px}.purchase-request-dialog .purchase-source-head p{font-size:11px}.purchase-request-dialog .purchase-catalog-missing{align-items:stretch;flex-direction:column}.purchase-request-dialog .purchase-catalog-missing .btn{width:100%}
  .rfq-dialog,.rfq-edit-dialog,.lifecycle-dialog,.monthly-budget-dialog{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important}.rfq-dialog #form-fields,.rfq-edit-dialog #form-fields,.monthly-budget-dialog #form-fields{padding:14px}.rfq-quote-list,.rfq-add-grid,.order-grid{grid-template-columns:minmax(0,1fr)!important}
  .setup-final-progress{grid-template-columns:repeat(2,minmax(0,1fr))!important}.setup-identity-main{grid-template-columns:minmax(0,1fr)!important}.setup-final-actions{flex-direction:column}.setup-final-actions .btn{width:100%}
  .toast{left:10px;right:10px;width:auto;max-width:none;bottom:calc(10px + env(safe-area-inset-bottom));font-size:11px}
}
@media(max-width:390px){
  .content{padding-inline:9px}.topbar{padding-inline:7px}.top-actions .user-chip{max-width:92px}.quick-actions{grid-template-columns:minmax(0,1fr)}.mobile-card-table td{grid-template-columns:minmax(0,42%) minmax(0,1fr)}
  .purchase-request-dialog .modal-actions{flex-direction:column}.purchase-request-dialog .modal-actions .btn{width:100%}
}

/* Phone touch and safe-area refinements. */
@media (max-width:760px){
  body{overscroll-behavior-x:none;-webkit-text-size-adjust:100%}
  .workspace,.main,.content,#view{isolation:isolate}
  .content{scrollbar-gutter:stable;overflow-wrap:anywhere}
  .topbar{padding-top:max(8px,env(safe-area-inset-top));padding-bottom:8px}
  .top-start #menu-toggle{display:grid;place-items:center;flex:none}
  .top-actions .user-chip{min-width:0;flex:0 1 auto}
  .card-head,.panel-head,.list-head,.toolbar-head{gap:9px;flex-wrap:wrap;min-width:0}
  .card-head > *, .panel-head > *, .list-head > *, .toolbar-head > *{min-width:0;max-width:100%}
  .action-row,.button-row,.form-actions{display:flex;flex-wrap:wrap;gap:8px;min-width:0}
  .action-row > *, .button-row > *, .form-actions > *{flex:1 1 130px;min-width:0}
  #view table{max-width:100%}
  #view img,.card img,.dashboard-module img{max-width:100%;height:auto}
  input[type=file]{min-height:46px;padding:11px 10px}
  dialog .modal-actions{position:sticky;bottom:0;z-index:2;box-shadow:0 -8px 18px #173f6012}
  .role-connection-graph,.organization-chart,.org-chart,.gantt-board{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
}
@media (pointer:coarse) and (max-width:760px){
  button,.btn,.tiny,.pill-tabs button,nav button{touch-action:manipulation}
  .tiny{min-height:44px;padding-inline:12px}
}
