/* kar.re 2 – Komponenten (7.5): Buttons, Chips, Karten, Felder, Toasts, Dialoge, Sheet, Dropzone,
   Plakette, Kacheln, Quelle-Chips, KI-Nachricht, Problem-Karte, Notiz, Schein-Feld, Wizard-Schritte,
   TÜV-Warnkarte, Job-Status, Tabellen, Menüs, Flash. */

/* ------------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  max-width: 100%;
  overflow-wrap: normal;      /* body bricht überall um – Knöpfe nur zwischen Wörtern */
  transition: background-color var(--dauer) var(--ease), border-color var(--dauer) var(--ease), color var(--dauer) var(--ease);
}

/* Knopf mit Kostenhinweis (<small>): darf zweizeilig werden – Hinweis rutscht unter den Text, statt eine dritte
   schmale Spalte zu bilden („Typische Probleme suchen (ca. 26–50 ct)“ bei 360–412 px) */
.btn:has(> small) {
  flex-wrap: wrap;
  row-gap: 0;
  padding-block: 6px;
}

.btn > small {
  font-weight: 400;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.btn:active {
  transform: translateY(1px);
}

.btn .icon {
  width: 20px;
  height: 20px;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--brand) 88%, #000);
  border-color: color-mix(in srgb, var(--brand) 88%, #000);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-ki {
  background: var(--ki-soft);
  border-color: transparent;
  color: var(--ki);
}

.btn-ki:hover {
  background: var(--ki);
  color: #0b1430;
}

.btn-icon {
  min-width: var(--tap);
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: transparent;
}

.btn-pill {
  border-radius: var(--radius-pill);
}

.btn-klein {
  min-height: 34px;
  padding: 0 12px;
  font-size: var(--fs-0);
}

.btn-breit {
  width: 100%;
}

.btn[aria-busy="true"] {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: var(--text-2) transparent var(--text-2) transparent;
  animation: drehen .8s linear infinite;
}

.btn-primary[aria-busy="true"]::after {
  border-color: var(--brand-ink) transparent var(--brand-ink) transparent;
}

@keyframes drehen {
  to { transform: rotate(360deg); }
}

.knopfgruppe {
  display: inline-flex;
  gap: var(--s-1);
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-0);
  font-weight: 500;
  line-height: 1.15;
  max-width: 100%;
  overflow-wrap: normal;      /* nur zwischen Wörtern umbrechen, kurze Chips bleiben einzeilig */
  vertical-align: middle;
}

.chip .icon {
  width: 15px;
  height: 15px;
}

.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-ki { background: var(--ki-soft); color: var(--ki); }
.chip-brand { background: var(--brand-soft); color: var(--brand); }
.chip-umriss { background: transparent; border: 1px solid var(--border-strong); }
.chip-zaehler { min-width: 26px; justify-content: center; padding: 0 8px; font-family: var(--mono); }

.chip-liste {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* Quelle-Chip (hand / schein / KI) */
.quelle-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: .75rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-3);
}

.quelle-chip[data-quelle="schein"] { background: var(--brand-soft); color: var(--brand); }
.quelle-chip[data-quelle="ki"] { background: var(--ki-soft); color: var(--ki); }
.quelle-chip[data-status="vorgeschlagen"] { outline: 1px dashed var(--ki); outline-offset: -1px; }

/* ------------------------------------------------------------------ Karten */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
  min-width: 0;
}

.card > h2:first-child, .card > h3:first-child {
  margin-top: 0;
}

.card-kopf {
  display: flex;
  flex-wrap: wrap;            /* Titel und Zusatz (Status, Hilfe) untereinander, wenn es eng wird */
  align-items: center;
  justify-content: space-between;
  gap: var(--s-1) var(--s-3);
  margin-bottom: var(--s-3);
}

.card-kopf h2, .card-kopf h3 {
  margin: 0;
  overflow-wrap: normal;      /* Überschriften nicht mitten im Wort trennen („Einträ-ge“) */
}

.card-aktionen {
  display: flex;
  gap: var(--s-1);
  flex-wrap: wrap;
}

.card-ki {
  border-color: color-mix(in srgb, var(--ki) 35%, var(--border));
}

@media (min-width: 600px) {
  .card { padding: var(--s-5); }
}

/* ------------------------------------------------------------------ Kachel (Fuhrpark) */
.kachel {
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  overflow: hidden;
  color: var(--text);
  transition: border-color var(--dauer) var(--ease);
}

.kachel:hover {
  text-decoration: none;
  border-color: var(--border-strong);
}

.kachel-bild {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  overflow: hidden;
}

.kachel-bild img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kachel-bild .plakette {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5));
}

@media (min-width: 600px) {
  .kachel-bild .plakette { width: 56px; height: 56px; }
}

.kachel-chips {
  position: absolute;
  left: 8px;
  top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.kachel-chips .chip {
  backdrop-filter: blur(6px);
  background: color-mix(in srgb, var(--surface-1) 80%, transparent);
}

/* Signalfarben auf dem Kachelbild unabhängig vom Theme (hell: --warn ist dunkelbraun → dunkle Schrift auf Braun, Kontrast 2,5) */
.kachel-chips .chip-danger { background: #b3261e; color: #fff; }
.kachel-chips .chip-warn { background: #ffb400; color: #1a1a1a; }

.kachel-text {
  padding: 10px 12px 12px;
}

.kachel-name {
  font-size: var(--fs-1);
  font-weight: 600;
  margin: 0;
}

.kachel-unterzeile {
  color: var(--text-2);
  font-size: var(--fs-0);
  margin: 2px 0 0;
}

/* ------------------------------------------------------------------ Plakette */
.plakette {
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 50%;
}

.plakette-96 { width: 96px; height: 96px; }
.plakette-mini { width: 22px; height: 22px; }

/* ------------------------------------------------------------------ Felder */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--s-4);
  min-width: 0;
}

.field > label {
  display: flex;
  justify-content: space-between;
  gap: var(--s-2);
}

/* Auswahl-Karte direkt im Feld bleibt Raster (Kästchen | Titel, darunter <small>) – sonst Flex mit drei Spalten */
.field > .wahl {
  display: grid;
  justify-content: normal;
  gap: 4px 12px;
}

/* <label> umschließt das Eingabeelement (Editor, Probleme-Box): Text oben, Eingabe volle Breite darunter,
   Pflicht-Stern rechts oben – statt Text und Feld nebeneinander (brach auf dem Handy mitten im Wort um).
   Nicht für Auswahl-Karten (.wahl) und Haken/Radios: dort steht das Kästchen links neben dem Text – sonst landet
   <small> in der auto-Spalte und quetscht den Labeltext auf 0 px (senkrechte Buchstaben, Profil 0.7.1). */
.field > label:not(.wahl, .wahl-inline):has(> input:not([type=checkbox], [type=radio]), > select, > textarea, > .input-suffix) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px var(--s-2);
}

.field > label:not(.wahl, .wahl-inline) > :is(input:not([type=checkbox], [type=radio]), select, textarea, .input-suffix) {
  grid-column: 1 / -1;
  grid-row: 2;
}

.field > label:not(.wahl, .wahl-inline):has(> input:not([type=checkbox], [type=radio]), > select, > textarea, > .input-suffix)::after {
  grid-row: 1;
  grid-column: 2;
}

.field .hilfe {
  margin: 0;
}

.field .fehlertext {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--danger);
  font-size: var(--fs-0);
  margin: 0;
}

.field.ungueltig input,
.field.ungueltig textarea,
.field.ungueltig select,
input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-zeile {
  flex-direction: row;
  align-items: center;
  gap: var(--s-3);
}

.field-zeile label {
  color: var(--text);
  font-weight: 400;
  font-size: var(--fs-1);
}

.field-pflicht::after {
  content: " *";
  color: var(--brand);
}

/* Eingabe mit Suffix („km“, „Nm“, „kW“) */
.input-suffix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-suffix input {
  padding-right: 52px;
}

.input-suffix > span {
  position: absolute;
  right: 12px;
  color: var(--text-3);
  font-size: var(--fs-0);
  pointer-events: none;
  font-family: var(--mono);
}

/* Radio-/Checkbox-Karten mit Erklärzeile */
.wahl-liste {
  display: grid;
  gap: var(--s-2);
}

.wahl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  cursor: pointer;
  color: var(--text);
  font-size: var(--fs-1);
  font-weight: 500;
}

.wahl:hover {
  border-color: var(--border-strong);
}

.wahl:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.wahl:has(input:disabled) {
  opacity: .55;
  cursor: not-allowed;
}

.wahl small {
  grid-column: 2;
  color: var(--text-2);
  font-weight: 400;
}

/* Passwortstärke */
.passwort-staerke {
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

.passwort-staerke::-webkit-meter-bar { background: var(--surface-3); border: 0; border-radius: var(--radius-pill); }
.passwort-staerke::-webkit-meter-optimum-value { background: var(--ok); border-radius: var(--radius-pill); }
.passwort-staerke::-webkit-meter-suboptimum-value { background: var(--warn); border-radius: var(--radius-pill); }
.passwort-staerke::-webkit-meter-even-less-good-value { background: var(--danger); border-radius: var(--radius-pill); }
.passwort-staerke::-moz-meter-bar { background: var(--ok); border-radius: var(--radius-pill); }

/* ------------------------------------------------------------------ Definitionsliste / Tabelle */
.dl {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr;
  gap: 6px var(--s-4);
  font-size: var(--fs-1);
}

.dl dt {
  color: var(--text-2);
  font-size: var(--fs-0);
  font-weight: 500;
  padding-top: 2px;
}

.dl dd {
  margin: 0;
  min-width: 0;
}

.dl dd.highlight, .highlight {
  color: var(--brand);
  font-weight: 600;
}

@media (min-width: 600px) {
  .dl-zweispaltig { grid-template-columns: repeat(2, minmax(120px, 1fr) 2fr); }
}

.tabelle {
  width: 100%;
  font-size: var(--fs-1);
}

.tabelle th, .tabelle td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: break-word;  /* Spalten nicht unter Wortbreite quetschen („ad-min_t“); breite Tabellen scrollen im .tabelle-wrap */
}

.tabelle th {
  color: var(--text-2);
  font-size: var(--fs-0);
  font-weight: 600;
}

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

.tabelle td.zahl, .tabelle th.zahl {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tabelle-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Horizontale Scroll-Container enthalten ihre absolut positionierten Kinder (.sr-only in Tabellenköpfen):
   sonst ragen diese über den Rand und verbreitern auf dem Handy das ganze Layout (Integration 0.7.0). */
.tabelle-wrap, .matrix-wrap, .tabelle-scroll, .admin-nav, .wizard-schritte {
  position: relative;
}

/* ------------------------------------------------------------------ Flash / Hinweiskarten */
.flashs {
  display: grid;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}

.flash {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  margin-bottom: var(--s-3);
}

.flash .icon {
  margin-top: 2px;
}

.flash-ok { background: var(--ok-soft); border-color: transparent; }
.flash-ok .icon { color: var(--ok); }
.flash-info { background: var(--ki-soft); border-color: transparent; }
.flash-info .icon { color: var(--ki); }
.flash-warn { background: var(--warn-soft); border-color: transparent; }
.flash-warn .icon { color: var(--warn); }
.flash-fehler { background: var(--danger-soft); border-color: transparent; }
.flash-fehler .icon { color: var(--danger); }

/* ------------------------------------------------------------------ Toasts */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s-3));
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: min(92vw, 420px);
  pointer-events: none;
}

@media (min-width: 900px) {
  .toasts { bottom: var(--s-5); }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  animation: toast-rein var(--dauer) var(--ease);
}

.toast .icon { margin-top: 2px; flex: 0 0 auto; }
.toast-ok .icon { color: var(--ok); }
.toast-fehler .icon { color: var(--danger); }
.toast-warn .icon { color: var(--warn); }
.toast-info .icon { color: var(--ki); }

.toast-text {
  flex: 1 1 auto;
}

.toast-schliessen {
  min-width: 32px;
  min-height: 32px;
  color: var(--text-2);
  border-radius: var(--radius-s);
}

.toast.geht {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dauer) var(--ease), transform var(--dauer) var(--ease);
}

@keyframes toast-rein {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ Dialog */
.dialog {
  width: min(92vw, 520px);
  max-height: 85vh;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  background: var(--surface-1);
  color: var(--text);
  box-shadow: var(--shadow-2);
}

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

.dialog-inhalt {
  padding: var(--s-5);
  overflow: auto;
  max-height: 85vh;
}

.dialog h2 {
  margin-top: 0;
}

.dialog-aktionen {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-5);
}

@media (max-width: 599.98px) {
  .dialog-aktionen > .btn { flex: 1 1 100%; }
}

.dialog-gross {
  width: min(96vw, 1100px);
}

/* Lightbox (Galerie) */
.lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, .94);
  padding: 0;
}

.lightbox::backdrop {
  background: transparent;
}

/* ------------------------------------------------------------------ Sheet (Handy, 85 vh) */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: none;
  max-height: 85vh;
  margin: 0;
  padding: 8px var(--gutter) calc(var(--s-4) + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  background: var(--surface-1);
  box-shadow: var(--shadow-2);
  overflow: auto;
  touch-action: pan-y;
}

.sheet::backdrop {
  background: rgba(0, 0, 0, .55);
}

.sheet[open] {
  animation: sheet-rein var(--dauer) var(--ease);
}

.sheet.geht {
  transform: translateY(100%);
  transition: transform var(--dauer) var(--ease);
}

@keyframes sheet-rein {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: none; opacity: 1; }
}

.sheet-griff {
  width: 44px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  margin: 0 auto var(--s-3);
}

.sheet-titel {
  font-size: var(--fs-2);
  margin-bottom: var(--s-3);
}

.sheet-liste {
  display: flex;
  flex-direction: column;
}

.sheet-liste a, .sheet-knopf {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 var(--s-2);
  color: var(--text);
  border-radius: var(--radius-m);
  width: 100%;
  text-align: left;
  font-weight: 500;
}

.sheet-liste a:hover, .sheet-knopf:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.sheet-liste .icon {
  color: var(--text-2);
}

.sheet-schliessen {
  width: 100%;
  margin-top: var(--s-3);
}

@media (min-width: 900px) {
  .sheet {
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 420px);
    border-radius: var(--radius-l);
    border-bottom: 1px solid var(--border-strong);
    padding: var(--s-5);
  }
  .sheet.geht { transform: translate(-50%, -50%); opacity: 0; transition: opacity var(--dauer) var(--ease); }
  .sheet-griff { display: none; }
}

/* ------------------------------------------------------------------ Menü (Konto) */
.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: .85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: normal;
  user-select: none;
}

.konto-menu > summary {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.konto-menu > summary .avatar {
  pointer-events: none;
}

.menu-liste {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 240px;
  padding: var(--s-2);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-2);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.menu-kopf {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-1);
}

.menu-kopf small {
  display: block;
  color: var(--text-3);
}

.menu-logo {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.menu-liste a, .menu-knopf {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-m);
  color: var(--text);
  font-weight: 500;
  width: 100%;
  text-align: left;
}

.menu-liste a:hover, .menu-knopf:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.menu-liste .icon {
  color: var(--text-2);
}

.menu-form {
  border-top: 1px solid var(--border);
  margin-top: var(--s-1);
  padding-top: var(--s-1);
}

/* ------------------------------------------------------------------ Dropzone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 140px;
  padding: var(--s-5);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-l);
  background: var(--surface-2);
  color: var(--text-2);
  text-align: center;
  transition: border-color var(--dauer) var(--ease), background-color var(--dauer) var(--ease);
}

.dropzone.aktiv, .dropzone:focus-within {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--text);
}

/* nur das große Upload-Symbol – nicht die Symbole in den Knöpfen „Foto aufnehmen“/„Dateien wählen“ (waren 32 px und grau) */
.dropzone > .icon {
  width: 32px;
  height: 32px;
  color: var(--text-3);
}

.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

/* Auswahl-Karte in der zentrierten Dropzone: Haken links, Text linksbündig daneben */
.dropzone .wahl {
  text-align: left;
}

.dropzone-knoepfe {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-2);
}

/* Bilder-Raster im Editor/Fahrzeugseite */
.bilder-raster {
  display: grid;
  gap: var(--s-2);
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.bild-kachel {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.bild-kachel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bild-kachel .badges {
  position: absolute;
  left: 6px;
  top: 6px;
  display: flex;
  gap: 4px;
}

.bild-kachel .aktionen {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  padding: 4px;
  background: linear-gradient(to top, rgba(0, 0, 0, .7), transparent);
}

.bild-kachel .aktionen .btn-icon {
  min-width: 36px;
  min-height: 36px;
  color: #fff;
}

/* ------------------------------------------------------------------ TÜV-Warnkarte */
.tuev-warnkarte {
  border-radius: var(--radius-l);
  padding: var(--s-3) var(--s-4);
  background: var(--warn-soft);
  border: 1px solid transparent;
  margin-bottom: var(--s-4);
}

.tuev-warnkarte.faellig {
  background: var(--danger-soft);
}

.tuev-warnkarte h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-1);
  margin-bottom: var(--s-2);
}

.tuev-warnkarte ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}

.tuev-warnkarte li a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: var(--text);
}

.tuev-warnkarte li .plakette {
  width: 22px;
  height: 22px;
}

.tuev-warnkarte .wann {
  margin-left: auto;
  color: var(--text-2);
  font-size: var(--fs-0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ Kategorien (details) */
.kategorie > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: var(--s-2) 0;
  font-size: var(--fs-2);
  font-weight: 700;
}

.kategorie > summary .chip {
  margin-left: 2px;
}

.kategorie > summary .pfeil {
  margin-left: auto;
  color: var(--text-3);
  transition: transform var(--dauer) var(--ease);
}

.kategorie[open] > summary .pfeil {
  transform: rotate(180deg);
}

/* ------------------------------------------------------------------ Checkheft-Timeline */
.timeline {
  list-style: none;
  padding: 0 0 0 22px;
  margin: 0;
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--brand);
  opacity: .7;
}

.timeline > li {
  position: relative;
  padding-bottom: var(--s-4);
}

.timeline > li::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--bg);
}

.timeline-kopf {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
}

.timeline-kopf strong {
  font-size: var(--fs-1);
}

.timeline-kopf .meta {
  color: var(--text-2);
  font-size: var(--fs-0);
  font-family: var(--mono);
}

/* ------------------------------------------------------------------ Problem-Karte */
.problem-karte {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface-1);
}

.problem-karte .schwere {
  grid-row: span 3;
  color: var(--text-3);
}

.problem-karte[data-schweregrad="achtung"] .schwere { color: var(--warn); }
.problem-karte[data-schweregrad="kritisch"] .schwere { color: var(--danger); }
.problem-karte[data-status="vorgeschlagen"] { border-style: dashed; border-color: var(--ki); }
.problem-karte[data-status="erledigt"] { opacity: .7; }

.problem-karte h3 {
  margin: 0;
}

.problem-karte .beschreibung {
  color: var(--text-2);
  margin: 0;
}

.problem-karte .meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  align-items: center;
}

/* ------------------------------------------------------------------ Notiz */
.notiz {
  position: relative;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface-1);
}

.notiz[data-angepinnt="1"] {
  border-color: color-mix(in srgb, var(--brand) 50%, var(--border));
}

.notiz-kopf {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: var(--fs-0);
  margin-bottom: 6px;
}

.notiz-kopf .icon { width: 16px; height: 16px; }
.notiz-kopf .aktionen { margin-left: auto; display: flex; gap: 2px; }

/* Kein pre-wrap am Container: der Text kommt als gerendertes HTML (notiz_render) bzw. in der Textarea –
   pre-wrap machte die Template-Einrückung zu Leerzeilen (Integration 0.7.0). */
.notiz-text textarea {
  background: transparent;
  border-color: transparent;
  padding: 0;
  min-height: 60px;
}

.notiz-text textarea:focus {
  border-color: var(--focus);
  padding: 8px;
}

.notiz[data-privat="1"] .notiz-kopf .icon-privat { color: var(--warn); }

/* ------------------------------------------------------------------ Schein-Feld */
.schein-feld {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.schein-feld:last-child {
  border-bottom: 0;
}

.schein-code {
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-2);
  padding: 2px 6px;
  border-radius: var(--radius-s);
  min-width: 34px;
  text-align: center;
}

.schein-label {
  font-size: var(--fs-0);
  color: var(--text-2);
  grid-column: 2;
}

.schein-wert {
  grid-column: 2;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-1);
}

.schein-feld.unsicher .schein-wert {
  border-bottom: 1px dashed var(--warn);
  display: inline-block;
}

.schein-feld.unsicher .schein-label::after {
  content: " · KI unsicher – prüfen";
  color: var(--warn);
}

.schein-kopieren {
  grid-column: 3;
  grid-row: 1 / span 2;
}

.schein-kopieren.kopiert {
  color: var(--ok);
}

/* ------------------------------------------------------------------ KI-Nachricht */
.ki-nachricht {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius-l);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.ki-nachricht[data-rolle="user"] {
  background: var(--surface-3);
  margin-left: var(--s-6);
}

.ki-nachricht[data-rolle="assistant"] {
  background: var(--ki-soft);
  border: 1px solid color-mix(in srgb, var(--ki) 30%, transparent);
}

.ki-nachricht .kurzantwort {
  font-size: var(--fs-2);
  font-weight: 600;
  margin-bottom: var(--s-2);
}

.ki-nachricht .ki-text p:last-child { margin-bottom: 0; }
.ki-nachricht .ki-text ul { margin-bottom: var(--s-2); }

.ki-nachricht .ki-text table { font-size: var(--fs-0); margin-bottom: var(--s-3); }
.ki-nachricht .ki-text th, .ki-nachricht .ki-text td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }

.ki-nachricht sup a {
  color: var(--ki);
  font-weight: 600;
  padding: 0 2px;
}

.ki-quellen {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid color-mix(in srgb, var(--ki) 30%, transparent);
  font-size: var(--fs-0);
}

.ki-quellen ol {
  margin: var(--s-1) 0 0;
  padding-left: 1.4em;
}

.ki-quellen a {
  color: var(--ki);
}

.ki-quellen .domain {
  color: var(--text-3);
}

.ki-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  align-items: center;
  margin-top: var(--s-3);
  color: var(--text-3);
  font-size: .78rem;
}

.ki-hinweis {
  color: var(--text-3);
  font-size: .78rem;
  margin-top: var(--s-2);
}

.ki-werte {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.ki-wert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-m);
  background: var(--surface-1);
  border: 1px solid var(--border);
}

.ki-wert .wert {
  font-family: var(--mono);
  font-weight: 600;
}

.ki-wert .btn {
  margin-left: auto;
}

.ki-vorschlaege {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.ki-vorschlaege .chip {
  min-height: 34px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.ki-vorschlaege .chip:hover {
  border-color: var(--ki);
}

.ki-eingabe {
  display: flex;
  gap: var(--s-2);
  align-items: flex-end;
  position: sticky;
  bottom: 0;
  background: var(--surface-1);
  padding-top: var(--s-2);
}

/* Handy: klebt oberhalb der Tab-Leiste (im Bottom-Sheet gilt wieder bottom: 0, ki.css .ki-sheet .ki-eingabe) */
@media (max-width: 899.98px) {
  .ki-eingabe { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
}

.ki-eingabe textarea {
  min-height: var(--tap);
  max-height: 160px;
}

/* Zuverlässigkeit */
.zuverlaessigkeit[data-wert="hoch"] { color: var(--ok); }
.zuverlaessigkeit[data-wert="mittel"] { color: var(--warn); }
.zuverlaessigkeit[data-wert="niedrig"] { color: var(--danger); }

/* ------------------------------------------------------------------ Job-Status (Polling) */
.job-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-0);
}

.job-status .spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--ki);
  border-right-color: transparent;
  animation: drehen .8s linear infinite;
}

.job-status[data-status="fertig"] { color: var(--ok); }
.job-status[data-status="fertig"] .spinner { display: none; }
.job-status[data-status="fehler"] { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.job-status[data-status="fehler"] .spinner { display: none; }
.job-status[data-status="abgebrochen"] .spinner { display: none; }

.job-status .abbrechen {
  margin-left: auto;
}

/* Fortschrittsbalken (Budget, Upload) */
.balken {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.balken > span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: var(--radius-pill);
  transition: width var(--dauer) var(--ease);
}

.balken.warn > span { background: var(--warn); }
.balken.danger > span { background: var(--danger); }

/* ------------------------------------------------------------------ Wizard-Schritte */
.wizard-schritte {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s-5);
  overflow-x: auto;
  scrollbar-width: none;
}

.wizard-schritte::-webkit-scrollbar { display: none; }

.wizard-schritte li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--text-3);
  font-size: var(--fs-0);
  font-weight: 500;
}

.wizard-schritte .nr {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  color: var(--text-2);
  font-family: var(--mono);
  font-weight: 700;
  font-size: .8rem;
}

.wizard-schritte li[aria-current="step"] {
  color: var(--text);
}

.wizard-schritte li[aria-current="step"] .nr {
  background: var(--brand);
  color: var(--brand-ink);
}

.wizard-schritte li.fertig .nr {
  background: var(--ok-soft);
  color: var(--ok);
}

.wizard-schritte li::after {
  content: "";
  width: 16px;
  height: 1px;
  background: var(--border-strong);
}

.wizard-schritte li:last-child::after {
  display: none;
}

@media (max-width: 599.98px) {
  .wizard-schritte li:not([aria-current="step"]) .titel { display: none; }

  /* kürzere Verbinder, damit ab Schritt 6 der Titel des aktuellen Schritts nicht rechts abgeschnitten wird */
  .wizard-schritte { gap: 4px; }
  .wizard-schritte li { gap: 4px; }
  .wizard-schritte li::after { width: 8px; }
}

/* Auswahlkarten (Wizard Schritt 1) */
.auswahl-karten {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .auswahl-karten { grid-template-columns: repeat(3, 1fr); }
}

.auswahl-karte {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface-1);
  color: var(--text);
  text-align: left;
  min-height: 120px;
}

.auswahl-karte:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}

.auswahl-karte.empfohlen {
  border-color: var(--brand);
}

.auswahl-karte .icon {
  width: 28px;
  height: 28px;
  color: var(--brand);
}

.auswahl-karte small {
  color: var(--text-2);
}

/* Autosave-Status */
.speicher-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: var(--fs-0);
  white-space: nowrap;
}

.speicher-status[data-status="gespeichert"] { color: var(--ok); }
.speicher-status[data-status="fehler"] { color: var(--danger); }
.speicher-status[data-status="konflikt"] { color: var(--warn); }

/* Suche */
.suche-feld-gross {
  display: flex;
  gap: var(--s-2);
}

.suche-feld-gross input {
  border-radius: var(--radius-pill);
  padding-left: 18px;
}

.suche-treffer {
  display: grid;
  gap: var(--s-2);
}

.suche-treffer .treffer-zeilen {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  color: var(--text-2);
  font-size: var(--fs-0);
}

/* Drag & Drop (Sortieren) */
.drag-griff {
  cursor: grab;
  touch-action: none;
  color: var(--text-3);
}

.drag-platzhalter {
  border: 2px dashed var(--brand);
  border-radius: var(--radius-l);
  background: var(--brand-soft);
}

.drag-aktiv {
  opacity: .6;
}

/* Initialen-Kreis Kundenliste */
.initialen {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* Kopieren-Feedback */
.kopiert-haken {
  color: var(--ok);
}

/* ------------------------------------------------------------------ Tap-Ziele ≥ 44 px (7.4) auf Handy/Touch */
@media (max-width: 899.98px), (pointer: coarse) {
  .btn-klein {
    min-height: var(--tap);
  }

  .btn-icon.btn-klein,
  .bild-kachel .aktionen .btn-icon {
    min-width: var(--tap);
    min-height: var(--tap);
  }

  .wahl,
  .wahl-inline {
    min-height: var(--tap);
  }

  details > summary {
    min-height: var(--tap);
  }

  .menu-liste a,
  .menu-knopf {
    min-height: var(--tap);
  }
}

/* reduced-motion (7.4): Spinner stehen still (Status bleibt über aria-busy/Text erkennbar) */
@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy="true"]::after,
  .job-status .spinner {
    animation: none;
  }
}

/* ------------------------------------------------------------------ Hinweis „Neue Version“ (app.js) */
.version-hinweis {
  position: fixed;
  left: 50%;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + var(--s-2));
  transform: translateX(-50%);
  z-index: 310;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(94vw, 480px);
  padding: 10px 10px 10px 14px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--brand);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  animation: toast-rein var(--dauer) var(--ease);
}
.version-hinweis .icon { color: var(--brand); flex: 0 0 auto; }
.version-hinweis .version-text { flex: 1 1 auto; min-width: 0; }
.version-hinweis .version-laden { flex: 0 0 auto; min-height: 44px; }
