* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.4 system-ui, sans-serif;
  color: #1c1917;
  background: #f6f5f3;
}

header, footer, main { padding: 16px 20px; }

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

h1 { margin: 0; font-size: 22px; font-weight: 650; }
#subtitle, #status, footer { margin: 4px 0 0; color: #57534e; }

.actions { display: flex; align-items: center; gap: 10px; }
#status { margin: 0; text-align: right; white-space: nowrap; }

button {
  border: 1px solid #d6d3d1;
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  cursor: pointer;
}
#refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 9.2em;
}
#refresh .ring {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(#1c1917 var(--progress, 0%), #d6d3d1 0);
  -webkit-mask: radial-gradient(farthest-side, transparent 62%, #000 63%);
  mask: radial-gradient(farthest-side, transparent 62%, #000 63%);
}
#refresh.busy .ring {
  background: none;
  border: 2px solid #d6d3d1;
  border-top-color: #1c1917;
  -webkit-mask: none;
  mask: none;
  animation: spin 0.7s linear infinite;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  margin: 0 20px;
}
.map-wrap { position: relative; min-width: 0; }
#map {
  height: 420px;
  border: 1px solid #e7e5e4;
  border-radius: 4px;
  overflow: hidden;
}
.advisories {
  height: 420px;
  overflow: auto;
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: 4px;
  padding: 10px 12px;
}
.advisories h2 { margin: 0 0 8px; font-size: 14px; font-weight: 650; }
.advisories .empty { margin: 0; color: #57534e; font-size: 13px; }
.advisory {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 8px 0;
  border: 0;
  border-top: 1px solid #f5f5f4;
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.advisory .mark {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  background: #f59e0b;
  transform: rotate(45deg);
}
.advisory .mark.heavy { background: #dc2626; }
.advisory .mark.work { background: #7c3aed; }
.advisory .kind { display: block; color: #57534e; font-size: 11px; }
.advisory strong { display: block; font-size: 13px; font-weight: 600; }
.advisory p { margin: 2px 0 0; color: #44403c; font-size: 12px; }
.advisory-pin {
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  background: #f59e0b;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transform: rotate(45deg);
}
.advisory-pin.heavy { background: #dc2626; }
.advisory-pin.work { background: #7c3aed; }

.legend {
  position: absolute;
  z-index: 500;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.swatch {
  display: inline-block;
  width: 16px;
  height: 4px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: middle;
}
.swatch.moving { background: #22c55e; }
.swatch.slow { background: #f59e0b; }
.swatch.heavy { background: #dc2626; }

.marker {
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  border-radius: 50%;
  background: #1d4ed8;
  color: #fff;
  font-weight: 650;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

#cameras {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
}

.card.selected { outline: 2px solid #1d4ed8; }

.card .shot {
  overflow: hidden;
  line-height: 0;
  background: #292524;
  aspect-ratio: 320 / 236;
}
.card img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.card img[src] { display: block; }

@media (max-width: 800px) {
  header { flex-direction: column; align-items: flex-start; }
  .actions { width: 100%; justify-content: space-between; }
  .stage { grid-template-columns: 1fr; }
  #map, .advisories { height: 320px; }
}

.card .meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 2px 8px 3px;
}
.card h2 { margin: 0; font-size: 12px; font-weight: 600; line-height: 1.2; }
.card .updated { margin: 0; color: #57534e; font-size: 11px; line-height: 1.2; white-space: nowrap; }
.card.refreshing .updated::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border: 1.5px solid #d6d3d1;
  border-top-color: #44403c;
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.card.failed .updated { color: #b91c1c; }

footer { font-size: 13px; }
footer a { color: inherit; }
