@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600;700&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: #0d1b2a;
  color: #eef1f5;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  padding: 24px 16px 90px;
}
.page { max-width: 720px; margin: 0 auto; }

input[type=date], input[type=time], input[type=text] {
  font-family: 'IBM Plex Mono', monospace;
  background: #16273a;
  border: 1px solid #2a3d54;
  color: #eef1f5;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
  width: 100%;
  min-width: 0;
}
input:focus { border-color: #e8a33d; }
input[type=text] { font-family: 'IBM Plex Sans', sans-serif; }
button { font-family: 'IBM Plex Sans', sans-serif; cursor: pointer; }
a { cursor: pointer; }

.header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.header .train-icon { font-size: 26px; line-height: 1; }
.eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; letter-spacing: 2px;
  color: #8fa1b8; text-transform: uppercase;
}
h1 { margin: 0; font-size: 22px; font-weight: 600; }

/* Bottom-Toolbar statt Burger-Menü - Icon (Inline-SVG) + Label je Tab, fix am unteren
   Bildschirmrand, wie in den Schwesterprojekten aprenderEspanol (Material-Theme) und Summit. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #16273a; border-top: 1px solid #2a3d54;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 2px; background: none; border: none; color: #8fa1b8;
  font-family: 'IBM Plex Sans', sans-serif; font-size: 10.5px; font-weight: 600;
  text-decoration: none;
}
.tab-icon { width: 36px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 999px; }
.tab-btn svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab-btn.active { color: #eef1f5; }
.tab-btn.active .tab-icon { background: rgba(232,163,61,0.18); color: #e8a33d; }

.week-nav-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.week-nav-row .current-week { font-size: 13px; color: #8fa1b8; }
.week-nav-row .current-week strong { color: #eef1f5; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.schedule-name {
  font-size: 11px; color: #8fa1b8; text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.schedule-card {
  background: #16273a; border: 1px solid #2a3d54; border-radius: 10px; padding: 12px 14px;
}
.schedule-card .label {
  display: flex; align-items: center; gap: 6px; color: #e8a33d; font-size: 12px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
}
.schedule-card .route { font-size: 13px; color: #8fa1b8; margin-top: 4px; }
.schedule-card .abfahrten {
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: #8fa1b8; margin-top: 6px;
}

.stats-wrap { margin-bottom: 22px; }
.stats-summary { display: flex; gap: 16px; font-size: 13px; color: #8fa1b8; flex-wrap: wrap; margin-bottom: 10px; }
.stats-summary strong.total { color: #eef1f5; }
.stats-summary strong.ontime { color: #4a9d6f; }
.stats-summary strong.late { color: #c9433f; }
.stats-card {
  background: #16273a; border: 1px solid #2a3d54; border-radius: 8px; padding: 8px 12px;
  font-size: 12px; color: #8fa1b8;
}
.stats-card .title { color: #e8a33d; font-weight: 600; text-transform: uppercase; font-size: 11px; }
.stats-card .empty { margin-left: 8px; color: #5b6472; }
.stats-card .row { margin-top: 4px; }
.stats-card .row2 { margin-top: 2px; }

.ontime-wrap { margin-bottom: 22px; }
.ontime-row { display: flex; gap: 10px; }
.ontime-card {
  flex: 1; background: #16273a; border: 1px solid #2a3d54; border-radius: 8px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
}
.ontime-card .pct { font-family: 'IBM Plex Mono', monospace; font-size: 22px; font-weight: 600; color: #4a9d6f; }
.ontime-card .pct.empty { color: #5b6472; font-family: 'IBM Plex Sans', sans-serif; font-size: 14px; }
.ontime-card .label { font-size: 11px; color: #8fa1b8; }

.section-label {
  color: #e8a33d; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px;
}
.section-label .section-sub {
  color: #8fa1b8; font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 6px;
}
.tagcloud-wrap { margin-bottom: 22px; }
.tag-cloud { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin-top: 8px; }
.tag-cloud .tag { color: #e8a33d; font-weight: 600; white-space: nowrap; }
.tag-cloud .tag .count { color: #8fa1b8; font-size: 11px; font-weight: 400; margin-left: 4px; }
.tag-cloud .tag.rank-0 { font-size: 22px; }
.tag-cloud .tag.rank-1 { font-size: 17px; }
.tag-cloud .tag.rank-2 { font-size: 13px; }

.io-row { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.btn-ghost {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid #2a3d54; background: transparent; color: #8fa1b8; font-size: 12px;
}
.btn-ghost:disabled { color: #5b6472; cursor: not-allowed; }
.import-msg { font-size: 12px; color: #8fa1b8; }

.section-label { display: block; margin: 0 0 8px; }
.settings-section { margin-bottom: 16px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-row-label { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.settings-row-title { font-size: 14px; font-weight: 600; color: #eef1f5; }
.settings-row-caption { font-size: 12px; color: #8fa1b8; }

.toggle-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.toggle-track { position: absolute; inset: 0; background: #2a3d54; border-radius: 999px; transition: background 0.2s ease; }
.toggle-track::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  background: #eef1f5; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transition: transform 0.2s ease;
}
.toggle-switch input:checked + .toggle-track { background: #e8a33d; }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); background: #0d1b2a; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(2,8,16,0.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: #16273a; border: 1px solid #2a3d54; border-radius: 12px; padding: 20px;
  max-width: 380px; width: 100%; box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.modal-title { font-size: 15px; font-weight: 600; color: #eef1f5; margin-bottom: 10px; }
.modal-message { font-size: 13px; color: #8fa1b8; white-space: pre-line; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; }
.btn-danger {
  padding: 8px 14px; border-radius: 8px; border: none; background: #c9433f; color: #eef1f5;
  font-weight: 600; font-size: 13px; white-space: nowrap;
}

.app-version { text-align: center; font-size: 11px; color: #8fa1b8; opacity: 0.75; margin: 24px 0 0; }

.form-card {
  background: #16273a; border: 1px solid #2a3d54; border-radius: 12px; padding: 16px; margin-bottom: 26px;
}
.richtung-toggle { display: flex; gap: 8px; margin-bottom: 12px; }
.richtung-btn {
  flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid #2a3d54;
  background: transparent; color: #8fa1b8; font-size: 13px; font-weight: 600;
}
.richtung-btn.active { border-color: #e8a33d; background: rgba(232,163,61,0.12); color: #e8a33d; }

.verbindung-toggle { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.verbindung-btn {
  padding: 5px 9px; border-radius: 6px; border: 1px solid #2a3d54; background: transparent;
  color: #8fa1b8; font-size: 12px; font-family: 'IBM Plex Mono', monospace;
}
.verbindung-btn.active { border-color: #e8a33d; background: rgba(232,163,61,0.12); color: #e8a33d; }
.verbindung-btn .tag-inline { font-family: 'IBM Plex Sans', sans-serif; font-size: 9px; opacity: 0.8; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; align-items: start; }
.field-label { font-size: 11px; color: #8fa1b8; display: flex; flex-direction: column; min-width: 0; }
.field-label > span { display: block; min-height: 15px; line-height: 15px; margin-bottom: 4px; }
.time-row { display: flex; gap: 4px; min-width: 0; }
.btn-jetzt {
  flex-shrink: 0; padding: 0 10px; border-radius: 6px; border: 1px solid #2a3d54;
  background: transparent; color: #e8a33d; font-size: 11px; font-weight: 600;
}

.comment-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.comment-row .line { display: flex; gap: 10px; }
.btn-add {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: none;
  background: #e8a33d; color: #0d1b2a; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.btn-add:disabled { cursor: not-allowed; opacity: 0.5; }
.btn-suggest {
  align-self: flex-start; background: transparent; border: none; color: #e8a33d; font-size: 12px;
  padding: 0; text-align: left;
}
.form-error { color: #c9433f; font-size: 12px; margin-top: 8px; }
.week-note { color: #8fa1b8; font-size: 12px; margin-top: 8px; display: none; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-placeholder { color: #5b6472; font-size: 13px; text-align: center; padding: 30px 0; }

.entry {
  background: #16273a; border: 1px solid #2a3d54; border-radius: 10px; padding: 10px 14px;
}
.entry .row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.entry .weekday { width: 78px; font-size: 12px; color: #8fa1b8; font-family: 'IBM Plex Mono', monospace; flex-shrink: 0; }
.entry .richtung { width: 64px; font-size: 11px; font-weight: 600; color: #e8a33d; text-transform: uppercase; flex-shrink: 0; }
.entry .times {
  font-family: 'IBM Plex Mono', monospace; font-size: 14px; display: flex; gap: 4px;
  align-items: baseline; flex-shrink: 0;
}
.entry .times .sep { color: #5b6472; }
.entry .actions { margin-left: auto; display: flex; gap: 4px; flex-shrink: 0; }
.btn-icon {
  background: transparent; border: none; color: #8fa1b8; padding: 4px; font-size: 12px;
}
.btn-icon.danger { color: #5b6472; }
.entry .kommentar { margin-top: 6px; padding-left: 92px; font-size: 12px; color: #8fa1b8; font-style: italic; }

.entry.editing { border-color: #e8a33d; }
.edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.edit-toggle { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.edit-richtung-btn {
  padding: 5px 10px; border-radius: 6px; border: 1px solid #2a3d54; background: transparent;
  color: #8fa1b8; font-size: 12px; font-weight: 600;
}
.edit-richtung-btn.active { border-color: #e8a33d; background: rgba(232,163,61,0.12); color: #e8a33d; }
.edit-comment-row { margin-bottom: 10px; }
.edit-actions { display: flex; gap: 10px; }
.btn-save, .btn-cancel { flex: 1; }
.btn-save {
  padding: 8px 14px; border-radius: 8px; border: none; background: #e8a33d; color: #0d1b2a;
  font-weight: 600; font-size: 13px; white-space: nowrap;
}
.btn-cancel {
  padding: 8px 14px; border-radius: 8px; border: 1px solid #2a3d54; background: transparent;
  color: #8fa1b8; font-size: 13px; white-space: nowrap;
}

.week-archive { display: flex; flex-direction: column; gap: 10px; }
.week-archive-placeholder { color: #5b6472; font-size: 13px; text-align: center; padding: 30px 0; }
.week-block { background: #16273a; border: 1px solid #2a3d54; border-radius: 12px; overflow: hidden; }
.week-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px; cursor: pointer; background: transparent; border: none; width: 100%;
  color: inherit; text-align: left;
}
.week-row .week-title { font-weight: 600; font-size: 14px; color: #eef1f5; }
.week-row .week-title .sub { display: block; font-size: 11px; color: #8fa1b8; font-weight: 400; margin-top: 2px; }
.week-row .chevron { color: #8fa1b8; font-size: 12px; transition: transform 0.15s; flex-shrink: 0; }
.week-block.open .chevron { transform: rotate(90deg); }
.week-details { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.week-details.hidden { display: none; }

/* Zuverlässigkeits-Legende (Monatsbericht/Vergangene Wochen) */
.reliability-legend {
  display: flex; gap: 14px; flex-wrap: wrap; font-size: 10px; color: #8fa1b8;
  padding: 10px 12px; background: #16273a; border: 1px solid #2a3d54; border-radius: 8px;
}
.reliability-legend .item { display: flex; align-items: center; gap: 5px; }
.reliability-legend .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Pünktlichkeits-Gauge + KPI-Kacheln (Berichts-Kopfzeile) */
.hero-row { display: flex; gap: 10px; margin-bottom: 16px; padding-top: 12px; border-top: 1px solid #2a3d54; }
.gauge-card {
  background: #0d1b2a; border: 1px solid #2a3d54; border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 0 0 112px;
}
.gauge-pct { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 24px; fill: #eef1f5; }
.gauge-label { font-size: 10px; color: #8fa1b8; margin-top: 6px; text-align: center; }
.kpi-col { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.kpi-tile {
  background: #0d1b2a; border: 1px solid #2a3d54; border-radius: 10px; padding: 8px 10px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
}
.kpi-tile .val { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 14px; color: #eef1f5; white-space: nowrap; }
.kpi-tile .lbl { font-size: 9px; color: #8fa1b8; text-align: right; line-height: 1.3; }

/* Kalender-Heatmap (Monatsbericht) */
.cal-wrap { background: #0d1b2a; border: 1px solid #2a3d54; border-radius: 12px; padding: 12px; margin-bottom: 16px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 6px; }
.cal-weekdays span { font-size: 8px; color: #5b6472; text-align: center; text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-cell { display: flex; flex-direction: column; gap: 2px; border-radius: 5px; padding: 3px 2px; min-height: 34px; }
.cal-cell.empty { visibility: hidden; }
.cal-day { font-size: 8px; color: #5b6472; font-family: 'IBM Plex Mono', monospace; }
.cal-bar { height: 5px; border-radius: 2px; }
.cal-bar-empty { background: #2a3d54; border: 1px dashed #5b6472; }
.cal-legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.cal-legend .item { display: flex; align-items: center; gap: 5px; font-size: 9px; color: #8fa1b8; }
.cal-legend .dot { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }

/* Balkendiagramm (Vergangene Wochen): zwei Balken pro Tag, Farbe = Verspätungsschwere */
.bar-wrap { background: #0d1b2a; border: 1px solid #2a3d54; border-radius: 12px; padding: 12px; margin-bottom: 16px; }
.bar-legend { display: flex; gap: 16px; font-size: 10px; color: #8fa1b8; margin-bottom: 12px; }
.bar-legend .item { display: flex; align-items: center; gap: 5px; }
.bar-legend .arrow { font-family: 'IBM Plex Mono', monospace; color: #eef1f5; font-weight: 600; }
.bar-plot { position: relative; height: 96px; margin-top: 22px; }
.tolerance-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #5b6472; height: 0; }
.tolerance-label { position: absolute; right: 0; font-size: 8px; color: #5b6472; transform: translateY(-11px); }
.bar-days { display: flex; justify-content: space-between; align-items: flex-end; height: 100%; position: relative; z-index: 1; }
.day-bars { display: flex; align-items: flex-end; gap: 3px; flex: 1; justify-content: center; height: 100%; }
.day-bar { width: 15px; border-radius: 3px 3px 1px 1px; position: relative; }
.day-bar .flag {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 8px;
  font-family: 'IBM Plex Mono', monospace; color: #c9433f; white-space: nowrap; font-weight: 600;
}
.day-bar-empty { width: 15px; height: 4px; border-radius: 2px; border: 1px dashed #5b6472; align-self: flex-end; }
.bar-day-labels { display: flex; justify-content: space-between; margin-top: 6px; }
.day-label { flex: 1; text-align: center; font-size: 9px; color: #5b6472; font-family: 'IBM Plex Mono', monospace; }

/* Ursachen-Rangliste (Monatsbericht/Vergangene Wochen) */
.causes-wrap { background: #0d1b2a; border: 1px solid #2a3d54; border-radius: 12px; padding: 12px 12px 4px; }
.cause-row { margin-bottom: 10px; }
.cause-row .top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.cause-row .name { color: #eef1f5; font-weight: 500; }
.cause-row .count { color: #8fa1b8; font-family: 'IBM Plex Mono', monospace; }
.cause-track { background: #16273a; border-radius: 4px; height: 8px; overflow: hidden; }
.cause-fill { background: #e8a33d; height: 100%; border-radius: 4px; }

@media (max-width: 480px) {
  .form-grid, .edit-grid { grid-template-columns: 1fr; }
}
