:root {
  font-family: Montserrat, Poppins, system-ui, sans-serif;
  color: #202124;
  background: #f5f7fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1rem;
}

.admin-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "map";
  gap: 1rem;
  height: calc(100dvh - 2rem);
}

.admin-shell[data-architecture-visible='true'] {
  grid-template-columns: minmax(16rem, 20rem) minmax(0, 1fr);
  grid-template-areas: "architecture map";
}

.architecture-toggle {
  padding: 0.4rem 0.75rem;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 0.125rem 0.5rem rgb(0 0 0 / 12%);
  color: inherit;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.architecture-toggle:hover {
  background: #ffffff;
}

.architecture-toggle:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

.map-frame {
  position: relative;
  grid-area: map;
  height: 100%;
  overflow: hidden;
  border-radius: 1.5rem;
  box-shadow: 0 0.5rem 2rem rgb(0 0 0 / 15%);
}

#map {
  position: absolute;
  inset: 0;
}

.map-overlay {
  position: absolute;
  z-index: 1;
  top: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  max-width: calc(100% - 5rem);
}

.admin-panel {
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 12%);
}

.admin-panel h1 {
  margin: 0;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
}

.connection-status {
  --connection-color: #f9ab00;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.connection-status[data-state='connected'] {
  --connection-color: #34A853;
}

.connection-status[data-state='disconnected'] {
  --connection-color: #EA4335;
}

.connection-status__dot {
  flex: 0 0 auto;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--connection-color);
}

#message:not(:empty) {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
}

#message:empty {
  display: none;
}

.fleet-panel {
  position: absolute;
  z-index: 1;
  right: 1rem;
  bottom: 3rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  width: min(22rem, calc(100% - 2rem));
  max-height: 45%;
}

.fleet-toggle {
  align-self: flex-end;
  padding: 0.4rem 0.75rem;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 0.125rem 0.5rem rgb(0 0 0 / 12%);
  color: inherit;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.fleet-toggle:hover {
  background: #ffffff;
}

.fleet-toggle:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

#fleet {
  display: grid;
  flex: 1 1 auto;
  gap: 0.5rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

#fleet:empty,
#fleet[hidden] {
  display: none;
}

#fleet li {
  display: grid;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 0.125rem 0.5rem rgb(0 0 0 / 12%);
}

.fleet-item__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fleet-item__dot {
  flex: 0 0 auto;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--vehicle-color, #4285F4);
  box-shadow: 0 0 0 3px rgb(0 0 0 / 6%);
}

.fleet-item__id {
  font-size: 0.85rem;
}

.fleet-item__state {
  margin-left: auto;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.fleet-item__state[data-state='moving'] {
  background: #e6f4ea;
  color: #1e7e34;
}

.fleet-item__state[data-state='stopped'] {
  background: #fef7e0;
  color: #b06000;
}

.fleet-item__state[data-state='error'] {
  background: #fce8e6;
  color: #c5221f;
}

.fleet-item__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.75rem;
  margin: 0;
}

.fleet-item__stat--wide {
  grid-column: 1 / -1;
}

.fleet-item__stats dt {
  margin: 0;
  color: #5f6368;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fleet-item__stats dd {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
}

.fleet-item__coords {
  font-variant-numeric: tabular-nums;
}

.architecture-panel {
  display: flex;
  flex-direction: column;
  grid-area: architecture;
  gap: 1rem;
  height: 100%;
  padding: 1.25rem;
  overflow-y: auto;
  border-radius: 1.5rem;
  background: #ffffff;
  box-shadow: 0 0.5rem 2rem rgb(0 0 0 / 15%);
}

.architecture-panel[hidden] {
  display: none;
}

.architecture-panel__header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.architecture-panel__header p {
  margin: 0.35rem 0 0;
  color: #5f6368;
  font-size: 0.8rem;
}

.architecture-panel__figure {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  margin: 0;
}

.architecture-panel__gif {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.75rem;
  background: #f5f7fa;
}

.architecture-panel__gif[hidden] {
  display: none;
}

.architecture-panel__fallback {
  display: grid;
  flex: 1 1 auto;
  place-items: center;
  margin: 0;
  padding: 1rem;
  border: 2px dashed #c4c7c5;
  border-radius: 0.75rem;
  color: #5f6368;
  font-size: 0.8rem;
  text-align: center;
}

.architecture-panel__fallback[hidden] {
  display: none;
}

.architecture-panel__fallback code {
  font-size: 0.75rem;
}

.architecture-panel figcaption {
  color: #5f6368;
  font-size: 0.72rem;
  text-align: center;
}

.vehicle-marker {
  width: 32px;
  height: 48px;
  color: var(--vehicle-color);
  cursor: pointer;
}

.vehicle-marker__icon {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0.125rem 0.125rem rgb(0 0 0 / 35%));
  transform-origin: center;
}

.vehicle-marker__body {
  fill: currentColor;
  stroke: #ffffff;
  stroke-width: 1.5;
}

.vehicle-marker__window {
  fill: rgb(255 255 255 / 80%);
}

.vehicle-marker__light {
  fill: #ffffff;
}

.maplibregl-ctrl-attrib,
.maplibregl-ctrl-group {
  font-family: Montserrat, Poppins, system-ui, sans-serif;
}

@media (max-width: 60rem) {
  .admin-shell,
  .admin-shell[data-architecture-visible='true'] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "map" "architecture";
  }

  .architecture-panel {
    height: auto;
    max-height: 38dvh;
  }
}

@media (max-width: 40rem) {
  body {
    padding: 0.5rem;
  }

  .admin-shell {
    height: calc(100dvh - 1rem);
  }

  .map-frame,
  .architecture-panel {
    border-radius: 1rem;
  }

  .fleet-panel {
    max-height: 35%;
  }

  .admin-shell[data-architecture-visible='true'] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "map" "architecture";
  }

  .admin-shell[data-architecture-visible='true'] .map-frame {
    height: auto;
  }

  .admin-shell[data-architecture-visible='true'] #map,
  .admin-shell[data-architecture-visible='true'] .fleet-panel {
    display: none;
  }

  .admin-shell[data-architecture-visible='true'] .map-overlay {
    position: static;
    max-width: none;
    padding: 0.75rem;
  }

  .admin-shell[data-architecture-visible='true'] .architecture-panel {
    height: 100%;
    max-height: none;
    overflow: hidden;
  }

  .architecture-panel__figure {
    overflow: hidden;
  }

  .architecture-panel__gif {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    object-fit: contain;
  }
}
