/* ============================================================
   GPS Maps Tracker — Dashboard Design System
   Dark theme with glassmorphism, premium aesthetics
   ============================================================ */

/* --- CSS Variables / Design Tokens --- */
:root {
  /* Colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2235;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-glass: rgba(17, 24, 39, 0.65);
  --bg-glass-hover: rgba(26, 34, 53, 0.8);

  --text-primary: #f0f4ff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #22d3ee;
  --accent-cyan-dim: rgba(34, 211, 238, 0.15);
  --accent-green: #34d399;
  --accent-green-dim: rgba(52, 211, 153, 0.15);
  --accent-amber: #fbbf24;
  --accent-amber-dim: rgba(251, 191, 36, 0.15);
  --accent-red: #f87171;
  --accent-red-dim: rgba(248, 113, 113, 0.15);
  --accent-purple: #a78bfa;
  --accent-purple-dim: rgba(167, 139, 250, 0.15);
  --accent-blue: #60a5fa;

  --border-color: rgba(148, 163, 184, 0.12);
  --border-glass: rgba(148, 163, 184, 0.08);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-cyan: 0 0 20px rgba(34, 211, 238, 0.2);
  --shadow-glow-green: 0 0 20px rgba(52, 211, 153, 0.2);

  /* Spacing & Sizing */
  --header-height: 56px;
  --sidebar-width: 340px;
  --reports-width: 320px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.35);
}

/* --- Stats Header Bar --- */
.stats-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border-glass);
}

.stats-bar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-bar__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: white;
  box-shadow: var(--shadow-glow-cyan);
}

.stats-bar__title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

.stats-bar__items {
  display: flex;
  gap: 6px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  min-width: 90px;
  transition: var(--transition-fast);
}

.stat-item:hover {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow-cyan);
}

.stat-item__value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.stat-item--online .stat-item__value { color: var(--accent-green); }
.stat-item--moving .stat-item__value { color: var(--accent-cyan); }
.stat-item--reports .stat-item__value { color: var(--accent-amber); }

.stat-item__label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-bar__actions {
  display: flex;
  gap: 6px;
}

/* --- Buttons --- */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.btn-icon.active {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

/* Endpoint Badge */
.endpoint-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.endpoint-badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-offline);
  transition: var(--transition-fast);
}

.endpoint-badge--online .endpoint-badge__dot {
  background: var(--status-online);
  box-shadow: 0 0 8px var(--status-online);
}

.endpoint-badge--offline .endpoint-badge__dot {
  background: var(--status-offline);
  box-shadow: 0 0 8px var(--status-offline);
}

.endpoint-badge__host {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

/* --- Layout --- */
.layout {
  display: flex;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
  transition: var(--transition-base);
  z-index: 100;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.sidebar__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.sidebar__toggle {
  width: 30px;
  height: 30px;
}

.sidebar-expand {
  display: none;
  position: fixed;
  top: calc(var(--header-height) + 12px);
  left: 12px;
  z-index: 200;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  align-items: center;
  justify-content: center;
}

.sidebar-expand.visible {
  display: flex;
}

.sidebar-expand:hover {
  background: var(--bg-glass-hover);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

/* Search */
.sidebar__search {
  padding: 0 16px 8px;
}

.search-input {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input__icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 13px;
  outline: none;
  transition: var(--transition-fast);
}

.search-input input::placeholder {
  color: var(--text-muted);
}

.search-input input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}

/* Filter Tabs */
.sidebar__filters {
  display: flex;
  gap: 4px;
  padding: 0 16px 12px;
}

.filter-btn {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.filter-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.filter-btn--active {
  color: var(--accent-cyan);
  background: var(--accent-cyan-dim);
  border-color: rgba(34, 211, 238, 0.3);
}

/* Device List */
.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
}

.device-list__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 16px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}

/* Device Card */
.device-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.device-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent-cyan);
  opacity: 0;
  transition: var(--transition-fast);
}

.device-card:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(34, 211, 238, 0.2);
  transform: translateX(2px);
}

.device-card:hover::before {
  opacity: 1;
}

.device-card.active {
  background: var(--accent-cyan-dim);
  border-color: rgba(34, 211, 238, 0.3);
}

.device-card.active::before {
  opacity: 1;
}

.device-card__icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.device-card__icon.offline {
  background: var(--accent-red-dim);
  color: var(--accent-red);
}

.device-card__status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-tertiary);
}

.device-card__status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.device-card__status-dot.offline {
  background: var(--text-muted);
}

.device-card__status-dot.moving {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 4px rgba(34, 211, 238, 0.4); }
  50% { box-shadow: 0 0 12px rgba(34, 211, 238, 0.8); }
}

.device-card__content {
  flex: 1;
  min-width: 0;
}

.device-card__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
}

.device-card__meta-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.device-card__speed {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  white-space: nowrap;
}

.device-card__battery {
  display: flex;
  align-items: center;
  gap: 4px;
}

.battery-bar {
  width: 20px;
  height: 9px;
  border-radius: 2px;
  border: 1.5px solid var(--text-muted);
  position: relative;
  overflow: hidden;
}

.battery-bar::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 5px;
  border-radius: 0 1px 1px 0;
  background: var(--text-muted);
}

.battery-bar__fill {
  height: 100%;
  border-radius: 1px;
  transition: var(--transition-base);
}

.battery-bar__fill.high { background: var(--accent-green); }
.battery-bar__fill.medium { background: var(--accent-amber); }
.battery-bar__fill.low { background: var(--accent-red); }

/* --- Map Container --- */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

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

/* Mapbox/Leaflet controls override */
.mapboxgl-ctrl-top-right,
.mapboxgl-ctrl-bottom-right {
  display: none;
}

/* Custom Map Controls */
.map-controls {
  position: absolute;
  bottom: 24px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.map-control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.map-control-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.map-control-divider {
  height: 1px;
  background: var(--border-color);
  margin: 2px 4px;
}

/* --- Device Panel (bottom of map) --- */
.device-panel {
  position: absolute;
  bottom: 16px;
  left: 16px;
  width: 380px;
  max-width: calc(100% - 32px);
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 16px;
  z-index: 10;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s var(--transition-base);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.device-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.device-panel__name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.device-panel__id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.device-panel__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
}

.panel-stat__icon {
  font-size: 16px;
}

.panel-stat__value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.device-panel__actions {
  display: flex;
  gap: 8px;
}

.panel-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.panel-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.panel-btn--trail:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.panel-btn--trail.active {
  background: var(--accent-cyan-dim);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.panel-btn--center:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

/* --- Reports Panel --- */
.reports-panel {
  width: var(--reports-width);
  min-width: var(--reports-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-glass);
  animation: slideInRight 0.3s var(--transition-base);
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.reports-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-glass);
}

.reports-panel__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.reports-panel__grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reports-panel__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 16px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}

/* Report Card */
.report-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.report-card:hover {
  border-color: var(--accent-amber);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.1);
}

.report-card__image {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.report-card__body {
  padding: 10px 12px;
}

.report-card__device {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-amber);
  margin-bottom: 2px;
}

.report-card__desc {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-card__time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 600px;
  max-width: 90vw;
  max-height: 85vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
}

.modal__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal__body {
  overflow-y: auto;
  max-height: calc(85vh - 60px);
}

.modal__image {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  background: var(--bg-primary);
}

.modal__details {
  padding: 16px 20px;
}

.modal__description {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.6;
}

.modal__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
}

.toast.toast--out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

.toast__icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast--info { border-left: 3px solid var(--accent-cyan); }
.toast--success { border-left: 3px solid var(--accent-green); }
.toast--warning { border-left: 3px solid var(--accent-amber); }
.toast--error { border-left: 3px solid var(--accent-red); }

/* --- Leaflet & OpenStreetMap Customizations --- */
.leaflet-div-icon,
.leaflet-device-marker-wrapper,
.leaflet-report-marker-wrapper {
  background: transparent !important;
  border: none !important;
}

.leaflet-container {
  background: #0a0e1a !important;
  font-family: var(--font-family) !important;
}

.leaflet-control-attribution {
  background: rgba(10, 14, 26, 0.75) !important;
  backdrop-filter: blur(6px) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  border-radius: var(--radius-sm);
  margin: 0 0 4px 4px !important;
  padding: 2px 6px !important;
}

.leaflet-control-attribution a {
  color: var(--accent-cyan) !important;
  text-decoration: none;
}

.marker-device {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: 3px solid rgba(34, 211, 238, 0.3);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.4);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-device::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
}

.marker-arrow {
  position: absolute;
  top: 1px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 7px solid #ffffff;
  pointer-events: none;
  transition: transform 0.3s ease;
}

.marker-device.moving {
  background: var(--accent-cyan);
  animation: marker-pulse 2s infinite;
}

.marker-device.stationary {
  background: var(--accent-green);
  border-color: rgba(52, 211, 153, 0.3);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.4);
}

.marker-device.offline {
  background: var(--text-muted);
  border-color: rgba(100, 116, 139, 0.3);
  box-shadow: 0 0 8px rgba(100, 116, 139, 0.3);
}

.marker-device.selected {
  width: 40px;
  height: 40px;
  border-width: 4px;
  border-color: var(--accent-purple);
  box-shadow: 0 0 24px rgba(167, 139, 250, 0.5);
  z-index: 10;
}

@keyframes marker-pulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.3);
  }
  50% {
    box-shadow: 0 0 24px rgba(34, 211, 238, 0.6);
  }
}

/* Marker label (tooltip below marker) */
.marker-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  pointer-events: none;
}

/* Report Marker */
.marker-report {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-amber);
  border: 3px solid rgba(251, 191, 36, 0.3);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--transition-fast);
}

.marker-report:hover {
  transform: scale(1.2);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

/* --- Map Popup Styles (Leaflet & OpenStreetMap) --- */
.mapboxgl-popup-content,
.leaflet-popup-content-wrapper {
  background: var(--bg-glass) !important;
  backdrop-filter: blur(16px) !important;
  border: 1px solid var(--border-glass) !important;
  border-radius: var(--radius-md) !important;
  padding: 12px 16px !important;
  color: var(--text-primary) !important;
  font-family: var(--font-family) !important;
  box-shadow: var(--shadow-lg) !important;
  min-width: 200px;
}

.mapboxgl-popup-tip {
  border-top-color: var(--bg-glass) !important;
}

.mapboxgl-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 18px !important;
  padding: 4px 8px !important;
}

.mapboxgl-popup-close-button:hover {
  color: var(--text-primary) !important;
  background: transparent !important;
}

.popup-content {
  font-size: 13px;
}

.popup-content__title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--accent-cyan);
}

.popup-content__row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid var(--border-glass);
}

.popup-content__row:last-child {
  border-bottom: none;
}

.popup-content__label {
  color: var(--text-muted);
}

.popup-content__value {
  font-weight: 600;
  color: var(--text-secondary);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .stats-bar__items {
    display: none;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    z-index: 500;
    width: 300px;
    min-width: 300px;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
    width: 300px;
    min-width: 300px;
  }

  .reports-panel {
    position: fixed;
    right: 0;
    top: var(--header-height);
    bottom: 0;
    z-index: 500;
    box-shadow: var(--shadow-lg);
  }

  .device-panel {
    width: calc(100% - 32px);
  }
}

@media (max-width: 480px) {
  .stats-bar__brand .stats-bar__title {
    display: none;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
  }
}
