* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, Arial, sans-serif;
  background: #111827;
  color: #f9fafb;
}

.container {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 16px;
}

h1,
h2 {
  margin-bottom: 12px;
}

.section-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  background: #1f2937;
  color: #f9fafb;
  border: 1px solid #374151;
}

.vehicles-section-toggle {
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.vehicles-section-title {
  display: block;
  width: 100%;
}

.vehicles-section-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.delete-all-vehicles-button,
.save-vehicle-list-button {
  border-radius: 999px;
  padding: 6px 12px;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

.delete-all-vehicles-button {
  background: #ef4444;
}

.save-vehicle-list-button {
  background: #22c55e;
}

.sort-by-distance-button {
  border-radius: 999px;
  padding: 6px 12px;
  background: #3b82f6;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

.sort-by-distance-button:hover,
.sort-by-distance-button:focus-visible,
.save-vehicle-list-button:hover,
.save-vehicle-list-button:focus-visible,
.delete-all-vehicles-button:hover,
.delete-all-vehicles-button:focus-visible {
  filter: brightness(1.08);
  outline: 2px solid #fecaca;
  outline-offset: 2px;
}

.sort-by-distance-button[aria-disabled="true"] {
  cursor: wait;
  filter: grayscale(0.35);
  opacity: 0.75;
}

.delete-all-vehicles-button[hidden] {
  display: none;
}

.section-toggle-icon {
  margin-left: auto;
}

.vehicles-section-controls .section-toggle-icon {
  margin-left: 0;
}

.section-toggle[aria-expanded="true"] .section-toggle-icon {
  transform: rotate(180deg);
}

.vehicle-list[hidden],
.saved-lists[hidden],
.map-card[hidden] {
  display: none;
}

.card,
.vehicle-card,
.saved-list-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

form {
  display: grid;
  gap: 12px;
}

input,
textarea,
button {
  width: 100%;
  font: inherit;
  border-radius: 10px;
  border: none;
  padding: 12px;
}

input,
textarea {
  background: #f9fafb;
  color: #111827;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

button {
  cursor: pointer;
  background: #22c55e;
  color: #052e16;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.08);
}

button:disabled {
  cursor: wait;
  filter: grayscale(0.35);
  opacity: 0.75;
}

.secondary {
  background: #6b7280;
  color: #f9fafb;
}

.map-card {
  margin-top: 0;
}

.vehicles-map {
  height: 340px;
  border: 1px solid #374151;
  border-radius: 10px;
  overflow: hidden;
  background: #111827;
}

.vehicle-map-marker-wrapper {
  background: transparent;
  border: 0;
}

.vehicle-map-marker {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  background: var(--marker-color, #38bdf8);
  border: 3px solid #ffffff;
  border-radius: 50% 50% 50% 0;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.45);
  transform: rotate(-45deg);
}

.vehicle-map-marker::after {
  content: "";
  position: absolute;
  inset: 7px;
  background: #ffffff;
  border-radius: 50%;
  opacity: 0.9;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #1f2937;
  color: #f9fafb;
}

.leaflet-popup-content {
  margin: 10px 12px;
}

.leaflet-popup-content .popup-maps-link {
  display: block;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #ef4444;
  color: #ffffff;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.leaflet-popup-content .popup-maps-link:hover,
.leaflet-popup-content .popup-maps-link:focus-visible {
  background: #dc2626;
  color: #ffffff;
  box-shadow: 0 6px 14px rgb(239 68 68 / 0.35);
  transform: translateY(-1px);
}

.vehicle-list {
  display: grid;
  gap: 12px;
}

.vehicle-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.vehicle-card h3 {
  margin: 0;
  font-size: 1.4rem;
}

.vehicle-card p {
  margin: 10px 0 0;
  color: #d1d5db;
}

.vehicle-address {
  display: grid;
  gap: 4px;
  color: #bfdbfe;
  font-size: 0.95rem;
}

.vehicle-address strong {
  color: #f9fafb;
}

.vehicle-route-distance {
  color: #bbf7d0;
  font-size: 0.95rem;
}

.vehicle-route-distance strong {
  color: #f9fafb;
}

.vehicle-route-distance-muted {
  color: #fbbf24;
}

.estado {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.vehicle-actions-dropdown summary {
  cursor: pointer;
  list-style: none;
  color: #f9fafb;
}

.vehicle-actions-dropdown summary::-webkit-details-marker {
  display: none;
}

.saved-lists {
  display: grid;
  gap: 12px;
}

.saved-list-details summary {
  cursor: pointer;
  list-style: none;
}

.saved-list-details summary::-webkit-details-marker {
  display: none;
}

.saved-list-summary,
.saved-list-vehicle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.saved-list-summary small {
  display: block;
  margin-top: 4px;
  color: #9ca3af;
}

.saved-list-details[open] .dropdown-arrow {
  transform: rotate(180deg);
}

.saved-list-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.saved-list-vehicles {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}

.saved-list-vehicle {
  padding: 12px;
  border: 1px solid #374151;
  border-radius: 12px;
  background: #111827;
}

.saved-list-vehicle p {
  margin: 8px 0 0;
  color: #d1d5db;
}

.saved-list-address {
  color: #bfdbfe;
  font-size: 0.95rem;
}

.saved-list-vehicle a {
  display: inline-block;
  margin-top: 10px;
  color: #93c5fd;
  font-weight: 700;
}

.vehicle-status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dropdown-arrow {
  color: #9ca3af;
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.vehicle-actions-dropdown[open] .dropdown-arrow {
  transform: rotate(180deg);
}

.pendiente {
  background: #facc15;
  color: #422006;
}

.cargando {
  background: #38bdf8;
  color: #082f49;
}

.cargado {
  background: #22c55e;
  color: #052e16;
}

.incidencia {
  background: #ef4444;
  color: #450a0a;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.actions a,
.actions button {
  text-align: center;
  text-decoration: none;
  border-radius: 10px;
  padding: 10px;
  font-weight: 700;
}

.actions a {
  background: #3b82f6;
  color: white;
}

.edit {
  background: #f97316;
  color: #431407;
}

.delete {
  background: #ef4444;
  color: white;
}

.empty {
  color: #9ca3af;
}

@media (max-width: 520px) {
  .vehicles-map {
    height: 300px;
  }

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

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