:root {
  --z-map: 0;
  --z-panels: 10;
  --z-toasts: 20;
  --z-dropdowns: 30;
  --z-modals: 40;
  --z-fab: 50;

  /* mörkt läge kontrast (justera vid behov) */
  --bg: #0f1115;
  --border: #2a2f3a;
  --text: #e9eef9;
  --muted: #a9b2c3;
  --accent: #0a65ff;

  /* shared panel styling */
  --panel-bg: rgba(23, 27, 35, 0.8);

  --panel-bg: #181818;

  --panel-border: 1px solid #2a2a2a;
  --panel-shadow: 0 0 25px rgba(0,0,0,0.6);
}

/* Håll "alltid överst"-lager */
#user-menu, .modal-layer { z-index: var(--z-modals); }
#darkmode-fab { z-index: var(--z-fab); }
#train-panel, #station-panel { z-index: var(--z-panels); }

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

body, html {
  width: 100%;
  height: 100%;
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--black);
  color: var(--white);
  overflow: hidden;
}


/* === OLD HEADER STYLES REMOVED === */
/* These were causing conflicts with the mist bar system */

#map {
  width: 100%;
  height: 100%;
  z-index: 0;
}

.leaflet-control-zoom {
  display: none !important;
}

.zoom-controls {
  position: absolute;
  bottom: 2rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.zoom-controls button {
  background-color: #222;
  color: white;
  border: none;
  margin: 2px;
  padding: 0.6rem 0.9rem;
  font-size: 1.2rem;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.zoom-controls button:hover {
  background-color: #444;
}

.train-panel {
  position: absolute;
  left: 20px;
  top: 80px;
  width: 360px;
  max-height: calc(100% - 100px);
  background: var(--panel-bg);
  border-radius: 16px;
  box-shadow: var(--panel-shadow);
  padding: 1.2rem 1.2rem 1.5rem;
  flex-direction: column;
  color: var(--text);
  z-index: 1000;
  overflow-y: auto;
  border: var(--panel-border);

  display: flex;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.train-panel.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.train-panel h2 {
  margin-bottom: 0.75rem;
  font-size: 1.4rem;
  font-weight: 600;
}

.train-panel {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.train-panel::-webkit-scrollbar {
  display: none;
}

.stop-list {
  margin-top: 1rem;
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stop-list {
  padding-left: 0;
  margin-top: 1rem;
  list-style: none;
  counter-reset: stop;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stop-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  position: relative;
}

.stop-line {
  border-left: 2px solid #4caf50;
  margin-left: 4px;
  height: 100%;
  position: absolute;
  top: 10px;
  left: 4px;
  z-index: 0;
}

.stop-content {
  background-color: #242424;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  flex-grow: 1;
  position: relative;
  z-index: 1;
}

.stop-time {
  font-weight: bold;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.stop-name {
  font-size: 1rem;
}

.stop-delay {
  color: #f44336;
  font-size: 0.85rem;
}

.stop-canceled .stop-content {
  text-decoration: line-through;
  color: gray;
  opacity: 0.6;
}


.stop-name {
  font-weight: bold;
  flex: 1;
  font-size: 0.95rem;
}

.stop-info {
  text-align: right;
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: pre-line;
}

.close-btn {
  background: none;
  border: none;
  color: #bbb;
  font-size: 1.3rem;
  align-self: flex-end;
  cursor: pointer;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: white;
}

body.light-theme {
  background-color: #f8f8f8;
  color: #000;
}

body.light-theme .search {
  background-color: #ddd;
  color: #000;
}

body.light-theme .train-panel {
  background-color: #fff;
  color: #000;
  border: 1px solid #ccc;
}

body.light-theme .stop-list li {
  background-color: #eee;
  border-color: #ccc;
  box-shadow: inset 0 0 0 1px #ddd;
}
.leaflet-marker-icon,
.leaflet-marker-icon img {
  opacity: 1 !important;
}

@keyframes train-clicked {
  0% { transform: scale(1) rotate(var(--rotation, 0deg)); }
  50% { transform: scale(1.3) rotate(var(--rotation, 0deg)); }
  100% { transform: scale(1) rotate(var(--rotation, 0deg)); }
}

.train-animate-click {
  animation: train-clicked 0.4s ease;
}


.logo {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  font-weight: bold;
  cursor: pointer;
}

.logo:hover {
  opacity: 0.8;
}

/* 🔧 Mobilanpassning */
@media (max-width: 768px) {
  .header-left,
  .header-right {
    padding: 0 0.5rem;
    gap: 0.3rem;
  }

  .search {
    width: 100%;
    max-width: 100vw;
    margin: 0.5rem 0;
  }

  .train-panel {
    top: 60px;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-height: calc(100vh - 60px);
    border-radius: 0;
  }

  .train-panel {
    padding: 1rem;
  }

  .zoom-controls {
    bottom: 1rem;
    right: 0.5rem;
  }

  .stop-content {
    padding: 0.6rem 0.8rem;
  }

  .stop-time, .stop-name {
    font-size: 0.9rem;
  }

  .stop-delay {
    font-size: 0.8rem;
  }

  body, html {
    overflow: auto;
    touch-action: manipulation;
  }
}

:root {
  --black: #000;
  --white: #fff;
  --gray: #1a1a1a;
}

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

body, html {
  width: 100%;
  height: 100%;
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--black);
  color: var(--white);
  overflow: hidden;
}

/* === DUPLICATE HEADER STYLES REMOVED === */

#map {
  width: 100%;
  height: 100%;
  z-index: 0;
}

.leaflet-control-zoom {
  display: none !important;
}

.zoom-controls {
  position: absolute;
  bottom: 2rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.zoom-controls button {
  background-color: #222;
  color: white;
  border: none;
  margin: 2px;
  padding: 0.6rem 0.9rem;
  font-size: 1.2rem;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.zoom-controls button:hover {
  background-color: #444;
}

/* 🚆 Tågpanel */
.train-panel {
  position: absolute;
  left: 20px;
  top: 80px;
  width: 360px;
  max-height: calc(100% - 100px);
  background-color: #181818;
  border-radius: 16px;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.6);
  padding: 1.2rem 1.2rem 1.5rem;
  flex-direction: column;
  color: white;
  z-index: 1000;
  overflow-y: auto;
  border: 1px solid #2a2a2a;

  display: flex;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.train-panel.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.train-panel h2 {
  margin-bottom: 0.75rem;
  font-size: 1.4rem;
  font-weight: 600;
}

.train-panel {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.train-panel::-webkit-scrollbar {
  display: none;
}

.stop-list {
  margin-top: 1rem;
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stop-list li {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
}

.stop-content {
  background-color: #242424;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  flex-grow: 1;
  position: relative;
  z-index: 1;
}

.stop-time {
  font-weight: bold;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.stop-name {
  font-weight: bold;
  flex: 1;
  font-size: 0.95rem;
}

.stop-delay {
  color: #f44336;
  font-size: 0.85rem;
}

.stop-canceled .stop-content {
  text-decoration: line-through;
  color: gray;
  opacity: 0.6;
}

.close-btn {
  background: none;
  border: none;
  color: #bbb;
  font-size: 1.3rem;
  align-self: flex-end;
  cursor: pointer;
  transition: color 0.2s ease;
}
.close-btn:hover {
  color: white;
}



/* ⚙️ Inställningspanel */

.setting-item {
  margin-bottom: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.light-theme {
  background-color: #f8f8f8;
  color: #000;
}
body.light-theme .search {
  background-color: #ddd;
  color: #000;
}
body.light-theme .train-panel {
  background-color: #fff;
  color: #000;
  border: 1px solid #ccc;
}
body.light-theme .stop-list li {
  background-color: #eee;
  border-color: #ccc;
  box-shadow: inset 0 0 0 1px #ddd;
}
.logo {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  font-weight: bold;
  cursor: pointer;
}
.logo:hover {
  opacity: 0.8;
}

/* 🧭 Stationpanel */
.station-panel {
  position: absolute;
  right: 20px;
  top: 80px;
  width: 360px;
  max-height: calc(100% - 100px);
  background: var(--panel-bg);
  border: var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--panel-shadow);
  padding: 20px;
  font-family: sans-serif;
  color: var(--text);
  z-index: 1000;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;

  scrollbar-width: none;
  -ms-overflow-style: none;
}

.station-panel::-webkit-scrollbar {
  display: none;
}

.station-panel.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* New station panel design components */
.station-header {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  border: 2px solid #000;
  border-radius: 16px;
  padding: 6px 14px;
  display: inline-block;
  margin: 0 auto 16px;
  width: fit-content;
}

.station-toggle {
  display: flex;
  justify-content: center;
  gap: 10px;
  background: #f3f3f3;
  border-radius: 20px;
  padding: 4px 8px;
  width: fit-content;
  margin: 0 auto 20px;
  font-size: 14px;
  font-weight: 500;
}

.station-toggle span {
  padding: 6px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.station-toggle .active {
  background: #000;
  color: #fff;
}

.station-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.station-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #ccc;
  padding-bottom: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  padding: 8px 0;
  border-radius: 8px;
}

.station-row:hover {
  background-color: #f8f8f8;
}

.station-row:last-child {
  border-bottom: none;
}

.left .dest {
  font-weight: 600;
  font-size: 16px;
  color: #000;
}

.left .train {
  font-size: 13px;
  color: #666;
  margin-top: 2px;
}

.right {
  text-align: right;
}

.right .time {
  font-weight: 600;
  font-size: 16px;
  color: #000;
}

.right .date {
  font-size: 13px;
  color: #666;
  margin-top: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .station-panel {
    background: #1a1a1a;
    color: #fff;
  }
  
  .station-header {
    border-color: #fff;
    color: #fff;
  }
  
  .station-toggle {
    background: #333;
  }
  
  .station-toggle .active {
    background: #fff;
    color: #000;
  }
  
  .station-row:hover {
    background-color: #2a2a2a;
  }
  
  .left .dest,
  .right .time {
    color: #fff;
  }
  
  .left .train,
  .right .date {
    color: #aaa;
  }
  
  .station-row {
    border-bottom-color: #444;
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .station-panel {
    width: calc(100vw - 40px);
    margin: 20px;
    border-radius: 20px;
  }
  
  .station-header {
    font-size: 18px;
    padding: 4px 12px;
  }
  
  .station-toggle {
    font-size: 13px;
  }
  
  .station-toggle span {
    padding: 5px 12px;
  }
  
  .left .dest {
    font-size: 15px;
  }
  
  .right .time {
    font-size: 15px;
  }
}





.departure-item.clickable {
  cursor: pointer;
}

.departure-item.clickable:hover {
  background-color: #333;
}

.status-icon {
  font-size: 1rem;
  margin-right: 0.5rem;
}

.departure-time, .departure-to, .departure-track {
  font-size: 0.95rem;
}

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

.dot-ontime {
  background-color: #4caf50; /* grön */
}

.dot-delayed {
  background-color: #f44336; /* röd */
}

.dot-canceled {
  background-color: #000; /* svart */
}

.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  padding: 2rem;
  border-radius: 10px;
  width: 300px;
  box-shadow: 0 0 10px #000;
  text-align: center;
}

.hidden {
  display: none;
}

.modal input {
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.5rem;
  font-size: 1rem;
}
.account-popup {
  position: absolute;
  top: 60px;
  left: 10px;
  background: #111;
  color: white;
  padding: 1rem;
  border: 1px solid #444;
  border-radius: 8px;
  z-index: 999;
  display: none;
  width: 240px;
}
.account-popup.visible {
  display: block;
}
.account-popup input {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.4rem;
  background: #222;
  border: 1px solid #555;
  color: white;
}
.account-popup button {
  width: 100%;
  padding: 0.5rem;
  background: #00aaff;
  color: white;
  border: none;
  cursor: pointer;
  margin-bottom: 0.5rem;
}
.message {
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 9999;
}

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

.modal-box {
  background: #1f1f1f;
  color: white;
  padding: 2rem;
  border-radius: 12px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-family: system-ui, sans-serif;
  text-align: center;
}

.modal-box h2 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.input-group {
  display: flex;
  align-items: center;
  background: #2a2a2a;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.input-group .icon {
  margin-right: 0.6rem;
  color: #aaa;
}

.input-group input {
  background: transparent;
  border: none;
  outline: none;
  color: white;
  flex: 1;
  font-size: 1rem;
}

.forgot {
  font-size: 0.85rem;
  color: #999;
  text-align: right;
  margin-bottom: 1rem;
}

.login-btn {
  width: 100%;
  padding: 0.7rem;
  font-size: 1rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 1rem;
}

.register-link {
  font-size: 0.9rem;
  color: #ccc;
}

.register-link a {
  color: #fff;
  text-decoration: underline;
}

.login-message {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}
/* === OLD MODERN HEADER SECTION REMOVED === */

/* Inloggad användare */
.user-badge {
  display: flex;
  align-items: center;
  background: #222;
  color: #eee;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  gap: 0.5rem;
  margin-left: 1rem;
  font-size: 0.9rem;
}

.logout-btn {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 1rem;
}

.logout-btn:hover {
  color: red;
}

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

/* Icon buttons */
.icon-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  margin-right: 0.5rem;
  cursor: pointer;
}

.search {
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: none;
  background: #333;
  color: white;
}
.account-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 1rem; /* skjut bort från kugghjul */
}

.header-left,
.header-right,
.header-center {
  display: flex;
  align-items: center;
  height: 100%;
}

.header-left {
  gap: 0.75rem;
}

.header-center {
  flex: 1;
  justify-content: center;
}

.header-right {
  gap: 0.75rem;
}

#search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: 90vw;
  background-color: #111;
  border-radius: 10px;
  max-height: 50vh;
  overflow-y: auto;
  z-index: 1400;
  display: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  padding: .2rem 0;
}

#search-suggestions.active { 
  display: block !important; 
  visibility: visible !important;
  opacity: 1 !important;
}

#search-suggestions::-webkit-scrollbar {
  width: 0;
  height: 0;
}

#train-panel.visible {
  opacity: 1;
  visibility: visible;
}

/* TÅGPANEL-STIL */
#train-panel {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 320px;
  max-height: 90vh;
  background-color: #18181b; /* mörkgrå bakgrund */
  color: #f4f4f5;
  border-radius: 1rem;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
  padding: 1rem;
  overflow-y: auto;
  z-index: 1000;
  transition: all 0.3s ease;
}

#train-panel h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

#train-panel button#close-panel {
  font-size: 1.5rem;
  color: #a1a1aa;
  background: none;
  border: none;
  cursor: pointer;
  float: right;
}
#train-panel button#close-panel:hover {
  color: #fff;
}

#panel-route {
  font-size: 0.9rem;
  color: #a1a1aa;
  margin-bottom: 0.5rem;
}

.train-stop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #27272a;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  transition: background-color 0.2s ease;
}

.train-stop:hover {
  background-color: #3f3f46;
}

.train-stop .station-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background-color: #888;
  flex-shrink: 0;
}

.status-dot.green {
  background-color: #4ade80;
}

.status-dot.red {
  background-color: #f87171;
}

.status-dot.black {
  background-color: #ccc;
}

/* Anpassa scrollbar för train-panel */
#train-panel::-webkit-scrollbar {
  width: 6px;
}

#train-panel::-webkit-scrollbar-thumb {
  background-color: #4b5563;
  border-radius: 3px;
}
.train-stop {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #333;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 9999px;
}

.status-dot.green {
  background-color: #00cc66;
}

.status-dot.red {
  background-color: #cc3333;
}

.status-dot.black {
  background-color: #444;
}

/* === OLD HEADER LOGO SECTION REMOVED === */

/* .suggestions styling removed - using #search-suggestions instead */

.suggestion-item {
  padding: 0.6rem 0.8rem;
  color: #fff;
  font-size: 0.95rem;
  border-bottom: 1px solid #222;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background-color: #222;
}

.suggestion-item.active {
  background-color: rgba(10,101,255,0.12);
}
@media screen and (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
  }

  .logo-container img {
    height: 80px; /* Lite mindre logga på mobil */
  }

  .search-container {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .search-container input {
    width: 90%;
    max-width: 300px;
  }

  .user-container {
    position: absolute;
    top: 10px;
    right: 10px;
  }
}
/* === OLD MOBILE HEADER STYLES REMOVED === */

@media (max-width: 768px) {
  .header-right {
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: center;
  }



  .main-header {
    flex-wrap: wrap;
  }

  .header-logo {
    order: 2;
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
  }

  .header-left {
    order: 1;
  }

  .header-right {
    order: 3;
    width: 100%;
    margin-top: 0.5rem;
  }

  .search {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  /* Search suggestions width handled in main rule */
}
@media (max-width: 768px) {
  .train-panel {
    transition: height 0.2s ease;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    background: #111;
  }

  .train-panel.dragging {
    transition: none;
  }

  .panel-drag-handle {
    width: 100%;
    padding: 10px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #222;
    touch-action: none;
    cursor: grab;
  }

  .drag-bar {
    width: 50px;
    height: 5px;
    background-color: #555;
    border-radius: 2.5px;
  }
}
@media (max-width: 768px) {
  .train-panel {
    height: 100vh;
    max-height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    transition: transform 0.3s ease;
    transform: translateY(0%);
    background: #111;
    z-index: 1000;
    display: flex;
    flex-direction: column;
  }

  .train-panel.minimized {
    transform: translateY(60%);
  }

  .panel-drag-handle {
    width: 100%;
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #222;
    cursor: grab;
    touch-action: none;
  }

  .drag-bar {
    width: 50px;
    height: 5px;
    background-color: #555;
    border-radius: 3px;
  }
}
.route-stop {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  padding: 0.6rem 0;
}

.stop-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  color: white;
}

.stop-name {
  font-weight: 500;
}

.track-box {
  font-size: 0.75rem;
  background-color: white;
  color: black;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

.stop-time {
  margin-left: auto;
  font-size: 1rem;
  color: white;
}

.delay-text {
  margin-left: 0.5rem;
  font-weight: bold;
}

.delay-text.red {
  color: #f87171;
}
.delay-text.green {
  color: #4ade80;
}
.delay-text.black {
  color: #ccc;
}
.panel-operator {
  font-size: 1.1rem;
  font-weight: 400;
  color: #ccc;
  margin-top: -10px;
  margin-bottom: 10px;
}
.panel-operator span {
  font-weight: bold;
  color: white;
}
.operator-logo {
  width: 28px;
  height: auto;
  margin-right: 8px;
  vertical-align: middle;
}
#panel-operator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 8px;
}
.operator-logo {
  height: 2em;            /* Justera höjden */
  width: auto;              /* Behåll proportionerna */
  vertical-align: middle;   /* Centrera med texten */
  margin-right: 0.5em;      /* Lite luft före texten */
  object-fit: contain;      /* Viktigt för att undvika stretch */
  image-rendering: auto;    /* Extra snygg skalning */
}
.booking-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.booking-button {
  background-color: #1e90ff;
  color: white;
  font-weight: 600;
  padding: 10px 18px;
  text-decoration: none;
  border-radius: 8px;
  font-size: 1rem;
  transition: background-color 0.2s ease;
}
.booking-button:hover {
  background-color: #006fd3;
}
.booking-wrapper {
  margin-top: 20px;
  text-align: center;
}

.booking-button {
  display: inline-block;
  padding: 10px 20px;
  background-color: #1e90ff;
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.2s;
}

.booking-button:hover {
  background-color: #0d6efd;
}
.booking-wrapper {
  margin: 1.5rem 0 1rem;
  text-align: center;
}

.booking-button {
  display: inline-block;
  background-color: #0054a6;
  color: white;
  padding: 0.75rem 1.5rem;
  font-weight: bold;
  text-decoration: none;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.booking-button:hover {
  background-color: #003d7a;
}

/* 🌐 Grundstil för alla loggor */
.operator-logo {
  object-fit: contain;
  display: block;
  max-width: 100%;
  margin-left: -4px; /* Standardförskjutning åt vänster */
}

/* 🎯 Individuell finjustering per operatör */
.operator-sj {
  height: 35px;
  transform: translate(-40px, 10px);
}

.operator-sl {
  height: 40px;
  transform: translate(-6px, 7px);
}

.operator-västtrafik {
  height: 130px;
  transform: translate(-90px, -30px);
}

.operator-xtrafik {
  height: 25px;
  transform: translate(-5px, 0px);
}

.operator-mälartåg {
  height: 30px; /* Minskad från 60px för bättre passform */
  transform: translate(-8px, 5px);
}

.operator-tib {
  height: 130px;
  transform: translate(-15px, 0px);
}

.operator-pågatågen {
  height: 26px;
  transform: translate(-5px, 0px);
}

.operator-öresundståg {
  height: 23px;
  transform: translate(-5px, 0px);
}

.operator-norrtag {
  height: 40px;
  transform: translate(-5px, 10px);
}

.operator-snälltåget {
  height: 24px;
  transform: translate(-5px, 0px);
}

.operator-default {
  height: 24px;
  transform: translate(-5px, 0px);
}
.rail-icon-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: -1px 0; /* kombinerar topp & botten */
  gap: 0;
}

.rail-icon {
  height: 40px;
  width: auto;
  margin: 0;
  padding: 0;
  line-height: 1;
}

.route-stop {
  gap: 1rem;
}

.route-stop + .route-stop .rail-icon-col {
  margin-top: -16px; /* minimerar mellanrum mellan ikoner */
}
.rail-icon {
  display: block; /* 🧽 tar bort "inline spacing" */
}

/* 🆕 Ny stil för tågpanel enligt mockup */
#train-panel {
  background-color: #1a1a1a;
  border-radius: 1rem;
  color: white;
  padding: 1.2rem;
  font-family: 'Segoe UI', sans-serif;
  width: 340px;
}

#train-panel h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

/* === TRAFFIC INFO BOX === */
.train-traffic-info {
  background-color: #ffeb3b;
  border: 2px solid #f57f17;
  border-radius: 8px;
  margin: 8px 16px;
  padding: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  /* TEMPORARY: Make sure it's visible for testing */
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.traffic-info-content {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.traffic-info-label {
  font-weight: bold;
  color: #e65100;
  font-size: 0.9rem;
  white-space: nowrap;
}

.traffic-info-message {
  color: #bf360c;
  font-size: 0.9rem;
  line-height: 1.4;
  flex: 1;
}

/* Dark theme support for traffic info box */
@media (prefers-color-scheme: dark) {
  .train-traffic-info {
    background-color: #ffc107;
    border-color: #ff8f00;
  }
  
  .traffic-info-label {
    color: #d84315;
  }
  
  .traffic-info-message {
    color: #bf360c;
  }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .train-traffic-info {
    margin: 6px 12px;
    padding: 10px;
  }
  
  .traffic-info-content {
    flex-direction: column;
    gap: 4px;
  }
  
  .traffic-info-label {
    font-size: 0.85rem;
  }
  
  .traffic-info-message {
    font-size: 0.85rem;
  }
}

#panel-operator {
  margin-bottom: 0.6rem;
}
#panel-operator img {
  height: 30px;
}

#panel-route {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: #ddd;
}

.stop-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stop-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 0.5rem 0;
  border-bottom: 1px solid #333;
}

.stop-icon {
  margin-right: 0.7rem;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stop-details {
  display: flex;
  flex-direction: column;
}

.stop-name {
  font-weight: bold;
  font-size: 1rem;
}

.stop-track {
  font-size: 0.85rem;
  color: #aaa;
}

.stop-time-status {
  text-align: right;
}

.stop-time {
  font-size: 1rem;
  font-weight: bold;
}

.stop-status {
  font-size: 0.9rem;
}

.stop-ontime .stop-status {
  color: #5dfcba;
}
.stop-delayed .stop-status {
  color: #f44336;
}
.stop-canceled .stop-status {
  color: gray;
}
@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(72, 239, 144, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(72, 239, 144, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(72, 239, 144, 0);
  }
}

.current-stop {
  position: relative;
  border-radius: 12px;
  animation: pulse-ring 1.5s ease-out infinite;
  background-color: #1f1f1f;
}
.panel-title-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-train-number {
  font-size: 2rem;
  font-weight: bold;
}

.booking-button {
  background-color: #1e90ff;
  color: white;
  padding: 6px 12px;
  font-size: 0.875rem;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.booking-button:hover {
  background-color: #0f78d1;
}
.stop-clickable {
  cursor: pointer;
}
.stop-clickable:hover {
  background-color: #2d2e2e;
}
.train-extra-info {
  padding: 10px;
  font-size: 14px;
}

.train-extra-info p {
  margin: 6px 0;
}

.train-extra-info strong {
  color: #333;
}

.train-info-button {
  display: block;
  margin: 0.5rem 0;
  padding: 0.5rem 1rem;
  background: linear-gradient(180deg, #ffd64d, #ffb700);
  color: white;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.train-info-button:hover {
  background: linear-gradient(180deg, #FFDE66, #cc9702);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}
.traffic-info-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.traffic-info-btn img {
  width: 56px;
  height: 56px;
}

.traffic-info-btn:hover img {
  filter: brightness(1.2);
}
#station-departures {
  max-height: 70vh; /* eller 60–80vh beroende på vad som passar din layout */
  overflow-y: auto;
  padding-right: 10px; /* så inte scrollbaren klipper texten */
}

/* Footer med start → slut underst */
.route-footer { margin-top:10px; padding-top:8px; border-top:1px solid rgba(255,255,255,.06); color:#ddd; font-weight:600; }


/* === Dark map mode (bara bas-tiles, inte markörer/overlays) === */
body.dark-map .leaflet-container {
  background: #0b0b0b;           /* mörk bakgrund när tiles laddar */
}

body.dark-map .leaflet-tile-pane img.leaflet-tile {
  /* Invertera + rotera färger så OSM-ljus blir mörkt men läsbart */
  filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.95) saturate(0.7);
}

/* (valfritt) justera zoomknappar lite i mörkt läge */
body.dark-map .zoom-controls button {
  background: #1a1a1a;
  color: #f2f2f2;
  border-color: #2a2a2a;
}
body.dark-map .zoom-controls button:hover {
  background: #242424;
}

/* === Dark map mode (tiles) === */
body.dark-map .leaflet-container {
  background: #0b0b0b; /* mörk bakgrund när tiles laddar */
}
body.dark-map .leaflet-tile-pane img.leaflet-tile {
  filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.95) saturate(0.7);
}





/* Snygg dark mode toggle med ikoner */
.switch {
  position: relative;
  width: 56px;
  height: 32px;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch input { 
  display: none; 
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #ffd700, #ffb347);
  border-radius: 16px;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    inset 0 0 0 2px rgba(255,255,255,0.15),
    0 2px 8px rgba(255, 215, 0, 0.3);
  overflow: hidden;
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 4px;
  top: 4px;
  background: #fff;
  border-radius: 50%;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 2px 8px rgba(0,0,0,0.2),
    0 0 0 1px rgba(255,255,255,0.8);
  z-index: 2;
}

.switch input:checked + .slider { 
  background: linear-gradient(135deg, #4a5568, #2d3748);
  box-shadow: 
    inset 0 0 0 2px rgba(255,255,255,0.1),
    0 2px 8px rgba(74, 85, 104, 0.4);
}

.switch input:checked + .slider::before { 
  transform: translateX(24px);
  background: #e2e8f0;
  box-shadow: 
    0 2px 8px rgba(0,0,0,0.3),
    0 0 0 1px rgba(226, 232, 240, 0.9);
}

/* Ikoner i slider */
.slider-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  transition: all .3s ease;
  z-index: 1;
}

.slider-icon.sun {
  left: 8px;
  opacity: 1;
}

.slider-icon.moon {
  right: 8px;
  opacity: 0.3;
}

.switch input:checked + .slider .slider-icon.sun {
  opacity: 0.3;
}

.switch input:checked + .slider .slider-icon.moon {
  opacity: 1;
}

/* Hover effekter */
.switch:hover .slider {
  transform: scale(1.05);
}

.switch:active .slider::before {
  transform: scale(0.95);
}



/* 1) Spårpill: ingen radbrytning och snygg align */
.track,
.track-box {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
/* === Apple-lik GPS-dot === */
.gps-icon { pointer-events: none; } /* markören ska inte få klick */
.gps-dot {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0a84ff;                /* iOS blå */
  box-shadow:
    0 0 0 2px #fff,                   /* vit tunn ring runt kärnan */
    0 0 0 6px rgba(10,132,255,0.28);  /* mjuk blå aura */
}
.gps-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;              /* centrera */
  border-radius: 50%;
  animation: gpsPulse 1.8s ease-out infinite;
  box-shadow: 0 0 0 0 rgba(10,132,255,0.45);
}
@keyframes gpsPulse {
  0%   { box-shadow: 0 0 0 0   rgba(10,132,255,0.45); }
  60%  { box-shadow: 0 0 0 14px rgba(10,132,255,0.00); }
  100% { box-shadow: 0 0 0 0   rgba(10,132,255,0.00); }
}

/* --- Rail & stopplista --- */
.stop-row{display:flex;gap:10px;padding:8px 0;border-bottom:1px solid rgba(255,255,255,.06);align-items:stretch;cursor:pointer;}
.stop-row.stop-canceled{opacity:.6;}

.rail-col{width:22px;display:flex;flex-direction:column;align-items:center;padding-top:6px;position:relative;}
.rail-dot{width:10px;height:10px;background:#ddd;border-radius:50%;position:relative;top:6px;z-index:2;}

/* LÄGG TILL – sammanhängande räls + slipers som bakgrund */
#panel-stops { position: relative; }

/* Slipers (trä), upprepade horisontella ribbor */
#panel-stops::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 9px;  /* top/right/bottom/left — vänster 9px */
  width: 14px;          /* total bredd för skenor + slipers */
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(139, 94, 60, 0.85) 0px,   /* träfärg */
      rgba(139, 94, 60, 0.85) 4px,   /* tjocklek på sliper */
      transparent 4px,
      transparent 22px               /* avstånd mellan slipers */
    );
  opacity: .55;
  border-radius: 2px;
}

/* Två silvriga skenor */
#panel-stops::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 9px;
  width: 14px;
  pointer-events: none;
  background-image:
    linear-gradient(to bottom, #e2e6ea, #b9c0c7),  /* vänster skena */
    linear-gradient(to bottom, #e2e6ea, #b9c0c7);  /* höger skena */
  background-size: 3px 100%, 3px 100%;
  background-repeat: no-repeat, no-repeat;
  background-position: left 2px top, right 2px top; /* 2px in från kanterna */
  filter: drop-shadow(0 0 1px rgba(255,255,255,.25));
  opacity: .95;
}

.main-col{flex:1;display:flex;justify-content:space-between;align-items:flex-start;gap:8px;}
.name-block{display:flex;flex-direction:column;gap:2px;}
.stop-name{font-weight:600;}
.stop-track{font-size:.9em;opacity:.9;}

.times{display:flex;flex-direction:column;gap:2px;text-align:right;min-width:96px;}
.time-line{display:flex;justify-content:flex-end;gap:6px;}
.old-time{text-decoration:line-through;opacity:.6;}
.new-time{color:#ddd;font-weight:600;}
.new-time.red{color:#f44336;}

/* --- Bild + meta + footer --- */
#loco-wrapper{margin:8px 0 6px;}
.panel-meta{margin:2px 0 10px;color:#ddd;}
.panel-meta .meta-row{display:flex;gap:6px;margin:2px 0;}
.panel-meta .meta-label{opacity:.8;}
.panel-meta .meta-value{font-weight:600;color:#fff;}

.route-footer{margin-top:10px;padding-top:8px;border-top:1px solid rgba(255,255,255,.06);color:#ddd;font-weight:600;}

/* --- Legacy/kompat: undvik radbrytning om någon gammal .track/.track-box används --- */
.track,.track-box{white-space:nowrap;display:inline-flex;align-items:center;line-height:1;}

/* Titel-storlekar enligt skissen */
.panel-title-top{display:flex;flex-direction:column;gap:2px;}
.panel-destination{font-size:1.6rem;font-weight:800;line-height:1.1;}
.panel-train-number{font-size:.9rem;opacity:.85;font-weight:700;letter-spacing:.3px;}

/* Säkerställa mellanrum i meta-rader även om gap inte appliceras */
.panel-meta .meta-label{margin-right:6px;}  





/* Toggle (switch) – om du använder .switch/.slider i HTML */
.switch { position: relative; display: inline-block; width: 48px; height: 28px; }
.switch input { display:none; }
.slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: #333; transition: background .18s ease;
}
.slider:before {
  content: ""; position: absolute; height: 22px; width: 22px;
  left: 3px; top: 3px; border-radius: 50%; background: #fff;
  transition: transform .18s ease;
}
.switch input:checked + .slider { background: #4c8dff; }
.switch input:checked + .slider:before { transform: translateX(20px); }







body.light-theme .slider {
  background: #ccc;
}

body.light-theme .switch input:checked + .slider {
  background: #007AFF;
}

/* Enhanced switch styling */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  inset: 0;
  background: #555;
  border-radius: 14px;
  transition: background .2s ease;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
  cursor: pointer;
}

.slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease, box-shadow .2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.switch input:checked + .slider {
  background: #1e90ff;
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.switch:hover .slider {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}

.switch input:checked + .slider:hover {
  background: #007AFF;
}



/* === FINAL OVERRIDES v2: Train panel + centrerd räls/slipers === */

/* Baslayout (överstyr äldre varianter) */
.stop-row{display:flex;gap:10px;padding:8px 0;border-bottom:1px solid rgba(255,255,255,.06);align-items:stretch;background:transparent;cursor:pointer;}
.main-col{flex:1;display:flex;justify-content:space-between;align-items:flex-start;gap:8px;}
.name-block{display:flex;flex-direction:column;gap:2px;}
.stop-name{font-weight:600;}
.stop-track{font-size:.9em;opacity:.9;}
.times{display:flex;flex-direction:column;gap:2px;text-align:right;min-width:96px;}
.time-line{display:flex;justify-content:flex-end;gap:6px;}
.old-time{text-decoration:line-through;opacity:.6;}
.new-time{color:#ddd;font-weight:600;}
.new-time.red{color:#f44336;}

#loco-wrapper{margin:8px 0 6px;}
.panel-meta{margin:2px 0 10px;color:#ddd;}
.panel-meta .meta-row{display:flex;gap:6px;margin:2px 0;}
.panel-meta .meta-label{opacity:.8;margin-right:6px;}
.panel-meta .meta-value{font-weight:600;color:#fff;}

.panel-title-top{display:flex;flex-direction:column;gap:2px;}
.panel-destination{font-size:1.6rem;font-weight:800;line-height:1.1;}
.panel-train-number{font-size:.9rem;opacity:.85;font-weight:700;letter-spacing:.3px;}

/* Vänsterkolumn + prick */
.rail-col{width:var(--rail-col-width,22px);display:flex;flex-direction:column;align-items:center;padding-top:6px;position:relative;z-index:2;}
.rail-dot{width:12px;height:12px;border-radius:50%;background:var(--dot-fill,#fff);border:2px solid var(--dot-stroke,#2a2a2a);box-shadow:0 0 0 2px rgba(0,0,0,.25) inset;position:relative;top:6px;z-index:3;}

/* === Rails-system (centrerat under pricken) – justera med variabler === */
.train-panel{
  /* 📐 Kolumn/centrering */
  --rail-col-width: 22px;                 /* måste matcha .rail-col */
  --rail-center: calc(var(--rail-col-width) / 2);

  /* 📏 Geometri */
  --rail-width: 26px;                     /* tot. bredd (båda skenor + gap + luft) */
  --rail-thickness: 3px;                  /* skenans tjocklek */
  --rail-inset: 4px;                      /* luft från ytterkant in till skena */

  /* 🪵 Slipers */
  --sleeper-thickness: 6px;               /* höjd per sliper */
  --sleeper-gap: 24px;                    /* avstånd mellan slipers */

  /* 🎨 Färger */
  --sleeper-color: #8a5b3a;               /* träfärg */
  --sleeper-opacity: .42;
  --rail-top: #e9eff6;                    /* ljus metall */
  --rail-bottom: #97a3af;                 /* skuggsida metall */

  /* ● Prick */
  --dot-fill: #ffffff;
  --dot-stroke: #2a2a2a;
}

/* Rita rälsen/slipers EN gång bakom hela listan */
.train-panel #panel-stops{position:relative;z-index:0;}
.train-panel #panel-stops::before{
  content:"";
  position:absolute;top:0;bottom:0;
  left: calc(var(--rail-center) - (var(--rail-width) / 2));
  width: var(--rail-width);
  pointer-events:none;z-index:0;border-radius:2px;opacity:var(--sleeper-opacity);
  background:
    repeating-linear-gradient(
      to bottom,
      var(--sleeper-color) 0,
      var(--sleeper-color) var(--sleeper-thickness),
      transparent var(--sleeper-thickness),
      transparent var(--sleeper-gap)
    );
}
.train-panel #panel-stops::after{
  content:"";
  position:absolute;top:0;bottom:0;
  left: calc(var(--rail-center) - (var(--rail-width) / 2));
  width: var(--rail-width);
  pointer-events:none;z-index:0;opacity:.97;
  filter: drop-shadow(0 0 1px rgba(255,255,255,.25));
  background-image:
    linear-gradient(to bottom, var(--rail-top), var(--rail-bottom)),
    linear-gradient(to bottom, var(--rail-top), var(--rail-bottom));
  background-size:
    var(--rail-thickness) 100%,
    var(--rail-thickness) 100%;
  background-repeat:no-repeat,no-repeat;
  background-position:
    left  var(--rail-inset) top,
    right var(--rail-inset) top;
}

/* Grå prick för passerade stopp */
.rail-dot.past{
  background:#6d6d6d;       /* ljusgrå fyllning */
  border-color:#505050;        /* mörkare kant */
  box-shadow:none;
  opacity:.85;
}

/* ==== User chip & meny ==== */
.user-badge { position: relative; margin: 0; }

.ub-chip {
  display: inline-flex; align-items: center; gap: .6rem;
  height: 40px; padding: 0 .9rem 0 .5rem;
  background: #1b1f27;           /* lite ljusare än #111 */
  border: 0; outline: 0; box-shadow: none; /* inga konturer/ringar */
  color: #e8ecf4; font-weight: 600; letter-spacing: .2px;
  border-radius: 999px;
  transition: background .15s ease, transform .05s ease;
  cursor: pointer;
}
.ub-chip:hover { background: #232938; }
.ub-chip:active { transform: translateY(0); } /* stäng av micro-bounce */

.ub-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #5ea2ff, #3963d5 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.ub-text { color: #f0f3f8; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ub-caret { opacity: .8; font-size: .9rem; }

.ub-menu {
  position: absolute; top: 48px; left: 0; /* direkt under chippen */
  background: #151922; border: 1px solid #22293a;
  border-radius: 12px; padding: .4rem; min-width: 200px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  display: none; z-index: 1200;
}
.ub-menu.open { display: block; }
.ub-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; color: #dfe6f3;
  padding: .55rem .7rem; border-radius: 8px; cursor: pointer;
  font-weight: 500;
}
.ub-item:hover { background: #1f2532; }
.ub-item.danger { color: #ffb4b4; }
.ub-item.danger:hover { background: #2b1f23; }

.ub-sep {
  border: 0; height: 1px; background: #22293a; margin: .35rem .3rem;
}

/* Se till att map inte "skiner igenom" framför menyn */
.main-header, .ub-menu { z-index: 1200; }


/* Se till att headern och user-badgen ligger över Leaflet */
header.main-header { z-index: 4000; }

.user-badge {
  position: relative;
  z-index: 4100;
}

.ub-chip { pointer-events: auto; }

/* Själva dropdownen */
.ub-menu {
  z-index: 4200;                /* över headern & kartan */
  pointer-events: none;         /* av tills den öppnas (se raden nedan) */
}

.ub-chip[aria-expanded="true"] + .ub-menu {
  pointer-events: auto;         /* klickbar när öppen */
}

/* Säkerställ att .hidden verkligen gömmer knappar som kan ligga ovanpå */
.hidden { display: none !important; }

/* Visa dropdown när chippen är expanderad */
.ub-chip[aria-expanded="true"] + .ub-menu {
  display: block;           /* <- detta saknades */
  pointer-events: auto;     /* redan delvis satt, behåll */
}

/* (valfritt) liten fade/slide */
.ub-menu {
  opacity: 0;
  transform: translateY(4px) scale(.98);
  transition: opacity .12s ease, transform .12s ease;
}
.ub-chip[aria-expanded="true"] + .ub-menu {
  opacity: 1;
  transform: translateY(6px) scale(1);
}

/* Dölj scrollbar men behåll scroll-funktion */
#station-panel {
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
}

#station-panel::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

/* Dölj scrollbar men behåll scroll (alla motorer) */
#station-panel,
.station-panel,
#station-departures {
  overflow-y: auto !important;
  -ms-overflow-style: none !important;   /* IE/legacy Edge */
  scrollbar-width: none !important;      /* Firefox */
}

/* WebKit-baserade (Chrome, Edge, Safari) */
#station-panel::-webkit-scrollbar,
.station-panel::-webkit-scrollbar,
#station-departures::-webkit-scrollbar,
#station-panel *::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
}

/* Säkerställ att inget barn tvingar fram egen scrollbar */
#station-panel .stop-list,
#station-panel .departure-list {
  overflow: visible !important;
}

/* Segmented toggle (Avgångar / Ankomster) */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 16px 6px 16px;
}
.seg-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #ddd;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.seg-btn:hover { transform: translateY(-1px); }
.seg-btn.active {
  background: rgba(30,144,255,0.18);   /* diskret blå som matchar rutlinjen */
  border-color: rgba(30,144,255,0.35);
  color: #fff;
}

/* Station hero (bild) – matchar tågpanelens kortstil */
.station-hero {
  margin: 8px 16px 10px 16px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #2a2a2a;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}
.station-image { width: 100%; height: auto; display: block; }
.station-image-fallback {
  padding: 12px; text-align: center; color: #aaa; font-size: 14px;
}

/* Lista & tom-state */
.station-content { padding: 0 16px 12px 16px; }
.empty-box {
  opacity: .8; border: 1px dashed #444; border-radius: 10px;
  padding: 12px; text-align: center; margin: 8px 0;
}
.station-footer {
  opacity: .7; font-size: .9rem; margin: 6px 16px 10px 16px;
}

/* Scrollbar-gömma (behåll scroll) */
#station-panel, #station-departures { 
  overflow-y: auto; 
  -ms-overflow-style: none; scrollbar-width: none;
}
#station-panel::-webkit-scrollbar, #station-departures::-webkit-scrollbar { width:0; height:0; }

#train-panel {
  margin-top: 50px; /* eller valfri px */
}

/* Alternativ: använder transform så det inte påverkar layouten runt */
#train-panel {
  transform: translateY(10px);
}

/* === Bottom sheet-beteende (mobil) för tåg- och stationspanel === */
@media (max-width: 768px), (pointer: coarse) {
  #train-panel,
  #station-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* Panelns maxhöjd – justera efter smak */
    max-height: 78vh;
    /* Låt innehållet scrolla men panelen följsamt animera */
    overflow: hidden;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -12px 30px rgba(0,0,0,0.45);
    transition: transform .25s ease;
    /* Startläge när panelen är "synlig men neddragen" */
    transform: translateY(55%);
    /* Säkerställ att panelen ligger över kartan */
    z-index: 4000;
  }

  /* Fullt uppfälld */
  #train-panel.expanded,
  #station-panel.expanded {
    transform: translateY(0%);
  }

  /* Mer neddra("minimerad") – aningen längre ned */
  #train-panel.minimized,
  #station-panel.minimized {
    transform: translateY(65%);
  }

  /* När panel inte visas alls – skicka helt av skärmen */
  #train-panel:not(.visible),
  #station-panel:not(.visible) {
    transform: translateY(110%);
    pointer-events: none;
  }

  /* Inre scrollområde (så rubrik & drag-handle ligger still) */
  #train-panel .panel-scroll,
  #station-panel .panel-scroll {
    overflow-y: auto;
    max-height: calc(78vh - 42px); /* 42px ≈ dragbar + lite padding */
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
  }

  /* Drag-handle */
  .panel-drag-handle {
    display: flex;
    justify-content: center;
    padding: 8px 0 6px 0;
    cursor: grab;
    touch-action: none;
  }
  .panel-drag-handle .drag-bar {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255,255,255,0.22);
  }
}

/* Göm synlig scrollbar men behåll scroll (alla motorer) */
#train-panel .panel-scroll,
#station-panel .panel-scroll {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
#train-panel .panel-scroll::-webkit-scrollbar,
#station-panel .panel-scroll::-webkit-scrollbar { width:0; height:0; }

/* ===== Stationspanel: basic structure only ===== */
#station-panel.visible { display: block; }






/* ===== Stationpanel: EN enda scroll ===== */
#station-panel {
  overflow-y: auto !important;     /* panelen scrollar */
}

/* Slå av inner‑scroll och fasta höjder */
#station-departures,
#station-panel .panel-scroll {
  max-height: none !important;
  overflow: visible !important;
  -webkit-overflow-scrolling: auto !important;
  overscroll-behavior: auto !important;
}

/* På mobil: låt panelen själv scrolla (inte en inner-div) */
@media (max-width: 768px), (pointer: coarse) {
  #station-panel {
    overflow-y: auto !important;     /* överstyr blocket som satte overflow:hidden */
    max-height: 78vh;                 /* behåll bottensheetskänslan men låt innehållet rulla */
  }
  #station-panel .panel-scroll {
    max-height: none !important;
    overflow: visible !important;
  }
}

/* Extra: stäng av tidigare regel som gav listan egen scroll */
#station-departures { 
  padding-right: 10px;               /* behåll spacing */
  /* gamla max-height/overflow neutraliseras ovan */
}

/* 🧭 Stationpanel – samma mobilbeteende som tågpanelen */
@media (max-width: 768px) {
  .station-panel {
    top: 60px;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-height: calc(100vh - 60px);
    border-radius: 0;
    padding: 1rem;          /* matcha train-panel */
  }
}

/* Säkerställ att hela stationpanelen är EN scroll (ingen inre list-scroll) */
.station-panel {
  overflow-y: auto;         /* panelen scrollar */
}
#station-departures,
#sp-list {
  overflow: visible;        /* inga egna scrollbars */
}



@media (max-width: 768px) {
  /* Gör stationpanelen till en bottom sheet på mobil */
  .station-panel {
    left: 0 !important;
    right: 0 !important;
    bottom: 0;
    top: auto !important;
    width: 100vw !important;
    max-height: none !important;
    height: 85vh; /* default om ingen klass satt */
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform .28s ease, height .18s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .station-panel.visible {
    transform: translateY(0);
    pointer-events: auto;
  }
  /* två lägen: neddragen ≈ 20vh, uppdragen ≈ fullhöjd under headern */
  .station-panel.minimized { height: 20vh; }
  .station-panel.expanded  { height: calc(100vh - 60px); } /* 60px = höjd på sidans header */
}


/* ===== Stationpanel som "bottom sheet" på mobil ===== */
@media (max-width: 768px) {
  .station-panel.bottom-sheet {
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    border-radius: 14px 14px 0 0;
    /* Anchora i botten och styr höjd med CSS-variabel */
    position: fixed;
    bottom: 0;
    top: auto !important;
    max-height: none;
    height: var(--sheet-height, 55vh);
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Liten skugga bakom arket */
  .station-panel.bottom-sheet {
    box-shadow: 0 -20px 40px rgba(0,0,0,0.6);
    transition: height 0.2s ease, border-radius 0.2s ease;
  }

  /* Grepplist / handtag */
  .station-panel .sheet-handle {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: #4a4a4a;
    opacity: 0.9;
    margin: 6px auto 10px;
    cursor: ns-resize;
    touch-action: none; /* vi hanterar drag själva */
  }

  /* När panelen är i minimiläge, lite rundare hörn ser bra ut */
  .station-panel.bottom-sheet.min {
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
  }

  /* Se till att huvudet inte "hoppar" under iOS elastisk scroll */
  body, html {
    overscroll-behavior-y: contain;
  }
}

/* Gör krysset lätt att nå och alltid överst */
#station-panel .close-btn {
  position: sticky;
  top: 8px;
  align-self: flex-end;
  z-index: 5;
  padding: 8px;
  touch-action: manipulation;
}

/* Hela stationpanelen scrollar (inte interna listor) */
#station-panel {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Bottom sheet-stilar på mobil */
@media (max-width: 768px) {
  .station-panel.bottom-sheet {
    position: fixed;
    left: 0 !important;
    right: 0 !important;
    bottom: 0;
    top: auto !important;
    width: 100vw !important;
    max-height: none;
    height: var(--sheet-height, 55vh);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -20px 40px rgba(0,0,0,0.6);
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto;
  }
  .station-panel .sheet-handle {
    width: 44px; height: 5px; border-radius: 999px;
    background: #4a4a4a; opacity: .9;
    margin: 6px auto 10px; cursor: ns-resize; touch-action: none;
  }
  .station-panel.bottom-sheet.min {
    border-top-left-radius: 18px; border-top-right-radius: 18px;
  }
}

/* 🚫 Bottom sheet ska INTE synas om .visible saknas */
.station-panel.bottom-sheet:not(.visible) {
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  transform: translateY(0) !important; /* förhindra att transition "blänker" */
}

/* 📱 Station-panel som bottom-sheet på mobil */
@media (max-width: 768px) {
  .station-panel.bottom-sheet {
    border-radius: 12px 12px 0 0;  /* endast topphörn rundade */
    bottom: 0;                     /* pressa panelen mot botten */
  }
}
@media (max-width: 768px) {
  .station-panel.bottom-sheet {
    border-radius: 12px 12px 0 0 !important;
    margin-bottom: 0 !important;
  }
}

/* 📱 Station- och tågpanel på mobil som bottom-sheets */
@media (max-width: 768px) {
  .station-panel.bottom-sheet,
  .train-panel.bottom-sheet {
    border-radius: 12px 12px 0 0 !important;  /* endast topphörn rundade */
    bottom: 0;
    margin-bottom: 0 !important;
  }
}

/* 📱 Tågpanel som bottom-sheet på mobil */
@media (max-width: 768px) {
  .train-panel.bottom-sheet {
    position: fixed;
    left: 0 !important;
    right: 0 !important;
    bottom: 0;
    top: auto !important;
    width: 100vw !important;
    max-height: none;
    height: var(--train-sheet-height, 55vh);
    border-radius: 12px 12px 0 0;   /* endast toppen rund */
    box-shadow: 0 -20px 40px rgba(0,0,0,0.6);
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .train-panel .sheet-handle {
    width: 44px; height: 5px; border-radius: 999px;
    background: #4a4a4a; opacity: .9;
    margin: 6px auto 10px; cursor: ns-resize; touch-action: none;
  }

  /* Dölj helt om inte visible (säkerhet mot "spökpanel") */
  .train-panel.bottom-sheet:not(.visible) {
    opacity: 0 !important;
    pointer-events: none !important;
    height: 0 !important;
  }
}

/* Gör X lätt att nå */
#train-panel .close-btn {
  position: sticky;
  top: 8px;
  align-self: flex-end;
  z-index: 5;
  padding: 8px;
  touch-action: manipulation;
}

@media (max-width: 768px) {
  .train-panel.bottom-sheet {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* viktigt: bara handtaget har touch-action: none */
  .train-panel .sheet-handle { touch-action: none; }
}

/* === FINAL OVERRIDES: Train bottom sheet på mobil === */
@media (max-width: 768px) {
  /* Använd EN scroll: hela panelen */
  #train-panel.bottom-sheet {
    height: var(--train-sheet-height, 55vh) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
    width: 100vw !important;
    border-radius: 12px 12px 0 0 !important; /* endast toppen rundad */
    transform: translateY(0) !important;     /* neutralisera gamla translate-systemet */
  }

  /* Döda det gamla translate/"minimized/expanded"-systemet */
  #train-panel,
  #train-panel.expanded,
  #train-panel.minimized {
    transform: none !important;
  }

  /* Vi använder inte intern .panel-scroll längre */
  #train-panel .panel-scroll {
    max-height: none !important;
    overflow: visible !important;
  }

  /* Endast själva handtaget ska stänga av touch-gesternas scroll */
  #train-panel { touch-action: auto !important; }
  #train-panel .sheet-handle { touch-action: none !important; }
}

/* Dölj bottom-sheet helt om panelen inte är synlig (ingen "spökpanel") */
@media (max-width: 768px) {
  #train-panel.bottom-sheet:not(.visible) {
    opacity: 0 !important;
    pointer-events: none !important;
    height: 0 !important;
  }
}

/* Gör stationspanelen identisk med tågpanelen på desktop */
#station-panel {
  position: fixed;            /* istället för absolute/bottom:0 */
  top: 20px;                  /* samma toppmarginal som tågpanelen */
  right: 20px;                /* eller left:20px beroende på vilken sida du vill ha den */
  bottom: auto;               /* ta bort klistrat i botten */
  max-height: calc(100% - 40px); /* så den aldrig sticker utanför fönstret */
  border-radius: 18px;        /* samma rundning som tågpanelen */
  overflow: hidden;           /* så att hörnen verkligen syns */
  box-shadow: var(--panel-shadow);
}

/* Endast på desktop (mobil fortsätter använda bottom-sheet) */
@media (max-width: 768px) {
  #station-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 18px 18px 0 0; /* din bottom-sheet look */
    max-height: none;
  }
}

/* Desktop: stationpanelen ligger som ett kort mellan headern och botten */
#station-panel {
  position: fixed;
  top: 70px;                  /* lämna plats för headern överst (justera efter din headers höjd) */
  right: 20px;                /* placering på skärmen */
  bottom: 20px;               /* lämna lite luft nedtill */
  width: 380px;               /* samma bredd som tågpanelen (justera om behövs) */
  border-radius: 18px;        /* rundade hörn som tågpanelen */
  overflow: hidden;           /* så att innehållet inte sticker utanför */
  box-shadow: var(--panel-shadow);
  /* background now handled in station-panel.css */
  max-height: calc(100% - 90px); /* försäkrar att den inte sticker utanför */
}

/* Mobil: behåll bottom-sheet logiken */
@media (max-width: 768px) {
  #station-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 90vh;          /* t.ex. max 90% av viewport-höjden */
  }
}
/* Station panel background now handled in station-panel.css */

/* Om du har ett handtag/overlay nära toppen, se till att det inte blockerar */
#station-sheet-handle { pointer-events: auto; }

#close-station-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 99999;
  pointer-events: auto;
  cursor: pointer;
}
#station-panel { z-index: 5000; }

/* === Station-panel: korrekt synlighet & klickbarhet === */
#station-panel {
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;                 /* 🚫 inte klickbar när dold */
  transition: opacity .25s ease, transform .25s ease;
}

#station-panel.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;                 /* ✅ klickbar endast när synlig */
}

/* Stationpanel – "Visa fler" ska alltid vara klickbar om den inte är disabled */
#station-panel .station-loadmore .muted {
  opacity: .65;           /* ser grå ut */
  pointer-events: auto;   /* ✅ fortfarande klickbar */
}

/* Enda fallet den INTE ska vara klickbar är när knappen faktiskt är disabled */
#station-panel .station-loadmore button[disabled] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;   /* okej här, för disabled state */
}

/* Gula tågpunkten i panelens räls */
#panel-stops { position: relative; }

:root{
  --z-map: 0;
  --z-legend: 5;
  --z-panels: 20;
  --z-header: 30;
  --z-menu: 40;     /* user menu / hamburger */
  --z-modal: 50;    /* t.ex. "Om oss" */
  --focus: #5B9FFF;
}

/* Stacking */
.header, .topbar { position: sticky; top:0; z-index: var(--z-header); }
.user-menu, .hamburger-menu { z-index: var(--z-menu); position: fixed; }
.train-panel, .station-panel { z-index: var(--z-panels); position: fixed; }
.modal, .modal-backdrop { z-index: var(--z-modal); position: fixed; }

/* Fokus (slippa gigantiska blå ramar men behålla a11y) */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Panelkrock: se till att bara en "flyter över" kartan */
.panel { position: fixed; inset: auto 0 0 auto; max-height: 90vh; overflow:auto; }

/* Legend */
.map-legend {
  position: fixed; bottom: 12px; left: 12px;
  z-index: var(--z-legend);
  padding: 8px 10px; border-radius: 8px;
  background: color-mix(in srgb, #000 60%, transparent);
  color: #fff; font-size: 12px; backdrop-filter: blur(4px);
}
.map-legend .row { display:flex; align-items:center; gap:8px; margin:4px 0; }
.map-legend .swatch { width:16px; height:3px; border-radius:2px; }

/* Stationbild – dölj ytan om ingen bild finns */
.station-hero.no-image { display:none; }
.station-hero.is-default img { opacity: .9; filter: grayscale(30%); }

/* Bättre keyboard-fokus utan "blå ram över hela sidan" */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
/* Ta bort webkit-tap highlight på mobiler */
* { -webkit-tap-highlight-color: transparent; }

#train-panel, #station-panel {
  background: var(--panel-bg);
  color: var(--text);
  border: var(--panel-border);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(6px);
}

.modal-layer {
  position: fixed; inset: 0; display: none; place-items: center;
  background: rgba(0,0,0,.55);
}
.modal-layer.active { display: grid; }
.modal-card {
  width: min(520px, 92%); background: #161922; color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
#darkmode-fab {
  position: fixed; right: 14px; bottom: 14px;
  background: #1b2130; color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 12px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}

.leaflet-control.legend {
  background: #1b2130cc; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  font-size: 12px;
}
.legend .row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.legend .swatch { width: 14px; height: 3px; border-radius: 2px; background: currentColor; }

.suggestion-item.active { background: rgba(10,101,255,0.12); }

/* Sökförslag över allt, och klickbara */
/* Search suggestions styling handled in main rule above */




/* Säkerställ att rotationen sker kring mitten */
.leaflet-marker-icon .train-icon-inner {
  transform-origin: center center;
  will-change: transform;
}

.stop-row.past-stop  .rail-dot { background:#9aa0a6; } /* gråare prick för passerat */
.stop-row.current-stop .rail-dot { background:#ffcc00; } /* gul prick */

:root{
  /* Matcha Trainar-panelens look */
  --tn-bg: rgba(17,17,17,0.78);       /* mörk, med lite transparens */
  --tn-border: rgba(255,255,255,0.10);
  --tn-shadow: 0 8px 24px rgba(0,0,0,0.35);
  --tn-text: #e9e9e9;                 /* samma textfärg aktiv/inaktiv */
  --tn-text-dim: #cfcfcf;
  --tn-indicator: rgba(255,255,255,0.9); /* liten vit indikator */
  --tn-hover: rgba(255,255,255,0.06);
  --tn-active-bg: rgba(255,255,255,0.10);
  --tn-badge: #ff4d4f;
}

.tn-bottom-nav{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(100vw - 24px, 420px); /* Minskad bredd för 4 knappar */
  height: 66px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* Ändrat tillbaka till 4 kolumner */
  gap: 6px;
  align-items: center;
  background: var(--tn-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--tn-border);
  border-radius: 18px;
  box-shadow: var(--tn-shadow);
  z-index: 1000;
}

.tn-nav-btn{
  position: relative;
  height: 54px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--tn-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease, transform .05s ease;
}

/* Ta bort focus-outline/visited/färgändringar */
.tn-nav-btn:focus { outline: none; }
.tn-nav-btn:focus-visible { outline: none; }
.tn-nav-btn:active { transform: translateY(0.5px); }
.tn-nav-btn:hover { background: var(--tn-hover); }

/* Etikett */
.tn-label{
  font: 500 12px/1.1 system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial;
  text-decoration: none !important;
  color: inherit;
}

/* Aktiv state: ingen färgändring, bara bakgrund + indikator */
.tn-nav-btn.is-active{
  background: var(--tn-active-bg);
  border-color: rgba(255,255,255,0.12);
}

/* Ensure no underline on active button text */
.tn-nav-btn.is-active .tn-label{
  text-decoration: none !important;
}
.tn-nav-btn.is-active::after{
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: var(--tn-indicator);
  opacity: .95;
}

/* Visa rätt ikon: outline när inaktiv, solid när aktiv */
.tn-icon { display: none; }
.tn-nav-btn .tn-icon-inactive { display: inline-flex; }
.tn-nav-btn.is-active .tn-icon-inactive { display: none; }
.tn-nav-btn.is-active .tn-icon-active { display: inline-flex; }

/* Storlek */
.tn-nav-btn svg {
  width: 22px;
  height: 22px;
}

/* Outline-varianten (inaktiv) */
.tn-icon-inactive svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Solid-varianten (aktiv) */
.tn-icon-active svg {
  fill: currentColor;
  stroke: none;
}

/* Badge för Trafikinfo */
.tn-badge{
  position: absolute;
  top: 6px;
  right: 12px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--tn-badge);
  color: white;
  border-radius: 9px;
  font: 700 11px/18px system-ui, Inter, Arial;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

/* Search button active state when search is open */
.tn-nav-btn#bottom-search-btn.search-active {
  background: var(--tn-active-bg);
  border-color: rgba(255,255,255,0.12);
}



/* Ljusläge om ni använder det */
@media (prefers-color-scheme: light){
  :root{
    --tn-bg: rgba(255,255,255,0.92);
    --tn-border: rgba(0,0,0,0.08);
    --tn-text: #222;
    --tn-text-dim: #555;
    --tn-indicator: rgba(0,0,0,0.85);
    --tn-hover: rgba(0,0,0,0.05);
    --tn-active-bg: rgba(0,0,0,0.08);
  }
}

/* === OLD HEADER KLICK-ZONER SECTION REMOVED === */

/* Search suggestions z-index is handled in the main #search-suggestions rule */

/* ====== PROFILPANEL ====== */
/* OLD PROFILE PANEL STYLES REMOVED - REPLACED WITH MODERN DESIGN TOKENS ABOVE */




/* Desktop: nere till höger, glasig bakgrund, över kartan */
.leaflet-control-attribution{
  position: fixed !important;
  bottom: 12px;
  right: 12px;
  font-size: 11px;
  background: rgba(0,0,0,.35);
  color: #ccc;
  border-radius: 10px;
  padding: 4px 9px;
  z-index: 1200;              /* över kartan men under modaler */
  line-height: 1.2;
  pointer-events: auto;
  white-space: nowrap;
}
.leaflet-control-attribution a{
  color: #ddd;
  text-decoration: none;
}
.leaflet-control-attribution a:hover{
  text-decoration: underline;
}

/* Mobil: lyft upp över bottennavigeringen och gör kompakt */
@media (max-width:768px){
  .leaflet-control-attribution{
    bottom: calc(var(--tn-nav-h, 66px) + 10px + env(safe-area-inset-bottom));
    right: 10px;
    font-size: 10px;
    padding: 2px 6px;
    opacity: .9;
    max-width: min(70vw, 320px);
    text-overflow: ellipsis;
    overflow: hidden;
  }
  /* Tryck & håll för att expandera texten om den klipps */
  .leaflet-control-attribution:active{
    white-space: normal;
    max-width: 90vw;
  }
}
/* Bottmeny överst av "vanliga" lager */
.tn-bottom-nav { z-index: 2000; }

/* (valfritt) Andra paneler under bottmenyn */
.train-panel, .station-panel { z-index: 1200; }

/* Se till att kartan ligger lägst */
#map { z-index: 0; }

/* === OLD SEARCH CONTAINER POSITIONING REMOVED === */

/* === OLD SEARCH STATES REMOVED === */

/* === OLD SEARCH CONTAINER POSITIONING REMOVED === */

/* === OLD STATUS-TEXT STYLING REMOVED === */

/* === OLD DUPLICATE PROFILE PANEL STYLES REMOVED === */

/* ====== MODERN PROFILPANEL WITH DESIGN TOKENS ====== */

/* CSS Design Tokens */
:root {
  --background: 220 30% 8%;
  --foreground: 210 40% 98%;
  --card: 220 25% 12%;
  --card-foreground: 210 40% 98%;
  --popover: 220 25% 12%;
  --popover-foreground: 210 40% 98%;
  --primary: 215 90% 45%;
  --primary-foreground: 210 40% 98%;
  --secondary: 220 20% 18%;
  --secondary-foreground: 210 40% 98%;
  --muted: 220 20% 15%;
  --muted-foreground: 215 20% 65%;
  --accent: 200 80% 50%;
  --accent-foreground: 210 40% 98%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 220 20% 20%;
  --input: 220 20% 18%;
  --ring: 215 90% 45%;
  --train-blue: 215 90% 45%;
  --train-dark: 220 30% 8%;
  --station-bg: 220 25% 12% / 0.8;
  --station-hover: 220 20% 18% / 0.9;
  
  --gradient-primary: linear-gradient(135deg, hsl(var(--train-blue)), hsl(200 80% 50%));
  --gradient-card: linear-gradient(145deg, hsl(220 25% 12% / 0.9), hsl(220 20% 15% / 0.8));
  --gradient-bg: linear-gradient(180deg, hsl(220 30% 8%), hsl(220 25% 10%));
  --shadow-elegant: 0 10px 30px -10px hsl(var(--train-blue) / 0.3);
  --shadow-card: 0 4px 20px -4px hsl(220 30% 5% / 0.5);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modern Profile Panel */
.profile-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 380px;
  max-height: calc(100vh - 40px);
  background: var(--gradient-card);
  border: 1px solid hsl(var(--border) / 0.2);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  color: hsl(var(--foreground));
  z-index: 5000;
  overflow: hidden;
  opacity: 0;
  transform: translateX(20px);
  transition: var(--transition-smooth);
  pointer-events: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.profile-panel.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* Make profile panel scrollable without scrollbars */
.profile-panel {
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.profile-panel::-webkit-scrollbar {
  display: none;
}

/* Ensure smooth scrolling */
.profile-panel {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Header med avatar och info */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid hsl(var(--border) / 0.1);
  background: hsl(var(--card) / 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  color: hsl(var(--primary-foreground));
  border: 2px solid hsl(var(--border) / 0.2);
  box-shadow: var(--shadow-elegant);
  transition: var(--transition-smooth);
}

.avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 40px -15px hsl(var(--train-blue) / 0.4);
  border-color: hsl(var(--border) / 0.4);
}

.avatar:active {
  transform: scale(0.98);
}

.profile-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-info .name {
  font-size: 1.3rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1.2;
}

.profile-info .email {
  font-size: 0.9rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.3);
  animation: pulse 2s infinite;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: hsl(var(--primary));
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: ripple 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 hsl(var(--primary) / 0.4); }
  70% { box-shadow: 0 0 0 6px hsl(var(--primary) / 0); }
  100% { box-shadow: 0 0 0 0 hsl(var(--primary) / 0); }
}

@keyframes ripple {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

.status-text {
  font-size: 0.85rem;
  color: hsl(var(--primary));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sektioner */
.profile-section {
  padding: 20px 24px;
  border-bottom: 1px solid hsl(var(--border) / 0.08);
}

.profile-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

/* Favoriter och senaste visningar */
.favorites-list,
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.favorite-item,
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: hsl(var(--station-bg));
  border: 1px solid hsl(var(--border) / 0.1);
  border-radius: 16px;
  cursor: pointer;
  transition: var(--transition-smooth);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.favorite-item:hover,
.recent-item:hover {
  background: hsl(var(--station-hover));
  border-color: hsl(var(--border) / 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.favorite-icon,
.recent-icon {
  font-size: 1.3rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--muted) / 0.3);
  border-radius: 8px;
  color: hsl(var(--accent));
}

.favorite-content,
.recent-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.favorite-text,
.recent-text {
  font-size: 0.95rem;
  color: hsl(var(--foreground));
  font-weight: 600;
  line-height: 1.3;
}

.favorite-subtitle,
.recent-subtitle {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

/* Action knappar */
.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid hsl(var(--border) / 0.08);
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid hsl(var(--border) / 0.15);
  border-radius: 14px;
  background: hsl(var(--station-bg));
  color: hsl(var(--foreground));
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.action-btn:hover {
  background: hsl(var(--station-hover));
  border-color: hsl(var(--border) / 0.3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.action-btn.primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: hsl(var(--primary-foreground));
  box-shadow: var(--shadow-elegant);
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 40px -15px hsl(var(--train-blue) / 0.4);
}

.action-btn.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: var(--transition-smooth);
}

.action-btn.danger:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.action-icon {
  font-size: 1.1rem;
}

.action-text {
  font-size: 0.9rem;
  font-weight: 600;
}



/* Close button */
#close-profile-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: hsl(var(--station-bg));
  color: hsl(var(--foreground));
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition-smooth);
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid hsl(var(--border) / 0.1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#close-profile-panel:hover {
  background: hsl(var(--station-hover));
  border-color: hsl(var(--border) / 0.3);
  transform: scale(1.1);
  box-shadow: var(--shadow-card);
}

/* Mobil anpassning */
@media (max-width: 768px) {
  .profile-panel {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    transform: translateX(100%) !important;
    opacity: 0 !important;
  }
  
  .profile-panel.visible {
    transform: translateX(0) !important;
    opacity: 1 !important;
  }
  
  .profile-header {
    padding: 28px 24px;
  }
  
  .avatar {
    width: 72px;
    height: 72px;
    font-size: 1.8rem;
  }
  
  .profile-info .name {
    font-size: 1.5rem;
  }
  
  .profile-actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .action-btn {
    padding: 18px;
    font-size: 1rem;
  }
  

  
  /* Larger close button on mobile */
  #close-profile-panel {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    top: 70px;
    right: 20px;
  }
}

/* Scrollbar styling */
.profile-panel {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border) / 0.3) transparent;
}

.profile-panel::-webkit-scrollbar {
  width: 6px;
}

.profile-panel::-webkit-scrollbar-track {
  background: transparent;
}

.profile-panel::-webkit-scrollbar-thumb {
  background: hsl(var(--border) / 0.3);
  border-radius: 3px;
}

.profile-panel::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--border) / 0.5);
}

/* Favorite button in train panel */
.favorite-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: hsl(var(--station-bg));
  color: hsl(var(--foreground));
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: var(--transition-smooth);
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid hsl(var(--border) / 0.1);
}

.favorite-btn:hover {
  background: hsl(var(--station-hover));
  border-color: hsl(var(--border) / 0.3);
  transform: scale(1.1);
  box-shadow: var(--shadow-card);
}

.favorite-btn.favorited {
  background: linear-gradient(135deg, hsl(45 100% 60%), hsl(35 100% 55%));
  color: hsl(45 100% 20%);
  box-shadow: 0 8px 25px -8px hsl(45 100% 50% / 0.4);
}

.favorite-btn.favorited:hover {
  transform: scale(1.15);
  box-shadow: 0 12px 35px -10px hsl(45 100% 50% / 0.5);
}

/* Update panel title to accommodate favorite button */
.panel-title-top {
  position: relative;
  padding-left: 48px;
}

/* Train panel header layout */
#train-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  position: relative;
}

#train-panel .panel-title-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  flex: 1;
  overflow: hidden;
}

#train-panel .panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#train-panel .panel-train-number {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-top: 2px;
}

#train-panel .train-favorite-btn,
#train-panel .panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  line-height: 0;
  margin: 0;
  background: none;
  border: none;
  cursor: pointer;
}

#train-panel .panel-header .panel-close {
  position: static;
  top: auto;
  align-self: center;
  padding: 0;
}

#train-panel .train-favorite-btn.favorited {
  color: gold;
}

/* Profile panel settings styling */
.profile-panel .setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid hsl(var(--border) / 0.08);
  transition: var(--transition-smooth);
  border-radius: 8px;
  padding-left: 8px;
  padding-right: 8px;
}

.profile-panel .setting-row:hover {
  background: hsl(var(--station-bg));
  padding-left: 12px;
  padding-right: 12px;
}

.profile-panel .setting-row:last-child {
  border-bottom: none;
}

.profile-panel .setting-text {
  flex: 1;
}

.profile-panel .setting-title {
  font-weight: 600;
  font-size: 14px;
  color: hsl(var(--foreground));
  margin-bottom: 4px;
}

.profile-panel .setting-sub {
  font-size: 12px;
  opacity: 0.8;
  color: hsl(var(--muted-foreground));
  line-height: 1.3;
}





/* Setting icons */
.setting-icon {
  margin-right: 8px;
  font-size: 1.1rem;
  opacity: 0.9;
}

.setting-sub {
  font-size: 12px;
  opacity: 0.8;
  color: inherit;
  line-height: 1.3;
}



/* === CLEANED UP HEADER SYSTEM === */
/* Remove all duplicate header styles and ensure mist bar works properly */

/* Main header - transparent background */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent !important;
  color: white;
  padding: 0.6rem 1.2rem;
  border-bottom: 0 !important;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  z-index: 1100;
  pointer-events: none;
}

.main-header * { 
  pointer-events: auto; 
}

/* Logo styling */
.header-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.logo-img {
  height: 150px;
  margin-top: 10px;
}

/* Header sections */
.header-left,
.header-right {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0.75rem;
  z-index: 1;
}

.header-left {
  order: 1;
}

.header-right {
  order: 3;
  justify-content: flex-end;
}

/* Logo link */
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.3rem;
  text-decoration: none;
  color: white;
}

.logo:hover {
  opacity: 0.8;
}

.logo-icon {
  height: 30px;
  width: auto;
}

/* === DESKTOP/MOBILE VISIBILITY === */
.desktop-only {
  display: flex;
}

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }
  
  .mobile-only {
    display: flex;
  }
}

/* === MIST BAR SYSTEM === */
/* This creates the gradient overlay effect over the header area */
.top-mist {
  position: fixed;
  top: 0; 
  left: 0; 
  right: 0;
  height: 60px;
  pointer-events: none;
  z-index: 900;
  background: linear-gradient(to bottom,
    rgba(0,0,0,.95) 0%,
    rgba(0,0,0,.70) 30%,
    rgba(0,0,0,.25) 70%,
    rgba(0,0,0,0.02) 100%
  );
  mix-blend-mode: multiply;
}

/* Remove any old header backgrounds that might interfere */
.header, 
.topbar, 
.main-header {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* === DESKTOP SEARCH SYSTEM === */
/* Desktop search container in header */
.header-right .search-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: auto;
  background: transparent;
  backdrop-filter: none;
  margin-right: 1rem;
}

.header-right .search {
  height: 36px;
  padding: 0.3rem 0.6rem;
  font-size: 1rem;
  border-radius: 8px;
  border: none;
  background: #333;
  color: white;
  transition: all 0.2s ease;
  width: 300px;
}

.header-right .search::placeholder {
  color: #bbb;
}

/* Desktop search states */
.header-right .search.tn-collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
  padding: 0;
  border: 0;
  transition: width .2s ease, opacity .2s ease;
}

.header-right .search.tn-open {
  width: 300px;
  opacity: 1;
  pointer-events: auto;
  padding: 0.6rem 0.8rem;
  border: none;
  background-color: #2c2c2c;
  color: white;
  border-radius: 6px;
  font-size: 1rem;
  height: 40px;
}

/* === MOBILE SEARCH SYSTEM === */
/* Mobile search container below header */
.mobile-search-container {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1400;
  display: none; /* Hidden by default */
  flex-direction: column;
  align-items: center;
  padding: 0 1rem;
  pointer-events: auto; /* Enable pointer events for the container */
  background: transparent;
  backdrop-filter: none;
  width: 100%;
  max-width: 100vw;
}

/* Show mobile search container on mobile */
@media (max-width: 768px) {
  .mobile-search-container {
    display: flex;
    pointer-events: auto;
    z-index: 1400;
  }
}

.mobile-search-container * {
  pointer-events: auto;
}

.mobile-search-container .search {
  height: 36px;
  padding: 0.3rem 0.6rem;
  font-size: 1rem;
  border-radius: 8px;
  border: none;
  background: #333;
  color: white;
  transition: all 0.2s ease;
  width: calc(100vw - 2rem);
  max-width: 400px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: text;
  -webkit-user-select: text;
}

.mobile-search-container .search::placeholder {
  color: #bbb;
}

/* Mobile search states */
.mobile-search-container .search.tn-collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
  padding: 0;
  border: 0;
  transition: width .2s ease, opacity .2s ease;
  overflow: hidden;
}

.mobile-search-container .search.tn-open {
  width: calc(100vw - 2rem);
  max-width: 400px;
  opacity: 1;
  pointer-events: auto;
  padding: 0.6rem 0.8rem;
  border: none;
  background-color: #2c2c2c;
  color: white;
  border-radius: 6px;
  font-size: 1rem;
  height: 40px;
  overflow: visible;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: width .2s ease, opacity .2s ease;
}

/* === SEARCH SUGGESTIONS === */
/* Desktop search suggestions */
.header-right #search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: 90vw;
  background-color: #111;
  border-radius: 10px;
  max-height: 50vh;
  overflow-y: auto;
  z-index: 1400;
  display: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  padding: .2rem 0;
}

/* Mobile search suggestions */
.mobile-search-container #mobile-search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  width: 100%;
  max-height: 45vh;
  background-color: #111;
  border-radius: 10px;
  overflow-y: auto;
  z-index: 1400;
  display: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
  padding: .2rem 0;
  pointer-events: auto;
}

/* Search suggestions active state */
#search-suggestions.active,
#mobile-search-suggestions.active { 
  display: block !important; 
  visibility: visible !important;
  opacity: 1 !important;
}

/* Hide scrollbars for search suggestions */
#search-suggestions::-webkit-scrollbar,
#mobile-search-suggestions::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Suggestion items */
.suggestion-item {
  padding: 0.6rem 0.8rem;
  color: #fff;
  font-size: 0.95rem;
  border-bottom: 1px solid #222;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background-color: #222;
}

.suggestion-item.active {
  background-color: rgba(10,101,255,0.12);
}

/* === MOBILE RESPONSIVENESS === */
@media (max-width: 768px) {
  .main-header {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 0.5rem 1rem;
  }

  .header-logo {
    order: 2;
    width: 100%;
    text-align: center;
    margin-top: 0;
    position: relative !important; /* Override absolute positioning */
    left: auto !important;
    transform: none !important;
    margin: 0 auto;
    top: -55px; /* Moved down slightly as requested */
  }

  .header-left {
    order: 1;
  }

  .header-right {
    order: 3;
    width: 100%;
    margin-top: 0.5rem;
  }

  .search {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  /* Mobile position button adjustments */
  .position-btn {
    width: 40px !important;
    height: 40px !important;
    bottom: max(120px, calc(env(safe-area-inset-bottom) + 120px)) !important; /* Position closer to bottom bar with padding */
    left: 20px !important; /* Position on left side over home button */
    right: auto !important; /* Override the PC positioning */
    z-index: 2500 !important; /* Ensure it's above bottom nav */
  }
  
  .position-icon {
    width: 18px;
    height: 18px;
  }

  /* Mobile logo adjustments */
  .logo-img {
    height: 140px; /* Make logo larger on mobile */
    margin-top: 0;
  }

  /* === MOBILE HEADER STYLES CONSOLIDATED === */
}

/* === ICON BUTTONS === */
.icon-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  height: 40px;
  width: 40px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.header-right .icon-btn {
  margin-left: 0.5rem;
}

/* === OLD DUPLICATE HEADER STYLES REMOVED === */

/* === Z-INDEX MANAGEMENT === */
/* Ensure proper layering */
#map { z-index: 0; }
.top-mist { z-index: 900; }
.main-header { z-index: 1100; }
#search-container { z-index: 1400; }
#search-suggestions { z-index: 1400; }
.train-panel, .station-panel { z-index: 1200; }


.modal-overlay { z-index: 9999; }
.tn-bottom-nav { z-index: 2000; }

/* === CLEANUP: REMOVE ANY REMAINING OLD HEADER STYLES === */
/* These were causing the black header to appear */
.header,
.topbar,
.main-header {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Ensure no old black backgrounds can show through */
body > header,
body > .header,
body > .topbar {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* === POSITION BUTTON === */
.position-btn {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  right: calc(50% + 220px); /* Position to the right of the bottom nav with spacing */
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 2500; /* Higher than bottom nav (2000) */
}

.position-btn:hover {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.position-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.position-btn.loading {
  animation: spin 1s linear infinite;
}

.position-btn.loading .position-icon {
  animation: pulse 1.5s ease-in-out infinite;
}

.position-icon {
  width: 20px;
  height: 20px;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* === TRAFFIC INFORMATION UI STYLES === */

/* Train Traffic Bar */
.train-traffic-bar {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  border-radius: 12px;
  margin: 12px 16px;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-left: 4px solid #ff6b6b;
  cursor: pointer;
  transition: all 0.3s ease;
}

.train-traffic-bar.severity-low {
  background: linear-gradient(135deg, #28a745, #20c997);
  border-left-color: #28a745;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.train-traffic-bar.severity-medium {
  background: linear-gradient(135deg, #ffc107, #fd7e14);
  border-left-color: #ffc107;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.train-traffic-bar.severity-high {
  background: linear-gradient(135deg, #dc3545, #e83e8c);
  border-left-color: #dc3545;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.train-traffic-bar:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.traffic-bar-header {
  display: flex;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.traffic-bar-header:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.traffic-icon {
  font-size: 20px;
  margin-right: 12px;
  animation: pulse 2s ease-in-out infinite;
}

.traffic-summary {
  flex: 1;
  color: white;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
}

.traffic-expand-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.traffic-expand-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.expand-icon {
  font-size: 16px;
  transition: transform 0.2s ease;
}

.traffic-bar-details {
  background: rgba(255, 255, 255, 0.95);
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.traffic-info-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.traffic-item {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #333;
}

.traffic-item strong {
  min-width: 120px;
  color: #666;
}

.traffic-severity {
  text-align: center;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.severity-low {
  background: #51cf66;
  color: white;
}

.severity-medium {
  background: #ffd43b;
  color: #333;
}

.severity-high {
  background: #ff6b6b;
  color: white;
}

/* Station Traffic List */
.station-traffic-list {
  background: white;
  border-radius: 12px;
  margin: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  border: 1px solid #e9ecef;
}

.traffic-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.traffic-list-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.traffic-refresh-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 16px;
}

.traffic-refresh-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.traffic-list-content {
  padding: 0;
}

.traffic-list-item {
  border-bottom: 1px solid #f1f3f4;
  transition: background-color 0.2s ease;
}

.traffic-list-item:last-child {
  border-bottom: none;
}

.traffic-list-item:hover {
  background-color: #f8f9fa;
}

.traffic-list-item.severity-high {
  border-left: 4px solid #ff6b6b;
}

.traffic-list-item.severity-medium {
  border-left: 4px solid #ffd43b;
}

.traffic-list-item.severity-low {
  border-left: 4px solid #51cf66;
}

.traffic-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}

.train-number {
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.traffic-severity-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.traffic-item-summary {
  padding: 0 20px 12px;
  color: #666;
  font-size: 13px;
  line-height: 1.4;
}

.traffic-item-details {
  padding: 0 20px 16px;
}

.traffic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.traffic-chip {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  background: #f1f3f4;
  color: #666;
  border: 1px solid #e1e5e9;
}

.line-chip {
  background: #e3f2fd;
  color: #1976d2;
  border-color: #bbdefb;
}

.delay-chip {
  background: #fff3e0;
  color: #f57c00;
  border-color: #ffe0b2;
}

.sources-chip {
  background: #f3e5f5;
  color: #7b1fa2;
  border-color: #e1bee7;
}

.traffic-item-expand {
  background: none;
  border: none;
  color: #667eea;
  cursor: pointer;
  padding: 8px 20px 16px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.traffic-item-expand:hover {
  color: #5a6fd8;
}

/* Traffic Animation */
@keyframes pulse {
  0%, 100% { 
    opacity: 1; 
    transform: scale(1);
  }
  50% { 
    opacity: 0.7; 
    transform: scale(1.05);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .train-traffic-bar {
    margin: 8px 12px;
  }
  
  .traffic-bar-header {
    padding: 12px;
  }
  
  .traffic-summary {
    font-size: 13px;
  }
  
  .station-traffic-list {
    margin: 12px;
  }
  
  .traffic-list-header {
    padding: 12px 16px;
  }
  
  .traffic-list-header h3 {
    font-size: 16px;
  }
  
  .traffic-item-header {
    padding: 12px 16px 6px;
  }
  
  .traffic-item-summary {
    padding: 0 16px 10px;
  }
  
  .traffic-item-details {
    padding: 0 16px 12px;
  }
  
  .traffic-item-expand {
    padding: 6px 16px 12px;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .traffic-bar-details {
    background: rgba(30, 30, 30, 0.95);
    color: #e0e0e0;
  }
  
  .traffic-item {
    color: #e0e0e0;
  }
  
  .traffic-item strong {
    color: #b0b0b0;
  }
  
  .station-traffic-list {
    background: #2d2d2d;
    border-color: #404040;
  }
  
  .traffic-list-item {
    border-bottom-color: #404040;
  }
  
  .traffic-list-item:hover {
    background-color: #353535;
  }
  
  .train-number {
    color: #e0e0e0;
  }
  
  .traffic-item-summary {
    color: #b0b0b0;
  }
  
  .traffic-chip {
    background: #404040;
    color: #b0b0b0;
    border-color: #555;
  }
  
  .line-chip {
    background: #1a3a5f;
    color: #64b5f6;
    border-color: #2d5a8b;
  }
  
  .delay-chip {
    background: #5d3c1a;
    color: #ffb74d;
    border-color: #8d5e2a;
  }
  
  .sources-chip {
    background: #4a2a5a;
    color: #ba68c8;
    border-color: #6a3a7a;
  }
/* Add these styles for clickable trains */
.is-clickable {
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.is-clickable:hover {
  background-color: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.is-clickable:active {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Removed hover arrow on clickable elements */
.is-clickable::after { display: none; }
.is-clickable:hover::after { display: none; }

/* Style for future trains */
.tag-future {
  background: #1f2f42;
  color: #cfe6ff;
  border-color: #2b4b6a;
}

.tag-route {
  background: #2a3650;
  color: #d6e6ff;
  border-color: #3d5a8a;
}


  .tab-button {
    flex: 1;
    padding: 16px 12px; 
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.tab-button:hover {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.05);
}

.tab-button.active {
    color: #f8fafc;
    background: rgba(59, 130, 246, 0.2);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #3b82f6;
}

/* Tab Content */
.tab-content {
    padding: 0;
}

.tab-section {
    display: none;
    padding: 0;
}

.tab-section.active {
    display: block;
}

.tab-section-title {
    padding: 12px 24px 8px;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* Train List */
.train-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.station-panel .train-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.03);
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    min-height: 60px;
}


.station-panel .train-card:hover {
  background: rgba(148, 163, 184, 0.02);
}

.station-panel .train-card:last-child {
  border-bottom: none;
}

.train-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.train-icon {
    width: 14px;
    height: 14px;
    background: #3b82f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.train-icon::before {
    content: '🚂';
    font-size: 7px;
}

.train-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.train-number {
    font-size: 1.125rem;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1;
}

.train-platform {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 500;
}

.train-destination {
    font-size: 0.8rem;
    color: #f8fafc;
    font-weight: 500;
}

.train-time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.time-display {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: #f8fafc;
    font-weight: 500;
}

.time-icon {
    width: 10px;
    height: 10px;
    background: #94a3b8;
    border-radius: 50%;
    flex-shrink: 0;
}

.time-icon::before {
    content: '🕐';
    font-size: 5px;
}

/* Status Badge */
.status-badge {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 500;
    text-align: center;
    min-width: 35px;
}

.status-on-time {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-delayed {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-cancelled {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Arlanda Express Info */
.arlanda-info {
    padding: 16px 24px;
    background: rgba(59, 130, 246, 0.05);
    border-top: 1px solid rgba(59, 130, 246, 0.1);
    margin-top: 8px;
}

.arlanda-info h4 {
    color: #3b82f6;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.arlanda-info p {
    color: #94a3b8;
    font-size: 0.75rem;
    margin: 0;
    line-height: 1.4;
}





/* Responsive Design */
@media (max-width: 768px) {
    .station-panel {
        margin: 10px;
        max-width: none;
    }
    
    .station-panel h2 {
        padding: 16px 20px 12px;
        font-size: 1.25rem;
    }
    
    .station-header-content {
        padding: 0 20px 12px;
    }
    
    .tab-button {
        padding: 12px 8px;
        font-size: 0.8rem;
    }
    
    .station-panel .train-card {
        padding: 10px 20px;
    }
    
    .train-number {
        font-size: 1.125rem;
    }
    
    .train-destination {
        font-size: 0.8rem;
    }
    
    .time-display {
        font-size: 0.8rem;
    }
    
    .tab-section-title {
        padding: 12px 20px 8px;
    }
    
    .arlanda-info {
        padding: 12px 20px;
    }
    

}

@media (max-width: 480px) {
    .station-panel {
        margin: 5px;
        border-radius: 12px;
    }
    
    .station-panel h2 {
        padding: 12px 16px 8px;
        font-size: 1.125rem;
    }
    
    .station-header-content {
        padding: 0 16px 8px;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .tab-button {
        padding: 10px 6px;
        font-size: 0.75rem;
    }
    
    .station-panel .train-card {
        padding: 8px 16px;
    }
    
    .train-card-header {
        gap: 8px;
    }
    
    .train-icon {
        width: 14px;
        height: 14px;
    }
    
    .train-number {
        font-size: 1rem;
    }
    
    .train-platform {
        font-size: 0.7rem;
    }
    
    .train-destination {
        font-size: 0.75rem;
    }
    
    .time-display {
        font-size: 0.75rem;
    }
    
    .time-icon {
        width: 10px;
        height: 10px;
    }
    
    .tab-section-title {
        padding: 8px 16px 6px;
        font-size: 0.8rem;
    }
    
    .arlanda-info {
        padding: 8px 16px;
    }
    

}
}

/* Station panel styling to match train panel */
#station-panel {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 400px;
  max-height: 90vh;
  padding: 2.5rem 1.5rem 1.5rem;
  background: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: #f4f4f5;
  overflow-y: auto;
}

#station-panel #close-station-panel {
  position: absolute;
  top: 12px;
  right: 12px;
}

#station-panel .sp-search input {
  background: rgba(24, 24, 27, 0.8);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #18181b;
  top: 1rem;
  right: 1rem;
  width: 320px;
  max-height: 90vh;
  color: #f4f4f5;
}

#station-panel .sp-search input {
  background: #18181b;
  color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  padding: 0.45rem 0.9rem;
}

/* ========================
   TRAFFIC PAGE STYLES
   ======================== */

/* Traffic Page Layout */
.traffic-page-content {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: calc(var(--tn-nav-h, 80px) + 20px);
  min-height: calc(100vh - var(--tn-nav-h, 80px));
}

.traffic-header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px 0;
}

.traffic-header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  color: #333;
  font-weight: 700;
}

.traffic-subtitle {
  color: #666;
  font-size: 1.1rem;
  margin: 0;
}

/* Traffic Sections */
.traffic-status-section,
.traffic-events-section,
.ai-summary-section,
.traffic-map-section {
  margin-bottom: 30px;
}

/* Status Card */
.status-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.status-header h3 {
  margin: 0;
  color: #333;
  font-size: 1.2rem;
  font-weight: 600;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffc107;
  animation: pulse 2s infinite;
}

.status-dot.success { 
  background: #28a745; 
  animation: none;
}

.status-dot.error { 
  background: #dc3545; 
  animation: none;
}

.status-dot.warning { 
  background: #ffc107; 
}

.status-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: #666;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.status-details {
  color: #666;
  line-height: 1.5;
}

.status-details p {
  margin: 8px 0;
}

.status-details strong {
  color: #333;
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h3 {
  margin: 0;
  color: #333;
  font-size: 1.5rem;
  font-weight: 600;
}

.refresh-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.2s;
}

.refresh-btn:hover {
  background: #0056b3;
}

.refresh-btn:active {
  transform: translateY(1px);
}

/* Traffic Events List */
.traffic-events-list {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
  min-height: 200px;
}

.loading-state {
  text-align: center;
  color: #666;
  padding: 40px 20px;
  font-style: italic;
}

.traffic-event {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fafafa;
}

.traffic-event:last-child {
  margin-bottom: 0;
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.event-header h4 {
  margin: 0;
  color: #333;
  font-size: 1.1rem;
  font-weight: 600;
}

.event-severity {
  background: #ffc107;
  color: #333;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.event-severity.high {
  background: #dc3545;
  color: white;
}

.event-severity.medium {
  background: #ffc107;
  color: #333;
}

.event-severity.low {
  background: #28a745;
  color: white;
}

.event-details p {
  margin: 8px 0;
  color: #666;
  line-height: 1.4;
}

.event-details strong {
  color: #333;
}

/* AI Summary Section */
.ai-summary-content {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
  min-height: 120px;
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #666;
}

.ai-indicator {
  font-size: 1.1rem;
}

.ai-text {
  font-weight: 500;
}

/* Traffic Map */
.traffic-map-container {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
  height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-style: italic;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .traffic-page-content {
    background: #1a1a1a;
    color: #e0e0e0;
  }
  
  .traffic-header h1 {
    color: #e0e0e0;
  }
  
  .traffic-subtitle {
    color: #999;
  }
  
  .status-card,
  .traffic-events-list,
  .ai-summary-content,
  .traffic-map-container {
    background: #2a2a2a;
    border-color: #404040;
    color: #e0e0e0;
  }
  
  .status-header h3,
  .section-header h3 {
    color: #e0e0e0;
  }
  
  .status-text,
  .status-details,
  .loading-state,
  .ai-text {
    color: #999;
  }
  
  .status-details strong,
  .event-details strong {
    color: #e0e0e0;
  }
  
  .traffic-event {
    background: #333;
    border-color: #404040;
  }
  
  .event-header h4 {
    color: #e0e0e0;
  }
  
  .event-details p {
    color: #999;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .traffic-page-content {
    padding: 15px;
  }
  
  .traffic-header h1 {
    font-size: 2rem;
  }
  
  .traffic-subtitle {
    font-size: 1rem;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .section-header h3 {
    font-size: 1.3rem;
  }
  
  .status-card,
  .traffic-events-list,
  .ai-summary-content,
  .traffic-map-container {
    padding: 15px;
  }
  
  .traffic-map-container {
    height: 300px;
  }
  
  .event-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ========================
   TRAFFIC SOURCES MODAL
   ======================== */

.traffic-sources-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.traffic-sources-modal .modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.traffic-sources-modal .modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.traffic-sources-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
}

.traffic-sources-modal .modal-header h3 {
  margin: 0;
  color: #333;
  font-size: 1.3rem;
  font-weight: 600;
}

.traffic-sources-modal .modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #666;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.traffic-sources-modal .modal-close:hover {
  background: #e0e0e0;
}

.traffic-sources-modal .modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

.traffic-sources-modal .traffic-summary-section {
  margin-bottom: 24px;
}

.traffic-sources-modal .traffic-summary-section h4 {
  margin: 0 0 12px 0;
  color: #333;
  font-size: 1.1rem;
  font-weight: 600;
}

.traffic-sources-modal .ai-summary {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  border-left: 4px solid #007bff;
  margin: 0 0 16px 0;
  font-style: italic;
  color: #555;
}

.traffic-sources-modal .traffic-details {
  display: grid;
  gap: 8px;
}

.traffic-sources-modal .detail-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.traffic-sources-modal .detail-item:last-child {
  border-bottom: none;
}

.traffic-sources-modal .detail-item strong {
  color: #333;
  min-width: 120px;
}

.traffic-sources-modal .traffic-sources-section {
  margin-bottom: 24px;
}

.traffic-sources-modal .traffic-sources-section h4 {
  margin: 0 0 16px 0;
  color: #333;
  font-size: 1.1rem;
  font-weight: 600;
}

.traffic-sources-modal .sources-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.traffic-sources-modal .source-item {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.traffic-sources-modal .source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.traffic-sources-modal .source-name {
  font-weight: 600;
  color: #333;
}

.traffic-sources-modal .source-count {
  font-size: 0.9rem;
  color: #666;
  background: #e9ecef;
  padding: 4px 8px;
  border-radius: 4px;
}

.traffic-sources-modal .source-items {
  padding: 12px 16px;
}

.traffic-sources-modal .source-item-text {
  padding: 4px 0;
  color: #555;
  font-size: 0.9rem;
  line-height: 1.4;
}

.traffic-sources-modal .traffic-metadata {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.traffic-sources-modal .metadata-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
}

.traffic-sources-modal .metadata-item strong {
  color: #333;
}

/* Dark mode support for traffic sources modal */
@media (prefers-color-scheme: dark) {
  .traffic-sources-modal .modal-content {
    background: #2a2a2a;
    color: #e0e0e0;
  }
  
  .traffic-sources-modal .modal-header {
    background: #333;
    border-bottom-color: #404040;
  }
  
  .traffic-sources-modal .modal-header h3 {
    color: #e0e0e0;
  }
  
  .traffic-sources-modal .modal-close {
    color: #999;
  }
  
  .traffic-sources-modal .modal-close:hover {
    background: #404040;
  }
  
  .traffic-sources-modal .ai-summary {
    background: #333;
    color: #ccc;
    border-left-color: #007bff;
  }
  
  .traffic-sources-modal .detail-item {
    border-bottom-color: #404040;
  }
  
  .traffic-sources-modal .detail-item strong {
    color: #e0e0e0;
  }
  
  .traffic-sources-modal .source-item {
    border-color: #404040;
  }
  
  .traffic-sources-modal .source-header {
    background: #333;
    border-bottom-color: #404040;
  }
  
  .traffic-sources-modal .source-name {
    color: #e0e0e0;
  }
  
  .traffic-sources-modal .source-count {
    background: #404040;
    color: #ccc;
  }
  
  .traffic-sources-modal .source-item-text {
    color: #ccc;
  }
  
  .traffic-sources-modal .traffic-metadata {
    background: #333;
    border-color: #404040;
  }
  
  .traffic-sources-modal .metadata-item strong {
    color: #e0e0e0;
  }
}

/* Mobile responsive for traffic sources modal */
@media (max-width: 768px) {
  .traffic-sources-modal .modal-content {
    width: 95%;
    max-height: 90vh;
  }
  
  .traffic-sources-modal .modal-header {
    padding: 16px 20px;
  }
  
  .traffic-sources-modal .modal-header h3 {
    font-size: 1.1rem;
  }
  
  .traffic-sources-modal .modal-body {
    padding: 20px;
  }
  
  .traffic-sources-modal .detail-item {
    flex-direction: column;
    gap: 4px;
  }
  
  .traffic-sources-modal .detail-item strong {
    min-width: auto;
  }
  

  .traffic-sources-modal .metadata-item {
    flex-direction: column;
    gap: 4px;
  }
}

#journey-results {
  list-style: none;
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 0;
}

#journey-results li {
  padding: 4px;
  cursor: pointer;
}

/* Traffic Info Popup Styles */
#traffic-info-overlay .modal-box { 
width: min(600px, 95vw); 
max-height: 80vh;
background: #111826; 
color: #e5e7eb; 
border-radius: 16px; 
box-shadow: 0 10px 30px rgba(0,0,0,.4); 
overflow: hidden;
}

#traffic-info-overlay .modal-header { 
display: flex; 
align-items: center; 
justify-content: space-between; 
padding: 16px 20px; 
border-bottom: 1px solid rgba(255,255,255,.06); 
background: rgba(255,255,255,.02);
}

.modal-header-actions {
display: flex;
align-items: center;
gap: 8px;
}

#traffic-info-overlay .modal-close { 
background: transparent; 
border: 0; 
color: #9ca3af; 
font-size: 18px; 
cursor: pointer; 
padding: 4px;
border-radius: 4px;
}

#traffic-info-overlay .modal-close:hover {
background: rgba(255,255,255,.1);
color: #e5e7eb;
}

#traffic-info-overlay .modal-refresh { 
background: transparent; 
border: 0; 
color: #9ca3af; 
font-size: 16px; 
cursor: pointer; 
padding: 4px;
border-radius: 4px;
transition: all 0.2s ease;
}

#traffic-info-overlay .modal-refresh:hover {
background: rgba(255,255,255,.1);
color: #e5e7eb;
transform: rotate(180deg);
}

.traffic-info-content {
max-height: 70vh;
overflow-y: auto;
padding: 20px;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}

@media (max-width: 768px) {
.traffic-info-content {
grid-template-columns: 1fr;
gap: 16px;
}
}

.traffic-summary-section,
.traffic-issues-section,
.traffic-stats-section {
margin-bottom: 24px;
}

.traffic-summary-section h3,
.traffic-issues-section h3,
.traffic-stats-section h3 {
margin: 0 0 12px 0;
font-size: 16px;
font-weight: 600;
color: #e5e7eb;
display: flex;
align-items: center;
gap: 8px;
}

.traffic-summary-text {
background: rgba(255,255,255,.05);
border: 1px solid rgba(255,255,255,.1);
border-radius: 12px;
padding: 16px;
color: #e5e7eb;
line-height: 1.5;
}

.traffic-issues-list {
display: grid;
gap: 12px;
}

.traffic-issue {
background: rgba(255,255,255,.05);
border: 1px solid rgba(255,255,255,.1);
border-radius: 12px;
padding: 16px;
transition: all 0.2s ease;
position: relative;
overflow: hidden;
}

.traffic-issue:hover {
background: rgba(255,255,255,.08);
border-color: rgba(255,255,255,.2);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.traffic-issue::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 4px;
height: 100%;
background: var(--severity-color, #f59e0b);
}

.traffic-issue-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 8px;
}

.traffic-issue-title {
font-weight: 600;
color: #fbbf24;
font-size: 14px;
display: flex;
align-items: center;
gap: 8px;
}

.traffic-issue-icon {
font-size: 16px;
}

.traffic-issue-severity {
padding: 2px 8px;
border-radius: 12px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}

.traffic-issue-severity.high {
background: #dc2626;
color: white;
}

.traffic-issue-severity.medium {
background: #f59e0b;
color: white;
}

.traffic-issue-severity.low {
background: #10b981;
color: white;
}

.traffic-issue-description {
color: #e5e7eb;
font-size: 14px;
line-height: 1.4;
margin-bottom: 8px;
}

.traffic-issue-details {
display: grid;
gap: 4px;
margin-top: 8px;
}

.traffic-issue-detail {
color: #9ca3af;
font-size: 12px;
}

.traffic-issue-detail strong {
color: #e5e7eb;
}

.traffic-stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
gap: 12px;
}

.traffic-stat {
background: rgba(255,255,255,.05);
border: 1px solid rgba(255,255,255,.1);
border-radius: 8px;
padding: 12px;
text-align: center;
}

.traffic-stat-value {
font-size: 20px;
font-weight: 700;
color: #e5e7eb;
margin-bottom: 4px;
}

.traffic-stat-label {
font-size: 12px;
color: #9ca3af;
text-transform: uppercase;
letter-spacing: 0.5px;
}

.traffic-last-updated {
text-align: center;
padding-top: 16px;
border-top: 1px solid rgba(255,255,255,.1);
color: #9ca3af;
font-size: 12px;
}

.issue-count {
background: #dc2626;
color: white;
border-radius: 12px;
padding: 2px 8px;
font-size: 12px;
font-weight: 600;
margin-left: 8px;
}

/* Train Panel Traffic Info */
.train-traffic-info {
background: linear-gradient(135deg, #fbbf24, #f59e0b);
color: #1f2937;
padding: 16px 20px;
margin: 12px 16px;
border-radius: 12px;
font-size: 14px;
font-weight: 600;
box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
border: 2px solid rgba(245, 158, 11, 0.2);
position: relative;
overflow: hidden;
}

.train-traffic-info::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: linear-gradient(90deg, #dc2626, #f59e0b, #10b981);
}

.traffic-info-content {
display: flex;
align-items: center;
gap: 8px;
}

.traffic-info-label {
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.5px;
}

.traffic-info-message {
flex: 1;
}

.issue-count:empty {
display: none;
}