/* GX Tracking Ecosystem v0.10.37 — histórico mobile aprovado.
   Isolado do drawer desktop; não modifica viewport/Leaflet/gestos.
*/
#gxHistorySpeedCycleV01037{display:none}
.gx-history-timeline-v01037{display:contents}
.gx-history-timeline-time{display:none}
@media(max-width:850px){
  /* Cabeçalho contextual e painel escuro da UI existente, sem ação voltar. */
  body.tracking-dashboard .device-inspector.mobile-history-mode #deviceInspectorBack,
  body.tracking-dashboard .device-inspector.mobile-history-mode .inspector-tabs,
  #historyPanel .history-mobile-controls > .inspector-section-head,
  #historyPanel #historyCurrentInfo,
  #historyPanel #historyGeofenceSection{display:none!important}
  body.tracking-dashboard .device-inspector.mobile-history-mode .device-inspector-head{
    gap:10px!important; padding:8px 14px 11px!important;
    border-bottom:1px solid rgba(101,135,167,.29)!important;
  }
  body.tracking-dashboard .device-inspector.mobile-history-mode .device-inspector-heading strong{
    font-size:clamp(15px,3.7vw,18px)!important;line-height:1.25!important;
  }
  body.tracking-dashboard .device-inspector.mobile-history-mode .device-inspector-heading .muted{
    font-size:11px!important;white-space:normal!important;line-height:1.35!important;
  }
  body.tracking-dashboard .device-inspector.mobile-history-mode .device-inspector-icon{
    background:#10375b!important;color:#168cff!important;border-radius:11px!important;
  }
  body.tracking-dashboard #historyPanel{padding:10px 12px 22px!important;}

  /* 4 períodos + seletor condicional Entrack; nunca reservar coluna vazia. */
  body.tracking-dashboard #historyPeriodActions{
    display:flex!important;flex-wrap:wrap!important;gap:6px!important;
    margin:0 0 16px!important;padding:0!important;
    overflow:visible!important;align-items:stretch!important;
  }
  body.tracking-dashboard #historyPeriodActions>button{
    flex:1 1 auto!important;min-width:52px!important;min-height:42px!important;
    margin:0!important;padding:7px 8px!important;white-space:nowrap!important;
    font-size:12px!important;line-height:1.2!important;border-radius:10px!important;
    border:1px solid #29455d!important;background:#0e2131!important;color:#e6eef7!important;
    box-shadow:none!important;
  }
  body.tracking-dashboard #historyPeriodActions>button.active{
    background:#0584f9!important;border-color:#1496ff!important;color:#fff!important;
  }
  body.tracking-dashboard #historyPeriodActions #gxHistoryNetworkFilter{
    display:flex!important;flex:0 1 auto!important;align-items:stretch!important;
    min-height:42px!important;margin:0!important;padding:0!important;
    border:1px solid #29455d!important;border-radius:10px!important;
    background:#0e2131!important;min-width:88px!important;
  }
  body.tracking-dashboard #historyPeriodActions #gxHistoryNetworkFilter label{
    display:flex!important;align-items:center!important;gap:0!important;min-width:0!important;padding:0!important;
  }
  body.tracking-dashboard #historyPeriodActions #gxHistoryNetworkFilter label>span{display:none!important;}
  body.tracking-dashboard #historyPeriodActions #gxHistoryNetworkSelect{
    display:block!important;appearance:auto!important;min-width:86px!important;max-width:124px!important;
    height:100%!important;min-height:40px!important;margin:0!important;
    padding:5px 5px!important;border:0!important;border-radius:10px!important;
    background:transparent!important;color:#e6eef7!important;font-size:12px!important;
  }
  body.tracking-dashboard #historyPeriodActions #gxHistoryNetworkSelect option{color:#152639;background:#fff;}
  body.tracking-dashboard #historyCustom{margin-top:4px!important;margin-bottom:12px!important;}

  /* Playback: único conjunto de 3 círculos. Mantém IDs e listeners originais. */
  body.tracking-dashboard #historyPanel #historyPlayback{
    display:flex!important;flex-direction:column!important;align-items:stretch!important;
    margin:0!important;padding:4px 0 0!important;gap:0!important;
    border:0!important;background:transparent!important;box-shadow:none!important;
  }
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-buttons{
    display:flex!important;justify-content:space-evenly!important;align-items:center!important;
    width:100%!important;gap:12px!important;padding:2px 10px 0!important;
    margin:0!important;visibility:visible!important;
  }
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-buttons>button{
    flex:0 0 58px!important;order:0;display:inline-flex!important;
    width:58px!important;height:58px!important;min-height:58px!important;
    padding:0!important;margin:0!important;border-radius:50%!important;
    border:1px solid #254b68!important;background:#0b1d2d!important;color:#f7fbff!important;
    font-size:18px!important;line-height:1!important;box-shadow:none!important;
    align-items:center!important;justify-content:center!important;
    white-space:nowrap!important;transition:background .13s ease!important;
  }
  body.tracking-dashboard #historyPanel #historyRestartButton{order:1!important;font-size:0!important;}
  body.tracking-dashboard #historyPanel #historyRestartButton::before{
    content:'↶';font-size:35px;font-weight:400;line-height:1;
  }
  body.tracking-dashboard #historyPanel #historyPlayButton{
    order:2!important;flex-basis:78px!important;
    width:78px!important;height:78px!important;min-height:78px!important;
    background:#0585f9!important;border-color:#159bff!important;
    font-size:0!important;box-shadow:0 5px 16px rgba(0,91,196,.20)!important;
  }
  body.tracking-dashboard #historyPanel #historyPlayButton::before{
    content:'▶';font-family:Arial,sans-serif;font-size:34px;line-height:1;margin-left:5px;color:#fff;
  }
  body.tracking-dashboard #historyPanel #historyPlayButton[data-gx-playing="1"]::before{
    content:'Ⅱ';font-size:32px;font-weight:800;margin-left:0;
  }
  body.tracking-dashboard #historyPanel #gxHistorySpeedCycleV01037{order:3!important;display:inline-flex!important;font-size:18px!important;}
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-buttons>button:disabled{
    opacity:.40!important;cursor:not-allowed!important;
  }
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-options,
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-options #historySpeed,
  body.tracking-dashboard #historyPanel #historyPlayback #historyPlaybackTime{
    display:none!important;visibility:hidden!important;max-height:0!important;
    margin:0!important;padding:0!important;
  }
  /* Espaçamento de segurança: margem, nunca um card adicional. */
  body.tracking-dashboard #historyPanel .gx-history-timeline-v01037{
    display:grid!important;grid-template-columns:auto minmax(0,1fr) auto!important;
    width:100%!important;align-items:center!important;gap:10px!important;
    margin:26px 0 13px!important;padding:0 2px!important;
  }
  body.tracking-dashboard #historyPanel .gx-history-timeline-time{
    display:block!important;font-size:11px!important;white-space:nowrap!important;
    color:#c5d8ea!important;font-variant-numeric:tabular-nums!important;
  }
  body.tracking-dashboard #historyPanel .gx-history-timeline-v01037 #historyProgress{
    width:100%!important;min-width:0!important;height:34px!important;
    margin:0!important;padding:0!important;accent-color:#0889ff!important;
    appearance:none!important;background:transparent!important;touch-action:pan-x!important;
  }
  body.tracking-dashboard #historyProgress::-webkit-slider-runnable-track{
    height:7px!important;border-radius:10px!important;
    background:linear-gradient(to right,#0788fe var(--history-progress-pct,0%),#34516c var(--history-progress-pct,0%))!important;
  }
  body.tracking-dashboard #historyProgress::-moz-range-track{
    height:7px!important;border-radius:10px!important;
    background:linear-gradient(to right,#0788fe var(--history-progress-pct,0%),#34516c var(--history-progress-pct,0%))!important;
  }
  body.tracking-dashboard #historyProgress::-webkit-slider-thumb{
    appearance:none!important;width:23px!important;height:23px!important;
    margin-top:-8px!important;border:3px solid #fff!important;border-radius:50%!important;
    background:#087dfa!important;box-shadow:0 1px 5px #001b37!important;
  }
  body.tracking-dashboard #historyProgress::-moz-range-thumb{
    width:19px!important;height:19px!important;border:3px solid #fff!important;
    border-radius:50%!important;background:#087dfa!important;
  }
  /* Lista: rolagem única do painel, cartões de duas linhas e índice fixo na direita. */
  body.tracking-dashboard #historyPanel .history-list-section{
    margin:9px 0 0!important;padding:0!important;border-top:0!important;
  }
  body.tracking-dashboard #historyPanel .history-list-head{
    display:flex!important;align-items:start!important;margin:0 0 10px!important;
    padding:0!important;
  }
  body.tracking-dashboard #historyPanel .history-list-head strong{
    font-size:17px!important;line-height:1.3!important;
  }
  body.tracking-dashboard #historyPanel #historyListMeta{
    margin-top:3px!important;color:#a9c0d6!important;font-size:12px!important;
  }
  body.tracking-dashboard #historyPanel #historyPositionList{
    display:flex!important;flex-direction:column!important;gap:7px!important;
    max-height:none!important;overflow:visible!important;padding:0 1px 8px!important;
    contain:layout style!important;
  }
  body.tracking-dashboard #historyPanel #historyPositionList .gx-history-card-v01037{
    width:100%!important;min-width:0!important;min-height:65px!important;
    display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;
    align-items:center!important;gap:8px!important;padding:9px 10px!important;
    border:1px solid #35566d!important;border-radius:11px!important;
    background:#0e2131!important;color:#e9f4ff!important;
    text-align:left!important;box-shadow:none!important;cursor:pointer;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-v01037.active{
    background:linear-gradient(100deg,#173c5a,#102b42)!important;
    border-color:#0698ff!important;
    box-shadow:inset 0 0 0 1px rgba(15,150,255,.55)!important;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-main-v01037{
    display:flex;flex-direction:column;gap:3px;min-width:0;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-line-v01037{
    display:flex;flex-wrap:nowrap;align-items:center;gap:clamp(8px,2.8vw,17px);
    white-space:nowrap;min-width:0;font-size:clamp(11px,2.8vw,14px);font-weight:700;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-line-v01037 time{
    font-variant-numeric:tabular-nums;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-coords-v01037{
    display:block!important;min-width:0!important;color:#9eb9d1!important;
    font-size:clamp(10px,2.6vw,12px)!important;line-height:1.3!important;
    font-variant-numeric:tabular-nums;white-space:nowrap;
    overflow:hidden;text-overflow:ellipsis;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-right-v01037{
    display:flex;align-items:center;justify-content:flex-end;gap:6px;
    align-self:center;flex-shrink:0;
  }
  body.tracking-dashboard #historyPanel .gx-history-origin-v01037{
    display:inline-flex;align-items:center;gap:1px;color:#e6edf7;
  }
  body.tracking-dashboard #historyPanel .gx-history-origin-v01037 svg{
    height:15px;width:15px;display:block;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-number-v01037{
    display:inline-grid;place-items:center;min-width:45px;max-width:none;
    height:31px;padding:0 7px;border:1px solid #41617d;
    border-radius:20px;color:#dce9f7;font-size:12px;
    font-variant-numeric:tabular-nums;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-v01037.active .gx-history-card-number-v01037{
    background:#078afc;border-color:#079bff;color:#fff;
  }
  body.tracking-dashboard #historyPanel .gx-history-fence-v01037{
    display:inline-grid!important;place-items:center!important;width:26px!important;height:26px!important;
    min-width:26px!important;min-height:26px!important;padding:0!important;
    border-radius:50%!important;font-size:15px!important;line-height:1!important;
    border:1px solid #426783!important;background:#163448!important;color:#8fe6b4!important;
  }
  body.tracking-dashboard #historyPanel .gx-history-fence-v01037.exit{
    color:#ffaf99!important;border-color:#8b5257!important;
  }
  body.tracking-dashboard #historyPanel .gx-history-event-details-v01037{
    grid-column:1/-1;border-top:1px solid #37536a;padding-top:8px;
    color:#cfe0ee;font-size:12px;line-height:1.4;
  }
  body.tracking-dashboard #historyPanel .gx-history-event-details-v01037 div{margin-top:4px;}
  body.tracking-dashboard #historyPanel .gx-history-event-details-v01037 small{
    display:block;color:#96b1ca;font-size:11px;
  }
  body.tracking-dashboard #historyPanel .gx-history-card-v01037:focus-visible,
  body.tracking-dashboard #historyPanel #historyPlayback button:focus-visible{
    outline:2px solid #69bbff!important;outline-offset:2px!important;
  }
}
@media(max-width:359px){
  body.tracking-dashboard #historyPeriodActions>button{font-size:11px!important;padding:6px!important;}
  body.tracking-dashboard #historyPanel .gx-history-card-right-v01037{gap:4px;}
  body.tracking-dashboard #historyPanel .gx-history-card-number-v01037{min-width:37px;padding:0 4px;}
  body.tracking-dashboard #historyPanel .gx-history-card-line-v01037{font-size:10.5px;gap:6px;}
}
@media(max-width:850px){
  /* Depois de ocultar Voltar, a grade precisa liberar a coluna do nome. */
  body.tracking-dashboard .device-inspector.mobile-history-mode .device-inspector-head{
    grid-template-columns:42px minmax(0,1fr)!important;
  }
  body.tracking-dashboard .device-inspector.mobile-history-mode .device-inspector-heading{
    min-width:0!important; width:auto!important;
  }
  /* Sobrescreve a especificidade herdada do botão antigo (texto). */
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-buttons #historyPlayButton,
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-buttons #historyRestartButton{
    font-size:0!important;overflow:hidden!important;
  }
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-buttons #historyPlayButton::before{
    font-size:34px!important;color:#fff!important;
  }
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-buttons #historyRestartButton::before{
    font-size:35px!important;color:#fff!important;
  }
}
@media(max-width:850px){
  body.tracking-dashboard #historyPanel #historyPlayback .history-playback-buttons #historyPlayButton{
    flex:0 0 78px!important;width:78px!important;height:78px!important;min-height:78px!important;
  }
  body.tracking-dashboard #historyPanel #historyPositionList .gx-history-card-right-v01037 .gx-history-card-number-v01037{
    flex:0 0 auto!important;min-width:46px!important;padding:0 7px!important;
  }
  body.tracking-dashboard #historyPanel #historyPlayback .gx-history-timeline-v01037 #historyProgress{
    border:0!important;box-shadow:none!important;outline-offset:4px!important;
  }
}
