:root {
  --bg: #0b0b0b;
  --card: #1a1a19;
  --card-2: #232322;
  --text: #ffffff;
  --muted: #8f8e88;
  --line: #2c2c2a;
  --accent: #4f7bff;
  --tour: #5cc2f2;
  --sport: #ef4444;
  --danger: #e24b4a;
  --ok: #4caf50;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, 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(--accent); }
button, input, select { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* Kopfzeile */
header { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
header .spacer { flex: 1; }

/* Buttons und Felder */
.btn { border: 0; border-radius: 9px; padding: 9px 16px; background: var(--card-2); color: var(--text); cursor: pointer; font-weight: 600; }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); }
.chip { border: 0; border-radius: 8px; padding: 7px 13px; background: var(--card); color: var(--text); cursor: pointer; }
.chip.active { background: var(--accent); color: #fff; font-weight: 700; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=email], input[type=password], input[type=text] {
  width: 100%; padding: 11px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.msg { margin-top: 12px; font-size: 14px; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* Anmeldeseite */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 16px; padding: 28px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 22px; }
.auth-card .brand img { width: 48px; height: 48px; border-radius: 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tabs .chip { flex: 1; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 13px; color: var(--muted); }
.legal { text-align: center; margin-top: 18px; font-size: 13px; }

/* Dashboard */
main { padding: 20px 24px 40px; max-width: 1400px; margin: 0 auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.filters .sep { width: 1px; height: 26px; background: var(--line); margin: 0 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 22px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 700; }
.tile .unit { color: var(--muted); font-size: 14px; margin-left: 3px; }
/* Kacheln in der Fahrt-Ansicht: etwas kleiner, heller als die Fläche dahinter */
.detail-tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 14px 0 0; }
.detail-tiles .tile { background: var(--card-2); }
.detail-tiles .tile .value { font-size: 21px; }
.layout { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 18px; align-items: start; }
.list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 330px); overflow: auto; padding-right: 4px; }
.trip { background: var(--card); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; border: 2px solid transparent; }
.trip:hover { background: var(--card-2); }
.trip.selected { border-color: var(--accent); }
.trip .row { display: flex; justify-content: space-between; gap: 10px; }
.trip .date { font-weight: 700; }
.trip .dist { font-weight: 700; font-size: 17px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }
.badge.TOUR { background: rgba(92, 194, 242, .15); color: var(--tour); }
.badge.DEMO { background: rgba(239, 159, 39, .15); color: #ef9f27; }
.badge.SPORT { background: rgba(239, 68, 68, .15); color: var(--sport); }
.detail { background: var(--card); border-radius: var(--radius); padding: 16px; position: sticky; top: 16px; }
.detail h2 { margin: 0 0 4px; font-size: 20px; }
#map { height: 420px; border-radius: 10px; overflow: hidden; margin: 14px 0; background: var(--bg); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px 18px; }
.kv div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 6px 0; }
.kv span:first-child { color: var(--muted); }
.empty { color: var(--muted); padding: 30px; text-align: center; background: var(--card); border-radius: var(--radius); }

/* Konto-Dialog */
dialog { background: var(--card); color: var(--text); border: 0; border-radius: 16px; padding: 24px; width: min(460px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin-top: 0; }
dialog section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }

/* Rechtstexte */
.page { max-width: 760px; margin: 0 auto; padding: 32px 24px 60px; }
.page h1 { font-size: 26px; }
.todo { background: rgba(239, 159, 39, .12); border-left: 3px solid #ef9f27; padding: 10px 14px; border-radius: 0 8px 8px 0; color: #f3c27a; }

.downloads { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.dl { background: var(--card); border-radius: var(--radius); padding: 16px 18px; border: 2px solid transparent; }
.dl.latest { border-color: var(--accent); }
.dl-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.dl-title { font-weight: 700; font-size: 17px; }
.dl-notes { margin: 10px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li { margin-bottom: 8px; }
.badge.NEW { background: rgba(79, 123, 255, .18); color: var(--accent); }

.manual { max-width: 860px; }
.manual h2 { margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.manual h3 { font-size: 16px; margin: 18px 0 6px; }
.manual li { margin-bottom: 6px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 8px; }
.toc a { background: var(--card); color: var(--text); text-decoration: none; padding: 6px 11px; border-radius: 8px; font-size: 13px; }
.toc a:hover { background: var(--card-2); }
.note { background: var(--card); border-left: 3px solid var(--accent); padding: 12px 14px; border-radius: 0 10px 10px 0; }
.mtable { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.mtable th, .mtable td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.mtable th { color: var(--muted); font-weight: 600; }
.faq dt { font-weight: 700; margin-top: 14px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }

.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 16px 28px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }
/* Anmeldeseiten: Platz für die Fußzeile lassen */
.auth-wrap { min-height: calc(100vh - 90px); }

@media (max-width: 600px) {
  header { flex-wrap: wrap; gap: 10px; }
  #user { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .list { max-height: none; }
  .detail { position: static; }
  header, main { padding-left: 16px; padding-right: 16px; }
}

/* Verlaufsübersicht (Wochen/Monate) */
.panel { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; }
.section-title { font-weight: 700; margin-bottom: 8px; }
.history-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.history-head .chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bars { display: flex; gap: 6px; align-items: flex-end; height: 170px; margin-top: 6px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-col { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-col div { width: 100%; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 2px; opacity: .85; }
.bar:hover .bar-col div { opacity: 1; }
.bar-val { font-size: 11px; color: var(--muted); height: 16px; white-space: nowrap; }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }

/* Fahrt: Puls-Zonen und Verlaufsdiagramme */
#zones { margin-top: 16px; }
.zonebar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--card-2); }
.zonelegend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13px; }
.zonelegend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
#charts { margin-top: 16px; }
.readout { font-size: 13px; min-height: 20px; margin-bottom: 6px; }
.chart { margin-bottom: 6px; }
.chart-label { font-size: 13px; font-weight: 700; }
.hover-dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid #2f6bff; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.uplot { font-family: inherit; }

.panel .chip { background: var(--card-2); }
.panel .chip.active { background: var(--accent); }
.chips .sep { width: 8px; }
