*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f6f8;
  color: #1f2937;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.header__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
}

.header__icon-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.map-shell {
  position: relative;
  flex: 1;
  min-height: 0;
}

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

.search-panel {
  position: absolute;
  top: 16px;
  right: 56px;
  z-index: 1000;
  width: min(420px, calc(100% - 120px));
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.coord-row input,
.keyword-row input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.coord-row input:focus,
.keyword-row input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn--primary {
  background: #2563eb;
  color: #fff;
}

.btn--primary:hover {
  background: #1d4ed8;
}

.keyword-row {
  position: relative;
}

.keyword-row__icon {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.keyword-row input {
  padding-left: 36px;
}

.map-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-controls__btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
  color: #374151;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.map-controls__btn:hover {
  background: #f9fafb;
}

.refresh-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
  color: #374151;
  cursor: pointer;
}

.refresh-btn:hover {
  background: #f9fafb;
}

.refresh-btn.is-spinning svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.status-bar {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: calc(100% - 90px);
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(17, 24, 39, 0.78);
  color: #f9fafb;
  font-size: 12px;
}

.status-bar.is-error {
  background: rgba(185, 28, 28, 0.88);
}

.device-marker {
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.device-marker--online {
  background: #22c55e;
}

.device-marker--offline {
  background: #ef4444;
}

.device-popup {
  font-size: 13px;
  line-height: 1.5;
}

.device-popup h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.device-popup p {
  margin: 0 0 4px;
  color: #4b5563;
}

.device-popup .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge--online {
  background: #dcfce7;
  color: #166534;
}

.badge--offline {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 768px) {
  .search-panel {
    right: 16px;
    width: calc(100% - 32px);
  }

  .map-controls {
    top: auto;
    bottom: 72px;
  }
}
