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

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  color: #333;
  overflow: hidden;
  height: 100vh;
}

#container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Map Panel */
#map-panel {
  flex: 1 1 70%;
  position: relative;
  min-width: 0;
}

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

.loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 1000;
  font-size: 14px;
  color: #555;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #ddd;
  border-top-color: #0078d4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Sidebar */
#sidebar {
  flex: 0 0 25%;
  min-width: 250px;
  max-width: 345px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e0e0e0;
  background: #fafafa;
  overflow: hidden;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f0f0f0;
  border-bottom: 1px solid #e0e0e0;
}

#sidebar-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #0078d4;
}

#close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
  line-height: 1;
}

#close-btn:hover {
  color: #c00;
}

#sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}

#sidebar-content section {
  margin-bottom: 14px;
}

#sidebar-content h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

/* Info rows */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 12px;
}

.info-label {
  color: #666;
}

.info-value {
  font-weight: 600;
  color: #222;
}

.total-row {
  border-top: 1px solid #ccc;
  margin-top: 4px;
  padding-top: 6px;
  font-size: 13px;
}

.total-row .info-value {
  color: #0078d4;
  font-size: 14px;
}

.profit {
  color: #107c10 !important;
}

.loss {
  color: #d13438 !important;
}

/* Truck selector */
#truck-select {
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  max-width: 160px;
}

/* truck-selector-row visibility controlled by JS */

.truck-notes {
  font-weight: normal;
  font-size: 11px;
  color: #666;
}

/* Waypoints */
.waypoint-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 0;
  font-size: 12px;
}

.waypoint-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 2px;
  flex-shrink: 0;
}

.waypoint-dot.pickup {
  background: #107c10;
}

.waypoint-dot.delivery {
  background: #d13438;
}

.waypoint-text {
  color: #444;
}

.waypoint-label {
  font-weight: 600;
  margin-right: 4px;
}

/* Country breakdown */
.country-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: #eee;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  margin: 2px 2px 2px 0;
}

.country-badge .flag {
  font-size: 12px;
}

.country-badge .km {
  color: #222;
}

/* Toll breakdown */
.toll-item {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 1px 0 1px 8px;
  color: #777;
}

/* Routes legend */
.route-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  margin: 2px 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.route-legend-item:hover {
  background: #e8e8e8;
}

.route-legend-item.active {
  background: #e0ecf7;
  font-weight: 600;
}

.route-line-sample {
  width: 24px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.hint {
  font-size: 11px;
  color: #999;
  margin-top: 6px;
  font-style: italic;
}

/* Value change animation */
.value-changed {
  animation: highlight 1s ease-out;
}

@keyframes highlight {
  0% { background: #fff3cd; }
  100% { background: transparent; }
}

/* Leaflet popup overrides */
.leaflet-popup-content {
  font-family: "Segoe UI", sans-serif;
  font-size: 12px;
  margin: 8px 12px;
}

.marker-popup-title {
  font-weight: 600;
  margin-bottom: 4px;
}

/* Map legend */
.map-legend {
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 10px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  font-size: 11px;
  line-height: 1.6;
  color: #444;
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid white;
  box-shadow: 0 0 1px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.legend-line {
  width: 18px;
  height: 3px;
  border-radius: 1px;
  flex-shrink: 0;
}

.legend-hint {
  margin-top: 4px;
  font-style: italic;
  color: #999;
  font-size: 10px;
}
