:root {
  --bg-dark: #0d0d12;
  --bg-card: #16161e;
  --bg-card-hover: #1e1e28;
  --bg-sidebar: #111118;
  --accent: #e8713a;
  --accent-light: #f0955e;
  --teal: #00cec9;
  --green: #27ae60;
  --blue: #4d96ff;
  --purple: #9b59b6;
  --red: #e74c3c;
  --yellow: #f39c12;
  --text: #e8e8ec;
  --text-muted: #8888a0;
  --text-dim: #555566;
  --border: #2a2a38;
  --radius: 8px;
  --sidebar-width: 420px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  z-index: 1000;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.sidebar-header h1 span {
  color: var(--accent);
}

.sidebar-header .subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-header .bikes {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  font-size: 11px;
}

.sidebar-header .bike-tag {
  padding: 3px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 500;
}

/* DAY NAVIGATION */
.day-nav {
  display: flex;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.day-nav::-webkit-scrollbar { height: 0; }

.day-nav button {
  flex: 1;
  min-width: 44px;
  padding: 10px 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.day-nav button:hover {
  color: var(--text-muted);
  background: var(--bg-card);
}

.day-nav button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-card);
}

/* SIDEBAR CONTENT */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sidebar-content::-webkit-scrollbar {
  width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* OVERVIEW PANEL */
.overview-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-card .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ROAD RATING */
.top-roads-list {
  margin-top: 16px;
}

.road-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.road-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.road-item .road-name {
  font-size: 13px;
  font-weight: 600;
}

.road-item .road-region {
  font-size: 11px;
  color: var(--text-muted);
}

.road-item .road-day {
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 6px;
  background: var(--bg-dark);
  border-radius: 3px;
}

.stars {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 1px;
  flex-shrink: 0;
  margin-left: 8px;
}

/* DAY PANEL */
.day-header {
  margin-bottom: 16px;
}

.day-header .day-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  margin-bottom: 4px;
}

.day-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.day-header .day-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.day-header .day-meta i {
  margin-right: 4px;
  width: 14px;
}

.day-summary {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* STOPS LIST */
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 10px;
  margin-top: 20px;
}

.section-title:first-of-type {
  margin-top: 0;
}

.stop-card {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.stop-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.stop-card .stop-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.stop-card .stop-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

.stop-card .stop-name {
  font-size: 13px;
  font-weight: 600;
}

.stop-card .stop-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-left: 36px;
}

.stop-card .stop-links {
  margin-top: 8px;
  margin-left: 36px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stop-card .stop-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  padding: 2px 8px;
  background: rgba(232, 113, 58, 0.1);
  border-radius: 3px;
  transition: all 0.2s;
}

.stop-card .stop-link:hover {
  background: rgba(232, 113, 58, 0.2);
}

/* ROADS SECTION */
.road-card {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.road-card .road-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.road-card .road-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
}

.road-card .road-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* TIPS */
.tips-box {
  padding: 12px;
  background: rgba(232, 113, 58, 0.08);
  border: 1px solid rgba(232, 113, 58, 0.2);
  border-radius: var(--radius);
  margin-top: 16px;
}

.tips-box .tips-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
}

.tips-box .tips-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* PACKING LIST */
.packing-list {
  list-style: none;
  padding: 0;
}

.packing-list li {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.packing-list li i {
  color: var(--accent);
  width: 14px;
  font-size: 10px;
}

/* FERRY INFO */
.ferry-card {
  padding: 14px;
  background: rgba(52, 152, 219, 0.08);
  border: 1px solid rgba(52, 152, 219, 0.2);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.ferry-card h3 {
  font-size: 14px;
  color: var(--blue);
  margin-bottom: 6px;
}

.ferry-card p {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

.ferry-card a {
  color: var(--blue);
  text-decoration: none;
}

/* FUEL STRATEGY */
.fuel-card {
  padding: 14px;
  background: rgba(243, 156, 18, 0.08);
  border: 1px solid rgba(243, 156, 18, 0.2);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.fuel-card h3 {
  font-size: 14px;
  color: var(--yellow);
  margin-bottom: 6px;
}

.fuel-card p {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* MAP */
.map-container {
  flex: 1;
  position: relative;
}

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

/* MAP LEGEND */
.map-legend {
  position: absolute;
  bottom: 24px;
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  z-index: 999;
  font-size: 11px;
  min-width: 140px;
}

.map-legend h4 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* SIDEBAR TOGGLE (mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
}

.leaflet-popup-content h3 {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text);
}

.leaflet-popup-content .popup-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-weight: 600;
}

.leaflet-popup-content p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.leaflet-popup-content a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}

/* Custom marker */
.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  font-size: 11px;
  color: #fff;
  transition: transform 0.2s;
}

.custom-marker:hover {
  transform: scale(1.2);
  z-index: 9999 !important;
}

.custom-marker.dimmed {
  opacity: 0.3;
  filter: grayscale(0.6);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 85vw;
    max-width: 380px;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .map-legend {
    bottom: 16px;
    right: 8px;
    font-size: 10px;
  }
}

/* ROUTE PROGRESS */
.route-progress-wrap {
  margin-bottom: 16px;
  transition: opacity 0.5s;
}
.route-progress-wrap.done .rp-bar-track { background: rgba(39,174,96,0.15); }
.route-progress-wrap.done .rp-bar { background: var(--green); }
.rp-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.rp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  transition: width 0.5s ease;
}
.rp-text {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.route-progress-wrap.done .rp-text { color: var(--green); }

/* GPX BUTTONS */
.gpx-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(45, 152, 218, 0.12);
  border: 1px solid rgba(45, 152, 218, 0.3);
  border-radius: var(--radius);
  color: #2d98da;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  margin-top: 8px;
}
.gpx-btn:hover {
  background: rgba(45, 152, 218, 0.22);
  border-color: #2d98da;
}
.gpx-btn.full-width {
  width: 100%;
  justify-content: center;
  padding: 10px 16px;
  font-size: 13px;
}
.gpx-pending {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
}
.route-badge {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(45,152,218,0.15);
  color: #2d98da;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-left: 4px;
  vertical-align: middle;
}

@media print {
  .sidebar {
    width: 100%;
    height: auto;
    overflow: visible;
    position: static;
    border: none;
  }
  .map-container, .sidebar-toggle, .map-legend, .day-nav { display: none; }
  .stop-card, .road-card, .tips-box { break-inside: avoid; }
}
