:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #647382;
  --border: #e1e6eb;
  --primary: #1f6feb;
  --primary-dark: #1a5fd0;
  --red: #d64545;
  --red-bg: #fdecec;
  --orange: #d98324;
  --orange-bg: #fdf2e3;
  --blue: #2d7fb8;
  --blue-bg: #e8f2fa;
  --green: #2f9e60;
  --green-bg: #e7f6ee;
  --grey: #8a97a5;
  --grey-bg: #eef1f4;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

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

a { color: var(--primary); }

/* Kopfzeile */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 1.1rem; margin: 0; }
.topbar .user { color: var(--muted); font-size: 0.9rem; }
.topbar .right { display: flex; align-items: center; gap: 1rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }

/* Karten */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; font-size: 1.05rem; }

/* Buttons */
button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { background: #f0f3f6; }
button.primary, .btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--red); border-color: var(--red); background: #fff; }
button.danger:hover { background: var(--red-bg); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Formulare */
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
input, select {
  font: inherit;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(31,111,235,0.35); border-color: var(--primary); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.field { margin-bottom: 0.9rem; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; }
th.no-sort { cursor: default; }
tbody tr:hover { background: #f7f9fb; }
td.num, th.num { text-align: right; }

/* Status-Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.red { color: var(--red); background: var(--red-bg); }
.badge.orange { color: var(--orange); background: var(--orange-bg); }
.badge.blue { color: var(--blue); background: var(--blue-bg); }
.badge.green { color: var(--green); background: var(--green-bg); }
.badge.grey { color: var(--grey); background: var(--grey-bg); }

/* Fortschrittsbalken */
.progress { background: var(--grey-bg); border-radius: 999px; height: 12px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.progress.orange > span { background: var(--orange); }
.progress.red > span { background: var(--red); }

/* Meldungen */
.alert { padding: 0.7rem 0.9rem; border-radius: 8px; margin: 0.75rem 0; font-size: 0.9rem; }
.alert.error { color: var(--red); background: var(--red-bg); border: 1px solid #f3c9c9; }
.alert.success { color: var(--green); background: var(--green-bg); border: 1px solid #bfe6cf; }
.alert.warn { color: var(--orange); background: var(--orange-bg); border: 1px solid #f0d8b0; }
.hidden { display: none !important; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }

/* Tabs */
.tabs { display: flex; gap: 0.4rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab { padding: 0.6rem 1rem; border: none; border-bottom: 2px solid transparent; background: none; border-radius: 0; color: var(--muted); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Kennzahlen (Fahrer) */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin: 1rem 0; }
.metric { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem; }
.metric .value { font-size: 1.5rem; font-weight: 700; }
.metric .label { font-size: 0.8rem; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right-align { text-align: right; }
.mt { margin-top: 1rem; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,0.45); display: grid; place-items: center; padding: 1rem; z-index: 50; }
.modal { background: var(--card); border-radius: 12px; padding: 1.5rem; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-top: 0; }
