:root {
  color-scheme: dark;
  --bg: #050507;
  --bg-soft: #09090d;
  --panel: #111116;
  --panel-2: #181820;
  --line: #292932;
  --line-bright: #3a3543;
  --text: #ffffff;
  --muted: #9a9aa8;
  --purple: #8b3dff;
  --purple-2: #bd68ff;
  --green: #20e58b;
  --orange: #ffad20;
  --red: #ff4057;
  --gray: #6f6f7b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --nav-height: 70px;
  --action-height: 60px;
  --network-offset: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 300px;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

html.hold-gesture-active,
html.hold-gesture-active body {
  overflow: hidden;
  overscroll-behavior: none;
}

body.network-banner-visible {
  --network-offset: calc(52px + var(--safe-top));
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="checkbox"],
input[type="range"] {
  min-height: 44px;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #bd68ff88;
  outline-offset: 2px;
}

a {
  color: var(--purple-2);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.mobile-only {
  display: inline-flex;
}

.panel {
  background: linear-gradient(145deg, #15151b, #0d0d12);
  border: 1px solid #24242d;
  border-radius: 18px;
  box-shadow: 0 14px 35px #0005;
}

.primary,
.danger,
.danger-outline,
.secondary,
.ghost-button {
  border-radius: 13px;
  padding: 10px 15px;
  color: var(--text);
}

.primary {
  border: 0;
  background: linear-gradient(135deg, #a84cff, #701cf2);
  font-weight: 800;
}

.danger {
  border: 0;
  background: linear-gradient(135deg, #ff5d68, #d92743);
  font-weight: 800;
}

.danger-outline {
  border: 1px solid #ff405766;
  background: #ff405710;
  color: #ff7d8c;
  font-weight: 750;
}

.secondary {
  border: 1px solid #34343e;
  background: #181820;
}

.ghost-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.icon-button {
  min-width: 44px;
  padding: 8px;
  font-size: 20px;
}

.network-banner {
  position: fixed;
  z-index: 5000;
  inset: 0 0 auto;
  min-height: calc(52px + var(--safe-top));
  padding: calc(8px + var(--safe-top)) max(14px, var(--safe-right)) 8px max(14px, var(--safe-left));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #4a2b08f2;
  border-bottom: 1px solid #ffad2066;
  box-shadow: 0 8px 24px #0008;
  backdrop-filter: blur(16px);
}

.network-banner.syncing {
  background: #25103df2;
  border-bottom-color: #8b3dff77;
}

.network-banner-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #171008;
  background: var(--orange);
  font-weight: 950;
}

.network-banner.syncing .network-banner-icon {
  color: #fff;
  background: var(--purple);
}

.network-banner b,
.network-banner small {
  display: block;
}

.network-banner b {
  font-size: 12px;
}

.network-banner small {
  margin-top: 2px;
  color: #e3d5c2;
  font-size: 10px;
}

.toast {
  position: fixed;
  z-index: 6000;
  left: 50%;
  width: max-content;
  max-width: min(90vw, 500px);
  padding: 11px 16px;
  border: 1px solid #343440;
  border-radius: 14px;
  background: #1b1b23f4;
  color: #fff;
  text-align: center;
  box-shadow: 0 15px 30px #0009;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast-top {
  top: calc(14px + var(--safe-top) + var(--network-offset));
  transform: translate(-50%, -90px);
}

.toast-bottom {
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 14px);
  transform: translate(-50%, 90px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  border-color: #ff405777;
  background: #38131af4;
}

.toast-warning {
  border-color: #ffad2077;
  background: #39280ef4;
}

.toast-success {
  border-color: #20e58b66;
}

.auth-screen {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: calc(24px + var(--safe-top)) max(18px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(18px, var(--safe-left));
  background:
    radial-gradient(circle at 50% 12%, #8b3dff2d, transparent 38%),
    radial-gradient(circle at 8% 92%, #4d17902a, transparent 34%),
    var(--bg);
}

.network-banner-visible .auth-screen {
  padding-top: calc(76px + var(--safe-top));
}

.auth-map-bg {
  position: absolute;
  z-index: -1;
  inset: -10%;
  opacity: 0.2;
  background:
    linear-gradient(32deg, transparent 48%, #8b3dff55 49%, #8b3dff55 50%, transparent 51%) 0 0 / 180px 140px,
    linear-gradient(-26deg, transparent 47%, #77717f38 48%, #77717f38 49%, transparent 50%) 0 0 / 230px 170px,
    repeating-linear-gradient(90deg, transparent 0 74px, #aaa1 75px 76px),
    repeating-linear-gradient(0deg, transparent 0 74px, #aaa1 75px 76px);
  filter: blur(0.2px);
  transform: rotate(-7deg) scale(1.08);
}

.auth-map-bg i {
  position: absolute;
  width: 36vw;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #8b3dffaa, transparent);
  box-shadow: 0 0 18px #8b3dff77;
  transform: rotate(24deg);
}

.auth-map-bg i:nth-child(1) {
  left: 5%;
  top: 30%;
}

.auth-map-bg i:nth-child(2) {
  right: 4%;
  top: 58%;
  transform: rotate(-34deg);
}

.auth-map-bg i:nth-child(3) {
  left: 28%;
  bottom: 13%;
  transform: rotate(8deg);
}

.auth-card {
  width: min(100%, 440px);
  padding: 28px;
  background: #0b0b10e8;
  box-shadow: 0 30px 90px #000d, 0 0 70px #8b3dff1c;
  backdrop-filter: blur(20px);
}

.brand-logo-block {
  display: grid;
  place-items: center;
}

.brand-logo {
  display: block;
  max-width: 100%;
  object-fit: contain;
}

.brand-logo-full {
  width: min(100%, 285px);
  height: 112px;
}

.auth-brand {
  margin-bottom: 22px;
}

.brand-image-fallback {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.brand-image-fallback img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.brand-image-fallback b {
  font-size: 28px;
}

.brand-image-fallback.text-only img {
  display: none;
}

.auth-loading {
  min-height: 190px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 13px;
}

.loading-mark {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.auth-loading i {
  width: 28px;
  height: 28px;
  border: 3px solid #34343f;
  border-top-color: var(--purple-2);
  border-radius: 50%;
  animation: dtrack-spin 0.8s linear infinite;
}

@keyframes dtrack-spin {
  to { transform: rotate(360deg); }
}

.auth-heading {
  text-align: center;
}

.auth-heading h1 {
  margin: 0 0 5px;
  font-size: 25px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label,
.app-dialog label {
  display: grid;
  gap: 7px;
  color: #d7d7df;
  font-size: 12px;
  font-weight: 700;
}

.login-form input,
.app-dialog input,
.app-dialog select,
.device-rename-form input,
.setting select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #34343f;
  border-radius: 13px;
  outline: none;
  background: #09090d;
  color: #fff;
  padding: 11px 13px;
}

.auth-submit {
  min-height: 50px;
  margin-top: 3px;
}

.form-error {
  margin: 0;
  border: 1px solid #ff405755;
  border-radius: 11px;
  background: #ff405714;
  color: #ff8493;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.desktop-sidebar {
  display: none;
}

main {
  max-width: 1500px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: auto;
  padding:
    var(--network-offset)
    max(14px, var(--safe-right))
    calc(var(--nav-height) + var(--action-height) + 66px + var(--safe-bottom))
    max(14px, var(--safe-left));
}

.topbar {
  position: sticky;
  z-index: 900;
  top: 0;
  min-height: calc(64px + var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 calc(-1 * max(14px, var(--safe-right))) 8px calc(-1 * max(14px, var(--safe-left)));
  padding: var(--safe-top) max(14px, var(--safe-right)) 0 max(14px, var(--safe-left));
  background: linear-gradient(#050507 72%, #050507e8 82%, transparent);
}

.mobile-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark-image {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  object-fit: contain;
}

.mobile-brand b {
  font-size: 19px;
}

.header-statuses {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.status-pill {
  max-width: 45vw;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0c0c11e8;
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status-pill i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px currentColor;
}

.status-pill.good i {
  background: var(--green);
}

.network-status i {
  background: var(--orange);
}

.network-status.syncing i {
  background: var(--purple-2);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 2px 16px;
}

.section-head h1 {
  margin: 0 0 4px;
  font-size: clamp(22px, 5vw, 28px);
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.section-actions {
  display: flex;
  gap: 7px;
}

.live-trip-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 11px 12px;
  border-color: #8b3dff55;
  background: linear-gradient(135deg, #251238, #101016 62%);
}

.live-trip-indicator {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ff40571b;
}

.live-trip-indicator i,
.recording-dot,
.eyebrow.recording i,
.device-badge.recording i {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 13px #ff405799;
  animation: dtrack-recording-pulse 1.6s ease-in-out infinite;
}

.live-trip-indicator.disconnected {
  background: #ffad2020;
}

.live-trip-indicator.disconnected i {
  background: var(--orange);
  box-shadow: 0 0 13px #ffad2099;
  animation: none;
}

@keyframes dtrack-recording-pulse {
  50% { opacity: 0.48; transform: scale(0.76); }
}

.live-trip-banner b,
.live-trip-banner span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-trip-banner b {
  font-size: 13px;
}

.live-trip-banner span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.live-trip-banner em {
  grid-column: 3;
  font-size: 9px;
  font-style: normal;
  font-weight: 850;
  color: var(--green);
}

.live-trip-action {
  grid-column: 3;
  grid-row: 1 / span 2;
  min-width: 92px;
  border: 1px solid #a84cff77;
  border-radius: 12px;
  background: #8b3dff25;
  color: #e9d6ff;
  font-size: 11px;
  font-weight: 800;
}

.live-trip-action:not(.hidden) + em {
  display: none;
}

.desktop-overview {
  display: none;
}

.recording-strip {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  padding: 9px 12px;
  border: 1px solid #8b3dff55;
  border-radius: 13px;
  background: linear-gradient(90deg, #2b133c, #111116);
}

.recording-strip span:last-child {
  min-width: 0;
}

.recording-strip b,
.recording-strip small {
  display: block;
}

.recording-strip b {
  font-size: 12px;
}

.recording-strip small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-areas:
    "speed"
    "map"
    "metrics"
    "gps";
  gap: 10px;
  padding-bottom: 8px;
}

.speed-card {
  grid-area: speed;
  position: relative;
  min-height: 260px;
  overflow: hidden;
  padding: 13px 14px 5px;
}

.speed-card-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
}

.context-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid #8b3dff55;
  border-radius: 999px;
  background: #8b3dff1c;
  color: #d8b7ff;
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 800;
}

.limit-row {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.limit-row b {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 3px solid var(--purple);
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
}

.speed-ring {
  position: relative;
  max-width: 390px;
  margin: -9px auto 0;
}

.speed-ring svg {
  display: block;
  width: 100%;
}

.ring-base,
.ring-progress {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.ring-base {
  stroke: #292934;
}

.ring-progress {
  stroke: var(--purple);
  filter: drop-shadow(0 0 6px var(--purple));
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  transition: stroke-dashoffset 0.3s ease, stroke 0.2s ease;
}

.speed-ring.over .ring-progress {
  stroke: var(--red);
  filter: drop-shadow(0 0 7px #ff4057aa);
}

.speed-ring.over .speed-value strong {
  color: #ff687b;
}

.speed-value {
  position: absolute;
  inset: 42% 0 auto;
  text-align: center;
  transform: translateY(-50%);
}

.speed-value span,
.speed-value em {
  display: block;
  color: var(--muted);
  font-style: normal;
}

.speed-value strong {
  display: block;
  font-size: clamp(68px, 19vw, 88px);
  line-height: 0.95;
  letter-spacing: -4px;
}

.speed-warning {
  margin-top: -30px;
  padding-bottom: 10px;
  color: var(--green);
  text-align: center;
  font-size: 13px;
}

.speed-warning.over {
  color: var(--red);
  font-weight: 800;
}

.map-card {
  grid-area: map;
  position: relative;
  height: clamp(230px, 45dvh, 460px);
  min-height: 230px;
  overflow: hidden;
}

.map {
  width: 100%;
  height: 100%;
}

.map-fab {
  position: absolute;
  z-index: 500;
  right: 12px;
  bottom: 12px;
  width: 46px;
  height: 46px;
  border: 1px solid #48434f;
  border-radius: 50%;
  background: #0c0c12e8;
  color: #fff;
  font-size: 23px;
  backdrop-filter: blur(12px);
}

.leaflet-container {
  background: #08080d;
  color: #d6d6df;
}

.map-style-dark .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.58) contrast(1.18) saturate(0.55);
}

.map-style-satellite .leaflet-tile-pane {
  filter: brightness(0.72) contrast(1.08) saturate(0.85);
}

.map-rotated .leaflet-tile-pane,
.map-rotated .leaflet-overlay-pane,
.map-rotated .leaflet-marker-pane,
.map-rotated .leaflet-shadow-pane {
  transition: rotate 0.18s linear;
}

.leaflet-control-attribution {
  border-radius: 7px 0 0 0;
  background: #09090ddb !important;
  color: #aaa !important;
  padding: 2px 5px !important;
  font-size: 8px !important;
}

.leaflet-control-attribution a {
  color: #c58aff !important;
}

.metrics {
  grid-area: metrics;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  min-width: 0;
  padding: 13px;
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 11px;
}

.metric span {
  display: block;
}

.metric b {
  margin-right: 4px;
  font-size: clamp(20px, 6vw, 25px);
}

.gps-panel {
  grid-area: gps;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 13px;
}

.gps-panel > div + div {
  border-left: 1px solid var(--line);
  padding-left: 15px;
}

.gps-panel span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.gps-panel b {
  font-size: 15px;
}

.action-dock {
  position: fixed;
  z-index: 1100;
  right: max(16px, var(--safe-right));
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 10px);
  left: max(16px, var(--safe-left));
}

@media (max-width: 699px) and (orientation: portrait) {
  .map-card {
    height: clamp(230px, calc(45dvh - 24px), 460px);
  }

  .dashboard-grid > .metrics {
    margin-top: calc(var(--action-height) + 12px);
  }
}

.action-btn {
  position: relative;
  width: 100%;
  min-height: var(--action-height);
  overflow: hidden;
  border-radius: 17px;
  padding: 16px;
  box-shadow: 0 14px 34px #000c;
  font-size: 17px;
  font-weight: 850;
}

.action-icon {
  margin-right: 6px;
}

.start-restriction {
  margin: 0;
  min-height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid #34343f;
  border-radius: 15px;
  background: #0c0c11ef;
  color: var(--muted);
  padding: 10px 14px;
  text-align: center;
  font-size: 11px;
  line-height: 1.45;
  box-shadow: 0 14px 34px #000b;
}

.hold-action {
  --hold-progress: 0%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #ff405755;
  background: #351218;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
}

.hold-action .hold-progress {
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: var(--hold-progress);
  background: linear-gradient(90deg, #d92743, #ff4057);
  box-shadow: 0 0 24px #ff405777;
  transition: none;
}

.hold-action.hold-reset .hold-progress {
  transition: width 0.2s ease-out;
}

.hold-action .hold-label {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.mobile-nav {
  position: fixed;
  z-index: 1200;
  inset: auto 0 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid #24242d;
  background: #09090df2;
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  backdrop-filter: blur(18px);
}

.nav-link {
  min-width: 44px;
  min-height: 52px;
  display: grid;
  place-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: #92929e;
}

.nav-link b {
  font-size: 20px;
}

.nav-link span {
  font-size: 10px;
}

.nav-link.active {
  color: var(--purple-2);
}

.nav-link.active b {
  filter: drop-shadow(0 0 7px #8b3dff99);
}

.live-view-layout {
  display: grid;
  gap: 10px;
}

.connection-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-color: #20e58b55;
}

.connection-panel > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-panel > div > i {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 13px #20e58b99;
}

.connection-panel b,
.connection-panel small {
  display: block;
}

.connection-panel b {
  font-size: 13px;
}

.connection-panel small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.connection-panel.disconnected {
  border-color: #ffad2066;
  background: linear-gradient(145deg, #2f210e, #111116);
}

.connection-panel.disconnected > div > i {
  background: var(--orange);
  box-shadow: 0 0 13px #ffad2099;
}

.countdown {
  max-width: 46%;
  color: var(--orange);
  text-align: right;
  font-size: 11px;
  font-weight: 750;
}

.live-map-panel {
  position: relative;
  height: min(55dvh, 540px);
  min-height: 340px;
  overflow: hidden;
}

.live-map-label {
  position: absolute;
  z-index: 500;
  right: 12px;
  bottom: 12px;
  border: 1px solid #393440;
  border-radius: 12px;
  background: #09090dde;
  padding: 8px 10px;
  backdrop-filter: blur(12px);
}

.live-map-label span,
.live-map-label b {
  display: block;
}

.live-map-label span {
  color: var(--muted);
  font-size: 9px;
}

.live-map-label b {
  margin-top: 2px;
  font-size: 10px;
}

.live-data-panel {
  display: grid;
  gap: 9px;
}

.live-device,
.live-speed {
  padding: 15px;
}

.live-device span,
.live-speed span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.live-device b {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.live-speed b {
  font-size: 52px;
}

.live-speed small {
  color: var(--muted);
}

.live-metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.map-layout {
  display: grid;
  gap: 12px;
}

.full-map-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.full-map {
  height: min(65dvh, 700px);
  min-height: 430px;
}

.map-controls {
  position: absolute;
  z-index: 550;
  top: max(12px, var(--safe-top));
  right: max(12px, var(--safe-right));
  display: grid;
  grid-auto-rows: 52px;
  gap: 8px;
}

.map-controls > button,
.map-style-trigger {
  width: 52px;
  height: 52px;
  min-height: 52px;
  margin: 0;
  padding: 0;
  border: 1px solid #47414f;
  border-radius: 14px;
  background: #0a0a10e8;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 7px 18px #0008;
  backdrop-filter: blur(12px);
}

.map-controls > button.active,
.map-controls > button[aria-pressed="true"],
.map-style-trigger[aria-expanded="true"] {
  border-color: var(--purple);
  background: #8b3dff33;
  color: #e8d5ff;
}

.map-style-control {
  position: relative;
  width: 52px;
  height: 52px;
}

.map-style-trigger {
  display: grid;
  place-items: center;
}

.map-style-trigger svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-style-popover {
  position: absolute;
  z-index: 2;
  top: 0;
  right: calc(100% + 10px);
  width: clamp(168px, 52vw, 210px);
  max-width: calc(100vw - max(12px, var(--safe-left)) - max(12px, var(--safe-right)) - 72px);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow: auto;
  border: 1px solid #47414f;
  border-radius: 14px;
  background: #0a0a10f5;
  padding: 6px;
  box-shadow: 0 14px 32px #000c;
  backdrop-filter: blur(16px);
}

.map-style-option {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
}

.map-style-option:hover,
.map-style-option:focus-visible {
  background: #ffffff0d;
}

.map-style-option[aria-checked="true"] {
  background: #8b3dff26;
  color: #e8d5ff;
}

.map-style-check {
  color: var(--purple-2);
  font-size: 18px;
  font-weight: 900;
  opacity: 0;
}

.map-style-option[aria-checked="true"] .map-style-check {
  opacity: 1;
}

.route-summary {
  height: max-content;
  padding: 18px;
}

.route-summary h2 {
  margin: 0 0 5px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.summary-row span {
  color: var(--muted);
}

.history-stats,
.stats-kpis {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-bottom: 12px;
}

.history-stats .panel,
.stats-kpis .panel {
  padding: 15px;
}

.history-stats span,
.stats-kpis span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.history-stats b,
.stats-kpis b {
  font-size: 23px;
}

.filter-summary {
  margin-bottom: 10px;
  border: 1px solid #8b3dff55;
  border-radius: 12px;
  background: #8b3dff16;
  color: #d6b6fb;
  padding: 9px 12px;
  font-size: 11px;
}

.trip-list {
  display: grid;
  gap: 10px;
}

.trip-card {
  min-width: 0;
  overflow: hidden;
}

.trip-open {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 0;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0;
  text-align: left;
}

.trip-thumbnail {
  position: relative;
  min-height: 156px;
  overflow: hidden;
  background: #09090d;
}

.trip-thumbnail canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 156px;
}

.trip-thumbnail > span {
  position: absolute;
  bottom: 7px;
  left: 8px;
  border-radius: 999px;
  background: #09090dc9;
  color: #aaa4b0;
  padding: 3px 7px;
  font-size: 8px;
}

.trip-card-body {
  min-width: 0;
  padding: 12px;
}

.trip-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.trip-title-row > div {
  min-width: 0;
}

.trip-title-row h3 {
  margin: 0 0 4px;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-title-row p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.trip-chevron {
  color: var(--purple-2);
  font-size: 25px;
}

.trip-card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 10px;
  margin-top: 11px;
}

.trip-card-metrics small,
.trip-card-metrics b {
  display: block;
}

.trip-card-metrics small {
  color: var(--muted);
  font-size: 8px;
}

.trip-card-metrics b {
  margin-top: 2px;
  font-size: 11px;
}

.trip-device {
  margin-top: 10px;
  overflow: hidden;
  color: #b8b2c0;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 38px;
  color: var(--muted);
  text-align: center;
}

.empty.compact {
  padding: 18px 8px;
  font-size: 11px;
}

.stats-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
  padding: 10px;
}

.stats-filter button {
  border: 1px solid #34343e;
  border-radius: 11px;
  background: #14141a;
  color: var(--muted);
  padding: 8px 12px;
}

.stats-filter button.active {
  border-color: var(--purple);
  background: #8b3dff25;
  color: #fff;
}

.stats-filter label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.stats-filter input {
  min-height: 40px;
  border: 1px solid #34343e;
  border-radius: 9px;
  background: #09090d;
  color: #fff;
  padding: 7px;
}

.stats-panels {
  display: grid;
  gap: 10px;
}

.chart-panel,
.frequent-panel {
  min-width: 0;
  padding: 15px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-title span {
  color: var(--muted);
  font-size: 9px;
}

#statsDistanceChart {
  display: block;
  width: 100%;
  height: 260px;
}

.frequent-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}

.frequent-row > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #8b3dff22;
  color: var(--purple-2);
  font-weight: 800;
}

.frequent-row b,
.frequent-row small {
  display: block;
}

.frequent-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.device-panel,
.account-panel {
  min-width: 0;
  padding: 16px;
}

.device-list {
  display: grid;
  gap: 9px;
}

.device-list-empty {
  padding: 28px 8px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.device-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0b0b10;
  padding: 11px;
}

.device-item-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #8b3dff1d;
  color: var(--purple-2);
  font-size: 23px;
}

.device-item-main {
  min-width: 0;
}

.device-name-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.device-name-line > b {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: 999px;
  padding: 3px 6px;
  font-size: 8px;
  font-weight: 800;
}

.device-badge.current {
  background: #8b3dff2b;
  color: var(--purple-2);
}

.device-badge.recording {
  background: #ff40571c;
  color: #ff8493;
}

.device-badge.recording i {
  width: 6px;
  height: 6px;
}

.device-item-main small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.device-item-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.device-item-actions button {
  min-width: 44px;
  padding: 7px 8px;
  font-size: 10px;
}

.device-remove {
  border: 1px solid #ff405744;
  border-radius: 11px;
  background: #ff405714;
  color: #ff7b8a;
}

.back-settings {
  width: 100%;
  margin-top: 12px;
  justify-content: center;
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.setting-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.setting-section-head b,
.setting-section-head small {
  display: block;
}

.setting-section-head small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.setting-section-head > span {
  max-width: 45%;
  overflow: hidden;
  color: var(--purple-2);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-rename-form {
  display: grid;
  gap: 8px;
}

.device-rename-form > label {
  color: var(--muted);
  font-size: 11px;
}

.device-rename-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.device-rename-form > small {
  color: var(--muted);
  font-size: 10px;
}

.setting {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
}

.setting > span {
  flex: 1;
  min-width: 0;
}

.setting b,
.setting small {
  display: block;
}

.setting small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.setting input[type="number"] {
  width: 70px;
  min-height: 44px;
  border: 1px solid #34343e;
  border-radius: 10px;
  background: #09090c;
  color: #fff;
  padding: 8px;
}

.setting em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.setting input[type="checkbox"] {
  width: 50px;
  height: 30px;
  flex: 0 0 50px;
  appearance: none;
  position: relative;
  border: 0;
  border-radius: 20px;
  background: #30303a;
  transition: background 0.2s ease;
}

.setting input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.setting input[type="checkbox"]:checked {
  background: var(--purple);
}

.setting input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.setting select {
  width: auto;
  max-width: 132px;
}

.settings-button {
  width: 100%;
  min-height: 50px;
  display: grid;
  place-items: center;
  font-weight: 750;
}

.version-note {
  margin: 22px 0 0;
  color: #70707c;
  text-align: center;
  font-size: 10px;
}

dialog {
  color: #fff;
}

dialog::backdrop {
  background: #000b;
  backdrop-filter: blur(7px);
}

.app-dialog {
  width: min(92vw, 460px);
  border: 1px solid #34343e;
  border-radius: 20px;
  background: #0b0b10;
  padding: 22px;
  box-shadow: 0 26px 80px #000d;
}

.app-dialog form {
  display: grid;
  gap: 14px;
}

.dialog-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dialog-brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.dialog-brand h2,
.dialog-head h2 {
  margin: 0;
}

.dialog-brand p,
.dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.dialog-head,
.fullscreen-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head > div,
.fullscreen-dialog-head > div {
  min-width: 0;
}

.dialog-button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.dialog-button-row button {
  min-height: 48px;
}

.dialog-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border: 1px solid #3b3b45;
  border-radius: 13px;
  background: #15151c;
  color: #fff;
  font-size: 18px;
}

.filter-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px;
}

.filter-presets legend {
  color: var(--muted);
  font-size: 10px;
}

.filter-presets label {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px;
  min-height: 38px;
}

.filter-presets input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--purple);
}

.date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.confirm-dialog {
  text-align: center;
}

.confirm-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #ff405720;
  color: #ff7888;
  font-size: 25px;
  font-weight: 900;
}

.confirm-dialog h2 {
  margin: 0;
}

.confirm-dialog p {
  color: var(--muted);
  line-height: 1.55;
}

.fullscreen-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  inset: 0;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: #0b0b10;
  padding:
    0
    max(12px, var(--safe-right))
    calc(18px + var(--safe-bottom))
    max(12px, var(--safe-left));
}

.fullscreen-dialog-head {
  position: sticky;
  z-index: 900;
  top: 0;
  margin: 0 calc(-1 * max(12px, var(--safe-right))) 10px calc(-1 * max(12px, var(--safe-left)));
  border-bottom: 1px solid #24242d;
  background: #0b0b10f2;
  padding:
    calc(10px + var(--safe-top))
    max(12px, var(--safe-right))
    10px
    max(12px, var(--safe-left));
  backdrop-filter: blur(17px);
}

.fullscreen-dialog-head h2 {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 24px;
}

.fullscreen-dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.eyebrow {
  color: var(--purple-2);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.success {
  color: var(--green);
}

.eyebrow.warning {
  color: var(--orange);
}

.summary-layout {
  display: grid;
  gap: 10px;
}

.summary-map-panel {
  height: min(42dvh, 390px);
  min-height: 280px;
  overflow: hidden;
}

.summary-details {
  display: grid;
  gap: 10px;
}

.summary-reason {
  border: 1px solid #ffad2066;
  border-radius: 13px;
  background: #ffad2013;
  color: #ffc764;
  padding: 11px 13px;
  font-size: 12px;
}

.summary-stats,
.dialog-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.summary-stats .panel,
.dialog-stats .panel {
  padding: 12px;
}

.summary-stats span,
.dialog-stats span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.summary-stats b,
.dialog-stats b {
  font-size: 16px;
}

.summary-meta {
  padding: 5px 14px;
}

.summary-meta > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}

.summary-meta > div:last-child {
  border-bottom: 0;
}

.summary-meta span {
  color: var(--muted);
  font-size: 11px;
}

.summary-meta b {
  max-width: 62%;
  text-align: right;
  font-size: 12px;
}

.summary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-bottom: 4px;
}

.summary-actions button {
  min-height: 48px;
}

.summary-actions .ghost-button {
  grid-column: 1 / -1;
}

.replay-layout {
  display: grid;
  gap: 10px;
}

.replay-map-panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.dialog-map {
  width: 100%;
  height: min(40dvh, 360px);
  min-height: 270px;
}

.replay-map-hud {
  position: absolute;
  z-index: 520;
  top: 9px;
  left: 9px;
  max-width: 49%;
  border: 1px solid #343440;
  border-radius: 15px;
  background: #08080dda;
  padding: 9px 11px;
  box-shadow: 0 10px 24px #0008;
  backdrop-filter: blur(12px);
}

.replay-map-hud > span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.replay-map-hud strong {
  display: block;
  font-size: 28px;
}

.replay-map-hud strong small {
  color: var(--muted);
  font-size: 11px;
}

.replay-map-hud em {
  display: block;
  margin-top: 4px;
  font-size: 9px;
  font-style: normal;
}

.replay-status.over {
  color: var(--red);
}

.replay-status.stopped {
  color: var(--muted);
}

.replay-status.moving {
  color: var(--green);
}

.replay-follow {
  position: absolute;
  z-index: 520;
  top: 9px;
  right: 9px;
  min-height: 44px;
  border: 1px solid #40404b;
  border-radius: 999px;
  background: #0b0b11df;
  color: #aaa;
  padding: 8px 11px;
  backdrop-filter: blur(12px);
}

.replay-follow.active {
  border-color: var(--purple);
  color: #fff;
  box-shadow: 0 0 16px #8b3dff55;
}

.replay-panel {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.replay-controller {
  order: -1;
  padding: 13px;
}

.replay-time-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.replay-time-row b {
  font-size: 20px;
}

.replay-time-row span,
.timeline-labels {
  color: var(--muted);
  font-size: 10px;
}

.replay-timeline input[type="range"] {
  width: 100%;
  accent-color: var(--purple);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
}

.replay-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 9px;
}

.replay-controls button,
.replay-rates button {
  min-width: 52px;
  min-height: 44px;
  border: 1px solid #343440;
  border-radius: 12px;
  background: #14141a;
  color: #fff;
}

.replay-controls button {
  min-width: 76px;
}

.replay-controls .replay-play {
  width: 56px;
  min-width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #a84cff, #701cf2);
  box-shadow: 0 0 20px #8b3dff55;
  font-size: 18px;
}

.replay-rates {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 10px;
}

.replay-rates button {
  color: var(--muted);
  padding: 6px 10px;
}

.replay-rates button.active {
  border-color: var(--purple);
  background: #8b3dff2c;
  color: #fff;
}

.replay-now {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px;
}

.replay-now > div {
  padding: 8px;
}

.replay-now > div + div {
  border-left: 1px solid var(--line);
}

.replay-now span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.replay-now b {
  font-size: 14px;
}

.speed-chart {
  padding: 12px;
}

.speed-chart canvas {
  display: block;
  width: 100%;
  height: 145px;
  cursor: crosshair;
  touch-action: none;
}

.replay-vehicle-wrap {
  border: 0 !important;
  background: transparent !important;
}

.replay-vehicle {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, #bd68ff, #701cf2);
  box-shadow: 0 0 18px #8b3dffaa;
  transform-origin: center;
  transition: transform 0.12s linear;
}

.replay-vehicle svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: #fff;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.dialog-actions button {
  min-height: 50px;
}

@media (min-width: 700px) {
  main {
    padding-right: max(24px, var(--safe-right));
    padding-left: max(24px, var(--safe-left));
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1.15fr;
    grid-template-areas:
      "speed map"
      "metrics metrics"
      "gps gps";
  }

  .speed-card {
    min-height: 380px;
  }

  .map-card {
    height: auto;
    min-height: 380px;
  }

  .metrics {
    grid-template-columns: repeat(4, 1fr);
  }

  .history-stats,
  .stats-kpis {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-kpis {
    grid-template-columns: repeat(4, 1fr);
  }

  .trip-list {
    grid-template-columns: 1fr 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }

  .account-panel {
    grid-column: 1 / -1;
  }

  .live-view-layout {
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
  }

  .connection-panel {
    grid-column: 1 / -1;
  }

  .live-map-panel {
    height: 650px;
  }

  .map-layout {
    grid-template-columns: minmax(0, 2fr) 330px;
  }

  .trip-open {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .summary-layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.75fr);
  }

  .summary-map-panel {
    height: calc(100dvh - 120px - var(--safe-top) - var(--safe-bottom));
    min-height: 600px;
  }

  .summary-actions {
    grid-template-columns: 1fr 1fr;
  }

  .replay-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(340px, 0.8fr);
  }

  .dialog-map {
    height: calc(100dvh - 120px - var(--safe-top) - var(--safe-bottom));
    min-height: 620px;
  }
}

@media (min-width: 1050px) {
  :root {
    --nav-height: 0px;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 258px minmax(0, 1fr);
  }

  .desktop-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid #202027;
    background: #09090d;
    padding: 22px 17px 17px;
  }

  .sidebar-logo {
    min-height: 94px;
    display: grid;
    place-items: center;
    margin-bottom: 15px;
  }

  .sidebar-logo .brand-logo-full {
    width: 210px;
    height: 88px;
  }

  .side-nav {
    display: grid;
    gap: 4px;
  }

  .side-link {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #aaaab4;
    padding: 10px 12px;
    text-align: left;
  }

  .side-link span {
    width: 23px;
    color: #7d7786;
    text-align: center;
  }

  .side-link.active {
    background: #8b3dff20;
    color: #e3caff;
  }

  .side-link.active span {
    color: var(--purple-2);
  }

  .sidebar-account {
    display: grid;
    gap: 4px;
    margin-top: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #0e0e13;
    padding: 12px;
  }

  .sidebar-account > span {
    overflow: hidden;
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-account small {
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-logout {
    min-height: 40px;
    margin-top: 7px;
    border: 1px solid #ff405744;
    border-radius: 10px;
    background: #ff405712;
    color: #ff8493;
    font-size: 10px;
  }

  .side-version {
    margin-top: 10px;
    color: #656570;
    text-align: center;
    font-size: 9px;
  }

  main {
    width: 100%;
    max-width: none;
    padding: var(--network-offset) 28px 50px;
  }

  .topbar,
  .mobile-nav,
  .mobile-only,
  .mobile-drive-dashboard,
  #actionDock {
    display: none !important;
  }

  .desktop-overview {
    display: block;
  }

  .live-trip-banner {
    margin-top: 16px;
  }

  .desktop-overview-section {
    padding-top: 18px;
  }

  .desktop-overview-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
  }

  .desktop-overview-head h2 {
    margin: 4px 0 0;
    font-size: 29px;
  }

  .desktop-overview-head > div:last-child {
    text-align: right;
  }

  .desktop-overview-head > div:last-child span,
  .desktop-overview-head > div:last-child b {
    display: block;
  }

  .desktop-overview-head > div:last-child span {
    color: var(--muted);
    font-size: 10px;
  }

  .desktop-overview-head > div:last-child b {
    margin-top: 4px;
    font-size: 13px;
  }

  .desktop-live-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(330px, 0.65fr);
    gap: 12px;
  }

  .desktop-map-wrap {
    position: relative;
    min-height: 660px;
    overflow: hidden;
  }

  .desktop-live-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .desktop-speed,
  .heartbeat-card {
    grid-column: 1 / -1;
    padding: 20px;
  }

  .desktop-speed span,
  .heartbeat-card span {
    display: block;
    color: var(--muted);
    font-size: 11px;
  }

  .desktop-speed b {
    font-size: 80px;
  }

  .desktop-speed small {
    color: var(--muted);
  }

  .heartbeat-card {
    border-color: #20e58b55;
  }

  .heartbeat-card b {
    display: block;
    margin-top: 5px;
    color: var(--green);
  }

  .heartbeat-card.disconnected {
    border-color: #ffad2066;
  }

  .heartbeat-card.disconnected b {
    color: var(--orange);
  }

  .desktop-idle-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(350px, 0.75fr);
    gap: 12px;
  }

  .desktop-idle-grid .desktop-map-wrap {
    min-height: 640px;
  }

  .map-empty {
    position: absolute;
    z-index: 500;
    inset: 50% auto auto 50%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0b0b10df;
    color: var(--muted);
    padding: 12px 15px;
    transform: translate(-50%, -50%);
  }

  .desktop-periods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .period-card {
    padding: 18px;
  }

  .period-card span,
  .period-card b,
  .period-card small {
    display: block;
  }

  .period-card span,
  .period-card small {
    color: var(--muted);
    font-size: 10px;
  }

  .period-card b {
    margin: 9px 0 4px;
    font-size: 25px;
  }

  .recent-card {
    grid-column: 1 / -1;
    padding: 16px;
  }

  .recent-card .card-title button {
    border: 0;
    background: transparent;
    color: var(--purple-2);
    font-size: 10px;
  }

  .desktop-recent-list {
    display: grid;
  }

  .desktop-recent-list button {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: #fff;
    padding: 8px 0;
    text-align: left;
  }

  .desktop-recent-list b,
  .desktop-recent-list small {
    display: block;
  }

  .desktop-recent-list small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
  }

  .desktop-recent-list em {
    color: #d9baff;
    font-size: 12px;
    font-style: normal;
  }

  .trip-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-panels {
    grid-template-columns: minmax(0, 1.7fr) minmax(310px, 0.7fr);
  }

  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }

  .fullscreen-dialog {
    width: min(96vw, 1360px);
    height: min(94dvh, 940px);
    max-height: 94dvh;
    margin: auto;
    inset: 0;
    border: 1px solid #34343e;
    border-radius: 22px;
    padding: 0 18px 18px;
  }

  .fullscreen-dialog-head {
    margin-right: -18px;
    margin-left: -18px;
    padding: 14px 18px;
  }

  .summary-map-panel,
  .dialog-map {
    height: min(78dvh, 760px);
    min-height: 620px;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  :root {
    --nav-height: 52px;
    --action-height: 50px;
  }

  main {
    padding-right: max(12px, var(--safe-right));
    padding-bottom: calc(var(--nav-height) + var(--action-height) + 34px + var(--safe-bottom));
    padding-left: max(12px, var(--safe-left));
  }

  .topbar {
    min-height: calc(50px + var(--safe-top));
    margin-bottom: 4px;
    padding-right: max(12px, var(--safe-right));
    padding-left: max(12px, var(--safe-left));
  }

  .brand-mark-image {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .mobile-brand b {
    font-size: 16px;
  }

  .status-pill {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 9px;
  }

  .live-trip-banner {
    margin-bottom: 6px;
    padding: 7px 10px;
  }

  .live-trip-indicator {
    width: 30px;
    height: 30px;
  }

  .recording-strip {
    position: absolute;
    z-index: 20;
    top: calc(4px + var(--safe-top));
    left: calc(39% + 12px);
    max-width: 33%;
    margin: 0;
    padding: 5px 9px;
  }

  .dashboard-grid {
    grid-template-columns: minmax(240px, 0.78fr) minmax(320px, 1.22fr);
    grid-template-areas:
      "speed map"
      "metrics metrics";
    align-items: stretch;
    gap: 7px;
  }

  .speed-card,
  .map-card {
    height: min(54dvh, 235px);
    min-height: 190px;
  }

  .speed-card {
    padding: 7px 10px 2px;
  }

  .speed-card-top {
    min-height: 30px;
  }

  .limit-row span,
  .context-badge {
    display: none;
  }

  .limit-row b {
    width: 32px;
    height: 32px;
    border-width: 2px;
    font-size: 13px;
  }

  .speed-ring {
    width: min(100%, 265px);
    margin-top: -18px;
  }

  .speed-value strong {
    font-size: clamp(52px, 14vh, 70px);
  }

  .speed-warning {
    margin-top: -35px;
    padding-bottom: 3px;
    font-size: 10px;
  }

  .metrics {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-left: calc(39% + 3px);
  }

  .metric {
    padding: 8px 10px;
  }

  .metric b {
    font-size: 17px;
  }

  .metric span,
  .metric small {
    font-size: 8px;
  }

  .gps-panel {
    display: none;
  }

  .action-dock {
    right: calc(61% + max(12px, var(--safe-right)));
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 7px);
    left: max(14px, var(--safe-left));
  }

  .action-btn,
  .start-restriction {
    min-height: var(--action-height);
    padding: 10px;
    font-size: 13px;
  }

  .mobile-nav {
    height: calc(var(--nav-height) + var(--safe-bottom));
  }

  .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
  }

  .nav-link b {
    font-size: 16px;
  }

  .nav-link span {
    font-size: 9px;
  }

  .live-map-panel,
  .full-map {
    height: calc(100dvh - 80px - var(--safe-top) - var(--safe-bottom));
    min-height: 260px;
  }

  .map-controls {
    top: max(7px, var(--safe-top));
    right: max(7px, var(--safe-right));
    grid-template-columns: repeat(3, 52px);
  }

  .map-style-popover {
    top: calc(100% + 8px);
    right: 0;
  }

  .fullscreen-dialog-head {
    padding-top: calc(6px + var(--safe-top));
    padding-bottom: 6px;
  }

  .summary-layout,
  .replay-layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  }

  .summary-map-panel,
  .dialog-map {
    height: calc(100dvh - 74px - var(--safe-top) - var(--safe-bottom));
    min-height: 260px;
  }
}

@media (max-width: 430px) {
  .auth-card {
    padding: 22px 17px;
  }

  .trip-open {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .trip-thumbnail,
  .trip-thumbnail canvas {
    min-height: 168px;
  }

  .connection-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .countdown {
    max-width: none;
    text-align: left;
  }

  .device-rename-form > div {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .live-trip-indicator i,
  .recording-dot,
  .eyebrow.recording i,
  .device-badge.recording i,
  .auth-loading i {
    animation: none !important;
  }
}
