* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #475569 transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  min-height: 36px;
}

/* User menu */
.user-menu {
  position: relative;
  margin-left: auto;
}

.user-menu-btn {
  background: #1e293b;
  border: 1px solid #475569;
  color: #cbd5e1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

.user-menu-btn:hover {
  border-color: #38bdf8;
  background: #334155;
}

.user-menu-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.user-menu-avatar.hidden {
  display: none;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 5000;
  overflow: hidden;
}

.user-dropdown.hidden {
  display: none;
}

.user-dropdown-email {
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #94a3b8;
  border-bottom: 1px solid #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  color: #e2e8f0;
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.user-dropdown-item:hover {
  background: #334155;
}

.user-dropdown-logout {
  color: #fca5a5;
  border-top: 1px solid #334155;
}

main {
  max-width: 1760px;
  margin: 0 auto;
  padding: 0.5rem 1rem 1rem;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  font-size: 0.9rem;
}

.breadcrumb-link {
  color: #38bdf8;
  text-decoration: none;
  cursor: pointer;
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: #475569;
  user-select: none;
}

.breadcrumb-current {
  color: #94a3b8;
}

#breadcrumb-tail {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Landing page */
.landing-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  padding: 2rem 1rem;
}

.landing-cards {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.landing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 260px;
  height: 280px;
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 16px;
  padding: 2rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  color: #e2e8f0;
  font-family: inherit;
  text-align: center;
}

.landing-card:hover:not(:disabled) {
  border-color: #38bdf8;
  background: #1e293b;
  transform: translateY(-4px);
}

.landing-card:active:not(:disabled) {
  transform: translateY(-1px);
}

.landing-card-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.landing-card-icon {
  color: #38bdf8;
}

.landing-card-disabled .landing-card-icon {
  color: #64748b;
}

.landing-card-title {
  font-size: 1.4rem;
  font-weight: 600;
}

.landing-card-desc {
  font-size: 0.9rem;
  color: #94a3b8;
  line-height: 1.4;
}

/* Routes page header */
/* Upload area */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  border: 2px dashed #475569;
  border-radius: 12px;
  padding: 3rem 2rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.05);
}

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

.upload-text {
  color: #94a3b8;
  font-size: 1.1rem;
}

/* Results */
.hidden,
#content-right.hidden,
.overlay-activity-btn.hidden,
.clear-activity-btn.hidden {
  display: none;
}

#results-section {
  margin-top: 0.5rem;
}

#course-name {
  font-size: 1.5rem;
  color: #38bdf8;
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stats-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.overlay-activity-btn,
.clear-activity-btn {
  background: #1e293b;
  border: 1px solid #475569;
  color: #cbd5e1;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.overlay-activity-btn:hover {
  background: #334155;
  border-color: #38bdf8;
}

.clear-activity-btn {
  border-color: #ef4444;
  color: #ef4444;
  font-size: 0.9rem;
}

.clear-activity-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

.stats-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.stats-header-title h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-toggle {
  display: flex;
  background: #0f172a;
  border-radius: 8px;
  overflow: hidden;
}

.unit-btn {
  background: none;
  border: none;
  color: #94a3b8;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-weight: 600;
}

.unit-btn.active {
  background: #38bdf8;
  color: #0f172a;
}

.unit-btn:hover:not(.active) {
  color: #e2e8f0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: #1e293b;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: #f8fafc;
}

/* Content layout */
#content-layout {
  position: relative;
  padding-right: calc(420px + 1rem);
}

#content-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#content-right {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tabbed route panel (Waypoints / Breakdown / Climbs) */
#route-tabs-panel {
  background: #1e293b;
  border-radius: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#waypoints-table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem 0.5rem;
}

#waypoints-table,
.waypoints-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#waypoints-table thead th,
.waypoints-table thead th {
  text-align: left;
  color: #64748b;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #334155;
  position: sticky;
  top: 0;
  background: #1e293b;
}

#waypoints-table thead th:not(:first-child),
.waypoints-table thead th:not(:first-child) {
  text-align: right;
}

#waypoints-table tbody tr,
.waypoints-table tbody tr {
  border-bottom: 1px solid #1e293b;
  transition: background 0.15s;
  cursor: default;
}

#waypoints-table tbody tr:hover,
.waypoints-table tbody tr:hover {
  background: #334155;
}

#waypoints-table td,
.waypoints-table td {
  padding: 0.45rem 0.5rem;
  color: #cbd5e1;
  white-space: nowrap;
}

#waypoints-table td:not(:first-child),
.waypoints-table td:not(:first-child) {
  text-align: right;
}

#waypoints-table td:first-child,
#waypoints-table th:first-child,
.waypoints-table td:first-child,
.waypoints-table th:first-child {
  width: 40%;
  white-space: normal;
  color: #f1f5f9;
  font-weight: 500;
}

.wp-table-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Map */
#map-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  flex: 1;
}

#map {
  height: clamp(420px, 60vh, 820px);
  width: 100%;
  background: #1e293b;
}

/* Full-screen (browser window) map expansion */
#map-container.map-expanded {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-radius: 0;
  flex: none;
}

#map-container.map-expanded #map {
  height: 100%;
}

body.map-expanded-lock {
  overflow: hidden;
}

.map-fullscreen-btn a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  text-decoration: none;
  color: #333;
  font-weight: bold;
}

.reset-zoom-btn a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  text-decoration: none;
  color: #333;
  font-weight: bold;
}

.map-style-control select {
  padding: 4px 8px;
  font-size: 0.8rem;
  border: none;
  border-radius: 2px;
  background: #fff;
  color: #333;
  cursor: pointer;
  outline: none;
}

/* Elevation chart */
#elevation-container {
  background: #1e293b;
  border-radius: 12px;
  padding: 1.2rem;
  min-width: 0;
  overflow: hidden;
}

#elevation-container h3 {
  margin-bottom: 0.8rem;
  color: #94a3b8;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 180px;
}

/* Map markers */
.svg-marker {
  background: none !important;
  border: none !important;
}

/* Route tabs (Waypoints / Breakdown / Climbs) */
.fs-tabs {
  display: flex;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
  background: #0f172a;
}

.fs-tab {
  flex: 1;
  padding: 0.6rem 0.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s, border-color 0.2s;
}

.fs-tab:hover {
  color: #94a3b8;
}

.fs-tab.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
}

.fs-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.fs-tab-content.hidden {
  display: none;
}

.fs-tab-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #293548;
  flex-shrink: 0;
}

.fs-tab-content .profile-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.fs-tab-content .climbs-legend {
  flex-shrink: 0;
}

/* ==============================
   Strava integration styles
   ============================== */

/* Header user badge */
/* Source options layout */
.source-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.source-divider {
  text-align: center;
  color: #475569;
  font-size: 0.85rem;
  position: relative;
}

.source-divider span {
  background: #0f172a;
  padding: 0 1rem;
  position: relative;
  z-index: 1;
}

.source-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #334155;
}

/* Strava connect button */
.strava-connect-area {
  text-align: center;
  padding: 1.5rem 0;
}

.strava-connect-hint {
  color: #94a3b8;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.strava-btn-img {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: opacity 0.2s;
  line-height: 0;
}

.strava-btn-img:hover {
  opacity: 0.85;
}

.strava-btn-img:active {
  transform: scale(0.98);
}

/* Strava routes browser */
.strava-routes-area {
  background: #1e293b;
  border-radius: 12px;
  padding: 1rem;
}

.strava-routes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.strava-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: flex-end;
}

.strava-disconnect-btn {
  background: none;
  border: 1px solid #475569;
  color: #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.strava-disconnect-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.strava-routes-header h3 {
  color: #f8fafc;
  font-size: 1rem;
  white-space: nowrap;
}

.strava-search-wrap {
  flex: 1;
  max-width: 300px;
  position: relative;
}

.strava-search {
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.strava-search-clear {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.2s;
}

.strava-search-clear:hover {
  color: #e2e8f0;
}

.strava-search:focus {
  border-color: #38bdf8;
}

.strava-search::placeholder {
  color: #475569;
}

.strava-routes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.strava-route-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: #0f172a;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  border: 1px solid transparent;
}

.strava-route-card:hover {
  background: #334155;
  border-color: #475569;
}

.strava-route-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

.strava-route-icon {
  flex-shrink: 0;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.strava-route-info {
  flex: 1;
  min-width: 0;
}

.strava-route-name {
  font-weight: 600;
  color: #f1f5f9;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strava-route-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.strava-route-arrow {
  display: none;
}

.strava-loading {
  text-align: center;
  color: #64748b;
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.strava-empty {
  text-align: center;
  color: #475569;
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.strava-error {
  text-align: center;
  color: #ef4444;
  padding: 1rem;
  font-size: 0.85rem;
}

.strava-routes-pagination {
  margin-top: 0.75rem;
  text-align: center;
}

.strava-load-more-btn {
  background: #334155;
  border: 1px solid #475569;
  color: #cbd5e1;
  padding: 0.5rem 1.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.strava-load-more-btn:hover {
  background: #475569;
  border-color: #64748b;
}

/* ==============================
   Profile Breakdown Panel
   ============================== */

.climbs-legend {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #293548;
  flex-wrap: wrap;
}

.climbs-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: #94a3b8;
}

.climbs-legend-swatch {
  width: 12px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.climb-threshold-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: #94a3b8;
  margin-left: auto;
}

.climb-threshold-select {
  background: #1e293b;
  border: 1px solid #475569;
  color: #94a3b8;
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
}

.profile-normalize-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.profile-normalize-label input[type="checkbox"] {
  accent-color: #38bdf8;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.profile-export-wrap {
  position: relative;
}

.profile-export-btn {
  background: none;
  border: 1px solid #475569;
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}

.profile-export-btn:hover {
  background: #1e293b;
  border-color: #38bdf8;
  color: #e2e8f0;
}

.profile-export-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  overflow: hidden;
  z-index: 10;
  min-width: 150px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.profile-export-dropdown.hidden {
  display: none;
}

.profile-export-option {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  color: #e2e8f0;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.profile-export-option:hover {
  background: #334155;
}

.profile-export-option:disabled {
  color: #64748b;
  cursor: wait;
}

.profile-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
}

.profile-section {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  margin-bottom: 1rem;
  overflow: hidden;
  transition: border-color 0.2s;
  cursor: pointer;
}

.profile-section:hover {
  border-color: #38bdf8;
}

.profile-section:last-child {
  margin-bottom: 0;
}

.profile-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #293548;
}

.profile-section-number {
  background: #38bdf8;
  color: #0f172a;
  font-weight: 700;
  font-size: 0.75rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 0.6rem;
}

.profile-section-name {
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-section-chart {
  padding: 0.5rem 1rem 0.25rem 0.75rem;
  height: 120px;
}

.profile-section-chart canvas {
  width: 100% !important;
  height: 100% !important;
}


.profile-no-waypoints {
  color: #94a3b8;
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ==============================
   Mobile responsive styles
   ============================== */

@media (max-width: 768px) {
  header {
    padding: 0.5rem 0.75rem 0.2rem;
  }

  .header-content {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }

  .header-left {
    width: 100%;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .subtitle {
    font-size: 0.85rem;
  }

  main {
    padding: 0.5rem;
  }

  .landing-container {
    min-height: 50vh;
    padding: 1rem 0.5rem;
  }

  .landing-card {
    width: 100%;
    max-width: 320px;
    height: auto;
    min-height: 200px;
    padding: 1.5rem;
  }

  .landing-cards {
    gap: 1rem;
    flex-direction: column;
    align-items: center;
  }

  /* Upload area */
  .upload-area {
    padding: 2rem 1rem;
  }

  .upload-icon {
    font-size: 2rem;
  }

  .upload-text {
    font-size: 0.9rem;
    text-align: center;
  }

  .upload-text-desktop {
    display: none;
  }

  /* Stats header */
  .stats-header {
    flex-direction: column;
    align-items: flex-start;
  }

  #course-name {
    font-size: 1.2rem;
  }

  .stats-header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Stats grid — 3 columns on phone */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .stat-card {
    padding: 0.7rem 0.4rem;
    border-radius: 8px;
  }

  .stat-label {
    font-size: 0.65rem;
    margin-bottom: 0.2rem;
  }

  .stat-value {
    font-size: 1rem;
  }

  /* Stack map and waypoints vertically */
  #content-layout {
    padding-right: 0;
  }

  #content-right {
    position: static;
    width: 100%;
    overflow: visible;
  }

  /* Smaller map on mobile */
  #map {
    height: 300px;
  }

  /* Chart */
  .chart-wrapper {
    height: 140px;
  }

  #elevation-container {
    padding: 0.8rem;
  }

  #elevation-container h3 {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
  }

  /* Tabbed route panel */
  #route-tabs-panel {
    border-radius: 8px;
    overflow: visible;
  }

  #waypoints-table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  #waypoints-table,
  .waypoints-table {
    font-size: 0.75rem;
  }

  #waypoints-table td,
  .waypoints-table td {
    padding: 0.35rem 0.4rem;
  }

  #waypoints-table thead th,
  .waypoints-table thead th {
    padding: 0.3rem 0.4rem;
    font-size: 0.65rem;
  }

  /* Let tab content flow naturally in the stacked mobile layout */
  .fs-tab-content {
    overflow: visible;
  }

  .fs-tab-content .profile-panel-body {
    overflow: visible;
  }
}

/* Small phones */
@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  #map {
    height: 250px;
  }

  .chart-wrapper {
    height: 120px;
  }
}
