:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #d9dce1;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #1d4ed8;
  --primary-text: #ffffff;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b23;
    --border: #2a303c;
    --text: #e6e8ec;
    --muted: #9aa2b1;
    --primary: #3b82f6;
    --primary-text: #ffffff;
    --danger: #f97066;
    --ok: #47cd89;
    --warn: #f79009;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }

.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar nav a.active { font-weight: 600; }
.whoami { color: var(--muted); font-size: 14px; }

.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--primary); cursor: pointer; font: inherit;
}
.link-button:hover { text-decoration: underline; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; }

.page { display: flex; flex-direction: column; gap: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-head h2 { margin: 0; font-size: 17px; }

h1 { font-size: 20px; margin: 0 0 16px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 16px;
}
legend { padding: 0 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

label { display: block; font-size: 14px; margin-bottom: 12px; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { margin: 0; }

input[type=text], input[type=password], input[type=number], input[type=date] {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.stack { display: block; }
.row-form {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: end;
  margin-bottom: 18px;
}
.row-form label { margin-bottom: 0; }
.row-form input { min-width: 180px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

.usage { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
td.muted, .muted { color: var(--muted); }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--border);
}
.pill-ok { color: var(--ok); border-color: currentColor; }
.pill-warn { color: var(--warn); border-color: currentColor; }
.pill-err { color: var(--danger); border-color: currentColor; }

.progress {
  position: relative; height: 8px; width: 90px;
  background: var(--border); border-radius: 999px; overflow: hidden;
}
.progress > span { position: absolute; inset: 0 auto 0 0; background: var(--primary); }

.mode-switch { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.mode-btn {
  border: none; background: none; cursor: pointer; font: inherit;
  padding: 6px 18px; border-radius: 999px; color: var(--muted);
}
.mode-btn.active { background: var(--primary); color: var(--primary-text); }

.small { font-size: 12px; }

.zuglauf-wrap { overflow-x: auto; }
table.zuglauf { width: 100%; font-size: 13px; }
table.zuglauf th { font-size: 11px; }
table.zuglauf td, table.zuglauf th { padding: 6px 10px; }
tr.stop-current > td {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  font-weight: 600;
  box-shadow: inset 0 2px 0 0 var(--primary), inset 0 -2px 0 0 var(--primary);
}
tr.stop-current > td:first-child {
  box-shadow: inset 0 2px 0 0 var(--primary), inset 0 -2px 0 0 var(--primary), inset 2px 0 0 0 var(--primary);
}
tr.stop-current > td:last-child {
  box-shadow: inset 0 2px 0 0 var(--primary), inset 0 -2px 0 0 var(--primary), inset -2px 0 0 0 var(--primary);
}
tr.stop-next > td { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
tr.stop-cancelled > td { text-decoration: line-through; color: var(--muted); }

.badge {
  display: inline-block; margin-right: 4px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; border: 1px solid var(--border); color: var(--muted);
}
.badge-now { color: var(--primary); border-color: currentColor; }
.badge-next { color: var(--warn); border-color: currentColor; }
.badge-alert { color: var(--danger); border-color: currentColor; }

tr.section-row td {
  background: color-mix(in srgb, var(--muted) 12%, var(--surface));
  color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
tr.section-toggle { cursor: pointer; }
tr.section-toggle:hover td { background: color-mix(in srgb, var(--muted) 22%, var(--surface)); }
.sec-caret { display: inline-block; width: 1em; color: var(--muted); }
tr.train-done td, tr.flight-done td { color: var(--muted); }
tr.train-done .flight-cell strong, tr.flight-done .flight-cell strong { font-weight: 500; }

.train-alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.train-alert {
  padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.4;
  color: var(--warn); border: 1px solid currentColor;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
.train-alert::before { content: "\26A0\FE0F  "; }

.flight-row { cursor: pointer; }
.flight-cell { white-space: nowrap; }
.row-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 12px; line-height: 1;
  padding: 2px 4px; margin-right: 2px;
  transition: transform .12s ease;
}
.row-toggle.open { transform: rotate(90deg); color: var(--text); }

.detail-row > td { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
dl.flight-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 28px;
  margin: 0; padding: 6px 2px;
}
dl.flight-detail > div { display: flex; flex-direction: column; gap: 2px; }
dl.flight-detail dt {
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted);
}
dl.flight-detail dd { margin: 0; font-size: 14px; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin: 0 0 14px; border: 1px solid transparent; }
.alert-error { color: var(--danger); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

.auth-wrap { min-height: 60vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 360px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: 90vw;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; font-size: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25); z-index: 50;
}
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .row-form { flex-direction: column; align-items: stretch; }
  .row-form input { min-width: 0; }
}

/* Geteilte Einzelfahrt-Ansicht (/s/<token>) */
dl.share-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 28px;
  margin: 4px 0 18px;
}
dl.share-overview > div { display: flex; flex-direction: column; gap: 2px; }
dl.share-overview dt {
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted);
}
dl.share-overview dd { margin: 0; font-size: 14px; }
.share-actions { display: flex; gap: 8px; flex-wrap: wrap; }
