/* Rad-App – immer im Darkmode, mobil zuerst; Grundgerüst und Farben wie Serienplaner/Einkaufsliste */
:root {
  color-scheme: dark;
  --bg: #0c0a09;
  --surface: #1c1917;
  --surface-2: #292524;
  --ring: #292524;
  --ring-strong: #44403c;
  --text: #f5f5f4;
  --muted: #a8a29e;
  --faint: #78716c;
  --brand: #3b82f6;
  --brand-strong: #2563eb;
  --brand-soft: rgba(59, 130, 246, 0.18);
  --success: #16a34a;
  --success-strong: #15803d;
  --warn: #eab308;
  --warn-soft: rgba(234, 179, 8, 0.18);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --radius: 16px;
  --nav-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; touch-action: pan-y; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex-shrink: 0; }
svg.i-sm { width: 16px; height: 16px; }

/* ---------- Navigation ---------- */
.topbar { display: none; }
.bottombar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  background: rgba(28, 25, 23, 0.95);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--ring);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottombar ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); }
.bottombar a {
  height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; font-weight: 500; color: var(--muted);
}
.bottombar .pill { display: flex; align-items: center; justify-content: center; width: 52px; height: 30px; border-radius: 999px; transition: background .15s; }
.bottombar a[aria-current="page"] { color: var(--brand); }
.bottombar a[aria-current="page"] .pill { background: var(--brand-soft); }
.bottombar a[aria-current="page"] svg { stroke-width: 2.4; }

main {
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
main.breit { max-width: 1080px; }

@media (min-width: 768px) {
  .bottombar { display: none; }
  .topbar {
    display: block; position: sticky; top: 0; z-index: 30;
    background: rgba(12, 10, 9, 0.9);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ring);
    padding-top: env(safe-area-inset-top);
  }
  .topbar-inner { max-width: 1080px; margin: 0 auto; height: 64px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
  .brand img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
  .topbar nav { display: flex; gap: 4px; }
  .topbar nav a {
    display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
    border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--muted); transition: background .15s;
  }
  .topbar nav a:hover { background: var(--surface-2); color: var(--text); }
  .topbar nav a[aria-current="page"] { background: var(--brand-strong); color: #fff; }
  main { padding-top: 24px; padding-bottom: 48px; }
}

/* ---------- Bausteine ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.page-head h1 .h1-icon { width: 1.15em; height: 1.15em; flex: none; color: var(--brand); }
@media (max-width: 480px) { .page-head h1 { font-size: 1.3rem; } }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--ring); overflow: hidden; }
.card + .card { margin-top: 12px; }
.divided > * + * { border-top: 1px solid var(--ring); }
.empty { padding: 24px 16px; text-align: center; font-size: 0.9rem; color: var(--faint); }
.hinweis { margin: 0; font-size: 0.8rem; line-height: 1.45; color: var(--faint); }
.section-title { margin: 24px 4px 8px; font-size: 0.8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 12px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: transform .1s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand-strong); color: #fff; }
.btn-primary:hover { background: var(--brand); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-strong); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--ring-strong); }
.btn-warn { background: var(--warn); color: #1c1917; font-weight: 800; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.8rem; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.95); }
.icon-btn.danger:hover { color: var(--danger); }
.fab { width: 44px; height: 44px; border-radius: 999px; background: var(--success); color: #fff; }
.fab:hover { background: var(--success-strong); color: #fff; }
.fab svg { stroke-width: 3; }
.stack { display: grid; gap: 12px; padding: 14px 16px; }

/* ---------- Formulare ---------- */
.input, .sheet input, .sheet select, .sheet textarea, .form-grid select {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--ring-strong); border-radius: 12px;
  background: var(--bg); color: var(--text); font-size: 16px; outline: none;
}
.input:focus, .sheet input:focus, .sheet select:focus, .sheet textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input[readonly] { color: var(--muted); border-style: dashed; }
.field-label { display: block; margin-bottom: 6px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label { font-size: 0.875rem; color: var(--muted); }

/* ---------- Sheet (Bearbeiten / Historie) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px;
  max-height: 92dvh; border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--text);
  box-shadow: 0 0 0 1px var(--ring-strong);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog.sheet[open] { animation: slide-up .2s ease-out; display: flex; flex-direction: column; }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 20px; border-bottom: 1px solid var(--ring); }
.sheet-head h2 { margin: 0; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { overflow-y: auto; padding: 16px 20px; display: grid; gap: 14px; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ring); }
.sheet-foot .btn-primary { flex: 1; }
@media (min-width: 768px) {
  dialog.sheet { margin: auto; border-radius: 20px; }
  .sheet-foot { padding-bottom: 12px; }
}

/* ---------- Rad-App ---------- */
/* Hintergrundbild vorerst behalten (Entscheidung in Schritt 7) */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: url('/static/background.png') center / cover; opacity: 0.12; pointer-events: none; }
body { background: transparent; }
.bottombar a { font-size: 10px; }
.bottombar .pill { width: 44px; }
textarea { font-family: inherit; resize: vertical; }

.card-pad { padding: 14px 16px; }
.ziel-zeile { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.ziel-zeile b { color: var(--text); font-size: 1.05rem; }
.progress { height: 12px; margin: 10px 0 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: var(--success); }
.prozent { font-size: 0.8rem; color: var(--faint); text-align: right; }
.letzte { font-size: 0.95rem; line-height: 1.45; }
.letzte span { color: var(--muted); }
.aktionen { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.aktionen .btn { min-height: 56px; font-size: 1rem; }

/* Fahrten: Jahre und Monate */
.jahre { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.jahr-btn { padding: 12px 6px; border: 0; border-radius: 12px; background: var(--surface); box-shadow: 0 0 0 1px var(--ring); cursor: pointer; text-align: center; font-weight: 700; }
.jahr-btn small { display: block; margin-top: 2px; font-weight: 500; font-size: 0.75rem; color: var(--muted); }
.jahr-btn[aria-pressed="true"] { background: var(--brand-strong); box-shadow: none; }
.jahr-btn[aria-pressed="true"] small { color: #dbeafe; }
.monate { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.monat-btn { display: block; padding: 12px 6px; border-radius: 12px; background: var(--surface-2); text-align: center; font-size: 0.85rem; font-weight: 600; }
.monat-btn small { display: block; margin-top: 2px; font-weight: 500; color: var(--muted); }
.monat-btn:hover { background: var(--ring-strong); }

/* Monat: Fahrtenliste */
.zurueck { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 0.85rem; color: var(--muted); }
.zurueck:hover { color: var(--text); }
.fahrt { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; }
.fahrt .tag { width: 52px; flex: none; font-size: 0.8rem; color: var(--muted); line-height: 1.2; }
.fahrt .tag b { display: block; font-size: 0.95rem; color: var(--text); }
.fahrt .was { flex: 1; min-width: 0; }
.fahrt .was b { font-variant-numeric: tabular-nums; }
.fahrt .was > span:not(.badge-gps) { display: block; font-size: 0.78rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fahrt form { display: contents; }
.badge-gps { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 0.7rem; font-weight: 700; vertical-align: 1px; }
.summe { display: flex; justify-content: space-between; padding: 10px 16px; font-weight: 700; }

/* Statistik */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi .sub { display: block; margin-top: 2px; font-size: 0.8rem; color: var(--muted); }

/* Admin / Info */

/* Tacho */
.tacho { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: center; }
.tacho .card { margin: 0; padding: 10px; position: relative; }
.tacho .breit { grid-column: span 2; }
.tacho .label { display: block; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.val-large { display: block; margin: 2px 0; font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.unit { display: block; font-size: 0.65rem; font-weight: 700; color: var(--muted); }
.btn-reset { position: absolute; top: 6px; right: 6px; min-height: 0; padding: 4px 8px; font-size: 0.65rem; border-radius: 8px; }
.segment-table { width: 100%; font-size: 0.7rem; color: var(--muted); border-collapse: collapse; }
.segment-table th, .segment-table td { padding: 6px 2px; text-align: center; border: 1px solid var(--ring-strong); min-width: 45px; }
.val-active { color: var(--text); font-weight: 700; font-size: 0.85rem; }
.tacho-einstellungen { display: grid; gap: 8px; margin-top: 10px; }
.btn-action { width: 100%; min-height: 64px; margin-top: 10px; font-size: 1.15rem; }
.btn-stop { background: var(--danger); color: #fff; }
/* Während der Fahrt: kein Menü, damit nichts versehentlich angetippt wird */
body.fahrt-laeuft .topbar, body.fahrt-laeuft .bottombar { display: none; }
body.fahrt-laeuft main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
body.fahrt-laeuft .tacho-kopf { display: none; }

/* aus Einkaufsliste: Kennzahlen und Wertezeilen */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { padding: 12px 14px; }
.kpi .label { font-size: 0.7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.kpi b { display: block; margin-top: 4px; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi b.gruen { color: var(--success); }
.kpi b.blau { color: var(--brand); }
.kpis .card + .card { margin-top: 0; }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr; } .kpi { display: flex; align-items: center; justify-content: space-between; } .kpi b { margin: 0; } }
.wert-zeile { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; font-size: 0.9rem; }
.wert-zeile > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wert-zeile .werte { display: flex; gap: 6px; flex-shrink: 0; }
.sheet-body .card + .card { margin-top: 0; }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi { display: block; } .kpi b { margin-top: 4px; } }

/* Info-Seite (wie Einkaufsliste) */
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; }
.row dt { font-size: 0.875rem; color: var(--muted); }
.row dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.row dd.big { font-size: 1.15rem; font-weight: 800; }
.logo-big { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0 20px; }
.logo-big img { width: 96px; height: 96px; border-radius: 22px; object-fit: cover; box-shadow: 0 0 0 1px var(--ring-strong); }
.logo-big p { margin: 0; font-size: 1.1rem; font-weight: 800; }
details.section { margin-top: 18px; }
details.section > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 4px; font-size: 0.8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); user-select: none; }
details.section > summary .chev { margin-left: auto; }
details.section[open] > summary { margin-bottom: 6px; }
details.ver > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; font-weight: 600; user-select: none; }
details.ver > summary .when { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--faint); font-weight: 500; }
details.ver ul { margin: 0; padding: 0 16px 14px 36px; font-size: 0.875rem; color: #d6d3d1; }
details.ver li + li { margin-top: 3px; }
.footer-note { text-align: center; font-size: 0.75rem; color: var(--faint); margin-top: 24px; font-weight: 600; }
.chart { padding: 4px 16px 14px; border-top: 1px solid var(--ring); }
.chart-readout { font-size: 0.85rem; color: var(--muted); margin: 10px 0 8px; min-height: 1.3em; }
.chart-readout b { color: var(--text); font-variant-numeric: tabular-nums; }
.chart-bars { height: 120px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; align-items: end; }
.chart .bar { all: unset; height: 100%; display: flex; align-items: flex-end; cursor: pointer; padding: 0 2px; }
.chart .bar span { display: block; width: 100%; border-radius: 4px 4px 0 0; background: var(--brand); opacity: .55; transition: opacity .1s; }
.chart .bar.current span { opacity: .85; }
.chart .bar:hover span, .chart .bar.active span, .chart .bar:focus-visible span { opacity: 1; }
.chart-axis { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; margin-top: 4px; }
.chart-axis span { font-size: 10px; color: var(--faint); text-align: center; white-space: nowrap; }
.ver-eintrag { padding: 0 16px 12px; }
.ver-eintrag + .ver-eintrag { border-top: 1px dashed var(--ring); padding-top: 10px; }
.ver-kopf { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.85rem; margin-bottom: 4px; }
.ver-kopf b { color: var(--brand); }
.ver-kopf span { color: var(--faint); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
details.ver .ver-eintrag ul { padding: 0 0 0 20px; }
details.section > summary::-webkit-details-marker, details.ver > summary::-webkit-details-marker { display: none; }
details.ver[open] > summary .chev, details.section[open] > summary .chev { transform: rotate(180deg); }

/* Admin: Räder, Import, Meldungen */
.rad-zeile { display: grid; gap: 8px; padding: 12px 16px; }
.rad-zeile.inaktiv .input { color: var(--faint); }
.rad-optionen { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 0.85rem; }
.rad-optionen .label { margin-right: auto; }
.rad-optionen label, .auswahl label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.rad-optionen .loeschen { color: var(--danger); }
.auswahl { display: grid; gap: 8px; font-size: 0.9rem; }
input[type=radio], input[type=checkbox] { accent-color: var(--brand); width: 18px; height: 18px; margin: 0; }
input[type=file].input { padding: 10px 12px; }
.meldung { margin: 0 0 10px; padding: 10px 14px; border-radius: 12px; background: rgba(22, 163, 74, 0.15); color: #86efac; font-size: 0.875rem; }
.meldung.fehler { background: var(--danger-soft); color: #fca5a5; }
details.section { scroll-margin-top: 80px; }

/* Statistik */
.ziel-balken { position: relative; overflow: visible; }
.ziel-balken > div { border-radius: 999px; }
.soll-marke { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--warn); }
.plus { color: var(--success); }
.minus { color: var(--danger); }
.jahr-zeile { padding: 10px 16px; }
.jahr-kopf { display: flex; align-items: baseline; gap: 10px; }
.jahr-kopf b { font-size: 1rem; }
.jahr-km { flex: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta { font-size: 0.8rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); }
.jahr-details { margin-top: 2px; font-size: 0.78rem; color: var(--faint); }
.wert-zeile > span:first-child { white-space: normal; }
.wert-zeile small { font-size: 0.75rem; }
.wert-zeile > b { white-space: nowrap; }

/* ---------- Info: Versionszeile mit Versionshistorie (in allen Apps gleich) ---------- */
.info-kopf { margin: 0; }
.info-kopf .row .label { font-size: 0.875rem; color: var(--muted); }
.info-kopf .row .wert { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.info-kopf .row .wert.big { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 800; }
details.vh > summary, details.vh-gruppe > summary { list-style: none; cursor: pointer; user-select: none; }
details.vh > summary::-webkit-details-marker, details.vh-gruppe > summary::-webkit-details-marker { display: none; }
details.vh > summary .chev, details.vh-gruppe > summary .chev { transition: transform .15s; color: var(--faint); transform: none; }
details.vh[open] > summary .chev, details.vh-gruppe[open] > summary .chev { transform: rotate(180deg); }
.vh-liste { border-top: 1px solid var(--ring); background: rgba(0, 0, 0, .18); }
details.vh-gruppe + details.vh-gruppe { border-top: 1px solid var(--ring); }
details.vh-gruppe > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 16px; font-weight: 700; }
details.vh-gruppe > summary .when { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.vh-eintrag { padding: 0 16px 12px; }
.vh-eintrag + .vh-eintrag { border-top: 1px dashed var(--ring); padding-top: 10px; }
.vh-kopf { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.85rem; margin-bottom: 4px; }
.vh-kopf b { color: var(--brand); font-variant-numeric: tabular-nums; }
.vh-kopf span { color: var(--faint); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.vh-eintrag ul { margin: 0; padding: 0 0 0 20px; font-size: 0.875rem; color: #d6d3d1; }
.vh-eintrag li + li { margin-top: 3px; }

/* Tacho: Etappenlänge als Knöpfe */
.etappen-wahl { display: grid; grid-template-columns: auto 1fr 1fr 1fr; align-items: center; gap: 8px; }
.etappen-wahl .label { padding: 0 4px; }
.etappen-wahl .btn[aria-pressed="true"] { background: var(--brand-strong); color: #fff; }

/* Tacho aus dem Kurzbefehl (…/gps?kurzbefehl=1): nie ein Menü */
body.kurzbefehl .topbar, body.kurzbefehl .bottombar, body.kurzbefehl .tacho-kopf { display: none; }
body.kurzbefehl main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
#gpsHinweis, #wachHinweis { margin: 10px 0 0; }
