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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* Upload Section */
.upload-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.upload-container {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.upload-container h1 {
  font-size: 1.75rem;
  color: #333;
  margin-bottom: 8px;
}

.upload-container p {
  color: #666;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.file-input-wrapper {
  position: relative;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.file-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  border: 2px dashed #ddd;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

.file-label:hover,
.file-label:active {
  border-color: #667eea;
  background: #f8f9ff;
}

.file-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.file-text {
  color: #666;
  font-size: 0.9rem;
}

.file-name {
  display: block;
  margin-top: 8px;
  color: #667eea;
  font-weight: 500;
  font-size: 0.85rem;
  word-break: break-all;
}

.detour-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.detour-input label {
  color: #666;
  font-size: 0.9rem;
}

.detour-input input {
  width: 120px;
  padding: 12px 16px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
}

/* POI Selection */
.poi-selection {
  text-align: left;
}

.poi-selection-label {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 10px;
  text-align: center;
}

.poi-checkboxes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.poi-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8f8f8;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.9rem;
}

.poi-checkbox:has(input:checked) {
  background: #f0f0ff;
}

.poi-checkbox input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.poi-icon {
  font-size: 1.2rem;
}

.submit-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-loader {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Map Section */
.map-section {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

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

/* Mobile: Bottom sheet style panel */
.controls-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  max-height: 50vh;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.controls-panel::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 0 auto 12px;
}

.controls-panel.collapsed {
  transform: translateY(calc(100% - 60px));
}

.back-btn {
  background: #f0f0f0;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 12px;
  transition: background 0.2s;
  width: 100%;
}

.back-btn:hover,
.back-btn:active {
  background: #e0e0e0;
}

.stats {
  background: #f8f9ff;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #666;
  text-align: center;
}

.filters h3,
.export-section h3 {
  font-size: 0.9rem;
  color: #333;
  margin-bottom: 8px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.filter-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  cursor: pointer;
  background: #f8f8f8;
  border-radius: 10px;
  transition: background 0.2s;
  text-align: center;
}

.filter-item:has(input:checked) {
  background: #f0f0ff;
}

.filter-item input {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.filter-item .filter-label {
  font-size: 0.75rem;
  color: #666;
}

.filter-item .filter-count {
  font-weight: 600;
  color: #333;
}

.marker-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.marker-icon.bakery {
  background: #f59e0b;
}

.marker-icon.cafe {
  background: #8b5cf6;
}

.marker-icon.water {
  background: #3b82f6;
}

.marker-icon.toilets {
  background: #10b981;
}

.export-section {
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.export-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.export-btn {
  padding: 10px 8px;
  background: #f0f0f0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.8rem;
}

.export-btn:hover,
.export-btn:active {
  background: #e0e0e0;
}

.hidden {
  display: none !important;
}

/* Custom markers */
.custom-marker {
  background: white;
  border-radius: 50%;
  border: 3px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.custom-marker.bakery {
  border-color: #f59e0b;
}

.custom-marker.cafe {
  border-color: #8b5cf6;
}

.custom-marker.water {
  border-color: #3b82f6;
}

.custom-marker.toilets {
  border-color: #10b981;
}

/* Popup styles */
.leaflet-popup-content {
  margin: 10px 12px;
}

.poi-popup h4 {
  margin: 0 0 5px 0;
  color: #333;
  font-size: 0.95rem;
}

.poi-popup p {
  margin: 3px 0;
  color: #666;
  font-size: 0.85rem;
}

.poi-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: white;
  margin-bottom: 5px;
}

.poi-type.bakery {
  background: #f59e0b;
}

.poi-type.cafe {
  background: #8b5cf6;
}

.poi-type.water {
  background: #3b82f6;
}

.poi-type.toilets {
  background: #10b981;
}

.poi-nav-links {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.nav-link {
  font-size: 0.8rem;
  text-decoration: none;
  color: #666;
}

.nav-link:hover {
  color: #333;
  text-decoration: underline;
}

/* Tablet and Desktop */
@media (min-width: 768px) {
  .upload-container {
    padding: 40px;
  }

  .upload-container h1 {
    font-size: 2.5rem;
  }

  .upload-container p {
    font-size: 1rem;
    margin-bottom: 30px;
  }

  .file-label {
    padding: 40px;
  }

  .file-icon {
    font-size: 3rem;
  }

  .detour-input {
    flex-direction: row;
    gap: 10px;
  }

  .controls-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: auto;
    left: auto;
    border-radius: 12px;
    padding: 20px;
    max-width: 300px;
    max-height: calc(100vh - 40px);
  }

  .controls-panel::before {
    display: none;
  }

  .back-btn {
    width: auto;
  }

  .filters-grid {
    grid-template-columns: 1fr;
  }

  .filter-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 12px;
  }

  .filter-item .filter-label {
    font-size: 0.85rem;
  }

  .export-buttons {
    grid-template-columns: 1fr;
  }

  .export-btn {
    font-size: 0.9rem;
    padding: 10px;
  }
}
