:root {
  --primary-color: #1f5eff;
  --sidebar-color: #101828;
  --background-color: #f4f6fa;
  --panel-color: #ffffff;
  --text-color: #172033;
  --accent-color: #ffb020;
  --button-color: #1f5eff;
  --muted-text-color: #667085;
  --input-background: #ffffff;
  --radius: 18px;
  --font-family: system-ui, Arial, sans-serif;
  font-family: var(--font-family);
  color: var(--text-color);
  background: var(--background-color);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--background-color); color: var(--text-color); }
button, input, textarea, select { font: inherit; }
button { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--button-color); color: white; cursor: pointer; }
button.secondary { background: #e7ecf6; color: var(--text-color); }
button.danger { background: #d93025; }
button.success { background: #188038; }
button:disabled, input:disabled, textarea:disabled, select:disabled { opacity: .75; cursor: not-allowed; background: #f8fafc; }
input, textarea, select { width: 100%; padding: 10px; border: 1px solid #d7deea; border-radius: 10px; background: var(--input-background); color: var(--text-color); }
textarea { min-height: 80px; }
label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; }
.hidden { display: none !important; }
.error { color: #d93025; }
.logo { max-width: 42px; max-height: 42px; object-fit: contain; border-radius: 8px; }
.login-card { width: min(420px, calc(100vw - 24px)); margin: 80px auto; background: var(--panel-color); padding: 24px; border-radius: var(--radius); box-shadow: 0 10px 30px #0001; display: grid; gap: 12px; }
.login-title { display: flex; gap: 12px; align-items: center; }
.app { display: grid; grid-template-columns: 330px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar-color); color: white; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.brand { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; }
.brand-left { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vehicle-list { display: grid; gap: 8px; overflow: auto; }
.vehicle-card { background: color-mix(in srgb, var(--sidebar-color) 75%, white); padding: 12px; border-radius: 12px; cursor: pointer; }
.vehicle-card:hover { background: color-mix(in srgb, var(--sidebar-color) 60%, white); }
.vehicle-card small { color: #cbd5e1; }
small, .muted, .welcome-user { color: var(--muted-text-color); }
.content { padding: 24px; overflow: auto; }
.panel { background: var(--panel-color); border-radius: var(--radius); padding: 22px; box-shadow: 0 8px 24px #0000000d; }
body[data-card-shadow="none"] .panel, body[data-card-shadow="none"] .card, body[data-card-shadow="none"] .login-card { box-shadow: none; }
body[data-card-shadow="strong"] .panel, body[data-card-shadow="strong"] .card, body[data-card-shadow="strong"] .login-card { box-shadow: 0 18px 45px #00000024; }
.header { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.vehicle-image { width: 220px; height: 150px; object-fit: cover; border-radius: 16px; background: #e7ecf6; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }
.card { border: 1px solid #e4eaf3; border-radius: 14px; padding: 14px; margin-top: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.table th, .table td { border-bottom: 1px solid #e4eaf3; padding: 8px; text-align: left; vertical-align: top; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.notice { background: color-mix(in srgb, var(--accent-color) 14%, white); border: 1px solid #d7e3ff; border-radius: 12px; padding: 10px; }
body[data-density="compact"] .panel, body[data-density="compact"] .card { padding: 12px; }
body[data-density="compact"] input, body[data-density="compact"] textarea, body[data-density="compact"] select, body[data-density="compact"] button { padding: 7px 10px; }
@media (max-width: 900px) { .app { grid-template-columns: 1fr; } .header, .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; } .sidebar { position: relative; } }

/* Zugeklappter Bereich für HU-E-Mail-Empfänger im Fahrzeugüberblick */
.details-summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  list-style: none;
}

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

.details-summary::before {
  content: '▶';
  margin-right: 10px;
  font-size: 12px;
}

details[open] .details-summary::before {
  content: '▼';
}

.details-summary small {
  opacity: 0.65;
  font-weight: 500;
}

/* Kompakter Kombi-Button für Service-Dokumente/Rechnungen */
button.compact {
  padding: 7px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.service-documents {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}

.service-documents ul {
  margin: 0;
  padding-left: 16px;
  font-size: 13px;
}


/* Einheitliche kompakte Kombi-Buttons für Upload/Import */
.upload-combo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

input[type="file"][hidden] {
  display: none !important;
}

/* Linke Fahrzeugliste: ausgewähltes Fahrzeug leicht aufklappen */
.vehicle-card.selected {
  border-color: var(--primary-color, #1f5eff);
  box-shadow: 0 8px 24px rgba(31,94,255,.14);
}
.vehicle-card-main {
  display: flex;
  gap: 10px;
  align-items: center;
}
.vehicle-list-image {
  width: 54px;
  height: 42px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.08);
}
.vehicle-card-extra {
  margin-top: 6px;
  font-size: 12px;
  opacity: .8;
}
.btn-link {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.12);
  text-decoration: none;
}

/* Kompakte Bearbeitungs- und Datei-Buttons */
.button-stack {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
button.tiny,
.tiny {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 8px;
}
.file-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.upload-line {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.upload-line input:not([type="file"]) {
  min-width: 280px;
  flex: 1;
}
tr.row-editing {
  background: rgba(31, 94, 255, 0.06);
}
tr.row-editing input:not([type="file"]) {
  border-color: var(--primary-color, #1f5eff);
  background: #fff;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  width: min(480px, 100%);
  background: var(--panel-color, #fff);
  color: var(--text-color, #172033);
  border-radius: var(--border-radius, 18px);
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.modal-card label {
  display: block;
  margin: 10px 0;
}


/* Ausgewähltes Fahrzeug links deutlicher hervorheben */
.vehicle-card.selected {
  padding: 16px;
  transform: scale(1.02);
}

.vehicle-card.selected .vehicle-card-main {
  align-items: flex-start;
}

.vehicle-card.selected .vehicle-list-image {
  width: 82px;
  height: 62px;
  border-radius: 12px;
}

.vehicle-card.selected strong {
  font-size: 15px;
}

.vehicle-card.selected small,
.vehicle-card.selected .vehicle-card-extra {
  font-size: 13px;
}


/* Linke Fahrzeugliste: Klick öffnet eine kompakte Detailkarte */
.vehicle-card.selected.expanded {
  padding: 16px;
  min-height: 132px;
}
.vehicle-card-text {
  min-width: 0;
}
.vehicle-sidebar-expanded {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.18);
}
.vehicle-sidebar-expanded div {
  background: rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 7px 8px;
  min-width: 0;
}
.vehicle-sidebar-expanded div:last-child {
  grid-column: 1 / -1;
}
.vehicle-sidebar-expanded span {
  display: block;
  font-size: 11px;
  opacity: .7;
  margin-bottom: 2px;
}
.vehicle-sidebar-expanded strong {
  display: block;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vehicle-list-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #64748b;
  background: #e2e8f0;
}

/* Final: einheitliche Schriftgrößen und saubere Seitenleisten-Auswahl */
.vehicle-card,
.vehicle-card strong,
.vehicle-card small,
.vehicle-card-extra,
.vehicle-sidebar-expanded,
.vehicle-sidebar-expanded strong,
.vehicle-sidebar-expanded span {
  font-size: 14px;
}
.vehicle-card small,
.vehicle-card-extra,
.vehicle-sidebar-expanded span {
  font-size: 13px;
}
.vehicle-card:not(.selected) .vehicle-sidebar-expanded,
.vehicle-card:not(.selected) .vehicle-list-image {
  display: none;
}
.vehicle-card.selected.expanded {
  padding: 16px;
  min-height: 132px;
}
.vehicle-card.selected.expanded .vehicle-list-image {
  display: block;
  width: 82px;
  height: 62px;
  object-fit: cover;
  border-radius: 12px;
}
.attachment-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}


/* Auswahl in der linken Seitenleiste: nicht mehr aufklappen, nur klar markieren */
.vehicle-card.selected {
  position: relative;
  padding: 12px;
  min-height: auto;
  transform: none;
  background: linear-gradient(90deg, var(--primary-color, #1f5eff), color-mix(in srgb, var(--primary-color, #1f5eff) 72%, white));
  color: #ffffff;
  border: 2px solid rgba(255,255,255,.55);
  box-shadow: 0 0 0 3px rgba(255,255,255,.16), 0 8px 20px rgba(0,0,0,.22);
}

.vehicle-card.selected::before {
  content: "✓";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.22);
  font-weight: 800;
}

.vehicle-card.selected strong,
.vehicle-card.selected small {
  color: #ffffff;
}

.vehicle-card.selected .vehicle-card-main {
  align-items: center;
}

.vehicle-card.selected .vehicle-list-image,
.vehicle-card.selected .vehicle-sidebar-expanded,
.vehicle-card.selected.expanded .vehicle-list-image,
.vehicle-card.selected.expanded .vehicle-sidebar-expanded {
  display: none !important;
}

.vehicle-card.selected.expanded {
  padding: 12px;
  min-height: auto;
}

/* Hauptnavigation in der Seitenleiste */
#vehiclesOverviewButton,
#customersOverviewButton {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
}

/* Ausgewählt markieren, aber nicht mehr vergrößern/aufklappen */
.vehicle-card.selected {
  transform: none !important;
  padding: 12px !important;
  background: color-mix(in srgb, var(--sidebar-color) 45%, white) !important;
  border: 2px solid var(--primary-color) !important;
  box-shadow: inset 4px 0 0 var(--primary-color), 0 8px 20px rgba(0,0,0,.18) !important;
}

.vehicle-card.selected strong { color: #fff; }


/* Neue Seitenleiste: Suche oben, Navigation darunter, Admin/Logout unten */
.sidebar { min-height: 100vh; }
.sidebar-search-box {
  display: grid;
  gap: 6px;
  margin-bottom: 4px;
}
.sidebar-search-box label {
  color: rgba(255,255,255,.72);
  font-size: 13px;
  font-weight: 700;
}
.sidebar-search-box input {
  background: rgba(255,255,255,.95);
  color: #172033;
}
.sidebar-nav {
  display: grid;
  gap: 10px;
}
.sidebar-nav button,
.sidebar-bottom button {
  width: 100%;
  text-align: left;
}
.sidebar-nav button.active,
.sidebar-bottom button.active {
  background: var(--primary-color) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,.45) !important;
  box-shadow: inset 4px 0 0 rgba(255,255,255,.75), 0 8px 18px rgba(0,0,0,.18);
}
.sidebar-spacer { flex: 1; }
.sidebar-bottom {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.15);
}
.vehicle-list { display: none !important; }
#vehicleSearch { display: none !important; }

/* Einheitliche Schriftgrößen in Tabellen und Formularen */
.table, .table input, .table button, .table a, input, textarea, select, button {
  font-size: 14px;
}


/* Benutzeranzeige in der Seitenleiste */
.welcome-user {
  display: block;
  margin-top: 4px;
  font-size: 0.86rem;
  font-weight: 500;
  opacity: 0.85;
}

/* Layout-Fix: Nur das Hauptfenster scrollt, Seitenleiste bleibt fest stehen */
html, body { height: 100%; overflow: hidden; }
.app {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}
.sidebar {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  position: sticky;
  top: 0;
}
.content {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.brand {
  align-items: flex-start;
}
.brand-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.welcome-user {
  margin-top: 0;
  color: rgba(255,255,255,.78);
}
.sidebar-bottom {
  flex-shrink: 0;
}
.customer-email-editor {
  margin-top: 14px;
}
.customer-email-editor .table {
  margin-top: 6px;
}
.customer-email-editor input {
  min-width: 180px;
}
.customer-link-button {
  white-space: nowrap;
}
@media (max-width: 900px) {
  html, body { overflow: auto; }
  .app { height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { height: auto; position: relative; overflow: visible; }
  .content { height: auto; overflow: visible; }
}

/* Readonly statt disabled: gesperrte Felder bleiben markier- und kopierbar */
input[readonly],
textarea[readonly] {
  opacity: 1;
  cursor: text;
  user-select: text;
  background: #f8fafc;
  color: var(--text-color);
}
select:disabled {
  opacity: .85;
  background: #f8fafc;
}
.notes-card textarea[readonly] {
  min-height: 140px;
  white-space: pre-wrap;
}

/* Druckauswahl: Checkbox und Beschriftung sauber ausrichten */
.print-options-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}
.print-options-list label {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.print-options-list input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

/* Admin: Checkboxen exakt neben dem passenden Text anzeigen */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border, #d9dee8);
  border-radius: 10px;
  background: rgba(255,255,255,0.55);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
}
.checkbox-row span {
  line-height: 1.25;
}

/* V1.5: ruhigeres Layout, Dashboard und professionellere Karten */
.app {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}
.sidebar {
  height: 100vh;
  overflow: hidden;
  position: sticky;
  top: 0;
}
.content {
  height: 100vh;
  overflow-y: auto;
}
.sidebar-nav button,
.sidebar-bottom button {
  width: 100%;
  text-align: left;
  margin-bottom: 7px;
  background: rgba(255,255,255,.08);
}
.sidebar-nav button.active,
.sidebar-bottom button.active {
  background: var(--primary-color);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0,0,0,.20);
}
.welcome-user {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  opacity: .78;
}
.muted { color: #64748b; }
.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 18%, white), #fff);
  border: 1px solid #e4eaf3;
}
.dashboard-hero h2 { margin: 2px 0 6px; font-size: 30px; }
.dashboard-hero p { margin: 0; color: #64748b; }
.eyebrow {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(31,94,255,.10);
  color: var(--primary-color);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .05em;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat-card {
  border: 1px solid #e4eaf3;
  border-radius: 18px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(15,23,42,.05);
}
.stat-card strong { display:block; font-size: 32px; line-height: 1; }
.stat-card span { display:block; margin-top: 8px; font-weight: 800; }
.stat-card small { display:block; margin-top: 4px; color:#64748b; }
.dashboard-card { min-height: 220px; }
.dashboard-list { display: grid; gap: 8px; }
.dashboard-list-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid #e4eaf3;
  background: #f8fafc;
  color: var(--text-color);
  text-align: left;
}
.dashboard-list-item:hover { border-color: var(--primary-color); background: #fff; }
.dashboard-list-item small { display:block; color:#64748b; margin-top:2px; }
.dashboard-list-item em { color: var(--primary-color); font-style: normal; font-weight: 800; }
.card {
  box-shadow: 0 6px 18px rgba(15,23,42,.04);
}
.table th {
  background: #f8fafc;
  font-size: 13px;
  color: #475569;
}
input[readonly], textarea[readonly] {
  background: #f8fafc;
  cursor: text;
  user-select: text;
}
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app, .sidebar, .content { height: auto; min-height: auto; overflow: visible; }
  .dashboard-grid { grid-template-columns: 1fr; }
}


/* Fix V1.5.1: Admin-Center/Logout in der Seitenleiste klar lesbar und fix unten */
.sidebar {
  position: fixed !important;
  left: 0;
  top: 0;
  bottom: 0;
  width: 330px;
}
.content {
  margin-left: 330px;
  width: calc(100vw - 330px);
}
.sidebar-bottom button,
.sidebar-bottom button.secondary {
  background: rgba(255,255,255,.14) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255,255,255,.22) !important;
  opacity: 1 !important;
}
.sidebar-bottom button:hover,
.sidebar-bottom button.secondary:hover {
  background: rgba(255,255,255,.22) !important;
}
.sidebar-bottom button.active,
.sidebar-bottom button.secondary.active {
  background: var(--primary-color) !important;
  color: #ffffff !important;
}
.sidebar-nav button,
.sidebar-nav button.secondary {
  color: #ffffff !important;
}
@media (max-width: 900px) {
  .sidebar {
    position: relative !important;
    width: auto;
  }
  .content {
    margin-left: 0;
    width: auto;
  }
}

/* ==========================================================
   V1.6 Mobile: Nur Smartphone-Ansicht, Desktop bleibt gleich
   ========================================================== */
.mobile-topbar,
.mobile-overlay {
  display: none;
}

@media (max-width: 760px) {
  :root {
    --radius: 14px;
  }

  html,
  body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    padding-top: 62px;
    background: var(--background-color);
  }

  .mobile-topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 10020;
    height: 62px;
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--sidebar-color);
    color: #fff;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .22);
  }

  .mobile-menu-button {
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 22px;
  }

  .mobile-title {
    display: grid;
    gap: 1px;
    min-width: 0;
  }

  .mobile-title strong {
    font-size: 16px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-title span {
    font-size: 12px;
    color: rgba(255,255,255,.72);
  }

  .mobile-overlay:not(.hidden) {
    position: fixed;
    inset: 0;
    z-index: 10005;
    display: block !important;
    background: rgba(15,23,42,.52);
  }

  .app {
    display: block;
    min-height: calc(100vh - 62px);
    height: auto;
    overflow: visible;
  }

  .sidebar {
    position: fixed !important;
    z-index: 10010;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 330px);
    height: 100vh;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform .22s ease;
    padding-top: 18px;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar .brand {
    margin-bottom: 14px;
  }

  .sidebar-nav,
  .sidebar-bottom {
    gap: 12px;
  }

  .sidebar-nav button,
  .sidebar-bottom button,
  button {
    min-height: 46px;
    padding: 12px 14px;
    border-radius: 12px;
  }

  .sidebar-search-box input,
  input,
  textarea,
  select {
    min-height: 46px;
    font-size: 16px; /* verhindert iOS-Zoom beim Fokussieren */
    border-radius: 12px;
  }

  .content {
    margin-left: 0;
    width: 100%;
    height: auto;
    overflow: visible;
    padding: 12px;
  }

  .panel {
    padding: 14px;
    border-radius: 16px;
    box-shadow: 0 8px 22px rgba(15,23,42,.06);
  }

  .dashboard-hero {
    display: block;
    padding: 18px;
    border-radius: 18px;
  }

  .dashboard-hero h2 {
    font-size: 24px;
    line-height: 1.18;
  }

  .dashboard-grid,
  .grid.two,
  .grid.three,
  .grid.four,
  .header {
    grid-template-columns: 1fr !important;
  }

  .header {
    display: grid;
    gap: 14px;
  }

  .vehicle-image {
    width: 100%;
    height: 210px;
    object-fit: cover;
    border-radius: 16px;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .section-title h3 {
    margin: 0;
  }

  .actions,
  .button-stack,
  .upload-line,
  .attachment-name-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .actions button,
  .button-stack button,
  .upload-line button,
  .attachment-name-row button,
  .btn-link {
    width: 100%;
    text-align: center;
  }

  .upload-line input:not([type="file"]) {
    min-width: 0;
    width: 100%;
  }

  .card {
    padding: 14px;
    border-radius: 16px;
    margin-top: 12px;
  }

  .table {
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  .table thead {
    display: none;
  }

  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    background: #fff;
    border: 1px solid #e4eaf3;
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 4px 14px rgba(15,23,42,.04);
  }

  .table td {
    border-bottom: 1px solid #eef2f7;
    padding: 8px 0;
  }

  .table td:last-child {
    border-bottom: 0;
  }

  .table td button,
  .table td .btn-link,
  .table td a.btn-link {
    margin-top: 6px;
  }

  .service-documents {
    min-width: 0;
  }

  .file-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 0;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 10px;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 90px);
    overflow: auto;
    border-radius: 18px;
  }

  .print-options-list label,
  .checkbox-row {
    min-height: 44px;
  }

  .login-card {
    margin: 40px auto;
    width: calc(100vw - 24px);
  }
}

@media (max-width: 420px) {
  .content {
    padding: 10px;
  }

  .panel,
  .card {
    padding: 12px;
  }

  .vehicle-image {
    height: 180px;
  }

  .dashboard-hero h2 {
    font-size: 22px;
  }
}

/* =========================================================
   V1.6 Mobile: Nur Smartphone-Ansicht wird angepasst
   Desktop/Tablet bleiben unverändert.
   ========================================================= */
.mobile-menu-button,
.mobile-sidebar-overlay {
  display: none;
}

@media (max-width: 760px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  .app {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .mobile-menu-button {
    display: grid;
    place-items: center;
    position: fixed;
    left: 12px;
    top: 12px;
    z-index: 10020;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 14px;
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .25);
    font-size: 22px;
    line-height: 1;
  }

  .mobile-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, .55);
  }

  .sidebar {
    position: fixed !important;
    z-index: 10010;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 330px);
    height: 100vh;
    padding: 18px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .brand {
    padding-left: 52px;
    min-height: 48px;
    align-items: center;
  }

  .brand strong {
    font-size: 17px;
  }

  .welcome-user {
    font-size: 12px;
  }

  .sidebar-search-box input {
    min-height: 48px;
    font-size: 16px;
  }

  .sidebar-nav button,
  .sidebar-bottom button,
  button {
    min-height: 46px;
    border-radius: 13px;
  }

  .content {
    margin-left: 0 !important;
    width: 100% !important;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 72px 12px 18px;
  }

  .panel {
    padding: 14px;
    border-radius: 18px;
    box-shadow: none;
  }

  .dashboard-hero {
    display: block;
    padding: 18px;
    border-radius: 18px;
  }

  .dashboard-hero h2 {
    font-size: 24px;
    line-height: 1.15;
  }

  .dashboard-hero p {
    font-size: 14px;
  }

  .dashboard-grid,
  .grid.two,
  .grid.three,
  .grid.four,
  .header {
    grid-template-columns: 1fr !important;
  }

  .card {
    padding: 13px;
    border-radius: 16px;
    margin-top: 12px;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .section-title h2,
  .section-title h3 {
    margin: 0;
  }

  .section-title button,
  .actions button,
  .button-stack button,
  .upload-line button {
    width: 100%;
  }

  input,
  textarea,
  select {
    min-height: 46px;
    font-size: 16px;
    border-radius: 13px;
  }

  textarea {
    min-height: 120px;
  }

  label {
    font-size: 13px;
  }

  .vehicle-image {
    width: 100%;
    height: auto;
    max-height: 240px;
    aspect-ratio: 16 / 10;
  }

  .actions,
  .button-stack,
  .upload-line,
  .attachment-name-row,
  .file-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
  }

  .upload-line input:not([type="file"]) {
    min-width: 0;
    width: 100%;
  }

  .btn-link,
  a.btn-link {
    width: 100%;
    text-align: center;
    min-height: 44px;
    display: grid;
    place-items: center;
  }

  /* Tabellen werden auf Handys zu lesbaren Karten */
  .table,
  .table thead,
  .table tbody,
  .table tr,
  .table th,
  .table td {
    display: block;
    width: 100%;
  }

  .table {
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  .table thead {
    display: none;
  }

  .table tr {
    border: 1px solid #e4eaf3;
    border-radius: 14px;
    background: #fff;
    padding: 10px;
    box-shadow: 0 5px 14px rgba(15, 23, 42, .05);
  }

  .table td {
    border: 0;
    padding: 7px 4px;
    word-break: break-word;
  }

  .table td button,
  .table td a.btn-link {
    margin-top: 4px;
  }

  .table td:empty {
    display: none;
  }

  .customer-email-editor .table tr {
    padding: 12px;
  }

  .stat-card strong {
    font-size: 28px;
  }

  .dashboard-list-item {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
  }

  .print-options-list label,
  .checkbox-row {
    min-height: 46px;
  }
}

/* =========================================================
   V1.6.4 Mobile Feinschliff
   - Menübutton liegt nicht mehr über der Schrift
   - Titel steht sauber rechts neben dem Menübutton
   - mobile Tabellen/Formularfelder kompakter
   ========================================================= */
@media (max-width: 760px) {
  body {
    padding-top: 58px !important;
  }

  .mobile-topbar {
    height: 58px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 12px !important;
  }

  .mobile-topbar .mobile-menu-button,
  #mobileMenuButton.mobile-menu-button {
    position: static !important;
    inset: auto !important;
    left: auto !important;
    top: auto !important;
    z-index: auto !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    background: rgba(255,255,255,.14) !important;
  }

  .mobile-title {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-align: left !important;
    padding-left: 2px !important;
  }

  .mobile-title strong {
    font-size: 15px !important;
    line-height: 1.1 !important;
  }

  .mobile-title span {
    font-size: 11px !important;
    line-height: 1.1 !important;
  }

  .content {
    padding-top: 68px !important;
  }

  .panel {
    padding: 10px !important;
    border-radius: 14px !important;
  }

  .card {
    padding: 10px !important;
    margin-top: 10px !important;
    border-radius: 14px !important;
  }

  input,
  textarea,
  select,
  .sidebar-search-box input {
    min-height: 38px !important;
    height: auto !important;
    font-size: 15px !important;
    padding: 8px 10px !important;
    border-radius: 10px !important;
  }

  input[type="date"],
  input[type="month"],
  input[type="number"] {
    min-height: 36px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }

  textarea {
    min-height: 90px !important;
  }

  label {
    font-size: 12px !important;
    gap: 4px !important;
  }

  button,
  .sidebar-nav button,
  .sidebar-bottom button,
  .section-title button,
  .actions button,
  .button-stack button,
  .upload-line button,
  .btn-link,
  a.btn-link {
    min-height: 38px !important;
    padding: 8px 10px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
  }

  .table {
    border-spacing: 0 7px !important;
  }

  .table tr {
    padding: 8px !important;
    border-radius: 12px !important;
  }

  .table td {
    padding: 4px 2px !important;
    font-size: 13px !important;
    line-height: 1.25 !important;
  }

  .table td button,
  .table td a.btn-link {
    margin-top: 3px !important;
  }

  .service-history,
  .service-list,
  .parts-list {
    gap: 8px !important;
  }

  .section-title {
    gap: 8px !important;
  }

  .section-title h2,
  .section-title h3,
  .card h3 {
    font-size: 17px !important;
    line-height: 1.2 !important;
  }
}

/* V1.6.5: Kilometer und Datum in Service-Tabellen sauber darstellen */
.table td.nowrap,
.table th.nowrap,
.service-date-cell,
.service-mileage-cell {
  white-space: nowrap;
}
.service-date-input,
.service-mileage-input {
  min-width: 8.5rem;
  max-width: 9.5rem;
}
.service-mileage-cell,
.service-mileage-input {
  text-align: right;
}
@media (max-width: 768px) {
  .service-date-input,
  .service-mileage-input {
    min-width: 100%;
    max-width: 100%;
  }
}


/* =========================================================
   V1.6.6 Mobile Loginfix
   - Mobile Topbar/Overlay sind vor dem Login komplett aus
   - Seitenmenü wird erst nach erfolgreichem Login aktiviert
   - verhindert, dass mobile Navigation den Login überdeckt
   ========================================================= */
@media (max-width: 760px) {
  body:not(.app-authenticated) {
    padding-top: 0 !important;
  }
  body:not(.app-authenticated) .mobile-topbar,
  body:not(.app-authenticated) #mobileTopbar,
  body:not(.app-authenticated) .mobile-overlay,
  body:not(.app-authenticated) #mobileOverlay {
    display: none !important;
    pointer-events: none !important;
  }
  body:not(.app-authenticated) .login-card {
    margin-top: 34px !important;
    position: relative;
    z-index: 1;
  }
  body.app-authenticated .mobile-topbar {
    display: flex !important;
  }
}


/* Design-Vorschau im Admin-Center */
.design-preview { margin-top: 14px; border: 1px solid #e4eaf3; border-radius: var(--radius); overflow: hidden; background: var(--background-color); }
.design-preview-shell { display: grid; grid-template-columns: 150px 1fr; min-height: 180px; }
.design-preview-sidebar { background: var(--sidebar-color); color: white; padding: 14px; display: grid; align-content: start; gap: 10px; }
.design-preview-nav { background: color-mix(in srgb, var(--sidebar-color) 70%, white); padding: 8px; border-radius: 10px; }
.design-preview-content { padding: 14px; color: var(--text-color); }
.design-preview-card { background: var(--panel-color); border-radius: var(--radius); padding: 14px; box-shadow: 0 8px 24px #0000000d; }
.design-preview-accent { height: 8px; width: 80px; border-radius: 20px; background: var(--accent-color); margin: 10px 0; }
.design-preview-button { display: inline-block; background: var(--button-color); color: white; border-radius: 10px; padding: 8px 12px; margin-top: 8px; }
body[data-card-shadow="none"] .design-preview-card { box-shadow: none; }
body[data-card-shadow="strong"] .design-preview-card { box-shadow: 0 18px 45px #00000024; }

/* V1.8.1: Ruhige Seitenwechsel-Animationen ohne Bearbeiten-Animation */
:root {
  --page-transition-duration: 340ms;
  --page-transition-distance: 18px;
  --page-transition-scale: .985;
  --motion-easing: cubic-bezier(.2, .8, .2, 1);
}

@keyframes wmPageEnter {
  from {
    opacity: 0;
    transform: translateY(var(--page-transition-distance)) scale(var(--page-transition-scale));
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes wmContentSoftSwap {
  0% {
    opacity: .55;
    transform: translateY(8px) scale(.995);
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes wmCardStagger {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wmNavClickNudge {
  0% { transform: translateX(0); }
  45% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

/* Animationen laufen nur noch während eines echten Seitenwechsels.
   Dadurch starten Karten/aktive Menüpunkte nicht bei jedem Re-Render erneut. */
.content.page-switching .panel:not(.hidden) {
  animation: wmPageEnter var(--page-transition-duration) var(--motion-easing) both;
  transform-origin: top center;
}

.panel.page-refreshed {
  animation: wmContentSoftSwap 240ms var(--motion-easing) both;
}

.content.page-switching .panel:not(.hidden) > .card,
.content.page-switching .panel:not(.hidden) .dashboard-hero,
.content.page-switching .panel:not(.hidden) .dashboard-grid > *,
.content.page-switching .panel:not(.hidden) .header,
.content.page-switching .panel:not(.hidden) table,
.content.page-switching .panel:not(.hidden) .notice {
  animation: wmCardStagger 320ms var(--motion-easing) both;
}

.content.page-switching .panel:not(.hidden) > .card:nth-of-type(1),
.content.page-switching .panel:not(.hidden) .dashboard-grid > *:nth-child(1) { animation-delay: 30ms; }
.content.page-switching .panel:not(.hidden) > .card:nth-of-type(2),
.content.page-switching .panel:not(.hidden) .dashboard-grid > *:nth-child(2) { animation-delay: 55ms; }
.content.page-switching .panel:not(.hidden) > .card:nth-of-type(3),
.content.page-switching .panel:not(.hidden) .dashboard-grid > *:nth-child(3) { animation-delay: 80ms; }
.content.page-switching .panel:not(.hidden) > .card:nth-of-type(4),
.content.page-switching .panel:not(.hidden) .dashboard-grid > *:nth-child(4) { animation-delay: 105ms; }
.content.page-switching .panel:not(.hidden) > .card:nth-of-type(n+5) { animation-delay: 130ms; }

.sidebar-nav button,
.sidebar-bottom button,
.vehicle-card,
.card,
.panel,
button,
input,
textarea,
select {
  transition:
    transform 180ms var(--motion-easing),
    box-shadow 180ms var(--motion-easing),
    background-color 180ms var(--motion-easing),
    border-color 180ms var(--motion-easing),
    color 180ms var(--motion-easing),
    opacity 180ms var(--motion-easing);
}

button:hover:not(:disabled),
.vehicle-card:hover,
.card:hover {
  transform: translateY(-1px);
}

button:active:not(:disabled),
.vehicle-card:active {
  transform: translateY(0) scale(.985);
}

.sidebar-nav button.nav-clicked,
.sidebar-bottom button.nav-clicked {
  animation: wmNavClickNudge 180ms var(--motion-easing);
}

input:focus,
textarea:focus,
select:focus {
  outline: 0;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 18%, transparent);
}

.modal-backdrop {
  animation: wmModalFade 140ms ease-out both;
}
.modal-card {
  animation: none;
}

@keyframes wmModalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Bearbeiten-Buttons/Formularaktionen bleiben bewusst ruhig. */
button[id*='edit' i],
button[id*='save' i],
button[id*='cancel' i],
button[data-action*='edit'],
button[data-action*='save'],
button[data-action*='cancel'] {
  transition: background-color 160ms var(--motion-easing), border-color 160ms var(--motion-easing), color 160ms var(--motion-easing), opacity 160ms var(--motion-easing);
}

button[id*='edit' i]:hover:not(:disabled),
button[id*='save' i]:hover:not(:disabled),
button[id*='cancel' i]:hover:not(:disabled),
button[data-action*='edit']:hover:not(:disabled),
button[data-action*='save']:hover:not(:disabled),
button[data-action*='cancel']:hover:not(:disabled),
button[id*='edit' i]:active:not(:disabled),
button[id*='save' i]:active:not(:disabled),
button[id*='cancel' i]:active:not(:disabled),
button[data-action*='edit']:active:not(:disabled),
button[data-action*='save']:active:not(:disabled),
button[data-action*='cancel']:active:not(:disabled) {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}


/* v1.8.8: Stammdaten/Zusätzliche Informationen wieder im ursprünglichen Layout. */
.description-cell {
  min-width: 280px;
  width: 34%;
}
.inline-description {
  min-height: calc(1.35em * 3 + 22px);
  height: auto;
  resize: vertical;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-y: auto;
  scrollbar-width: thin;
}
.inline-description[readonly] {
  cursor: text;
  overflow-y: auto;
  background: color-mix(in srgb, var(--input-background) 94%, var(--background-color));
}
.service-description,
#newServiceDescription,
.service-new-description textarea {
  height: calc(1.35em * 3 + 22px) !important;
  min-height: calc(1.35em * 3 + 22px);
  max-height: calc(1.35em * 3 + 22px);
  resize: none;
  line-height: 1.35;
  overflow-y: auto !important;
  scrollbar-width: thin;
}
/* Servicebeschreibung bleibt 3 Zeilen hoch; ab Zeile 4 wird gescrollt. */
textarea.autogrow-textarea {
  overflow-y: auto !important;
}
.table td.description-cell {
  padding-top: 6px;
  padding-bottom: 6px;
}
@media (max-width: 900px) {
  .description-cell {
    min-width: 220px;
    width: auto;
  }
}


/* v1.8.9: Ausgewähltes Fahrzeug kompakt in der Seitenleiste */
.selected-vehicle-sidebar {
  margin-top: 2px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: inset 4px 0 0 var(--primary-color);
  display: grid;
  gap: 4px;
}
.selected-vehicle-sidebar-label {
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.62);
  font-weight: 800;
}
.selected-vehicle-sidebar strong {
  font-size: 18px;
  line-height: 1.15;
  color: #fff;
}
.selected-vehicle-sidebar span {
  font-size: 13px;
  line-height: 1.35;
  color: rgba(255,255,255,.82);
  overflow-wrap: anywhere;
}
