/*
  CENTRAL FLEET SYSTEMS
  CFS_MOBILE_PILOT_FIT_20261004

  Final mobile fit layer for the pilot.
  Scope: <= 900px only. Desktop is intentionally untouched.
*/

@media (max-width:900px){

  html,
  body{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:hidden !important;
    -webkit-text-size-adjust:100%;
  }

  body{
    overscroll-behavior-x:none;
  }

  img,
  video,
  canvas{
    max-width:100% !important;
    height:auto;
  }

  #top,
  main,
  #admin,
  #detail,
  #breakdown,
  #job,
  #driver,
  #garage,
  #recovery,
  #tech,
  #check,
  #vehicleForm,
  #users,
  #platformAdmin,
  .admin-tab-panel,
  .ff-shell-hub,
  .ff2-page{
    box-sizing:border-box !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }

  #admin:not(.hidden){
    display:block !important;
  }

  #adminCalendarHub,
  #adminWorkshopHub,
  #adminDispatchHub,
  #adminAuditHub,
  #adminOperationsHub,
  #adminComplianceHub,
  #adminReportsHub,
  #adminSettingsHub,
  #adminFleetTab,
  #adminBreakdownsTab,
  #adminFinanceTab,
  #adminTeamTab,
  #ff2JobsHub,
  #ff2MoreHub,
  #detail,
  #breakdown,
  #job,
  #garage,
  #recovery,
  #tech,
  #driver,
  #check,
  #vehicleForm,
  #users{
    padding-bottom:
      calc(
        118px +
        env(safe-area-inset-bottom)
      ) !important;
  }

  .card,
  .item,
  .notice,
  .stat,
  .ff-hub-card,
  .ff2-action-card{
    box-sizing:border-box !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-wrap:anywhere;
  }

  h1,
  h2,
  h3,
  p,
  .muted,
  .small{
    max-width:100%;
    overflow-wrap:anywhere;
  }

  h1,
  .ff-page-heading h1,
  .ff-wp-head h1,
  .ff-dispatch-head h1,
  .ff-audit-head h1,
  .ff-report-head h1,
  .ff-calendar-page-head h1{
    font-size:clamp(28px,8vw,36px) !important;
    line-height:1.08 !important;
  }

  .ff-page-head,
  .ff-section-head,
  .ff-wp-head,
  .ff-dispatch-head,
  .ff-audit-head,
  .ff-report-head,
  .ff-calendar-page-head{
    min-width:0 !important;
  }

  .ff-page-head > *,
  .ff-section-head > *,
  .ff-wp-head > *,
  .ff-dispatch-head > *,
  .ff-audit-head > *,
  .ff-report-head > *,
  .ff-calendar-page-head > *{
    min-width:0 !important;
    max-width:100% !important;
  }

  .button,
  button{
    max-width:100%;
  }

  .button{
    white-space:normal !important;
    overflow-wrap:anywhere;
  }

  .actions{
    max-width:100%;
  }

  .actions > .button{
    flex:1 1 140px;
    min-width:0;
  }

  .field,
  input,
  select,
  textarea{
    box-sizing:border-box !important;
    max-width:100% !important;
    min-width:0 !important;
    font-size:16px;
  }

  .row > *,
  .grid > *{
    min-width:0 !important;
  }

  .vehicle,
  .vehicle > *{
    min-width:0 !important;
  }

  .badge{
    max-width:100%;
    overflow-wrap:anywhere;
  }

  .ff-tabs,
  .breakdown-tabs,
  .team-filter-tabs,
  .garage-subtabs{
    max-width:100% !important;
    -webkit-overflow-scrolling:touch;
  }

  .ff-tab,
  .breakdown-tab,
  .garage-tab{
    min-width:0;
  }

  /*
    Workshop Planner
    The old desktop-fit rules at the end of workshop-planner.css
    force five summary cards and seven squeezed days on phones.
    This mobile layer deliberately overrides those rules.
  */

  #adminWorkshopHub,
  #fixFleetWorkshopPlannerContent{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:hidden !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-head{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:12px !important;
    margin-bottom:14px !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-head .button{
    width:100% !important;
    min-height:46px !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-head p{
    margin-bottom:0 !important;
    line-height:1.45 !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-summary{
    display:grid !important;
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
    gap:8px !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-summary
  .ff-wp-stat:last-child{
    grid-column:1 / -1;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-stat{
    min-width:0 !important;
    padding:11px 10px !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-stat-label{
    font-size:9px !important;
    line-height:1.25 !important;
    letter-spacing:.35px !important;
    overflow-wrap:anywhere;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-stat-value{
    font-size:22px !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-toolbar{
    display:grid !important;
    grid-template-columns:
      repeat(3,minmax(0,1fr)) !important;
    gap:7px !important;
    align-items:stretch !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-toolbar
  > .button{
    width:100% !important;
    min-width:0 !important;
    min-height:44px !important;
    padding:10px 5px !important;
    font-size:11px !important;
    line-height:1.2 !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-range-title{
    grid-column:1 / -1 !important;
    grid-row:1 !important;
    width:100% !important;
    min-width:0 !important;
    padding:4px 0 7px !important;
    text-align:left !important;
    font-size:17px !important;
    line-height:1.25 !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-toggle{
    grid-column:1 / -1 !important;
    display:grid !important;
    grid-template-columns:1fr 1fr !important;
    width:100% !important;
    min-width:0 !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-toggle button{
    width:100% !important;
    min-width:0 !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-week{
    display:grid !important;
    grid-template-columns:
      repeat(7,minmax(150px,1fr)) !important;
    gap:8px !important;
    width:100% !important;
    max-width:100% !important;
    overflow-x:auto !important;
    overflow-y:hidden !important;
    scroll-snap-type:x proximity;
    -webkit-overflow-scrolling:touch;
    padding-bottom:10px !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-day{
    min-width:150px !important;
    width:auto !important;
    scroll-snap-align:start;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-day-head{
    padding:9px !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-day-body{
    min-height:150px !important;
    padding:7px !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-lane-head,
  #fixFleetWorkshopPlannerContent .ff-wp-unscheduled-head{
    align-items:flex-start !important;
    flex-wrap:wrap !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-lane-body,
  #fixFleetWorkshopPlannerContent .ff-wp-unscheduled-grid{
    grid-template-columns:1fr !important;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-booking,
  #fixFleetWorkshopPlannerContent .ff-wp-repair{
    min-width:0 !important;
  }

  .ff-wp-modal-backdrop{
    align-items:flex-start !important;
    padding:
      max(10px,env(safe-area-inset-top))
      10px
      max(10px,env(safe-area-inset-bottom)) !important;
  }

  .ff-wp-modal{
    width:100% !important;
    max-width:100% !important;
    max-height:
      calc(
        100dvh -
        20px -
        env(safe-area-inset-top) -
        env(safe-area-inset-bottom)
      ) !important;
    padding:15px !important;
  }

  /*
    Dispatch
  */

  #adminDispatchHub,
  #fixFleetDispatchContent{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }

  .ff-dispatch-head{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:12px !important;
  }

  .ff-dispatch-head-actions{
    width:100% !important;
    display:grid !important;
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
  }

  .ff-dispatch-head-actions .button{
    width:100% !important;
    min-width:0 !important;
  }

  .ff-dispatch-summary{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
    gap:8px !important;
  }

  .ff-dispatch-summary .ff-dispatch-stat:last-child{
    grid-column:1 / -1;
  }

  .ff-dispatch-stat{
    min-width:0 !important;
    padding:11px 10px !important;
  }

  .ff-dispatch-stat-label{
    line-height:1.25 !important;
    overflow-wrap:anywhere;
  }

  .ff-dispatch-toolbar{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:8px !important;
  }

  .ff-dispatch-range{
    width:100% !important;
    min-width:0 !important;
    text-align:left !important;
  }

  .ff-dispatch-toggle{
    display:grid !important;
    grid-template-columns:
      repeat(3,minmax(0,1fr)) !important;
    width:100% !important;
  }

  .ff-dispatch-toggle button{
    min-width:0 !important;
    padding:9px 5px !important;
    font-size:11px !important;
  }

  .ff-dispatch-columns{
    grid-template-columns:1fr !important;
  }

  .ff-dispatch-allocation-top{
    flex-direction:column;
    align-items:flex-start;
  }

  .ff-dispatch-week{
    grid-template-columns:
      repeat(7,minmax(150px,1fr)) !important;
    max-width:100% !important;
    overflow-x:auto !important;
    -webkit-overflow-scrolling:touch;
    scroll-snap-type:x proximity;
  }

  .ff-dispatch-day{
    min-width:150px !important;
    scroll-snap-align:start;
  }

  .ff-dispatch-modal-backdrop{
    align-items:flex-start !important;
    padding:
      max(10px,env(safe-area-inset-top))
      10px
      max(10px,env(safe-area-inset-bottom)) !important;
  }

  .ff-dispatch-modal{
    width:100% !important;
    max-width:100% !important;
    padding:15px !important;
  }

  /*
    Audit Trail
  */

  #adminAuditHub,
  #fixFleetAuditContent{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }

  .ff-audit-head{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:12px !important;
  }

  .ff-audit-actions{
    width:100% !important;
  }

  .ff-audit-actions .button{
    flex:1 1 140px;
    min-width:0 !important;
  }

  .ff-audit-summary{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
    gap:8px !important;
  }

  .ff-audit-summary .ff-audit-stat:last-child{
    grid-column:1 / -1;
  }

  .ff-audit-stat{
    min-width:0 !important;
    padding:11px !important;
  }

  .ff-audit-filters{
    grid-template-columns:1fr !important;
  }

  .ff-audit-panel,
  .ff-audit-table-wrap{
    max-width:100% !important;
  }

  .ff-audit-table-wrap{
    -webkit-overflow-scrolling:touch;
  }

  .ff-audit-modal-backdrop{
    align-items:flex-start !important;
    padding:
      max(10px,env(safe-area-inset-top))
      10px
      max(10px,env(safe-area-inset-bottom)) !important;
  }

  .ff-audit-modal{
    width:100% !important;
    max-width:100% !important;
    padding:15px !important;
  }

  /*
    Fleet Diary / Calendar
  */

  #adminCalendarHub,
  #fixFleetCalendarContent{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }

  .ff-calendar-page-head{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:10px !important;
  }

  .ff-calendar-summary{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
    gap:8px !important;
  }

  .ff-calendar-toolbar{
    grid-template-columns:1fr !important;
    gap:9px !important;
    padding:11px !important;
  }

  .ff-calendar-toolbar h2{
    order:-1;
    text-align:left !important;
    font-size:21px !important;
  }

  .ff-calendar-move,
  .ff-calendar-view-buttons{
    max-width:100% !important;
    overflow-x:auto !important;
    -webkit-overflow-scrolling:touch;
  }

  .ff-calendar-move .button,
  .ff-calendar-view-buttons .button{
    flex:0 0 auto;
  }

  .ff-calendar-scroll{
    width:100% !important;
    max-width:100% !important;
    overflow-x:auto !important;
    -webkit-overflow-scrolling:touch;
  }

  .ff-calendar-list-group{
    padding:12px !important;
  }

  .ff-calendar-event{
    min-width:0 !important;
  }

  /*
    Reports
  */

  #adminReportsHub,
  #fixFleetReportsContent{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }

  .ff-reports-grid{
    grid-template-columns:1fr !important;
  }

  .ff-report-card{
    min-width:0 !important;
    grid-template-columns:42px minmax(0,1fr) auto !important;
    gap:10px !important;
    padding:14px !important;
  }

  .ff-report-head{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:10px !important;
  }

  .ff-report-actions{
    width:100% !important;
    flex-wrap:wrap !important;
  }

  .ff-report-actions .button{
    flex:1 1 140px;
    min-width:0 !important;
  }

  .ff-report-summary{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
  }

  .ff-report-table-scroll{
    width:100% !important;
    max-width:100% !important;
    overflow-x:auto !important;
    -webkit-overflow-scrolling:touch;
  }

  /*
    Settings / More
  */

  #adminSettingsHub,
  #fixFleetSettingsMenu,
  .ff-settings-page-card{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }

  .ff-settings-grid,
  .ff-settings-two{
    grid-template-columns:1fr !important;
  }

  .ff-settings-card{
    min-width:0 !important;
    grid-template-columns:42px minmax(0,1fr) auto !important;
    gap:10px !important;
    padding:14px !important;
  }

  .ff-settings-page-card{
    padding:16px !important;
  }

  .ff-setting-inline{
    grid-template-columns:1fr !important;
  }

  .ff-settings-info-row,
  .ff-integration-card{
    min-width:0 !important;
    align-items:flex-start !important;
    flex-direction:column !important;
  }

  /*
    Performance / fleet detail summaries
  */

  .ff-performance-shell{
    max-width:100% !important;
    min-width:0 !important;
    padding:15px !important;
  }

  .ff-performance-grid{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
    gap:8px !important;
  }

  .ff-performance-card{
    min-width:0 !important;
    padding:12px !important;
  }

  .ff-performance-heading,
  .ff-performance-form-heading,
  .ff-performance-section-title{
    align-items:flex-start !important;
    flex-direction:column !important;
  }

  .ff-performance-vehicle{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
    gap:9px !important;
  }

  .ff-performance-vehicle-main,
  .ff-performance-vehicle-bottom{
    grid-column:1 / -1 !important;
  }

  .ff-performance-vehicle-bottom,
  .ff-performance-recent-row{
    flex-wrap:wrap !important;
  }

  /*
    Team / driver hours
  */

  .team-summary-grid,
  .driver-hours-summary{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
  }

  .team-member-grid,
  .team-form-grid,
  .team-vehicle-options,
  .driver-hours-grid,
  .driver-hours-form-grid{
    grid-template-columns:1fr !important;
  }

  .team-member-head,
  .driver-hours-head{
    min-width:0 !important;
    flex-wrap:wrap !important;
  }

  .team-role-chip,
  .team-status-chip,
  .driver-hours-chip{
    max-width:100% !important;
    white-space:normal !important;
  }

  /*
    Fleet / vehicle forms / role portals
  */

  #adminFleetTab,
  #fleet,
  #fleetFilterPanel,
  #vehicleForm,
  #users,
  #garage,
  #recovery,
  #tech,
  #driver,
  #check,
  #detail,
  #breakdown,
  #job{
    min-width:0 !important;
    max-width:100% !important;
  }

  .garage-job-card,
  .tech-job-card{
    max-width:100% !important;
    min-width:0 !important;
  }

  .garage-job-card .actions{
    grid-template-columns:1fr !important;
  }

  .garage-subtabs{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
  }

  #tech .workshop-subtabs{
    grid-template-columns:
      repeat(3,minmax(0,1fr)) !important;
  }

  #technicianBreakdownAlerts .breakdown-tabs{
    max-width:100% !important;
  }

  /*
    Driver compliance / overlays / popovers
  */

  #ffDriverCompliancePanel,
  .ff-dc-grid,
  .ff-dc-stat,
  .ff-dc-driver{
    max-width:100% !important;
    min-width:0 !important;
  }

  .ff-dc-grid{
    grid-template-columns:1fr !important;
  }

  .ff-dc-modal{
    align-items:flex-start !important;
    padding:
      max(10px,env(safe-area-inset-top))
      10px
      max(10px,env(safe-area-inset-bottom)) !important;
  }

  .ff-dc-modal-card{
    width:100% !important;
    max-width:100% !important;
    max-height:
      calc(
        100dvh -
        20px -
        env(safe-area-inset-top) -
        env(safe-area-inset-bottom)
      ) !important;
    padding:15px !important;
  }

  #fixFleetNotificationPopover{
    max-width:
      calc(
        100vw -
        16px
      ) !important;
  }

  /*
    Platform admin
  */

  #platformAdmin{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    padding-left:12px !important;
    padding-right:12px !important;
  }

  #cfsAdminControlBar{
    align-items:flex-start !important;
    flex-direction:column !important;
  }

  #cfsAdminInfoStrip{
    grid-template-columns:
      repeat(2,minmax(0,1fr)) !important;
  }

  #cfsExecutiveGrid{
    grid-template-columns:1fr !important;
  }

  /*
    Wide data areas must scroll inside the page rather than
    increasing the viewport width.
  */

  .ff-report-table-scroll,
  .ff-audit-table-wrap,
  .ff-calendar-scroll,
  .ff-wp-week,
  .ff-dispatch-week,
  [class*="table-scroll"]{
    max-width:100% !important;
    overscroll-behavior-x:contain;
  }

  table{
    max-width:none;
  }

  /*
    Floating assistant remains above the fixed mobile nav.
  */

  .ff-ai-launcher{
    bottom:
      calc(
        94px +
        env(safe-area-inset-bottom)
      ) !important;
  }

}

@media (max-width:700px){

  .row{
    grid-template-columns:1fr !important;
  }

  .ff-page-head,
  .ff-section-head{
    align-items:stretch !important;
    flex-direction:column !important;
  }

  .ff-section-head .button{
    width:100% !important;
  }

  .vehicle{
    display:grid !important;
    grid-template-columns:minmax(0,1fr) auto !important;
    align-items:start !important;
  }

}

@media (max-width:430px){

  #cfsAdminInfoStrip{
    grid-template-columns:1fr !important;
  }

  .ff-performance-grid,
  .ff-report-summary{
    grid-template-columns:1fr !important;
  }

  .vehicle{
    grid-template-columns:1fr !important;
  }

  .vehicle > .badge{
    justify-self:start;
  }

  #fixFleetWorkshopPlannerContent .ff-wp-toolbar
  > .button{
    font-size:10px !important;
  }

  #tech .workshop-subtabs{
    grid-template-columns:1fr !important;
  }

}

