/* GX Tracking v0.10.71: mobile-only integrity of the selected-device header,
   history scrollport, and Leaflet contextual balloons.
   Presentation-only. No hidden data fields are manufactured. */
@media (max-width:850px) {
  /* The legacy Back button is hidden by the native shell.  Reclaim its grid
     track or the device name is confined to ~40px and becomes "AE1...". */
  html body.tracking-dashboard.gx64-mobile #sidebar.gx64-sheet #deviceInspector > .device-inspector-head {
    display:grid!important;
    grid-template-columns:46px minmax(0,1fr)!important;
    grid-template-rows:auto!important;
    gap:10px!important;
    align-items:center!important;
    width:100%!important;
    box-sizing:border-box!important;
    padding:8px 14px!important;
    min-height:60px!important;
    height:auto!important;
    flex:0 0 auto!important;
  }
  html body.tracking-dashboard.gx64-mobile #sidebar.gx64-sheet #deviceInspectorBack {display:none!important}
  html body.tracking-dashboard.gx64-mobile #sidebar.gx64-sheet #deviceInspector .device-inspector-icon {
    grid-column:1!important;grid-row:1!important;
    width:40px!important;height:40px!important;
  }
  html body.tracking-dashboard.gx64-mobile #sidebar.gx64-sheet #deviceInspector .device-inspector-heading {
    grid-column:2!important;grid-row:1!important;
    display:grid!important;grid-template-columns:minmax(0,1fr)!important;
    gap:3px!important;min-width:0!important;max-width:100%!important;
    width:100%!important;box-sizing:border-box!important;
  }
  html body.tracking-dashboard.gx64-mobile #sidebar.gx64-sheet #deviceInspector .device-inspector-heading strong,
  html body.tracking-dashboard.gx64-mobile #sidebar.gx64-sheet #deviceInspector .device-inspector-heading .muted {
    white-space:normal!important;word-break:normal!important;overflow-wrap:anywhere!important;
    text-overflow:clip!important;overflow:visible!important;max-width:100%!important;
    width:100%!important;display:block!important;
  }
  html body.tracking-dashboard.gx64-mobile #sidebar.gx64-sheet #deviceInspector .device-inspector-heading strong {
    font-size:14px!important;line-height:1.35!important;
  }
  html body.tracking-dashboard.gx64-mobile #sidebar.gx64-sheet #deviceInspector .device-inspector-heading .muted {
    font-size:11px!important;line-height:1.35!important;
  }
  /* The native sheet already scrolls its content.  Old mobile-history rules
     also cap #historyPositionList and create a SECOND scroll area, leaving a
     blank footer beneath cards. Use one continuous scrollport on this view.
     All original cards, batching and event handlers remain intact. */
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #deviceInspector .device-inspector-content {
    display:flex!important;flex-direction:column!important;
    flex:1 1 auto!important;min-height:0!important;overflow:hidden!important;
  }
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #deviceInspector .inspector-panels {
    display:block!important;flex:1 1 auto!important;
    height:auto!important;min-height:0!important;max-height:none!important;
    overflow-x:hidden!important;overflow-y:auto!important;
    overscroll-behavior-y:contain!important;touch-action:pan-y!important;
    -webkit-overflow-scrolling:touch!important;
    padding:3px 12px max(12px,env(safe-area-inset-bottom))!important;
    scroll-behavior:auto!important;overflow-anchor:none!important;
  }
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPanel:not(.hidden) {
    display:block!important;position:static!important;
    height:auto!important;min-height:0!important;max-height:none!important;
    flex:0 0 auto!important;overflow:visible!important;
    margin:0!important;padding:0 0 10px!important;
  }
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPanel .history-list-section {
    display:block!important;height:auto!important;min-height:0!important;
    max-height:none!important;flex:0 0 auto!important;
    overflow:visible!important;margin-top:4px!important;padding:0!important;
  }
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPanel #historyPositionList {
    display:flex!important;flex-direction:column!important;
    height:auto!important;min-height:0!important;max-height:none!important;
    flex:0 0 auto!important;overflow:visible!important;
    padding:0 1px 8px!important;
    contain:none!important;scroll-behavior:auto!important;
  }
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPanel #historyPositionList > .gx-history-card-v01037 {
    flex:0 0 auto!important;max-width:100%!important;
  }
  /* Network selector uses the same period row.  Distribute all five controls
     across the actual width rather than clipping Apple/Android at the edge. */
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPeriodActions:has(> #gxHistoryNetworkFilter) {
    display:grid!important;
    grid-template-columns:minmax(0,.82fr) minmax(0,.91fr) minmax(0,.91fr) minmax(0,1.65fr) minmax(0,1.12fr)!important;
    gap:4px!important;flex-wrap:nowrap!important;
    width:100%!important;min-width:0!important;overflow:visible!important;
  }
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPeriodActions:has(> #gxHistoryNetworkFilter) > button,
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPeriodActions #gxHistoryNetworkFilter {
    min-width:0!important;width:100%!important;max-width:none!important;
    margin:0!important;box-sizing:border-box!important;
    padding:7px 2px!important;
    font-size:clamp(9px,2.7vw,11px)!important;
    text-align:center!important;
  }
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPeriodActions #gxHistoryNetworkFilter {
    padding:0!important;
  }
  html body.tracking-dashboard.gx64-mobile[data-gx64-view="history"] #sidebar.gx64-sheet #historyPeriodActions #gxHistoryNetworkSelect {
    min-width:0!important;max-width:none!important;width:100%!important;
    padding:5px 2px!important;font-size:clamp(9px,2.7vw,11px)!important;
    box-sizing:border-box!important;
  }
  /* Preserve the existing Leaflet popup content and source fields; keep it
     compact and legible, including when the map marker is near the edge. */
  html body.gx64-mobile #map .gx-context-popup .leaflet-popup-content-wrapper {
    max-width:calc(100vw - 24px)!important;
    transform:translateX(var(--gx71-popup-shift-x,0px));
    will-change:transform;
  }
  html body.gx64-mobile #map .gx-context-popup .leaflet-popup-content {
    width:auto!important;min-width:0!important;
    max-width:min(235px,calc(100vw - 40px))!important;
    margin:0!important;
  }
  html body.gx64-mobile #map .gx-context-popup .gx-map-device-popup {
    min-width:0!important;box-sizing:border-box!important;
    padding:9px 11px!important;gap:5px!important;
    overflow-wrap:anywhere!important;
  }
  html body.gx64-mobile #map .gx-context-popup .gx-map-device-popup > strong {
    font-size:13px!important;line-height:1.3!important;
  }
  html body.gx64-mobile #map .gx-context-popup .gx-map-popup-time,
  html body.gx64-mobile #map .gx-context-popup .gx-map-popup-coords,
  html body.gx64-mobile #map .gx-context-popup .gx71-popup-device-label {
    font-size:10.5px!important;line-height:1.4!important;
  }
  html body.gx64-mobile #map .gx-context-popup .gx71-popup-device-label {
    color:var(--muted,#a5b5c5);overflow-wrap:anywhere;
  }
  html body.gx64-mobile #map .gx-context-popup .gx-map-popup-grid {gap:5px!important}
}
