*,
*::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;
}

.map-controls__btn--text {
  font-size: 13px;
  font-weight: 700;
}

.map-controls__btn.is-active {
  background: #1a73e8;
  color: #fff;
}

.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);
}

.map-type {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: flex;
  padding: 4px;
  gap: 2px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.map-type__btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #3c4043;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.map-type__btn:hover {
  background: #f1f3f4;
}

.map-type__btn.is-active {
  background: #1a73e8;
  color: #fff;
}

@media (max-width: 768px) {
  .map-type {
    font-size: 12px;
  }
  .map-type__btn {
    padding: 6px 9px;
  }
}

/* Advanced Marker pins. Default anchor is bottom-center, so nudge down
   half the height to center the dot on the coordinate. */
.map-pin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-sizing: border-box;
  transform: translateY(50%);
  cursor: pointer;
}

.map-pin--online {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(52, 168, 83, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.map-pin--offline {
  background: #ea4335;
  animation: pin-blink 1s ease-in-out infinite;
}

@keyframes pin-blink {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(234, 67, 53, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
  50% {
    opacity: 0.45;
    box-shadow: 0 0 0 9px rgba(234, 67, 53, 0), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
}

/* Google Maps InfoWindow: strip the default chrome so the card sits flush. */
.gm-style .gm-style-iw-c {
  padding: 0 !important;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}

.gm-style .gm-style-iw-d {
  overflow: hidden !important;
}

.gm-style .gm-style-iw-chr {
  position: absolute;
  top: 6px;
  right: 6px;
  height: 0;
}

.tag-card {
  width: 268px;
  padding: 16px 16px 14px;
  font-size: 13px;
  color: #202124;
}

.tag-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tag-card__icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #f1f3f4;
  color: #5f6368;
}

.tag-card__name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.tag-card__eui {
  margin-top: 1px;
  font-size: 12px;
  color: #9aa0a6;
  letter-spacing: 0.02em;
}

.tag-card__coords {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef7e0;
  color: #7a5b00;
  font-weight: 500;
}

.tag-card__coords svg {
  flex: 0 0 auto;
  color: #f4b400;
}

.tag-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.tag-card__time {
  color: #5f6368;
  font-size: 12px;
}

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

.badge--online {
  background: #e6f4ea;
  color: #137333;
}

.badge--offline {
  background: #fce8e6;
  color: #c5221f;
  animation: badge-blink 1s steps(1, end) infinite;
}

@keyframes badge-blink {
  50% { opacity: 0.35; }
}

.tag-card__actions {
  display: flex;
  gap: 10px;
}

.tag-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: #fff;
  color: #3c4043;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tag-btn:hover {
  background: #f8f9fa;
}

.tag-btn--primary {
  border-color: #1a73e8;
  background: #1a73e8;
  color: #fff;
}

.tag-btn--primary:hover {
  background: #1765cc;
}

.tag-btn:disabled {
  opacity: 0.7;
  cursor: default;
}

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

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