* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #000;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Leaflet marker popups readable outdoors */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
}
.leaflet-popup-content {
  font-size: 15px;
  line-height: 1.4;
}

.panel {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 14px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.panel-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.panel-label {
  color: #b8b8b8;
  font-weight: 500;
}

.panel-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel-value.ok {
  color: #4ade80;
}

.panel-value.bad {
  color: #f87171;
}

.panel-value.warn {
  color: #facc15;
}

.panel-actions {
  width: 100%;
  margin-top: 2px;
}

.panel-btn {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.panel-btn:active {
  background: rgba(255, 255, 255, 0.25);
}

.toast {
  position: absolute;
  bottom: max(140px, calc(120px + env(safe-area-inset-bottom)));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: rgba(20, 20, 20, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 18px 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.btn:active {
  transform: scale(0.96);
}

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

.btn-secondary {
  background: #ffffff;
  color: #111;
}

.btn-toggle {
  background: #444;
  color: #fff;
}

.btn-zone {
  background: #0d9488;
  color: #fff;
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.6);
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay:not([hidden]) {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: #1c1c1e;
  color: #fff;
  border-radius: 18px 18px 0 0;
  padding: 20px 20px max(20px, env(safe-area-inset-bottom));
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.modal-sub {
  margin: 0 0 14px;
  color: #aaa;
  font-size: 14px;
}

.label-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.label-btn {
  border: 2px solid #555;
  background: transparent;
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.label-btn.selected {
  border-color: #2563eb;
  background: #2563eb;
}

.modal-note {
  width: 100%;
  background: #2c2c2e;
  color: #fff;
  border: 1px solid #555;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  resize: none;
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn {
  flex: 1;
  padding: 14px 8px;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.progress-wrap {
  margin-bottom: 14px;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: #2c2c2e;
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #0d9488;
  transition: width 0.15s ease-out;
}

.progress-text {
  margin-top: 6px;
  font-size: 13px;
  color: #aaa;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
