* { box-sizing: border-box; }

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #5b6b7b;
  --grid: #e8ecf1;
  --line: #e3e8ee;
  --brand: #fc5200;
  --header: #1e3a5f;
  --good: #0a7a33;
  --warn-bg: #fff7ed;
  --warn-ink: #9a3412;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

/* ---------- Header & Tabs ---------- */

header {
  background: var(--header);
  color: #fff;
  padding: 0.8rem 1.5rem 0;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 76rem;
  margin: 0 auto;
}
header h1 { margin: 0 0 0.4rem; font-size: 1.2rem; }

#tabs {
  display: flex;
  gap: 0.25rem;
  max-width: 76rem;
  margin: 0.35rem auto 0;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
  padding: 0.45rem 0.9rem;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.tab-btn.active { color: #fff; border-bottom-color: var(--brand); font-weight: 600; }

/* ---------- Layout ---------- */

main {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}
.grid .card { margin-bottom: 0; }
.card.wide { grid-column: 1 / -1; }
@media (max-width: 920px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.25rem;
}
.card h2 { margin: 0; font-size: 1.02rem; }
.card h3 { margin: 0.9rem 0 0.3rem; font-size: 0.88rem; color: var(--muted); font-weight: 600; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.card-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.card-controls { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.card-body.dimmed > svg.chart { opacity: 0.35; }
.sub { margin: 0.1rem 0 0.4rem; font-size: 0.8rem; }
.empty { padding: 1rem 0; }

/* ---------- KPI-Zeile ---------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.9rem 1.1rem; margin-bottom: 0; }
.kpi-label { color: var(--muted); font-size: 0.78rem; }
.kpi-value { font-size: 1.65rem; font-weight: 650; letter-spacing: -0.01em; }
.kpi-delta { font-size: 0.78rem; color: var(--muted); }
.kpi-delta.good { color: var(--good); font-weight: 600; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }
.spark { width: 96px; height: 28px; margin-top: 0.3rem; }

/* ---------- Charts ---------- */

svg.chart { width: 100%; height: auto; display: block; }
.radar-wrap { max-width: 30rem; margin: 0 auto; }

.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; margin: 0.25rem 0 0.5rem; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted); }
.swatch.line { width: 14px; height: 3px; border-radius: 2px; }
.swatch.rect { width: 10px; height: 10px; border-radius: 3px; }

.seg { display: inline-flex; background: #edf1f5; border-radius: 8px; padding: 2px; }
.seg-btn {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.78rem; padding: 0.2rem 0.6rem;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.seg-btn.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }

.tooltip {
  position: fixed;
  z-index: 50;
  background: #22303e;
  color: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  max-width: 20rem;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.tip-title { font-weight: 600; margin-bottom: 0.2rem; }
.tip-row { display: flex; align-items: center; gap: 0.45rem; }
.tip-row b { font-variant-numeric: tabular-nums; }
.tip-key { width: 12px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.tip-key.none { background: transparent; }
.tip-label { color: #b9c4cf; }

/* ---------- Buttons & Formulare ---------- */

button {
  font: inherit;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.6; cursor: default; }
button.secondary { background: #e6ebf0; color: var(--ink); }
button.danger { background: #c22f2f; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.78rem; }
header button.secondary { background: rgba(255, 255, 255, 0.18); color: #fff; }
.icon-btn {
  background: transparent; color: var(--muted); padding: 0.1rem 0.35rem;
  font-size: 0.9rem; border-radius: 6px;
}
.icon-btn:hover { background: #edf1f5; filter: none; }
.linklike {
  background: none; color: var(--brand); padding: 0; font-size: inherit;
  text-decoration: underline; border-radius: 0;
}
.linklike:hover { filter: brightness(0.9); }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }

/* ---------- Tabellen ---------- */

table.data { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data th, .data td { text-align: left; padding: 0.4rem 0.55rem; }
.data thead th { border-bottom: 2px solid var(--line); color: var(--muted); font-weight: 600; }
.data tbody tr:nth-child(even) { background: #f8fafc; }
.data td { font-variant-numeric: tabular-nums; }
.td-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { margin-top: 0.75rem; max-height: 24rem; overflow: auto; border-top: 1px solid var(--line); }

/* ---------- Strecken ---------- */

.route-grid { display: grid; grid-template-columns: minmax(16rem, 24rem) 1fr; gap: 1.25rem; }
@media (max-width: 920px) { .route-grid { grid-template-columns: 1fr; } }
.route-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 22rem; overflow-y: auto; }
.route-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.55rem; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.route-row:hover { background: #f2f5f8; }
.route-row.active { background: #eef4fb; border-color: #d3e2f4; }
.route-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.route-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-row .muted { font-size: 0.76rem; }
.star { background: transparent; color: #b9c4cf; padding: 0 0.2rem; font-size: 1.05rem; }
.star.on { color: #eda100; }
.star:hover { filter: none; color: #eda100; }
.route-edit { font: inherit; padding: 0.15rem 0.3rem; border: 1px solid var(--line); border-radius: 6px; width: 100%; }

/* ---------- Material ---------- */

.gear { border-top: 1px solid var(--line); padding: 0.75rem 0; }
.gear:first-of-type { border-top: 0; }
.gear.retired { opacity: 0.55; }
.gear-head { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.gear-icon { font-size: 1.1rem; }
.gear-name { font-weight: 650; }
.gear-km { font-weight: 650; font-variant-numeric: tabular-nums; margin-left: auto; }
.gear-head .muted { font-size: 0.78rem; }
.comp-table { margin-top: 0.5rem; }
.comp-form { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; margin-top: 0.5rem; font-size: 0.82rem; color: var(--muted); }
.comp-input { font: inherit; padding: 0.3rem 0.45rem; border: 1px solid var(--line); border-radius: 6px; }
.comp-km { width: 6rem; font: inherit; padding: 0.3rem 0.45rem; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- Einstellungen ---------- */

.settings-group { max-width: 46rem; }
.settings-group h2 { margin-bottom: 0.6rem; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.3rem 0; flex-wrap: wrap; }
.field > span:first-child { color: var(--ink); font-size: 0.9rem; }
.field-input { display: flex; align-items: center; gap: 0.4rem; }
.field input[type="number"] { width: 5.2rem; font: inherit; padding: 0.3rem 0.45rem; border: 1px solid var(--line); border-radius: 6px; }
.field.bounds .field-input { flex-wrap: wrap; }
.field .unit { color: var(--muted); font-size: 0.8rem; }
.field.check .field-input { gap: 0.55rem; }
.field.check input { width: 1.05rem; height: 1.05rem; }
.field .sub { flex-basis: 100%; }

/* ---------- Detail-Sync-Leiste ---------- */

#detail-bar { background: #fff7ed; border-bottom: 1px solid #fed7aa; }
.detail-inner {
  max-width: 76rem; margin: 0 auto; padding: 0.45rem 1.5rem;
  display: flex; align-items: center; gap: 0.8rem; font-size: 0.82rem; color: var(--warn-ink);
  flex-wrap: wrap;
}
.progress { flex: 0 0 10rem; height: 6px; background: #fde8d2; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 3px; transition: width 0.3s; }

/* ---------- Sonstiges ---------- */

.muted { color: var(--muted); font-size: 0.85rem; }
.warning { color: var(--warn-ink); background: var(--warn-bg); border-radius: 8px; padding: 0.6rem 0.9rem; }
#status { min-height: 1.5rem; color: var(--muted); margin-top: 0.75rem; }
code { background: #eef1f4; padding: 0.1rem 0.3rem; border-radius: 4px; }
