/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0c0a0a;
  --surface:     #141111;
  --surface2:    #201c1c;
  --border:      #352828;
  --text:        #e8eaf0;
  --muted:       #8e98a8;
  --accent:      #e3000f;   /* KVB-Rot */
  --green:       #00e676;
  --amber:       #ffab40;
  --red:         #ff4d6a;
  --taxi:        #7c4dff;
  --line-width:  3px;
}

/* ── Light theme ────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:       #f4f1f1;
  --surface:  #ffffff;
  --surface2: #ebe7e7;
  --border:   #d0c8c8;
  --text:     #1a1212;
  --muted:    #5a5252;
  --green:    #1b8a3e;
  --amber:    #b86000;
  --red:      #c41230;
  --taxi:     #5b2dd4;
}

[data-theme="light"] body::before { opacity: 0.3; }

[data-theme="light"] .guarantee-text { color: var(--muted); }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  overflow-x: hidden;
}

/* ── Noise texture overlay ─────────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ────────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: var(--line-width) solid var(--accent);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.header-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.line-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  background: var(--accent);
  color: #fff;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 3rem;
  letter-spacing: 0.05em;
  border-radius: 6px;
  padding-top: 0.3rem;
}

h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--text);
}

.station-sub {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 0.35rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
}

/* ── Live indicator ────────────────────────────────────────────── */
.live-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
}

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
}

.live-dot.active { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2s infinite; }
.live-dot.error  { background: var(--red); }

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

/* ── Direction sections ────────────────────────────────────────── */
.directions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .directions { grid-template-columns: 1fr; }
}

.direction-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.dir-header {
  padding: 0.85rem 1.1rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dir-arrow { font-size: 0.9rem; color: var(--accent); margin-right: 0.4rem; }
.dir-name  { font-family: 'Bebas Neue', sans-serif; font-size: 1.05rem; letter-spacing: 0.06em; }
.dir-count { font-family: 'DM Sans', sans-serif; font-size: 0.75rem; color: var(--muted); }

/* ── Departure rows ────────────────────────────────────────────── */
.dep-list { list-style: none; }

.dep-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  animation: slideIn 0.35s ease both;
}

.dep-row:last-child { border-bottom: none; }
.dep-row:hover { background: var(--surface2); }

/* Ausgefallene Fahrten: rote Hervorhebung */
.dep-row--cancelled {
  background: rgba(227, 0, 15, 0.08);
  border-left: 3px solid var(--red);
  padding-left: calc(1.1rem - 3px);
}
.dep-row--cancelled:hover { background: rgba(227, 0, 15, 0.14); }
.dep-row--cancelled .planned {
  color: var(--red);
  opacity: 0.8;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.dep-time {
  font-family: 'Space Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.dep-time .planned { color: var(--text); }
.dep-time .realtime {
  font-size: 0.75rem;
  margin-top: 0.2rem;
  font-weight: 400;
}

.dep-delay {
  text-align: right;
}

.dep-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Status colors */
.s-on-time     { background: rgba(0,230,118,0.15);  color: var(--green); }
.s-early       { background: rgba(0,230,118,0.1);   color: var(--green); }
.s-slight      { background: rgba(255,171,64,0.12); color: var(--amber); }
.s-delayed     { background: rgba(255,61,90,0.12);  color: var(--red); }
.s-taxi        { background: rgba(124,77,255,0.18); color: var(--taxi); }
.s-unknown     { background: rgba(90,96,112,0.2);   color: var(--muted); }
.s-cancelled   { background: rgba(255,61,90,0.18);  color: var(--red); }

.dep-info {
  font-size: 0.78rem;
  color: var(--muted);
}

.dep-current-stop {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.15rem;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-data {
  padding: 2rem 1.1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif;
}

/* ── Footer ────────────────────────────────────────────────────── */
footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-note {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
}

.refresh-btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }
.refresh-btn:active { transform: scale(0.97); }

/* ── Mobility guarantee note ───────────────────────────────────── */
.guarantee-note {
  background: rgba(124,77,255,0.08);
  border: 1px solid rgba(124,77,255,0.2);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  display: none;
}

.guarantee-note.visible { display: block; animation: slideIn 0.4s ease; }

.guarantee-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
  color: var(--taxi);
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.guarantee-text {
  font-size: 0.8rem;
  color: rgba(220,210,230,0.8);
  line-height: 1.6;
}

.guarantee-link {
  color: var(--taxi);
  text-decoration: none;
}
.guarantee-link:hover { text-decoration: underline; }

/* ── Clock ─────────────────────────────────────────────────────── */
.clock {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  margin: .75rem 0;
}

/* ── Theme toggle ───────────────────────────────────────────────── */
.theme-toggle {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* Im Dark-Mode: Sonne zeigen (wechselt zu Light) */
.theme-toggle::after { content: '☀️'; }
/* Im Light-Mode: Mond zeigen (wechselt zu Dark) */
[data-theme="light"] .theme-toggle::after { content: '🌙'; }

/* ── Richtungs-KPIs ────────────────────────────────────────────── */
.dir-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.dir-stats:empty { display: none; }

.kpi-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.kpi-good          { background: rgba(0,230,118,0.12);  color: var(--green); }
.kpi-warn          { background: rgba(255,171,64,0.12); color: var(--amber); }
.kpi-bad           { background: rgba(255,61,90,0.12);  color: var(--red); }
.kpi-chip--delay   { background: rgba(255,171,64,0.08); color: var(--amber); }

.kpi-meta {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: auto;
}

/* ── Historische Abfahrten ──────────────────────────────────────── */
.history-section {
  border-top: 1px solid var(--border);
  padding: 0.6rem 1.1rem 0.75rem;
}

.history-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.history-list { list-style: none; }

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  opacity: 0.5;
}

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

.history-time {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}

.history-realtime {
  font-size: 0.7rem;
  color: var(--red);
}

/* ── Footer actions group ──────────────────────────────────────── */
.footer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Statistik-Toggle-Button ───────────────────────────────────── */
.stats-toggle-btn {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.stats-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.stats-toggle-btn:active { transform: scale(0.97); }

/* ── Statistik-Modal (Vollbild) ────────────────────────────────── */
.stats-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.stats-modal.visible { display: flex; }

.stats-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.stats-modal-content {
  position: relative;
  z-index: 1;
  width: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Modal-Header ──────────────────────────────────────────────── */
.stats-modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  flex-shrink: 0;
}

.stats-modal-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.stats-modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  color: var(--text);
}

.stats-modal-period {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
}

.stats-modal-nav {
  flex: 1;
  /* Platzhalter für künftige Tab-Navigation */
}

.stats-modal-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.stats-modal-close:hover { border-color: var(--accent); color: var(--accent); }

/* ── Modal-Body ────────────────────────────────────────────────── */
.stats-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ── Analytics Block (Sektions-Wrapper) ────────────────────────── */
.analytics-block {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.analytics-block-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

/* ── KPI-Grid ──────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.kpi-tile {
  background: var(--surface);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.kpi-tile.kpi-loading {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: 'DM Sans', sans-serif;
}

.kpi-tile-value {
  font-family: 'Space Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.kpi-tile-value--accent { color: var(--accent); }
.kpi-tile-value--good   { color: var(--green); }
.kpi-tile-value--warn   { color: var(--amber); }

.kpi-tile-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

/* ── Statusverteilung ──────────────────────────────────────────── */
.dist-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface2);
}

.dist-segment { height: 100%; transition: width 0.5s ease; }
.dist-segment--punctual  { background: var(--green); }
.dist-segment--slight    { background: var(--amber); }
.dist-segment--delayed   { background: var(--red); }
.dist-segment--cancelled { background: rgba(255, 77, 106, 0.5); }

.dist-legend {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.dist-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
}

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

/* ── Tagesverlauf-Chart ────────────────────────────────────────── */
.hourly-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  padding-bottom: 1.6rem;
  position: relative;
}

.hourly-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
  min-width: 0;
}

.hourly-bar {
  width: 100%;
  background: var(--amber);
  opacity: 0.75;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  height: var(--bar-h, 0%);
  transition: height 0.4s ease;
}
.hourly-bar--empty { background: var(--surface2); opacity: 0.6; min-height: 4px; }

.hourly-label {
  position: absolute;
  bottom: -1.4rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.48rem;
  color: var(--muted);
  white-space: nowrap;
  text-align: center;
}

/* ── Heatmap ───────────────────────────────────────────────────── */
.heatmap-grid {
  display: grid;
  grid-template-columns: 2.25rem repeat(24, 1fr);
  gap: 2px;
  min-width: 540px;
}

.heatmap-hour-header {
  font-family: 'Space Mono', monospace;
  font-size: 0.44rem;
  color: var(--muted);
  text-align: center;
  padding: 0.15rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heatmap-day-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.62rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding-right: 0.3rem;
  font-weight: 600;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: rgba(255, 61, 90, var(--intensity, 0));
  cursor: default;
  transition: opacity 0.15s;
  position: relative;
}

.heatmap-cell--nodata {
  background: var(--surface2) !important;
  opacity: 0.5;
}

.heatmap-cell--clean {
  background: rgba(0, 230, 118, 0.18) !important;
}

/* Tooltip via ::after */
.heatmap-cell[data-tooltip] { isolation: isolate; }
.heatmap-cell[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.65rem;
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  transition: opacity 0.15s;
}
.heatmap-cell[data-tooltip]:hover::after { opacity: 1; }

/* Tooltip auf letzten Spalten links ausrichten, damit er nicht abgeschnitten wird */
.heatmap-cell:nth-child(24n)::after,
.heatmap-cell:nth-child(24n-1)::after,
.heatmap-cell:nth-child(24n-2)::after {
  left: auto;
  right: 0;
  transform: none;
}

/* ── Stats Modal Tab Nav ───────────────────────────────────────── */
.stats-nav-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.stats-nav-btn:hover { color: var(--text); }
.stats-nav-btn--active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Stats Modal: Tube Map braucht volle Breite ────────────────── */
.stats-modal-body--fullwidth {
  max-width: 100%;
  padding: 0;
}

#tabPanelTubemap {
  padding: 4rem 2rem 2rem;
}

/* ── Tube Map ──────────────────────────────────────────────────── */

.tubemap-track-container {
  position: relative;
  width: 100%;
  padding: 7rem 2rem 2rem;
}

/* Horizontale Linie hinter den Stop-Dots – relativ zur Stops-Row positioniert */
.tubemap-stops-row::before {
  content: '';
  position: absolute;
  top: 8px;   /* Mitte der 24px-Dots (12px - 4px halbe Linienhöhe) */
  left: 0;
  right: 0;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  z-index: 0;
}

.tubemap-stops-row {
  display: flex;
  align-items: flex-start;
  position: relative;
}

.tubemap-stop {
  flex: 0 0 calc(100% / 33);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.tubemap-stop-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  border: 3px solid var(--bg);
  z-index: 1;
  position: relative;
}

.tubemap-stop--home .tubemap-stop-dot {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-color: var(--bg);
  box-shadow: 0 0 16px var(--accent);
}

.tubemap-stop-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.3rem;
  color: var(--muted);
  text-align: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 10rem;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0.7;
}

.tubemap-stop--home .tubemap-stop-label {
  color: var(--accent);
  opacity: 1;
  font-weight: 600;
}

/* Züge-Schicht – absolut positioniert über der Strecke */
.tubemap-trains-row {
  position: absolute;
  top: 0;
  left: 2rem;
  right: 2rem;
  height: 7rem;
  pointer-events: none;
}

.tubemap-train {
  position: absolute;
  left: calc(var(--stop-index) / 32 * 100%);
  top: calc(var(--stack, 0) * 3rem);
  transform: translateX(-50%);
  pointer-events: all;
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tubemap-train-label {
  font-family: 'Space Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  white-space: nowrap;
}

/* Dotted Verbindungslinie Marker → Track */
.tubemap-train::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: calc(7rem - var(--stack, 0) * 3rem - 1.8rem);
  border-left: 3px dashed currentColor;
  opacity: 0.45;
  pointer-events: none;
}

/* Tooltip */
.tubemap-train[data-tooltip] { isolation: isolate; }
.tubemap-train[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  transition: opacity 0.15s;
}
.tubemap-train[data-tooltip]:hover::after { opacity: 1; }

/* Legende */
.tubemap-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.tubemap-legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 1.1rem;
  color: var(--muted);
}

.tubemap-legend-dot {
  width: 18px;
  height: 18px;
  border-radius: 2px;
}

.tubemap-no-trains {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: 'DM Sans', sans-serif;
  padding: 2rem 0;
}

/* ── Debug-Manager ─────────────────────────────────────────────── */
.dbm-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-end;
  padding: 0.75rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.dbm-filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dbm-filter-bar select,
.dbm-filter-bar input[type="date"] {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  font-family: inherit;
}

.dbm-load-btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  align-self: flex-end;
}
.dbm-load-btn:hover { border-color: var(--accent); color: var(--accent); }

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

.dbm-status {
  font-size: 0.8rem;
  color: var(--muted);
}

.dbm-delete-btn {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.dbm-delete-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 15%, transparent); }
.dbm-delete-btn:disabled { opacity: 0.35; cursor: default; }

.dbm-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.dbm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-family: 'Space Mono', monospace;
}

.dbm-table th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  z-index: 1;
}

.dbm-table td {
  padding: 0.3rem 0.55rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  white-space: nowrap;
  vertical-align: middle;
}

.dbm-table tr:last-child td { border-bottom: none; }
.dbm-table tr:hover td { background: var(--surface2); }

.dbm-row--cancelled td { color: var(--red); }
.dbm-row--synthetic td { color: var(--amber); }
.dbm-row--cancelled.dbm-row--synthetic td { color: color-mix(in srgb, var(--red) 60%, var(--amber)); }

.dbm-icon { text-align: center; }

.dbm-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.dbm-status-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  background: var(--surface2);
}
.dbm-status-ON_TIME,
.dbm-status-EARLY    { color: var(--green); }
.dbm-status-SLIGHT_DELAY { color: var(--amber); }
.dbm-status-DELAYED  { color: var(--red); }
.dbm-status-TAXI     { color: var(--taxi); }
.dbm-status-UNKNOWN  { color: var(--muted); }

.dbm-pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  padding: 0.75rem 0 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.dbm-pagination button {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.dbm-pagination button:disabled { opacity: 0.3; cursor: default; }
.dbm-pagination button:hover:not(:disabled) { border-color: var(--accent); }
