/* style.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #1a1a2e;
  color: #333;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#map {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#info-box {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 20px;
  width: 320px;
  font-size: 14px;
  line-height: 1.2;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

#info-box h3 {
  margin-bottom: 12px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.info-item {
  display: flex;
  flex-direction: column;
  padding: 7px;
  background: rgba(236, 240, 241, 0.6);
  border-radius: 6px;
}

.info-label {
  font-weight: 600;
  color: #34495e;
  font-size: 12px;
  margin-bottom: 4px;
}

.info-value {
  color: #2c3e50;
  font-weight: 500;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-moving {
  background-color: #2ecc71;
  color: white;
}

.status-stopped {
  background-color: #e74c3c;
  color: white;
}

.controls {
  position: absolute;
  top: 15px;
  right: 55px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 12px;
  font-size: 14px;
  line-height: 1.2;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

.control-btn {
  background: rgba(236, 240, 241, 0.6);
  border: none;
  border-radius: 6px;
  padding: 10px 15px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #2c3e50;
}

.control-btn:hover {
  background: #fff;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.control-btn i {
  font-size: 16px;
}

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  background: rgba(255, 255, 255, 0.95);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top: 4px solid #3498db;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

.signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
  margin-top: 5px;
}

.signal-icon {
  font-size: 20px;
  color: #4e637a;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.bar {
  width: 4px;
  background-color: #ddd;
  border-radius: 1px;
}

.bar-1 {
  height: 5px;
}

.bar-2 {
  height: 10px;
}

.bar-3 {
  height: 15px;
}

.bar-4 {
  height: 20px;
}

.snr-good .bar {
  background-color: #2ecc71;
}

.snr-medium .bar {
  background-color: #f39c12;
}

.snr-poor .bar {
  background-color: #e74c3c;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.compass {
  width: 100%;
  height: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 12px 0;
}

.compass-inner {
  position: relative;
  width: 100px;
  height: 100px;
}

.compass-rose {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(45deg, #f5f5f5, #e0e0e0);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.compass-arrow {
  position: absolute;
  top: 10%;
  left: 50%;
  width: 4px;
  height: 40px;
  background-color: #e74c3c;
  transform-origin: bottom center;
  z-index: 2;
  border-radius: 2px;
}

.compass-n,
.compass-e,
.compass-s,
.compass-w {
  position: absolute;
  font-weight: bold;
  color: #2c3e50;
}

.compass-n {
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
}

.compass-e {
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
}

.compass-s {
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
}

.compass-w {
  top: 50%;
  left: 5px;
  transform: translateY(-50%);
}

#device-controls {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 15px;
  width: 340px;
  overflow-y: auto;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

#device-controls h3 {
  margin-bottom: 12px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
}

.device-control-item {
  margin-bottom: 10px;
}

.device-control-item label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #34495e;
}

.device-control-item select,
.device-control-item input {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.device-control-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.device-control-buttons button {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background-color: #3498db;
  color: white;
  cursor: pointer;
  font-weight: 600;
}

.device-control-buttons button:hover {
  background-color: #2980b9;
}

.fleet-selector,
.device-selector {
  margin-bottom: 12px;
}

.fleet-selector select,
.device-selector select {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background-color: rgba(255, 255, 255, 0.9);
}

#graficoWrapper {
  position: absolute;
  bottom: 45px;
  right: 15px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 15px;
  width: 500px;
  height: 180px;
  display: none;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

#graficoVelocidad {
  width: 100% !important;
  height: 100% !important;
  background: rgba(236, 240, 241, 0.6);
}

@media (max-width: 768px) {
  #info-box {
    width: 280px;
    font-size: 13px;
    padding: 15px;
  }

  #device-controls {
    width: 280px;
  }

  #graficoWrapper {
    width: 280px;
  }

  .controls {
    top: auto;
    bottom: 15px;
    right: 15px;
    flex-direction: row;
  }

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

.marker {
  width: 28px;
  height: 28px;
  background-color: #3fb1ce;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  position: relative;
}

.marker::after {
  content: '';
  width: 14px;
  height: 14px;
  margin: 7px 0 0 7px;
  background: white;
  border-radius: 50%;
  position: absolute;
}

#zoom-select {
  width: 100%;
  margin-bottom: 10px;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.zoom-slider {
  margin-bottom: 12px;
}

.zoom-slider label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #34495e;
  font-size: 13px;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.zoom-slider-input {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  outline: none;
  -webkit-appearance: none;
}

.zoom-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3498db;
  cursor: pointer;
}

.zoom-value {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
  color: #2c3e50;
}

.follow-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 6px;
}

.follow-toggle label {
  font-weight: 600;
  color: #34495e;
  font-size: 13px;
}

.switch {
  position: relative;
  margin-left: auto;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: #3498db;
}

input:checked+.slider:before {
  transform: translateX(20px);
}

.marker-tooltip {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #2c3e50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(5px);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
}

.marker-tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid rgba(255, 255, 255, 0.95);
}

#toggle-style {}

.style-indicator {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 10;
}

#tacografo-panel {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 20px;
  width: 320px;
  font-size: 14px;
  line-height: 1.2;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  display: none;
}

#tacografo-panel h3 {
  margin-bottom: 12px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#latencia-panel {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 20px;
  width: 420px;
  font-size: 14px;
  line-height: 1.2;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  display: none;
}

#latencia-panel h3 {
  margin-bottom: 12px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#latencia-panel .device-control-item {
  margin-bottom: 10px;
}

#latencia-panel .device-control-item label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #34495e;
}

#latencia-panel input {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ddd;
}

#latencia-panel .device-control-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

#latencia-panel .device-control-buttons button {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background-color: #3498db;
  color: white;
  cursor: pointer;
  font-weight: 600;
}

#latencia-panel .device-control-buttons button:hover {
  background-color: #2980b9;
}

.latency-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.latency-grid div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.console-box {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: monospace;
  font-size: 12px;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 10px;
}

.latency-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  font-size: 13px;
}

.latency-table th,
.latency-table td {
  border: 1px solid #ddd;
  padding: 4px 6px;
  text-align: center;
}

.latency-table th {
  background: #e9eef3;
  font-weight: bold;
}

.latency-table input[type="number"] {
  width: 70px;
  padding: 2px;
  text-align: right;
}

/* Selector de dispositivos/flotas dentro del panel de latencia */
#config-device-select {
  width: 100%;
  height: 180px;
  padding: 6px;
  border: 1px solid #ccd5dd;
  border-radius: 6px;
  background: #f9fafb;
  font-size: 13px;
  line-height: 1.4;
  color: #222;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
  outline: none;
  resize: vertical;
}

#config-device-select optgroup {
  font-weight: bold;
  color: #2b4a6a;
  padding: 4px 0 2px 0;
  background: #eef3f8;
}

#config-device-select option {
  padding: 2px 6px;
  border-bottom: 1px solid #e0e6ec;
}

/* Dispositivos apagados (disabled) */
#config-device-select option:disabled {
  color: #aaa;
  background: #f2f2f2;
}

#tacografo-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 700px;
  overflow-y: auto;
}

.tacografo-chart {
  background: rgba(236, 240, 241, 0.6);
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  height: 120px;
}

#graficoWrapperHist {
  width: 100%;
  background: #fff;
  border-top: 1px solid #ccc;
  padding: 10px;
  box-sizing: border-box;
}

#sliderHist {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.origen-radios {
  display: flex;
  justify-content: space-around;
  gap: 20px;
  margin-bottom: 10px;
}

.origen-option {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.origen-option input[type="radio"] {
  transform: scale(1.2);
}

.origen-label {
  font-size: 0.75em;
  margin-top: 4px;
  color: #34495e;
}

.flatpickr-day.has-data::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: #2a9d8f;
}

.flatpickr-day.disabled {
  opacity: .35;
}

.flatpickr-disabled {
  pointer-events: none !important;
  opacity: 0.3 !important;
  filter: grayscale(100%);
}

#graficoWrapperHist {
  position: absolute;
  bottom: 15px;
  right: 15px;
  left: auto;
  width: calc(100% - 380px - 30px);
  max-width: 900px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 15px;
  height: 220px;
  display: none;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

#graficoVelocidadHist {
  width: 100% !important;
  height: 150px !important;
}

#sliderHist {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#timeSliderHist {
  width: 70%;
}

#graficoWrapperHist .device-control-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

#graficoWrapperHist .device-control-buttons label {
  margin: 0;
  font-size: 12px;
  white-space: nowrap;
}

#graficoWrapperHist .device-control-buttons select {
  width: 80px;
  padding: 4px;
  font-size: 12px;
}

#graficoWrapperHist .device-control-buttons button {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 12px;
}

#alias-panel {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 20px;
  width: 320px;
  font-size: 14px;
  line-height: 1.2;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  display: none;
  /* oculto por defecto */
}

#alias-panel h3 {
  margin-bottom: 12px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#alias-panel select,
#alias-panel input {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ddd;
  margin-bottom: 10px;
}

#alias-panel button {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: none;
  background-color: #3498db;
  color: white;
  cursor: pointer;
  font-weight: 600;
}

#alias-panel button:hover {
  background-color: #2980b9;
}

#graficoVelocidadHist {
  cursor: ew-resize;
}

#dateRange[style*="pointer-events: none"],
.time-row[style*="pointer-events: none"] {
  filter: grayscale(100%);
}

.maplibregl-canvas-container canvas {
  transition: opacity 0.7s ease;
}

#admin-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* centro absoluto */
  z-index: 100;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 20px;
  width: 900px;
  height: 80vh;
  font-size: 14px;
  line-height: 1.3;
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  display: none;
  overflow-y: auto;
}

#admin-panel h3 {
  margin-bottom: 15px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.adm-controls {
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.adm-btn {
  background: rgba(236, 240, 241, 0.9);
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  color: #2c3e50;
}

.adm-btn:hover {
  background: #fff;
  transform: translateY(-2px);
}

.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}

.adm-table th,
.adm-table td {
  border: 1px solid #ddd;
  padding: 5px 8px;
}

.adm-table th {
  background: rgba(52, 152, 219, 0.15);
  color: #2c3e50;
  font-weight: 700;
}

.adm-mini {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  margin: 0 3px;
}

#adm-apikey-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.45);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  padding: 30px;
  z-index: 300;
  width: 450px;
  max-width: 90%;
  text-align: center;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

#adm-apikey-modal h4 {
  margin-bottom: 20px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 12px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

#adm-apikey-modal .api-key-content {
  text-align: center;
  margin-bottom: 20px;
}

#adm-apikey-modal .api-key-value {
  background: rgba(52, 152, 219, 0.1);
  border: 2px dashed #3498db;
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  word-break: break-all;
  text-align: center;
}

#adm-apikey-modal .api-key-instructions {
  font-size: 13px;
  color: #5d6d7e;
  line-height: 1.5;
  margin: 15px 0;
  text-align: left;
  background: rgba(236, 240, 241, 0.5);
  padding: 12px;
  border-radius: 6px;
}

#adm-apikey-modal .api-key-instructions code {
  background: rgba(52, 152, 219, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  color: #2980b9;
}

#adm-apikey-modal .adm-modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

#adm-apikey-modal button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  min-width: 100px;
}

#adm-apikey-modal .adm-save {
  background-color: #3498db;
  color: white;
}

#adm-apikey-modal .adm-save:hover {
  background-color: #2980b9;
  transform: translateY(-1px);
}

#adm-apikey-modal .adm-cancel {
  background-color: #95a5a6;
  color: white;
}

#adm-apikey-modal .adm-cancel:hover {
  background-color: #7f8c8d;
  transform: translateY(-1px);
}

/* ──────────────────────────────
   RESTAURAR ESTILOS DEL MODAL ADMIN
──────────────────────────────────*/

#adm-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 25px;
  z-index: 200;
  width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  display: none;
  border: 1px solid #e0e0e0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}

#adm-modal h4 {
  margin-bottom: 15px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
}

#adm-modal .adm-field {
  margin-bottom: 15px;
}

#adm-modal label {
  font-weight: 600;
  color: #34495e;
  font-size: 14px;
  display: block;
  margin-bottom: 6px;
}

#adm-modal input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  transition: all 0.3s ease;
}

#adm-modal input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

#adm-modal .adm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}

#adm-modal button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  min-width: 80px;
}

#adm-modal .adm-save {
  background-color: #3498db;
  color: white;
}

#adm-modal .adm-save:hover {
  background-color: #2980b9;
  transform: translateY(-1px);
}

#adm-modal .adm-cancel {
  background-color: #95a5a6;
  color: white;
}

#adm-modal .adm-cancel:hover {
  background-color: #7f8c8d;
  transform: translateY(-1px);
}

/* ──────────────────────────────
   ESTILOS PARA SELECTS EN MODAL (role, status, etc.)
──────────────────────────────────*/

#adm-modal select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: white;
  font-size: 14px;
  color: #2c3e50;
  cursor: pointer;
  transition: all 0.3s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

#adm-modal select:hover {
  border-color: #3498db;
  background-color: #f8f9fa;
}

#adm-modal select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

#adm-modal select option {
  padding: 10px;
  background: white;
  color: #2c3e50;
  font-size: 14px;
}

#adm-modal select option:hover {
  background: #3498db;
  color: white;
}

#adm-modal select option:checked {
  background: #3498db;
  color: white;
}

/* ──────────────────────────────
   ÁRBOL JERÁRQUICO MEJORADO (DENTRO DEL MODAL)
──────────────────────────────────*/

#adm-modal .tree-wrapper {
  border: 1px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  padding: 12px 15px;
  max-height: 250px;
  overflow-y: auto;
  font-size: 14px;
  color: #2c3e50;
  margin-top: 5px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

#adm-modal .tree-root,
#adm-modal .tree-branch {
  list-style: none;
  margin: 0;
  padding-left: 20px;
  position: relative;
}

/* Líneas verticales entre hijos */
#adm-modal .tree-branch::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  border-left: 1px solid #e0e0e0;
}

/* Flechas y etiquetas */
#adm-modal .tree-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 6px 8px;
  user-select: none;
  transition: all 0.2s ease;
  border-radius: 6px;
  margin: 2px 0;
  min-height: 32px;
}

#adm-modal .tree-label:hover {
  background-color: #f8f9fa;
  transform: translateX(2px);
}

#adm-modal .tree-toggle {
  margin-right: 8px;
  font-size: 14px;
  color: #7f8c8d;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 18px;
  text-align: center;
  font-weight: bold;
}

#adm-modal .tree-toggle:hover {
  color: #3498db;
  transform: scale(1.2);
}

/* Checkbox mejorado */
#adm-modal .tree-label input[type="checkbox"] {
  margin-right: 8px;
  transform: scale(1.2);
  accent-color: #3498db;
  cursor: pointer;
}

/* Texto de las etiquetas */
#adm-modal .tree-label span:last-child {
  padding-left: 4px;
  font-size: 14px;
  font-weight: 500;
  flex: 1;
}

/* Texto resaltado al seleccionar */
#adm-modal .tree-label input[type="checkbox"]:checked+span {
  font-weight: 600;
  color: #2980b9;
}

/* Transición suave para expandir/contraer */
#adm-modal .tree-branch {
  overflow: hidden;
  transition: all 0.3s ease-out;
}

/* Nodo raíz sin padding izquierdo */
#adm-modal .tree-root {
  padding-left: 0;
}

/* Scrollbar para el árbol */
#adm-modal .tree-wrapper::-webkit-scrollbar {
  width: 8px;
}

#adm-modal .tree-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

#adm-modal .tree-wrapper::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

#adm-modal .tree-wrapper::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ──────────────────────────────
   ESTILOS PARA CAMPOS DESHABILITADOS
──────────────────────────────────*/

#adm-modal input:disabled {
  background-color: #f8f9fa;
  color: #6c757d;
  cursor: not-allowed;
  opacity: 0.7;
}

#adm-modal select:disabled {
  background-color: #f8f9fa;
  color: #6c757d;
  cursor: not-allowed;
  opacity: 0.7;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

#adm-modal select[multiple] {
  min-height: 120px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ccc;
}

#adm-modal optgroup {
  font-weight: 600;
  color: #2c3e50;
  background: rgba(52, 152, 219, 0.05);
}

#adm-modal option {
  padding-left: 10px;
  color: #34495e;
}

/* Botón de cierre del panel admin */
.adm-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.adm-close-btn {
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  font-size: 15px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease;
}

.adm-close-btn:hover {
  background: #c0392b;
}

/* Ordenamiento de columnas */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.sort-arrow {
  font-size: 10px;
  margin-left: 4px;
  color: #555;
}

th.sortable:hover {
  background: rgba(52, 152, 219, 0.15);
}

/* ──────────────────────────────
   COLUMNA ORDENADA ACTIVAMENTE
──────────────────────────────────*/
.adm-table th.active-sort {
  background: rgba(52, 152, 219, 0.15);
  color: #2c3e50;
}

.adm-table td.active-sort {
  background: rgba(52, 152, 219, 0.07);
}

.adm-btn i {
  margin-right: 6px;
  color: #2c3e50;
}

/* Estilos para la tabla de conflictos */
#admin-panel .adm-table td {
  vertical-align: top;
}

#admin-panel .adm-table td:nth-child(1) {
  text-transform: capitalize;
  font-weight: 600;
}

#admin-panel .adm-table td:nth-child(4) {
  color: #c0392b;
}

/* ===================== GEOVALLA PANEL (ajustado a 600px) ===================== */

#geovalla-panel {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 18px;
  width: 650px;
  font-size: 14px;
  line-height: 1.4;
  backdrop-filter: blur(6px);
  transition: all 0.3s ease;
  display: none;
  max-height: 90vh; /* nunca más alto que la ventana */
  overflow: hidden;
}

#geovalla-panel h3 {
  margin-bottom: 12px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* selector múltiple */
#geofence-device-select {
  width: 100%;
  height: 160px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background-color: rgba(255, 255, 255, 0.9);
  margin-bottom: 10px;
  padding: 6px;
  font-size: 13px;
}

/* tabla de zonas */
.geo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  overflow: hidden;
}

/* columnas con ancho definido */
.geo-table .col-nombre  { width: 30%; }
.geo-table .col-lat     { width: 18%; }
.geo-table .col-lon     { width: 18%; }
.geo-table .col-enter   { width: 10%; }
.geo-table .col-exit    { width: 10%; }
.geo-table .col-accion  { width: 14%; }

/* inputs dentro de celdas */
.geo-table input {
  width: 95%;
  padding: 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-align: center;
  font-size: 12px;
}

.geo-table .geo-btn i {
  pointer-events: none;
  font-size: 13px;
}

.geo-table th,
.geo-table td {
  border: 1px solid #ccc;
  padding: 6px;
  text-align: center;
}

.geo-table th {
  background: #3498db;
  color: white;
  font-weight: 600;
}

.geo-table tr:nth-child(even) {
  background: rgba(240, 240, 240, 0.9);
}

/* botones */
.geo-btn {
  padding: 5px 8px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.geo-btn-map {
  background-color: #3498db;
  color: white;
}

.geo-btn-map:hover {
  background-color: #2980b9;
}

.geo-btn-delete {
  background-color: #e74c3c;
  color: white;
}

.geo-btn-delete:hover {
  background-color: #c0392b;
}

/* estado habilitado/deshabilitado */
.geo-btn-disabled,
.geo-btn-enabled {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  color: white;
  cursor: pointer;
}

.geo-btn-disabled {
  background-color: #bbb;
}

.geo-btn-enabled {
  background-color: #2ecc71;
}

.geo-btn-enabled.sending,
.geo-btn-disabled.sending {
  opacity: 0.6;
  animation: pulse 0.5s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

/* botones inferiores */
#geovalla-panel .device-control-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

#geovalla-panel .device-control-buttons button {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background-color: #3498db;
  color: white;
  cursor: pointer;
  font-weight: 600;
}

#geovalla-panel .device-control-buttons button:hover {
  background-color: #2980b9;
}

#geovalla-panel .device-control-buttons .danger {
  background-color: #e74c3c;
}

#geovalla-panel .device-control-buttons .danger:hover {
  background-color: #c0392b;
}

/* consola inferior */
#geo-console {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: monospace;
  font-size: 12px;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 10px;
}

/* Estados de arrastre */
.center-marker.dragging .center-dot {
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.handle-marker.dragging .handle-icon {
  transform: scale(1.2);
  background: #065a9c;
  animation: none;
}

/* Efectos de hover adicionales */
.center-marker:hover .center-dot {
  transform: translate(-50%, -50%) scale(1.1);
}

/* Responsive para móviles */
@media (max-width: 768px) {
  .center-marker {
    width: 40px;
    height: 40px;
  }
  
  .center-dot {
    width: 20px;
    height: 20px;
  }
  
  .handle-icon {
    width: 32px;
    height: 32px;
  }
}

/* === Panel de Lugares === */
#places-panel {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 18px;
  width: 650px;
  font-size: 14px;
  line-height: 1.4;
  backdrop-filter: blur(6px);
  transition: all 0.3s ease;
  display: none;
  max-height: 90vh;
  overflow: hidden;
}

#places-panel h3 {
  margin-bottom: 12px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.places-tabs-container {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  margin-top: 10px;
}

.place-tab {
  flex: 1;
  background: linear-gradient(to bottom, #fefefe, #eaeaea);
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 6px 0;
  font-weight: 600;
  color: #333;
  transition: all 0.2s ease;
}

.place-tab i {
  margin-right: 6px;
  font-size: 14px;
}

.place-tab:hover {
  background: #f5f9ff;
  border-color: #7cb0ff;
}

.place-tab.active {
  background: #2b7de9;
  color: #fff;
  border-color: #2b7de9;
}

#places-output table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#places-output th, #places-output td {
  border-bottom: 1px solid #ccc;
  padding: 6px;
  text-align: left;
}

#places-output th {
  background: #f0f0f0;
  font-weight: bold;
}

#places-output td button {
  margin-right: 4px;
}

.places-controls {
  text-align: center;
  margin-top: 8px;
}

.adm-modal .adm-form input {
  width: 100%;
  padding: 4px;
  margin-bottom: 6px;
}

.places-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.places-filters {
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.filter-row select {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #f9f9f9;
  font-size: 13px;
}

#places-save-map {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: #27ae60;
  color: white;
}
#places-save-map:hover {
  background: #219150;
}

.geo-actions button {
  margin-right: 4px;
}
.geo-actions i {
  font-size: 13px;
}

#places-save-zone {
  display: none;
  width: 100%;
  margin-top: 10px;
  background: #27ae60;
  color: white;
  font-weight: 600;
}
#places-save-zone:hover {
  background: #219150;
}

#search-company, #search-fleet {
  padding: 5px 8px;
  border: 1px solid #aaa;
  border-radius: 5px;
  font-size: 13px;
  background: rgba(255,255,255,0.85);
  outline: none;
  transition: border-color 0.2s;
}
#search-company:focus, #search-fleet:focus {
  border-color: #3498db;
}

.geo-actions .adm-mini.active {
  background: #3498db;
  color: white;
  border-color: #2980b9;
}
.geo-actions .adm-mini.active:hover {
  background: #2980b9;
}
.geo-actions .adm-mini {
  margin: 0 2px;
}

#places-zone-tools {
  justify-content: center;
  padding: 6px;
  background: rgba(255,255,255,0.9);
  border-top: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
#places-zone-tools .adm-mini.active {
  background: #3498db;
  color: #fff;
  border-color: #2980b9;
}
#places-zone-tools .adm-mini {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 8px;
}

#places-zone-tools .danger {
  background: #e74c3c;
  color: #fff;
  border-color: #c0392b;
}
#places-zone-tools .danger:hover {
  background: #c0392b;
}

.geo-table tbody tr {
  cursor: pointer;
  transition: background 0.2s ease;
}

.geo-table tbody tr:hover {
  background-color: rgba(52, 152, 219, 0.1);
}

.geo-table tbody tr.selected {
  background-color: rgba(52, 152, 219, 0.3);
  font-weight: 600;
}

/* === Panel superior de Rutas === */
.routes-panel {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 10px 16px;
  width: 90%;
  max-width: 800px;
  color: #222;
  font-family: 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.2;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

.routes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.routes-header h3 {
  margin: 0;
  font-size: 16px;
}
.routes-close-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
}
.routes-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.routes-controls label {
  font-size: 13px;
}
.routes-controls select {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #ccc;
  min-width: 120px;
}

.mapboxgl-popup.marker-tooltip .mapboxgl-popup-content,
.maplibregl-popup.marker-tooltip .maplibregl-popup-content {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  z-index: 10;
  transition: all 0.3s ease;
  border-radius: 10px;
  padding: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #222;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.maplibregl-popup.marker-tooltip .maplibregl-popup-tip {
  display: none; /* oculta la flecha */
}
