:root {
  color-scheme: light dark;
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #d9dce1;
  --color-text: #1f2430;
  --color-muted: #6b7280;
  --color-primary: #1b6b3e;
  --color-primary-dark: #14522f;
  --color-primary-soft: #eaf5ee;
  --color-ok: #15803d;
  --color-soon: #b45309;
  --color-overdue: #b91c1c;
  --color-unknown: #6b7280;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Ohne dieses color-scheme rendert der Browser Formularelemente wie
       Checkboxen weiterhin mit seinem hellen Standard-Rahmen und ignoriert
       accent-color faktisch - erst mit "dark" hier greift der Akzent auch
       im Dark Mode sichtbar. */
    color-scheme: dark;
    --color-bg: #14171c;
    --color-surface: #1c2027;
    --color-border: #333944;
    --color-text: #e7e9ec;
    --color-muted: #9aa1ab;
    --color-primary: #2f9e5c;
    --color-primary-dark: #3fbb70;
    --color-primary-soft: #17251c;
    --color-ok: #34a853;
    --color-soon: #d69324;
    --color-overdue: #e35d5d;
    --color-unknown: #9aa1ab;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

header.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

footer.site-footer {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.85rem;
}

footer.site-footer a {
  color: var(--color-muted);
}

header.site-header nav a {
  margin-left: 1.25rem;
  color: var(--color-text);
  font-weight: 500;
}

header.site-header nav a.nav-cta {
  color: white;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
}

.nav-toggle { display: none; }
.lang-switch { margin-left: 1.25rem; }
.lang-switch a { margin-left: 0.25rem; }

header.site-header .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
}

main.container {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

h1 { font-size: 1.6rem; margin-top: 0; }
h2 { font-size: 1.2rem; }

.table-responsive { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.inline-mileage-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.inline-mileage-form input[type=number] {
  width: 6.5rem;
  padding: 0.3rem 0.4rem;
}

.inline-mileage-form .btn {
  padding: 0.3rem 0.6rem;
  line-height: 1;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
}

th { color: var(--color-muted); font-weight: 600; }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn:hover { background: var(--color-primary-dark); text-decoration: none; }

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
}

.btn-secondary:hover { background: var(--color-primary-soft); }

.btn-danger {
  background: transparent;
  color: var(--color-overdue);
  border: 1px solid var(--color-overdue);
}

.btn-danger:hover { background: var(--color-overdue); color: white; }

.actions { display: flex; gap: 0.75rem; margin: 1rem 0; }

form.stacked label {
  display: block;
  margin-bottom: 1rem;
}

form.stacked label > span {
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], select, textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

fieldset {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

legend { font-weight: 600; padding: 0 0.4rem; }

.accordion-section {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  background: var(--color-surface);
  overflow: hidden;
}

.accordion-section summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.75rem 1rem;
  color: var(--color-primary);
  list-style: none;
}

.accordion-section summary::-webkit-details-marker { display: none; }

.accordion-section summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform 0.15s ease;
}

.accordion-section[open] summary::before { transform: rotate(90deg); }

.accordion-section .accordion-body {
  padding: 0 1rem 1rem 1rem;
  border-top: 1px solid var(--color-border);
}

.vehicle-photo {
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  margin-bottom: 1rem;
  display: block;
}

.vehicle-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem 1rem;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
}

.checkbox-grid input { width: auto; }

input[type=checkbox] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.category-group-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
}

.category-group-column {
  flex: 1 1 200px;
  max-width: 260px;
}

.category-group-heading {
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.5rem;
}

.category-group-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-group-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

.badge-ok { background: var(--color-ok); }
.badge-soon { background: var(--color-soon); }
.badge-overdue { background: var(--color-overdue); }
.badge-unknown { background: var(--color-unknown); }
.badge-planned { background: var(--color-soon); }

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row > label { flex: 1; min-width: 140px; }

.field-mini { display: flex; flex-direction: column; gap: 0.2rem; }
.field-mini > span { font-size: 0.75rem; color: var(--color-muted); }

.field-with-button { display: flex; gap: 0.5rem; }
.field-with-button select { flex: 1; }
.field-with-button .btn-secondary { padding: 0.5rem 0.9rem; }

dialog.modal {
  border: none;
  border-radius: 8px;
  padding: 1.5rem;
  background: var(--color-surface);
  color: var(--color-text);
  max-width: 420px;
  width: 90%;
}

dialog.modal::backdrop { background: rgba(0, 0, 0, 0.5); }

.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.muted { color: var(--color-muted); font-size: 0.9rem; }

@media (min-width: 769px) {
  .pwa-install-card { display: none !important; }
}

.hero { text-align: center; padding: 2rem 1rem 1rem; }
.hero h1 { font-size: 2rem; margin: 1rem 0 0.75rem; }
.hero p.lead { font-size: 1.1rem; color: var(--color-muted); max-width: 640px; margin: 0 auto 1.5rem; }
.hero .actions { justify-content: center; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0 2.5rem;
  text-align: center;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.final-cta {
  text-align: center;
  padding: 2.5rem 1rem;
  background: var(--color-primary-soft);
  border-radius: 8px;
  margin: 2rem 0;
}

.history-filter {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.history-filter label { margin-bottom: 0; }
.history-filter select { width: auto; }

.mobile-sub { display: none; }

/* Mobil: Hamburger-Menue statt Nav-Zeile, gestapelte Aktionen/Formulare */
@media (max-width: 720px) {
  header.site-header { flex-wrap: wrap; padding: 0.75rem 1rem; }

  .nav-toggle {
    display: inline-block;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--color-text);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
  }

  header.site-header nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.75rem;
  }

  header.site-header nav.open { display: flex; }

  header.site-header nav a { margin-left: 0; }

  .lang-switch { margin-left: 0; }

  main.container { margin: 1rem auto; padding: 0 1rem; }

  .card { padding: 1rem; }

  .actions { flex-direction: column; align-items: stretch; }
  .actions .btn, .actions .btn-secondary { text-align: center; }

  table { font-size: 0.85rem; }
  th, td { padding: 0.4rem; }

  .category-group-column { flex: 1 1 100%; max-width: none; }

  .history-filter { flex-direction: column; align-items: stretch; }
  .history-filter select, .history-filter input { width: 100%; }

  .hide-mobile { display: none; }
  .mobile-sub { display: block; font-size: 0.8rem; color: var(--color-muted); }

  /* Tabellen mit verschiedenartigem Inhalt pro Spalte (z.B. Wartungsstatus)
     lassen sich nicht sinnvoll durch Spalten-Ausblenden verschmalern - hier
     wird stattdessen jede Zeile zu einem eigenen Block mit Feld-Labels. */
  table.stack-mobile thead { display: none; }
  table.stack-mobile, table.stack-mobile tbody, table.stack-mobile tr, table.stack-mobile td {
    display: block;
    width: 100%;
  }
  table.stack-mobile tr { border-bottom: 1px solid var(--color-border); padding: 0.5rem 0; }
  table.stack-mobile td { border-bottom: none; padding: 0.15rem 0; }
  table.stack-mobile td.stack-heading { font-weight: 600; padding-top: 0.5rem; }
  table.stack-mobile td[data-label]::before {
    content: attr(data-label) ": ";
    display: inline-block;
    min-width: 7.5rem;
    font-weight: 600;
    color: var(--color-muted);
  }
}
