/* FleetFlow AI — responsive overrides, widest breakpoint first (loaded last). Tokens and values are documented in DESIGN_TOKENS.md. */

@media (max-width: 1399.98px) {
  .kpi-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 20px; }
  .kpi-sep { display: none; }
  .kpi { padding: 0 24px; border-left: 1px solid var(--ff-border); }
  .kpi:nth-of-type(3n+1) { padding-left: 0; border-left: 0; }
  .layout-form { grid-template-columns: minmax(0, 1fr) 340px; }
  .layout-rail-r { grid-template-columns: minmax(0, 1fr) 320px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-pill { width: 200px; }
  .tabs-ff { max-width: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .dash-grid-top { grid-template-columns: minmax(0, 1fr); }
  .dash-grid-bottom { grid-template-columns: 360px minmax(0, 1fr); }
  .ship-grid { grid-template-columns: minmax(0, 1fr); }
  .dispatch-grid { grid-template-columns: 290px minmax(0, 1fr) 300px; } .map-pop { left: auto !important; right: 56px; }
  .drv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .veh-layout .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cust-row2 { grid-template-columns: minmax(0, 1fr) 320px; }
  .inbox-grid { grid-template-columns: 300px minmax(0, 1fr); } .convo-rail { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
  .analytics-layout { grid-template-columns: minmax(0, 1fr) 360px; } .an-split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1199.98px) {
  body:not(.sidebar-expanded) .sidebar { width: var(--sidebar-w-collapsed); }
  body:not(.sidebar-expanded) .main-panel { margin-left: var(--sidebar-w-collapsed); }
  body:not(.sidebar-expanded) .sb-toggle { left: calc(var(--sidebar-w-collapsed) - 11px); transform: rotate(180deg); }
  body:not(.sidebar-expanded) .sb-brand-name, body:not(.sidebar-expanded) .sb-brand .ai-chip,
  body:not(.sidebar-expanded) .sb-label, body:not(.sidebar-expanded) .sb-value, body:not(.sidebar-expanded) .sb-ask span,
  body:not(.sidebar-expanded) .sb-user > div { display: none; }
  body:not(.sidebar-expanded) .sb-group { position: relative; color: transparent; overflow: hidden; }
  body:not(.sidebar-expanded) .sb-group::before { content: ""; position: absolute; left: 12px; top: 5px; width: 20px; height: 1px; background: var(--ff-border-strong); }
  body:not(.sidebar-expanded) .sb-link { width: 44px; padding: 0; justify-content: center; }
  body:not(.sidebar-expanded) .sb-count { position: absolute; top: 4px; left: 28.5px; min-width: 22px; height: 12px; padding: 0 3px; font-size: 12.5px; line-height: 12px; border-radius: 6px; }
  body:not(.sidebar-expanded) .sb-ask { width: 44px; padding: 0; justify-content: center; }
  body:not(.sidebar-expanded) .sb-user { padding: 4px; width: 44px; justify-content: center; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-rail-r, .layout-form, .layout-rail { grid-template-columns: minmax(0, 1fr); }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .page-head-r { flex-wrap: wrap; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { display: flex; overflow-x: auto; gap: 4px; min-height: 0; }
  .settings-nav a { flex: none; }
  .dash-grid-top, .dash-grid-bottom { grid-template-columns: minmax(0, 1fr); }
  .dash-grid-bottom .map-card { min-height: 280px; }
  .dispatch-grid { grid-template-columns: minmax(0, 1fr); }
  .track-grid { grid-template-columns: 290px minmax(0, 1fr); }
  .route-grid { grid-template-columns: 340px minmax(0, 1fr); }
  .exc-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } .exc-grid { grid-template-columns: minmax(0, 1fr); }
  .veh-layout { grid-template-columns: minmax(0, 1fr); }
  .cust-grid, .cust-row, .cust-row2 { grid-template-columns: minmax(0, 1fr); }
  .agent-layout { grid-template-columns: minmax(0, 1fr); }
  .agents-hero { flex-direction: column; }
  .analytics-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-2col { grid-template-columns: minmax(0, 1fr) !important; } .level-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
  :root { --panel-pad: 16px; }
  .sb-toggle { display: none; }
  .sidebar, body:not(.sidebar-expanded) .sidebar { width: var(--sidebar-w) !important; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--sh-lg); z-index: 1060; }
  body.sidebar-open .sidebar { transform: none; }
  body:not(.sidebar-expanded) .sidebar .sb-label, body:not(.sidebar-expanded) .sidebar .sb-brand-name,
  body:not(.sidebar-expanded) .sidebar .sb-brand .ai-chip, body:not(.sidebar-expanded) .sidebar .sb-value,
  body:not(.sidebar-expanded) .sidebar .sb-ask span, body:not(.sidebar-expanded) .sidebar .sb-user > div { display: initial; }
  body:not(.sidebar-expanded) .sidebar .sb-group { color: var(--ff-ink-3); }
  body:not(.sidebar-expanded) .sidebar .sb-group::before { display: none; }
  body:not(.sidebar-expanded) .sidebar .sb-link { width: auto; padding: 0 12px; justify-content: flex-start; }
  body:not(.sidebar-expanded) .sidebar .sb-count { position: static; min-width: 20px; height: 20px; padding: 0 6px; font-size: 12px; border-radius: 10px; box-shadow: none; }
  body:not(.sidebar-expanded) .sidebar .sb-ask { width: 100%; padding: 0 12px 0 8px; justify-content: flex-start; }
  body:not(.sidebar-expanded) .sidebar .sb-user { width: 100%; justify-content: flex-start; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(17, 17, 19, .25); z-index: 1055; display: none; }
  body.sidebar-open .sidebar-scrim { display: block; }
  .main-panel, body:not(.sidebar-expanded) .main-panel, .sidebar-collapsed .main-panel { margin: 0; border-radius: 0; min-height: 100vh; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; }
  .mobile-bar img { width: 32px; height: 32px; }
  .page-title { font-size: 32px; line-height: 38px; white-space: normal; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 0 16px; border-left: 1px solid var(--ff-border); } .kpi:nth-of-type(odd) { padding-left: 0; border-left: 0; } .kpi:nth-of-type(even) { padding-left: 16px; border-left: 1px solid var(--ff-border); }
  .kpi-value { font-size: 30px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .search-pill { width: 100%; }
  .page-head-r { width: 100%; }
  .table-wrap { overflow-x: auto; }
  .table-ff { min-width: 860px; }
  .tabs-row { flex-wrap: wrap; }
  .tabs-ff { overflow-x: auto; max-width: 100%; }
  .hero-stage .truck { left: 50% !important; transform: translateX(-50%) !important; width: min(100%, 360px) !important; top: 0 !important; }
  .hero-stage .callout { display: none; }
  .hero-top { flex-direction: column; }
  .hero-metrics { text-align: left; }
  .drawer-ff.offcanvas { --bs-offcanvas-width: calc(100vw - 16px); }
  .track-grid { grid-template-columns: minmax(0, 1fr); } .track-map { position: relative; height: 640px; }
  .route-grid { grid-template-columns: minmax(0, 1fr); } .route-map { min-height: 760px; }
  .drv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inbox-grid { grid-template-columns: minmax(0, 1fr); } .convo-rail { display: block; }
}

@media (max-width: 767.98px) {
  .ship-sub { grid-template-columns: minmax(0, 1fr); } .pallets { display: grid; width: max-content; max-width: 100%; overflow-x: auto; }
  .veh-panel { left: 12px; right: 12px; width: auto; top: auto; max-height: 60%; }
  .route-card { left: 12px; right: 12px; width: auto; top: auto; bottom: 12px; }
  .exc-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .level-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stop-panels { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 575.98px) {
  .main-panel { overflow-x: clip; }
  .page-head .monitor-pill { display: none; }
  .page-head-r .btn-ff { flex: 0 1 auto; }
  .kpi-value { font-size: 26px; }
  .ai-banner, .list-row, .inner-ff.d-flex, .card-dark .d-flex, .card-ai .d-flex, .d-flex:has(> .dropdown) { flex-wrap: wrap; }
  .levels { max-width: 100%; overflow-x: auto; }
  .list-row [style*="min-width"] { min-width: 0 !important; }
  .drv-grid, .veh-layout .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .axle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; height: auto; padding-bottom: 13px; }
  .route-track .rt-label:not(.left):not(.right) { display: none; }
  .hero-stage { height: 200px; }
}
