* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body,
html {
  height: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  overflow: hidden;
}

#loading-overlay {
  position: fixed;
  right: 14px;
  top: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  pointer-events: none;
}

#loading-overlay.open {
  display: flex;
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  color: #333;
  font-size: 14px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d0d0d0;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

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

.layer-selector,
.provider-selector,
.balloon-type-control {
  margin-bottom: 15px;
}

.layer-selector label,
.provider-selector label,
.balloon-type-control label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #333;
}

.layer-selector select,
.provider-selector select,
.balloon-type-control select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.controls-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  padding: 15px;
  width: 350px;
  max-height: 80vh;
  overflow-y: auto;
}

.mode-selector {
  margin-bottom: 15px;
}

.mode-selector label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #333;
}

.mode-selector select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.altitude-control {
  margin-bottom: 15px;
}

.altitude-control label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #333;
}

.altitude-control input[type="range"] {
  width: 100%;
  margin: 5px 0;
}

.altitude-control datalist {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 2px;
}

.altitude-control option {
  padding: 0;
  font-size: 10px;
  color: #666;
}

#altitude-value {
  font-weight: normal;
  color: #667eea;
}

.ascent-rate-control,
.burst-altitude-control,
.descent-rate-control {
  margin-bottom: 15px;
}

.ascent-rate-control label,
.burst-altitude-control label,
.descent-rate-control label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #333;
}

.ascent-rate-control input[type="range"],
.burst-altitude-control input[type="range"],
.descent-rate-control input[type="range"] {
  width: 100%;
  margin: 5px 0;
}

#ascent-rate-value,
#burst-altitude-value,
#descent-rate-value {
  font-weight: normal;
  color: #667eea;
}

.time-control {
  margin-bottom: 15px;
}

.time-control label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #333;
}

.time-control input[type="range"] {
  width: 100%;
  margin: 5px 0;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

.time-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.time-control input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.time-control input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.time-control input[type="range"]:disabled::-webkit-slider-thumb {
  cursor: not-allowed;
}

.time-control input[type="range"]:disabled::-moz-range-thumb {
  cursor: not-allowed;
}

.prediction-file-selector {
  margin-bottom: 15px;
}

.prediction-file-selector label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #333;
}

.prediction-file-selector select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.controls-panel h3 {
  margin: 0 0 10px 0;
  font-size: 16px;
  color: #333;
}

.controls-panel textarea {
  width: 100%;
  height: 200px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  resize: vertical;
}

.controls-panel button {
  margin: 5px 5px 5px 0;
  padding: 8px 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.controls-panel button:hover {
  background: #5a6fd8;
}

.controls-panel button.secondary {
  background: #6c757d;
}

.controls-panel button.secondary:hover {
  background: #5a6268;
}

.status {
  margin-top: 10px;
  padding: 8px;
  border-radius: 4px;
  font-size: 12px;
  min-height: 18px;
}

.status.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Target detail panel */
#target-detail {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  padding: 15px;
  width: 280px;
}

.target-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: bold;
  color: #333;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.field-row label {
  width: 40px;
  font-size: 13px;
  color: #555;
  flex-shrink: 0;
}

.field-row input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
}

/* Icon button */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #666;
  padding: 2px 6px;
  border-radius: 4px;
}

.icon-btn:hover {
  background: #f0f0f0;
}

/* Danger button */
button.danger {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  margin-top: 8px;
}

button.danger:hover {
  background: #c82333;
}

/* Modal */
#json-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

#json-modal.open {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: 8px;
  padding: 20px;
  width: 480px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.modal-header {
  margin-bottom: 12px;
  font-size: 16px;
  color: #333;
}

.modal-box textarea {
  flex: 1;
  min-height: 300px;
  font-family: monospace;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  resize: vertical;
}

.modal-error {
  color: #dc3545;
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}

.modal-footer {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.modal-footer button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.modal-footer button:first-child {
  background: #667eea;
  color: white;
}

.modal-footer button.secondary {
  background: #6c757d;
  color: white;
}

/* predictions-actions */
.predictions-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.trends-render-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.trends-render-control label {
  font-size: 13px;
  color: #333;
}

.trends-render-control select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  background: white;
}

.altitude-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #333;
}

.altitude-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.altitude-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}

#demo-chart-panel {
  display: none;
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 24px;
  z-index: 1000;
  width: auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  padding: 12px;
}

.demo-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #333;
}

.demo-points,
.demo-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 4px;
  font-size: 12px;
  color: #333;
}

.demo-chart-header > div:last-child {
  text-align: right;
}

.demo-chart {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 180px;
  padding: 8px 0 0;
  border-left: 1px solid #bbb;
  border-bottom: 1px solid #bbb;
  overflow-x: auto;
}

.demo-chart-bar {
  position: relative;
  flex: 1 0 3px;
  min-height: 2px;
  background: #2a9d8f;
  border-radius: 2px 2px 0 0;
}

.demo-chart-bar.pending {
  min-height: 100%;
  background: #d0d5dd;
  opacity: 0.7;
}

.demo-chart-bar.missing {
  min-height: 100%;
  background: #d92d20;
  opacity: 0.55;
}

/* Checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
}

/* Map interaction hint */
.map-hint {
  margin-top: 6px;
  font-size: 11px;
  color: #999;
}

/* Field unit label (e.g. "m" after radius input) */
.field-unit {
  font-size: 12px;
  color: #888;
  flex-shrink: 0;
}

/* Add-type popup menu */
#add-type-menu {
  display: none;
  position: fixed;
  z-index: 1500;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  min-width: 160px;
}

#add-type-menu.open {
  display: block;
}

#add-type-menu button {
  display: block;
  width: 100%;
  padding: 13px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  color: #333;
}

#add-type-menu button:last-child {
  border-bottom: none;
}

#add-type-menu button:hover {
  background: #f5f5f5;
}

/* Logo in bottom left corner */
.logo {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 1000;
  pointer-events: none;
}

.logo a {
  display: block;
  pointer-events: auto;
}

.logo img {
  height: 80px;
  width: auto;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.logo img:hover {
  opacity: 1;
}
