:root {
  --bg: #f4f6f8;
  --karte: #ffffff;
  --rand: #e2e6ea;
  --text: #1f2933;
  --grau: #6b7280;
  --primary: #2563eb;
  --primary-dunkel: #1d4ed8;
  --gefahr: #dc2626;
  --warnung: #f59e0b;
  --ok: #16a34a;
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--karte);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { margin: 0; font-size: 1.4rem; }
.kopf-rechts { display: flex; align-items: center; gap: 0.8rem; }
.abmelden { color: var(--grau); text-decoration: none; font-size: 0.9rem; }
.abmelden:hover { color: var(--gefahr); text-decoration: underline; }

/* Login-Seite */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; margin: 0;
}
.login-box {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 14px;
  padding: 2rem;
  width: 100%; max-width: 340px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.08);
  text-align: center;
}
.login-box h1 { font-size: 1.4rem; margin: 0 0 0.3rem; }
.login-hinweis { color: var(--grau); margin: 0 0 1.2rem; }
.login-box input {
  width: 100%; padding: 0.6rem; margin-bottom: 0.9rem;
  border: 1px solid var(--rand); border-radius: 8px; font: inherit;
}
.login-box button { width: 100%; }
.login-fehler { color: var(--gefahr); margin: 0 0 0.9rem; font-size: 0.9rem; }

main { max-width: 1000px; margin: 0 auto; padding: 1.5rem; }

/* Buttons */
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--rand);
  background: var(--karte);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { background: #eef1f4; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dunkel); }
button.gefahr { color: var(--gefahr); border-color: #f3c4c4; }
button.gefahr:hover { background: #fdecec; }
button.link { background: none; border: none; color: var(--primary); padding: 0; margin-bottom: 1rem; }
button.link:hover { text-decoration: underline; background: none; }

.hidden { display: none !important; }

/* Fahrzeug-Karten */
.karten {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 1.1rem;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.karte:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); transform: translateY(-2px); }
.karte h3 { margin: 0 0 0.2rem; }
.karte .kennzeichen {
  display: inline-block;
  font-weight: 700;
  letter-spacing: 1px;
  border: 2px solid #111;
  border-radius: 4px;
  padding: 1px 6px;
  margin-bottom: 0.6rem;
  background: #fff;
}
.karte .meta { color: var(--grau); font-size: 0.9rem; }

.tuev-badge {
  display: inline-block;
  margin-top: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.tuev-ok { background: #dcfce7; color: var(--ok); }
.tuev-bald { background: #fef3c7; color: #b45309; }
.tuev-faellig { background: #fee2e2; color: var(--gefahr); }
.tuev-keiner { background: #f1f5f9; color: var(--grau); }

.leer-hinweis { color: var(--grau); text-align: center; padding: 2rem; }

/* Detailansicht */
.detail-kopf { margin-bottom: 1rem; }
.detail-kopf h2 { margin: 0.2rem 0; }
.detail-kopf .grau { color: var(--grau); }
.detail-aktionen { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.filter { margin-bottom: 0.8rem; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--karte);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--rand);
}
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--rand); font-size: 0.92rem; }
th { background: #f8fafc; color: var(--grau); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.typ-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.typ-Wartung { background: #dbeafe; color: #1d4ed8; }
.typ-Reparatur { background: #fee2e2; color: #b91c1c; }
.typ-TUEV { background: #ede9fe; color: #6d28d9; }

.zeilen-aktionen button { padding: 0.25rem 0.5rem; font-size: 0.82rem; margin-left: 0.2rem; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 100;
}
.modal-inhalt {
  background: var(--karte);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
}
.modal-inhalt h2 { margin-top: 0; }
form label { display: block; margin-bottom: 0.7rem; font-size: 0.9rem; color: var(--grau); }
form input, form select, form textarea {
  display: block;
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.5rem;
  border: 1px solid var(--rand);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
}
.modal-buttons { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
