/* ==========================================================================
   Reifendaten – gemeinsames Stylesheet aller Seiten

    1  Variablen (Farben, Radien, Abstände)
    2  Grundstil
    3  App-Rahmen: Kopfzeile, Navigation, Handy-Leiste, „Mehr“-Menü, Seitenkopf
    4  Schaltflächen
    5  Formulare (Felder, Auswahl-Leisten, Kontrollkästchen, Foto-Upload)
    6  Karten, Abschnitte, Akkordeon
    7  Abzeichen und Lagerort-Chip
    8  Meldungen, Einblendungen (Toasts), Hinweisboxen
    9  Tabellen
   10  Dialoge
   11  Leer- und Ladezustand
   12  Seiten: Dashboard · Erfassen · Detailseite · Scanner · Einstellungen ·
       Benutzer · Willkommen/Login/Nicht gefunden · Druckseiten
   13  Hilfsklassen, reduzierte Bewegung, Druck

   Nur lokale Ressourcen (CSP: default-src 'self'). Symbole sind Inline-SVG in
   den Seiten oder data:-URLs hier im Stylesheet.
   Kontraste: Text ≥ 4,5:1 (WCAG AA), Rahmen von Eingabefeldern ≥ 3:1.
   ========================================================================== */

/* 1  Variablen ------------------------------------------------------------ */

:root {
  color-scheme: light;

  /* Marke: Koralle wie im Entwurf (Logo, Hauptknöpfe, Erfassen in der Handy-Leiste).
     Gefüllte Knöpfe tragen dunkle Schrift: 5,6:1 auf Koralle (weiße Schrift hätte nur 2,8:1).
     So bleibt Koralle klar getrennt vom dunkleren Fehler-Rot (--bad). */
  --accent: #ff6d5a;
  --accent-hover: #ff5a44;
  --accent-soft: #fff1ee;
  --accent-soft-hover: #ffe4de;
  --primary: #ff6d5a;
  --primary-hover: #ff5a44;
  --primary-active: #f9563f;
  --on-primary: #1d2433;
  /* Koralle als Schrift auf hellem Grund (AA) */
  --accent-ink: #b43a2c;

  --canvas: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --border-ui: #8a93a3;
  --border-ui-hover: #6f7889;

  --text: #1d2433;
  --text-2: #5d6576;
  --text-3: #667085;

  --ok: #0f7553;
  --ok-bg: #e7f6ef;
  --ok-border: #b5e3cd;
  --bad: #c4321f;
  --bad-hover: #a92a19;
  --bad-bg: #fdecea;
  --bad-border: #f4c4bc;
  --warn: #7a4a00;
  --warn-bg: #fff6e5;
  --warn-border: #f1d6a0;
  --info: #1e47a8;
  --info-bg: #eef3ff;
  --info-border: #cbd8f6;

  /* Tastatur-Fokus dunkel: nie mit Fehler-Rot oder Koralle zu verwechseln */
  --focus: #1d2433;

  --radius: 14px;
  --radius-ctl: 11px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, 0.2);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --content-max: 1180px;
  --header-h: 64px;
  --tabbar-h: 0px;
  --page-x: 24px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 759.98px) {
  :root {
    --header-h: 56px;
    --tabbar-h: 68px;
    --page-x: 16px;
  }
}

/* Seiten ohne Handy-Leiste (Willkommen, Login, Nicht gefunden, Druck) */
body:not(.app) {
  --tabbar-h: 0px;
}

/* 2  Grundstil ------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
  scroll-padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 15px;
  line-height: 1.35;
  font-weight: 600;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: #ffd8d0;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

/* 3  App-Rahmen ----------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: 16px;
  top: 0;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-ctl);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(8px);
  box-shadow: var(--shadow-lg);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header-bar {
  max-width: var(--content-max);
  height: var(--header-h);
  margin: 0 auto;
  padding: 0 max(var(--page-x), env(safe-area-inset-right)) 0 max(var(--page-x), env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  flex: none;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
}

.brand-mark svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark-xl {
  width: 64px;
  height: 64px;
  border-radius: 18px;
}

.brand-mark-xl svg {
  width: 36px;
  height: 36px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

@media (hover: hover) {
  .main-nav a:hover {
    background: var(--surface-2);
    color: var(--text);
  }
}

.main-nav a.active,
.main-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  color: var(--text-2);
  font-size: 14px;
}

.user-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name:empty {
  display: none;
}

.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.avatar:empty::before {
  content: "";
  width: 16px;
  height: 16px;
  background: var(--text-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Abmelden: am Desktop mit Text, auf dem Tablet nur als Symbol */
.header-logout .icon {
  display: none;
}

/* Tablet (760–1099 px): kompakter Kopf, damit alle Menüpunkte in eine Zeile passen */
@media (min-width: 760px) and (max-width: 1099.98px) {
  .app-header-bar {
    gap: 16px;
  }

  .app-header .brand-name,
  .header-user .user-name {
    display: none;
  }

  .main-nav {
    gap: 2px;
  }

  .main-nav a {
    padding: 0 10px;
  }

  .header-user .header-logout {
    width: 44px;
    padding: 0;
  }

  .header-logout .icon {
    display: block;
  }

  .header-logout-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
}

/* Kopfzeile nur mit Logo (Willkommen, Login, Nicht gefunden) */
.app-header-minimal .app-header-bar {
  justify-content: space-between;
}

.app-main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px max(var(--page-x), env(safe-area-inset-right)) 72px max(var(--page-x), env(safe-area-inset-left));
}

/* Schmalere Seiten (Erfassen, Scanner, Einstellungen) links bündig: Überschriften stehen
   auf allen Seiten an derselben Kante wie das Logo – nichts springt beim Wechseln */
.page-narrow {
  max-width: 780px;
}

.page-medium {
  max-width: 980px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 20px;
}

.page-head-text {
  min-width: 0;
}

.page-sub {
  margin-top: 4px;
  color: var(--text-2);
}

.page-sub:empty {
  display: none;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: -8px 0 8px;
  color: var(--text-2);
  font-weight: 600;
  text-decoration: none;
}

@media (hover: hover) {
  .back-link:hover {
    color: var(--text);
  }
}

.back-link .icon {
  width: 18px;
  height: 18px;
}

/* Handy-Leiste unten (nur schmale Bildschirme) */
.tabbar {
  display: none;
}

/* „Mehr“-Menü als Blatt von unten */
/* top/right/bottom/left statt „inset“: auch ältere iPads/iPhones (Safari < 14.1) */
.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 70;
}

.sheet-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(16, 24, 40, 0.45);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  overflow-y: auto;
  padding: 14px 16px calc(16px + var(--safe-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.22s ease-out;
}

.sheet-panel:focus {
  outline: none;
}

.sheet-user:has([data-user-name]:empty) {
  display: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sheet-title {
  font-size: 17px;
  font-weight: 700;
}

.sheet-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
}

.sheet-user strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.sheet-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.sheet-link .icon {
  width: 22px;
  height: 22px;
  color: var(--text-2);
}

.sheet-link:active {
  background: var(--surface-2);
}

@media (hover: hover) {
  .sheet-link:hover {
    background: var(--surface-2);
  }
}

.sheet-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.sheet-link[aria-current="page"] .icon {
  color: var(--accent-ink);
}

.sheet-link-danger,
.sheet-link-danger .icon {
  color: var(--bad);
}

.sheet-divider {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

@keyframes sheet-up {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
}

@media (min-width: 760px) {
  .sheet {
    display: none !important;
  }
}

@media (max-width: 759.98px) {
  .main-nav,
  .header-user .user-name,
  .header-user .header-logout {
    display: none;
  }

  .app-header-bar {
    gap: 12px;
  }

  .app-main {
    padding-top: 20px;
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 32px);
  }

  h1 {
    font-size: 24px;
  }

  .hide-mobile {
    display: none !important;
  }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    /* Auf breiteren Handys/kleinen Tablets höchstens 480 px breit, mittig */
    padding: 7px max(8px, env(safe-area-inset-right), calc((100% - 480px) / 2)) calc(8px + var(--safe-bottom)) max(8px, env(safe-area-inset-left), calc((100% - 480px) / 2));
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
  }

  .tabbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 44px;
    padding: 0 4px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--text-2);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
  }

  .tabbar-item .icon {
    width: 22px;
    height: 22px;
  }

  .tabbar-item[aria-current="page"],
  .tabbar-item.is-active {
    background: var(--accent-soft);
    color: var(--accent-ink);
  }

  .tabbar-item.tabbar-fab {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 4px 12px rgba(255, 109, 90, 0.35);
  }

  .tabbar-item.tabbar-fab .icon {
    stroke-width: 2.4;
  }

  /* Aktuelle Seite: kräftigere Koralle, flach (kein Ring – der sähe aus wie Tastatur-Fokus) */
  .tabbar-item.tabbar-fab[aria-current="page"] {
    background: var(--primary-hover);
    box-shadow: none;
  }

  /* Avatar oben rechts öffnet am Handy das „Mehr“-Menü (Konto, Abmelden) */
  .header-user .header-avatar {
    display: none;
  }

  .header-user .avatar-button {
    display: inline-grid;
  }
}

.avatar-button {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  font-family: var(--font);
  font-size: 15px;
  cursor: pointer;
}

@media (hover: hover) {
  .avatar-button:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
  }
}

/* 4  Schaltflächen -------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

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

@media (hover: hover) {
  .btn:hover {
    background: var(--surface-2);
    border-color: #b9c0cb;
  }
}

.btn:active {
  background: var(--surface-3);
}

.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

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

@media (hover: hover) {
  .btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
  }
}

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

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

@media (hover: hover) {
  .btn-soft:hover {
    background: var(--accent-soft-hover);
    border-color: transparent;
  }
}

.btn-soft:active {
  background: var(--accent-soft-hover);
}

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

@media (hover: hover) {
  .btn-ghost:hover {
    background: var(--surface-3);
    border-color: transparent;
    color: var(--text);
  }
}

/* Bestätigen im Lösch-Dialog */
.btn-danger,
.btn-delete {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

@media (hover: hover) {
  .btn-danger:hover,
  .btn-delete:hover {
    background: var(--bad-hover);
    border-color: var(--bad-hover);
  }
}

.btn-danger:active,
.btn-delete:active {
  background: var(--bad-hover);
}

/* Löschen anstoßen (öffnet erst den Dialog) */
.btn-danger-outline {
  background: var(--surface);
  border-color: var(--bad-border);
  color: var(--bad);
}

@media (hover: hover) {
  .btn-danger-outline:hover {
    background: var(--bad-bg);
    border-color: #eaa79c;
  }
}

.btn-danger-outline:active {
  background: var(--bad-bg);
}

.btn-icon {
  width: 44px;
  flex: none;
  padding: 0;
  color: var(--text-2);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  min-height: 52px;
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 16px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Lade-Kreisel, solange die Schaltfläche beim Senden gesperrt ist */
.btn-busy:disabled {
  opacity: 0.75;
  cursor: progress;
}

.btn-busy:disabled::after {
  content: "";
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* 5  Formulare ------------------------------------------------------------ */

.form-group {
  margin-bottom: 16px;
  min-width: 0;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group > label:not(.check-row),
.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.req {
  margin-left: 2px;
  color: var(--bad);
  font-weight: 700;
}

.hint {
  color: var(--text-2);
  font-weight: 400;
}

.help-text {
  display: block;
  margin-top: 6px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.45;
}

/* Fehlertext unter einem Feld (erfassen.js) */
.field-error {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  color: var(--bad);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}

.field-error::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v6M12 16.6h.01'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v6M12 16.6h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}

.file-upload-container.is-invalid {
  border-color: var(--bad);
  background: var(--bad-bg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-grid:last-child {
  margin-bottom: 0;
}

.form-grid > .form-group {
  margin-bottom: 0;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-all {
  grid-column: 1 / -1;
}

@media (max-width: 559.98px) {
  .form-grid,
  .form-grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"])),
select,
textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--border-ui);
  border-radius: var(--radius-ctl);
  background-color: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
  opacity: 1;
}

@media (hover: hover) {
  input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"])):hover,
  select:hover,
  textarea:hover {
    border-color: var(--border-ui-hover);
  }
}

/* Fokus in Feldern dunkel (nicht rot), damit er nicht wie ein Fehler aussieht */
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"])):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(29, 36, 51, 0.14);
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}

[aria-invalid="true"] {
  border-color: var(--bad) !important;
  box-shadow: 0 0 0 3px rgba(196, 50, 31, 0.16) !important;
}

select {
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235d6576' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 18px 18px;
  cursor: pointer;
}

select:disabled {
  cursor: not-allowed;
}

textarea {
  min-height: 104px;
  line-height: 1.5;
  resize: vertical;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

input[type="search"]::-webkit-search-cancel-button {
  width: 18px;
  height: 18px;
  margin-left: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6576' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
  -webkit-appearance: none;
  cursor: pointer;
}

/* Leeres Suchfeld: kein Platz für das (dann unsichtbare) „x“ reservieren –
   sonst fehlen dem Platzhalter am Handy 26 px und er wird abgeschnitten */
input[type="search"]:placeholder-shown::-webkit-search-cancel-button {
  display: none;
}

/* Kontrollkästchen (echtes <input>, nur neu gezeichnet) */
input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: none;
  margin: 0;
  border: 2px solid var(--border-ui);
  border-radius: 6px;
  background: var(--surface) center / 14px 14px no-repeat;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

input[type="checkbox"]:checked {
  border-color: var(--text);
  background-color: var(--text);
  color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

@media (hover: hover) {
  .check-row:hover {
    border-color: var(--border-ui);
  }
}

/* „Reifen sind in Ordnung“: angehakt = grün */
.check-row-ok input[type="checkbox"]:checked {
  border-color: var(--ok);
  background-color: var(--ok);
}

.check-row-ok:has(input:checked) {
  border-color: var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok);
}

/* Auswahl-Leiste (segmented control) mit echten Optionsfeldern darunter */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  min-width: 0;
}

.segment {
  position: relative;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
}

.segment > input {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segment-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--text-2);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.segment-sub {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
}

@media (hover: hover) {
  .segment > input:hover + .segment-body {
    color: var(--text);
  }
}

.segment > input:checked + .segment-body {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-ui), 0 1px 2px rgba(16, 24, 40, 0.08);
}

.segment > input:focus-visible + .segment-body {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

/* Variante im Formular: größer. Gewählt wie überall weiße Fläche mit dunkler Schrift,
   hier mit kräftigerem dunklem Rand – Rot bleibt allein den Fehlern vorbehalten. */
.segmented-choice {
  padding: 5px;
}

.segmented-choice .segment-body {
  min-height: 52px;
  padding: 10px 12px;
}

.segmented-choice .segment > input:checked + .segment-body {
  box-shadow: 0 0 0 2px var(--text), 0 2px 6px rgba(16, 24, 40, 0.12);
}

.segmented-choice .segment > input:checked + .segment-body .segment-sub {
  color: var(--text-2);
}

@media (max-width: 559.98px) {
  .segmented-stack {
    flex-direction: column;
  }

  .segmented-stack .segment-body {
    min-height: 48px;
  }
}

/* Foto-Upload: sichtbare Fläche, echtes Datei-Feld unsichtbar darüber erreichbar */
.file-upload-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

@media (hover: hover) {
  .file-upload-container:hover {
    border-color: var(--primary);
    background: var(--accent-soft);
  }
}

.file-upload-container.image-upload-highlight,
.file-upload-container.highlight {
  border-color: var(--primary);
  background: var(--accent-soft);
}

.file-upload-container:focus-visible,
.file-upload-container:has(.file-input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.file-upload-container p {
  color: var(--text);
  font-weight: 600;
}

.upload-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.upload-icon .icon {
  width: 26px;
  height: 26px;
}

.upload-hint {
  color: var(--text-2);
  font-size: 13.5px;
}

.file-input {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
}

/* Eingabe mit Knopf in einer Zeile (z. B. Reifen-ID suchen) */
.input-group {
  display: flex;
  gap: 8px;
}

.input-group > input {
  flex: 1;
  min-width: 0;
}

.input-group > .btn {
  flex: none;
}

/* Suchfeld mit Lupe */
.search-field {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}

.search-field .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
  color: var(--text-2);
  pointer-events: none;
}

.search-field input {
  padding-left: 42px;
}

/* 6  Karten, Abschnitte, Akkordeon ---------------------------------------- */

.card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h2 {
  min-width: 0;
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.subhead {
  margin: 22px 0 10px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.subhead:first-child {
  margin-top: 0;
}

.step {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
}

.accordion {
  padding: 0;
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  margin: 0;
  padding: 16px 20px;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .accordion-header:hover {
    background: var(--surface-2);
  }
}

.accordion-header:focus-visible {
  outline-offset: -3px;
  border-radius: var(--radius);
}

.accordion-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.accordion-sub {
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 400;
}

.accordion-header .chevron {
  margin-left: auto;
  color: var(--text-2);
  transition: transform 0.2s;
}

.accordion-header.active .chevron {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding: 4px 20px 20px;
}

.accordion-header.active + .accordion-content {
  display: block;
}

.optional-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  vertical-align: 2px;
}

/* 7  Abzeichen und Lagerort-Chip ----------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chip-lg {
  padding: 5px 12px;
  font-size: 15px;
  border-radius: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 18px;
  white-space: nowrap;
}

.badge-ok,
.badge-success {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.badge-primary {
  background: var(--info-bg);
  color: var(--info);
}

.badge-secondary {
  background: var(--surface-3);
  color: var(--text-2);
}

.badge-warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-ok::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.badge-bad::before {
  content: "";
  width: 10px;
  height: 10px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.6' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.6' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
}

.badge-lg {
  padding: 6px 13px;
  font-size: 13.5px;
}

/* 8  Meldungen, Einblendungen, Hinweisboxen ------------------------------- */

.status-message,
.success-message,
.error-message,
.info-message,
.alert {
  position: relative;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--info-border);
  border-radius: var(--radius-ctl);
  background: var(--info-bg);
  color: var(--info);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  overflow-wrap: anywhere;
}

.status-message::before,
.success-message::before,
.error-message::before,
.info-message::before,
.alert::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 13px;
  width: 19px;
  height: 19px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.5M12 7.6h.01'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.5M12 7.6h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}

.success-message,
.status-success,
.success {
  border-color: var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok);
}

.success-message::before,
.status-success::before,
.success::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8 12.4l2.7 2.7L16 9.8'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8 12.4l2.7 2.7L16 9.8'/%3E%3C/svg%3E");
}

.error-message,
.status-error,
.error {
  border-color: var(--bad-border);
  background: var(--bad-bg);
  color: var(--bad);
}

.error-message::before,
.status-error::before,
.error::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v6M12 16.6h.01'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v6M12 16.6h.01'/%3E%3C/svg%3E");
}

/* Leere Meldungsfelder nehmen keinen Platz ein */
.status-message:empty,
.success-message:empty,
.error-message:empty,
.info-message:empty,
.alert:empty {
  display: none;
}

/* Einblendungen (Toasts) unten: über Handy- und Speichern-Leiste, unter Dialogen und „Mehr“-Menü.
   Sie fangen keine Klicks ab – Knöpfe darunter bleiben bedienbar, solange die Meldung steht. */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(560px, calc(100% - 2 * var(--page-x)));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast-region > * {
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

/* Hinweisboxen */
.callout {
  padding: 14px 16px;
  border: 1px solid var(--info-border);
  border-radius: 12px;
  background: var(--info-bg);
  color: var(--text);
}

.callout h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--info);
}

.callout p + p {
  margin-top: 6px;
}

.callout-warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.callout-warn h3,
.callout-warn strong {
  color: var(--warn);
}

/* 9  Tabellen ------------------------------------------------------------- */

.table-container,
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.data-table th {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow-wrap: break-word;
}

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

@media (hover: hover) {
  .data-table tbody tr:hover td {
    background: var(--surface-2);
  }
}

.data-table .action-cell,
.data-table .action-buttons {
  white-space: nowrap;
  text-align: right;
}

.data-table .action-buttons .btn + .btn {
  margin-left: 8px;
}

.data-table td[colspan] {
  padding: 28px 16px;
  color: var(--text-2);
  text-align: center;
}

/* Löschen in Tabellen: zurückhaltend, der Dialog fragt nach */
.data-table .btn-delete,
.data-table .btn-danger {
  background: var(--surface);
  border-color: var(--bad-border);
  color: var(--bad);
}

@media (hover: hover) {
  .data-table .btn-delete:hover,
  .data-table .btn-danger:hover {
    background: var(--bad-bg);
    border-color: #eaa79c;
  }
}

/* Handy: jede Zeile als kleine Karte, Spaltennamen aus data-label (nav.js) */
@media (max-width: 759.98px) {
  .data-table[data-responsive] thead {
    display: none;
  }

  .data-table[data-responsive],
  .data-table[data-responsive] tbody,
  .data-table[data-responsive] tr,
  .data-table[data-responsive] td {
    display: block;
    width: 100%;
  }

  .data-table[data-responsive] tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }

  .data-table[data-responsive] tbody tr:last-child {
    border-bottom: 0;
  }

  .data-table[data-responsive] td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
    gap: 12px;
    padding: 5px 0;
    border: 0;
    text-align: left;
  }

  .data-table[data-responsive] td::before {
    content: attr(data-label);
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 600;
  }

  .data-table[data-responsive] td > * {
    justify-self: start;
  }

  .data-table[data-responsive] td:not([data-label])::before,
  .data-table[data-responsive] td[colspan]::before {
    display: none;
  }

  .data-table[data-responsive] td[colspan] {
    display: block;
    padding: 16px 0;
    text-align: center;
  }

  @media (hover: hover) {
    .data-table[data-responsive] tbody tr:hover td {
      background: none;
    }
  }

  .data-table[data-responsive] .action-cell,
  .data-table[data-responsive] .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
    white-space: normal;
  }

  .data-table[data-responsive] .action-cell::before,
  .data-table[data-responsive] .action-buttons::before {
    display: none;
  }

  .data-table[data-responsive] .action-cell .btn,
  .data-table[data-responsive] .action-buttons .btn {
    flex: 1 1 0;
    margin: 0;
  }
}

/* 10  Dialoge ------------------------------------------------------------- */

.modal {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 90;
  overflow-y: auto;
  padding: 16px;
  background: rgba(16, 24, 40, 0.5);
}

.modal-content {
  position: relative;
  max-width: 480px;
  margin: min(14vh, 140px) auto 24px;
  padding: 24px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s ease-out;
}

.modal-content h2 {
  margin: 0 44px 8px 0;
  font-size: 19px;
  font-weight: 700;
}

.modal-content > p {
  color: var(--text-2);
}

/* Welcher Reifensatz gelöscht wird (Lagerort + Kunde) */
.modal-record {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.modal-record:empty {
  display: none;
}

.modal-record .chip {
  flex: none;
}

.modal-content h2 + form {
  margin-top: 18px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.icon-btn .icon {
  width: 22px;
  height: 22px;
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--surface-3);
    color: var(--text);
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.modal-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.modal-content form .btn[type="submit"] {
  margin-top: 4px;
}

.modal-open,
.modal-open body {
  overflow: hidden;
}

@keyframes modal-in {
  from {
    transform: translateY(10px) scale(0.98);
    opacity: 0;
  }
}

/* Handy: Dialog als Blatt von unten (Daumen-Bereich) */
@media (max-width: 559.98px) {
  .modal {
    padding: 0;
  }

  .modal-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    max-height: 92vh;
    margin: 0;
    overflow-y: auto;
    padding: 22px 16px calc(20px + var(--safe-bottom));
    border-radius: 20px 20px 0 0;
    animation-name: sheet-up;
  }

  .modal-buttons {
    flex-direction: column-reverse;
  }

  .modal-buttons .btn {
    width: 100%;
  }
}

/* 11  Leer- und Ladezustand ---------------------------------------------- */

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 10px;
  border: 3px solid rgba(29, 36, 51, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
}

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

.loading-state {
  display: block;
  padding: 48px 20px;
  color: var(--text-2);
  font-size: 16px;
  text-align: center;
}

.empty-state {
  padding: 44px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
}

.empty-icon .icon {
  width: 26px;
  height: 26px;
}

.empty-title {
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
}

.empty-text {
  margin-top: 4px;
}

/* 12a  Dashboard ---------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 20px;
  padding: 12px;
}

.toolbar .segmented {
  flex: 0 0 auto;
}

/* Segmente so breit wie ihr Text (wie im Entwurf), „Nicht OK“ wird nicht gequetscht */
.toolbar .segment {
  flex: 0 0 auto;
}

.toolbar .segment-body {
  padding: 8px 14px;
  white-space: nowrap;
}

/* Platzhalter: dashboard.js nimmt auf schmalen Handys die kurze Fassung;
   reicht selbst die nicht, mit „…“ abschneiden statt mitten im Wort */
#searchInput,
#searchInput::placeholder {
  text-overflow: ellipsis;
}

.sort-field {
  position: relative;
  display: flex;
  flex: 0 1 190px;
  min-width: 0;
}

.sort-field .sort-icon {
  display: none;
}

.toolbar select {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  font-weight: 600;
}

.toolbar #refreshBtn {
  flex: none;
}

@media (max-width: 1099.98px) {
  .toolbar #refreshBtn {
    width: 44px;
    padding: 0;
  }
}

/* Tablet: Suche in eigener Zeile, darunter Filter, Sortierung, Aktualisieren */
@media (min-width: 760px) and (max-width: 1023.98px) {
  .toolbar .search-field {
    flex-basis: 100%;
  }

  .toolbar .sort-field {
    flex: 0 1 220px;
    margin-left: auto;
  }
}

.etikett-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
  gap: 18px;
}

.etikett-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}

@media (hover: hover) {
  .etikett-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
  }
}

.etikett-thumb {
  display: grid;
  place-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.etikett-img {
  display: block;
  width: 62%;
  max-width: 260px;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.16);
}

.etikett-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 16px 18px 0;
}

.etikett-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

/* Name und Auto höchstens zwei Zeilen (voller Text im title-Attribut und auf der Detailseite) */
.etikett-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.etikett-subtitle {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-2);
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* Reifengröße nie mitten drin umbrechen („225/45 R17“) */
.nowrap {
  white-space: nowrap;
}

.etikett-date {
  color: var(--text-3);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.etikett-buttons {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding: 14px 18px 18px;
}

.etikett-buttons .btn {
  flex: 1 1 0;
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
}

/* Löschen auf der Karte: nur Symbol, öffnet den Bestätigungsdialog */
.etikett-buttons .btn-delete {
  flex: 0 0 44px;
  padding: 0;
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
}

@media (hover: hover) {
  .etikett-buttons .btn-delete:hover {
    border-color: var(--bad-border);
    background: var(--bad-bg);
    color: var(--bad);
  }
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
}

.pagination:empty {
  display: none;
}

.pagination button {
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

@media (hover: hover) {
  .pagination button:hover:not(.active) {
    background: var(--surface-2);
  }
}

.pagination button.active {
  border-color: var(--primary);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Ausgelassene Seitenzahlen („…“) */
.pagination-gap {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 44px;
  color: var(--text-2);
  font-weight: 600;
}

/* Leer- und Fehlerzustand mit Knopf */
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.empty-state-error {
  border-style: solid;
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.empty-state-error .empty-icon {
  background: var(--surface);
  color: var(--bad);
}

.empty-state-error .empty-title {
  color: var(--bad);
}

.empty-state-error .empty-text {
  color: var(--text);
}

.empty-state-error + .etikett-grid:not(:empty) {
  margin-top: 18px;
}

@media (max-width: 759.98px) {
  /* Handy: Suche | Status-Filter + Sortierung (als Symbol) + Aktualisieren */
  .toolbar {
    gap: 10px 8px;
  }

  .toolbar .search-field {
    flex-basis: 100%;
    order: 1;
  }

  .toolbar .segmented {
    flex: 1 1 auto;
    order: 2;
  }

  .toolbar .segment {
    flex: 1 1 auto;
  }

  .toolbar .segment-body {
    padding: 8px 10px;
  }

  /* Sortierung als 44-px-Symbol; die echte Auswahlliste liegt unsichtbar darüber */
  .toolbar .sort-field {
    flex: 0 0 44px;
    order: 3;
    height: 44px;
    align-self: center;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-ctl);
    background: var(--surface);
    color: var(--text-2);
  }

  .toolbar .sort-field .sort-icon {
    display: block;
  }

  .toolbar .sort-field select {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    opacity: 0;
    cursor: pointer;
  }

  .toolbar .sort-field:focus-within {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }

  .toolbar #refreshBtn {
    order: 4;
  }
}

/* Handy: kompakte Karten (Etikett klein links, Text rechts) */
@media (max-width: 599.98px) {
  .etikett-grid {
    gap: 12px;
  }

  .etikett-card {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    grid-template-areas:
      "thumb info"
      "buttons buttons";
    column-gap: 14px;
    padding: 14px 14px 0;
  }

  .etikett-thumb {
    grid-area: thumb;
    align-self: start;
    padding: 0;
    border: 0;
    background: none;
  }

  .etikett-img {
    width: 100%;
    max-width: none;
    border: 1px solid var(--border);
    box-shadow: none;
  }

  .etikett-info {
    grid-area: info;
    padding: 0;
    gap: 2px;
  }

  .etikett-top {
    margin-bottom: 4px;
  }

  .etikett-title {
    font-size: 16px;
  }

  .etikett-subtitle {
    font-size: 14px;
  }

  .etikett-date {
    font-size: 13px;
  }

  .etikett-buttons {
    grid-area: buttons;
    padding: 12px 0 14px;
  }
}

/* 12b  Erfassen ------------------------------------------------------------ */

.form-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-sections > .card:not(.accordion) {
  padding: 20px;
}

.profil-container {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.profil-container label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.conditional-field {
  display: none;
  margin-bottom: 16px;
}

.photo-preview {
  display: none;
  max-width: 100%;
  max-height: 420px;
  margin: 14px auto 0;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.ai-info {
  display: none;
  margin-top: 16px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.form-actions .btn {
  min-width: 220px;
}

#printOptions {
  display: none;
}

/* Druckoptionen nach dem Speichern: grün umrandet, Erfolgsmeldung oben in der Karte */
.print-options {
  border-color: var(--ok-border);
  box-shadow: 0 0 0 3px var(--ok-bg);
}

.print-options .success-message {
  margin-bottom: 16px;
}

.print-options h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.print-options h3:focus {
  outline: none;
}

.print-options p {
  margin-bottom: 14px;
  color: var(--text-2);
}

.print-options .button-row .btn {
  flex: 1 1 200px;
}

.saved-record {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 8px 0 10px;
}

.saved-record:empty {
  display: none;
}

.saved-record-name {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* „Pflicht“-Hinweis an Schritt 3 (Foto) */
.required-tag {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Foto gewählt: Auswahlfläche wird zur schmalen Zeile „Foto ändern“ */
.upload-change {
  display: none;
}

.file-upload-container.has-photo {
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctl);
  background: var(--surface);
}

.file-upload-container.has-photo p,
.file-upload-container.has-photo .upload-hint {
  display: none;
}

.file-upload-container.has-photo .upload-icon {
  width: 24px;
  height: 24px;
  background: none;
  color: var(--text-2);
}

.file-upload-container.has-photo .upload-icon .icon {
  width: 20px;
  height: 20px;
}

.file-upload-container.has-photo .upload-change {
  display: inline;
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 759.98px) {
  /* Speichern-Knopf bleibt über der Handy-Leiste sichtbar */
  .sticky-actions {
    position: sticky;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom));
    z-index: 30;
    margin: 0 calc(-1 * var(--page-x));
    padding: 12px var(--page-x);
    background: linear-gradient(to top, var(--canvas) 72%, rgba(245, 246, 248, 0));
  }

  .form-actions .btn {
    width: 100%;
    min-width: 0;
    box-shadow: 0 8px 20px rgba(255, 109, 90, 0.32);
  }

  /* Gerade gespeichert: Senden steht normal im Formular und verdeckt die Druckoptionen
     nicht – bis der nächste Reifensatz eingegeben wird */
  .is-saved .sticky-actions {
    position: static;
    background: none;
  }

  .is-saved .form-actions .btn {
    box-shadow: none;
  }

  .page-erfassen .toast-region {
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 88px);
  }

  /* Erfassen: Beim Weitertippen (Tab) und Hineinscrollen bleibt ein Feld über der
     Senden-Leiste (76 px) statt dahinter. Klasse am <html>, weil nur der Abstand
     am Wurzelelement für das Scrollen der Seite zählt. */
  html.has-sticky-actions {
    scroll-padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 100px);
  }

  .accordion-header {
    padding: 14px 16px;
  }

  .accordion-content {
    padding: 4px 16px 18px;
  }

  .form-sections > .card:not(.accordion) {
    padding: 16px;
  }
}

/* 12c  Detailseite --------------------------------------------------------- */

.detail-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 20px;
  padding: 22px 24px;
}

.detail-hero-text {
  min-width: 0;
  flex: 1 1 360px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
}

.detail-title {
  overflow-wrap: anywhere;
}

.detail-meta {
  margin-top: 6px;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.detail-hero-label {
  flex: none;
  width: 210px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

/* Das Etikett nur einmal zeigen: breit oben im Kopf, schmal (unter 860 px) als eigene Karte */
@media (min-width: 860px) {
  .detail-card-etikett {
    display: none;
  }
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 20px;
}

.detail-main,
.detail-aside {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.detail-card {
  overflow-wrap: anywhere;
}

/* Datenzeilen: Bezeichnung | Wert (im Bearbeiten-Modus: Eingabefeld) */
.info-list {
  display: flex;
  flex-direction: column;
}

.info-row {
  display: grid;
  grid-template-columns: minmax(120px, 38%) minmax(0, 1fr);
  align-items: center;
  gap: 4px 16px;
  min-height: 44px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}

.info-row:first-child {
  border-top: 0;
  padding-top: 0;
}

/* Lange Wörter mit Trennstrich umbrechen („Geschwindigkeits-index“), nicht mitten im Wort;
   nur was dann noch nicht passt, wird hart umbrochen (z. B. lange Links oder Nummern) */
.info-label {
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.info-value {
  min-width: 0;
  color: var(--text);
  font-weight: 500;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.info-date {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.info-text {
  color: var(--text);
  white-space: pre-line;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.analyze-status:not(:empty) {
  margin-top: 14px;
  color: var(--text-2);
}

.edit-field {
  display: none;
  min-width: 0;
}

.edit-mode .edit-field {
  display: block;
}

.edit-mode .info-value {
  display: none;
}

.edit-mode .detail-card-actions {
  display: none;
}

.edit-mode .detail-card-kunde,
.edit-mode .detail-card-reifen {
  border-color: #f2b8ad;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Profiltiefen: vier Räder um ein Auto (von oben gesehen) */
.depth-diagram {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr);
  grid-template-areas:
    "fl car fr"
    "rl car rr";
  gap: 12px 16px;
  align-items: center;
  max-width: 520px;
  margin: 0 auto;
}

.depth-cell {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.depth-cell[data-pos="fl"] { grid-area: fl; }
.depth-cell[data-pos="fr"] { grid-area: fr; text-align: right; }
.depth-cell[data-pos="rl"] { grid-area: rl; }
.depth-cell[data-pos="rr"] { grid-area: rr; text-align: right; }

.depth-pos {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.tire-depth {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.edit-mode .tire-depth,
.edit-mode .depth-hint {
  display: none;
}

/* Profiltiefe unter dem gesetzlichen Minimum (1,6 mm): rot, mit Text (nicht nur Farbe) */
.depth-cell.is-low {
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.depth-cell.is-low .tire-depth {
  color: var(--bad);
}

.depth-hint {
  color: var(--bad);
  font-size: 12.5px;
  font-weight: 700;
}

.depth-cell .edit-field input {
  margin-top: 4px;
  text-align: center;
}

.depth-car {
  grid-area: car;
  position: relative;
  justify-self: center;
  width: 54px;
  height: 128px;
  border: 2px solid var(--border-strong);
  border-radius: 22px 22px 16px 16px;
  background: linear-gradient(var(--surface-3), var(--surface-3)) center 30px / 38px 22px no-repeat, var(--surface);
}

.depth-car span {
  position: absolute;
  width: 12px;
  height: 26px;
  border-radius: 4px;
  background: var(--text);
}

.depth-car .wheel-fl { top: 14px; left: -9px; }
.depth-car .wheel-fr { top: 14px; right: -9px; }
.depth-car .wheel-rl { bottom: 14px; left: -9px; }
.depth-car .wheel-rr { bottom: 14px; right: -9px; }

.ai-analysis,
.ai-hinweis {
  margin-top: 18px;
}

.ai-hinweis p {
  margin: 0;
}

.ai-hinweis .ai-hinweis-tipp {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 14px;
}

.ai-analysis .info-row {
  border-top-color: var(--info-border);
}

/* Aktionen rechts */
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-grid .btn {
  padding-left: 10px;
  padding-right: 10px;
}

.action-grid .span-all {
  grid-column: 1 / -1;
}

.action-grid .action-sep {
  grid-column: 1 / -1;
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

.image-container {
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.image-container img {
  display: block;
  width: 100%;
  height: auto;
}

.label-preview {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.qr-container {
  display: grid;
  place-items: center;
  padding: 8px 0;
}

.qr-container img {
  width: 168px;
  max-width: 100%;
  image-rendering: pixelated;
}

.card-note {
  margin-top: 10px;
  color: var(--text-2);
  font-size: 13.5px;
}

/* Bearbeiten-Leiste (Speichern/Abbrechen), nur im Bearbeiten-Modus */
.edit-controls {
  display: none;
}

.edit-mode .edit-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: block;
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 -8px 24px rgba(16, 24, 40, 0.08);
}

/* Beim Bearbeiten verschwindet die Handy-Leiste: ein Tipp knapp unter „Speichern“
   führt so nicht auf eine andere Seite (und die Änderungen gingen verloren).
   Die Leiste „Abbrechen / Speichern“ rückt an ihren Platz. */
@media (max-width: 759.98px) {
  body.edit-mode,
  body.edit-area-open {
    --tabbar-h: 0px;
  }

  body.edit-mode .tabbar,
  body.edit-area-open .tabbar {
    display: none;
  }
}

/* Meldungen über der Bearbeiten-Leiste, nicht auf ihren Knöpfen */
.edit-mode .toast-region {
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 84px);
}

.edit-bar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 12px var(--page-x);
}

.edit-bar-text {
  margin-right: auto;
  color: var(--text-2);
  font-weight: 600;
}

.edit-mode .app-main {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 120px);
}

#saveStatus:empty {
  display: none;
}

#saveStatus {
  margin-top: 16px;
}

.status-text {
  font-weight: 600;
}

.status-text.is-ok { color: var(--ok); }
.status-text.is-error { color: var(--bad); }
.status-text.is-info { color: var(--info); }

.edit-area-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* „Daten bearbeiten“ unter dem Raster: gleicher Abstand wie zwischen den Karten */
.detail-card-edit {
  margin-top: 20px;
}

@media (max-width: 859.98px) {
  .detail-card-edit {
    margin-top: 16px;
  }
}

@media (max-width: 1023.98px) {
  .detail-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

/* Handy/Tablet: eine Spalte – Aktionen zuerst, dann Daten, dann Bilder */
@media (max-width: 859.98px) {
  .detail-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .detail-main,
  .detail-aside {
    display: contents;
  }

  .detail-card-actions { order: 1; }
  .detail-card-kunde { order: 2; }
  .detail-card-reifen { order: 3; }
  .detail-card-foto { order: 4; }
  .detail-card-etikett { order: 5; }
  .detail-card-qr { order: 6; }

  .detail-hero-label {
    display: none;
  }
}

@media (max-width: 559.98px) {
  .detail-hero {
    padding: 18px 16px;
  }

  .info-row {
    grid-template-columns: minmax(104px, 40%) minmax(0, 1fr);
    gap: 2px 12px;
  }

  /* Bearbeiten am Handy: Bezeichnung über dem Eingabefeld */
  .edit-mode .info-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .edit-mode .info-row .edit-field {
    margin-top: 4px;
  }

  .depth-diagram {
    grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr);
    gap: 10px;
  }

  .depth-car {
    width: 40px;
    height: 104px;
    border-radius: 18px 18px 12px 12px;
    background-size: 28px 18px;
    background-position: center 24px, 0 0;
  }

  .depth-car span {
    width: 10px;
    height: 22px;
  }

  .depth-car .wheel-fl, .depth-car .wheel-rl { left: -8px; }
  .depth-car .wheel-fr, .depth-car .wheel-rr { right: -8px; }

  .depth-cell {
    padding: 10px 12px;
  }

  .tire-depth {
    font-size: 20px;
  }

  .edit-bar-text {
    display: none;
  }

  .edit-bar-inner .btn {
    flex: 1 1 0;
  }
}

/* 12d  Scanner -------------------------------------------------------------- */

.tab-buttons {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.tab-button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

@media (hover: hover) {
  .tab-button:hover {
    color: var(--text);
  }
}

.tab-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-ui), 0 1px 2px rgba(16, 24, 40, 0.08);
}

.tab-button:focus-visible {
  outline-offset: 1px;
}

.tab-content {
  display: none;
  margin-top: 16px;
}

.tab-content.active {
  display: block;
}

.scanner-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.scanner-stack > .page-head {
  margin-bottom: 4px;
}

.scanner-settings {
  margin-bottom: 12px;
}

.scanner-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: #10151f;
}

#video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#canvas {
  display: none;
}

.scanner-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border: 40px solid rgba(16, 21, 31, 0.45);
  pointer-events: none;
}

.scanner-region {
  position: absolute;
  top: 40px;
  right: 40px;
  bottom: 40px;
  left: 40px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  pointer-events: none;
}

.scanner-corners {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 4px solid #fff;
  pointer-events: none;
}

.corner-top-left { top: 40px; left: 40px; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.corner-top-right { top: 40px; right: 40px; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.corner-bottom-left { bottom: 40px; left: 40px; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.corner-bottom-right { bottom: 40px; right: 40px; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }

.scanner-container .status-indicator {
  position: absolute;
  left: 50%;
  bottom: 14px;
  max-width: calc(100% - 28px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transform: translateX(-50%);
}

.scanner-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.scanner-controls .btn {
  flex: 1 1 160px;
}

.image-preview-container {
  display: none;
  margin-top: 16px;
  text-align: center;
}

.image-preview {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.scan-file-btn {
  display: none;
  margin-top: 14px;
}

.camera-fallback h3 {
  font-size: 17px;
}

.camera-fallback p {
  margin: 4px 0 12px;
  color: var(--text-2);
}

.scan-result {
  display: none;
  border-color: var(--ok-border);
  box-shadow: 0 0 0 3px var(--ok-bg);
}

.scan-result h2 {
  margin-bottom: 10px;
}

/* Ergebnis als Zeilen „Bezeichnung  Wert“ (Bezeichnung links, umbrochene Werte bündig) */
#scanResultText {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-2);
}

#scanResultText:empty {
  display: none;
}

.scan-row {
  padding-left: 92px;
  text-indent: -92px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.scan-row > * {
  text-indent: 0;
}

/* 88 px + Leerzeichen ≈ 92 px Einzug: umbrochene Werte stehen bündig unter dem Wert */
.scan-key {
  display: inline-block;
  width: 88px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
}

.scan-name {
  font-size: 17px;
  font-weight: 700;
}

.scan-row-id:not(:first-child) {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.scan-id {
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 13px;
}

.scan-result .button-row .btn {
  flex: 1 1 200px;
}

/* 12e  Einstellungen -------------------------------------------------------- */

.admin-links {
  margin-bottom: 20px;
}

.admin-links-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}

.admin-links h3 {
  margin-bottom: 2px;
}

.admin-links p {
  color: var(--text-2);
}

.admin-links ul {
  padding: 0;
  list-style: none;
}

.tab-container .tab-buttons {
  margin-bottom: 16px;
}

.page-settings .tab-buttons {
  display: inline-flex;
  max-width: 100%;
}

.page-settings .tab-button {
  flex: 0 1 auto;
  padding: 8px 18px;
}

@media (max-width: 559.98px) {
  .page-settings .tab-buttons {
    display: flex;
  }

  .page-settings .tab-button {
    flex: 1 1 auto;
    padding: 8px 10px;
  }
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section h2 {
  margin-bottom: 14px;
}

.section .hint {
  margin-bottom: 16px;
}

.section-table {
  padding: 0;
  overflow: hidden;
}

.section-table h2 {
  margin: 0;
  padding: 18px 20px 14px;
}

.form-inline-submit {
  display: flex;
  align-items: flex-end;
}

/* Gespeicherte Autos am Handy: je Auto ein kompakter Block –
   Anzeigetext fett, darunter „Marke · Modell · Typ“, rechts der Mülleimer */
@media (max-width: 759.98px) {
  #autoTable.data-table[data-responsive] tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 2px;
  }

  #autoTable.data-table[data-responsive] td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
  }

  #autoTable.data-table[data-responsive] td::before {
    display: none;
  }

  #autoTable .auto-anzeige {
    order: 1;
    flex: 1 1 calc(100% - 60px);
    font-weight: 700;
    overflow-wrap: anywhere;
  }

  #autoTable.data-table[data-responsive] .action-cell {
    order: 2;
    flex: 0 0 44px;
    margin-left: 16px;
    padding: 0;
  }

  #autoTable .auto-marke,
  #autoTable .auto-modell,
  #autoTable .auto-typ {
    order: 3;
    color: var(--text-2);
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  #autoTable.data-table[data-responsive] .auto-modell::before,
  #autoTable.data-table[data-responsive] .auto-typ::before {
    content: "·";
    display: inline;
    margin: 0 6px;
    color: var(--text-2);
  }

  #autoTable.data-table[data-responsive] td.auto-typ:empty {
    display: none;
  }

  #autoTable.data-table[data-responsive] .action-cell .btn {
    width: 44px;
    flex: none;
    padding: 0;
  }

  #autoTable .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  #autoTable.data-table[data-responsive] td[colspan] {
    flex: 1 1 100%;
    padding: 16px 0;
    text-align: center;
  }
}

/* 12f  Benutzerverwaltung ------------------------------------------------- */

.user-table td:first-child {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.user-table td:nth-child(2) {
  font-weight: 600;
}

/* Desktop (ab 1200 px): die Tabelle passt ganz in die Karte – Kopfzeilen und
   Datum/Uhrzeit dürfen umbrechen, Abstände etwas enger */
@media (min-width: 1200px) {
  .user-table th,
  .user-table td {
    padding-left: 12px;
    padding-right: 12px;
  }

  .user-table th {
    white-space: normal;
  }

  .user-table td:nth-child(6),
  .user-table td:nth-child(7) {
    min-width: 104px;
    font-variant-numeric: tabular-nums;
  }

  .user-table th:first-child,
  .user-table td:first-child {
    padding-left: 18px;
  }

  .user-table th:last-child,
  .user-table td:last-child {
    padding-right: 18px;
  }
}

/* Tablet und Handy (unter 1200 px): jeder Zugang als eigene Karte – nichts wird
   abgeschnitten, Bearbeiten und Löschen sind immer sichtbar. Spaltennamen aus data-label. */
@media (max-width: 1199.98px) {
  .users-card {
    padding: 0;
    overflow: visible;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .users-card .table-wrap {
    overflow: visible;
  }

  .user-table.data-table[data-responsive] thead {
    display: none;
  }

  .user-table.data-table[data-responsive],
  .user-table.data-table[data-responsive] tbody {
    display: block;
    width: 100%;
  }

  .user-table.data-table[data-responsive] tbody {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr));
    gap: 14px;
  }

  .user-table.data-table[data-responsive] tr {
    display: flex;
    flex-direction: column;
    width: auto;
    min-width: 0;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .user-table.data-table[data-responsive] td {
    display: grid;
    grid-template-columns: minmax(112px, 40%) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: auto;
    padding: 5px 0;
    border: 0;
    text-align: left;
    background: none;
  }

  .user-table.data-table[data-responsive] td::before {
    content: attr(data-label);
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 600;
  }

  .user-table.data-table[data-responsive] td > * {
    justify-self: start;
  }

  /* Die interne ID braucht hier niemand; der Benutzername ist der Titel der Karte */
  .user-table.data-table[data-responsive] td:first-child {
    display: none;
  }

  .user-table.data-table[data-responsive] td:nth-child(2) {
    display: block;
    margin-bottom: 6px;
    padding-top: 0;
    font-size: 17px;
    font-weight: 700;
    overflow-wrap: anywhere;
  }

  .user-table.data-table[data-responsive] td:nth-child(2)::before {
    display: none;
  }

  .user-table.data-table[data-responsive] .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    white-space: normal;
  }

  .user-table.data-table[data-responsive] .action-buttons::before {
    display: none;
  }

  .user-table.data-table[data-responsive] .action-buttons .btn {
    flex: 1 1 0;
    margin: 0;
  }
}

/* 12g  Willkommen, Login, Nicht gefunden ---------------------------------- */

.auth-shell {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px max(var(--page-x), env(safe-area-inset-right)) 40px max(var(--page-x), env(safe-area-inset-left));
}

.page-login .auth-shell,
.page-welcome .auth-shell {
  min-height: 100vh;
}

.page-welcome .auth-shell {
  min-height: calc(100vh - 64px);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  text-align: center;
}

.auth-brand h1 {
  font-size: 24px;
}

.auth-brand h2 {
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
}

.auth-card .btn-block {
  margin-top: 6px;
}

.auth-card .error-message {
  margin-top: 14px;
}

.auth-card .hint {
  margin-top: 20px;
  font-size: 14px;
  text-align: center;
}

/* Anmeldung mit dem MoreTime-Konto: Meldung über dem Knopf, Trennlinie zu den Gerätekonten */
.auth-card .auth-message {
  margin: 0 0 16px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 18px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.welcome-card {
  width: 100%;
  max-width: 620px;
  padding: 40px 36px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.welcome-card h1 {
  margin: 18px 0 12px;
  font-size: 32px;
}

.welcome-card .description {
  max-width: 500px;
  margin: 0 auto;
  color: var(--text-2);
  font-size: 17px;
  line-height: 1.6;
}

.feature-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

/* Schlichte Liste mit Symbolen (keine Kacheln – sie sähen wie Knöpfe aus) */
.feature-list li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.feature-list .icon {
  width: 24px;
  height: 24px;
  color: var(--accent-ink);
}

.welcome-card .button-container {
  margin-top: 28px;
}

.welcome-card .button-container .btn {
  min-width: 220px;
}

.welcome-card .hint {
  margin-top: 14px;
  font-size: 14px;
}

.footer {
  padding: 20px var(--page-x) calc(20px + var(--safe-bottom));
  color: var(--text-2);
  font-size: 14px;
  text-align: center;
}

.notfound-card {
  width: 100%;
  max-width: 560px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.notfound-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--warn-bg);
  color: var(--warn);
}

.notfound-icon .icon {
  width: 30px;
  height: 30px;
}

.notfound-card h1 {
  margin-bottom: 10px;
  font-size: 24px;
}

.notfound-card p {
  color: var(--text-2);
}

.notfound-card p + p {
  margin-top: 10px;
}

.notfound-card .id {
  display: inline-block;
  max-width: 100%;
  margin-top: 14px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.notfound-card .links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 559.98px) {
  .auth-card,
  .notfound-card {
    padding: 26px 20px;
  }

  .welcome-card {
    padding: 30px 20px;
  }

  .welcome-card h1 {
    font-size: 28px;
  }

  /* Untereinander, als Block mittig, Text linksbündig neben dem Symbol */
  .feature-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: fit-content;
    max-width: 100%;
    margin: 24px auto 0;
  }

  .feature-list li {
    flex-direction: row;
    gap: 12px;
    padding: 0;
    text-align: left;
  }

  .notfound-card .links .btn,
  .welcome-card .button-container .btn {
    width: 100%;
  }
}

/* 12h  Druckseiten --------------------------------------------------------
   Nur die Bildschirm-Ansicht ist gestaltet (@media screen). Die Druckregeln des
   Etiketts (150 × 100 mm) stehen unverändert in print-etikett.html. */

.print-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media screen {
  .page-print-etikett {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 24px var(--page-x) 40px;
  }

  .page-print-etikett .print-header {
    margin-bottom: 18px;
  }

  .page-print-etikett h1 {
    font-size: 22px;
    text-align: center;
  }

  .page-print-etikett .etikett-container {
    max-width: 100%;
    margin: 20px 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .page-print-etikett #etikettImage {
    display: block;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.2);
  }

  .page-print-etikett .status-message {
    width: 100%;
    max-width: 500px;
  }

  .page-print-etikett .button-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
  }

  .page-print-etikett .button-container .btn {
    min-width: 150px;
  }

  .page-print-pdf .print-header {
    justify-content: center;
    margin-bottom: 14px;
  }

  .page-print-pdf h1 {
    font-size: 22px;
  }

  .page-print-pdf .pdf-container {
    overflow: hidden;
    border-color: var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .page-print-pdf iframe {
    display: block;
    border: 0;
  }

  .page-print-pdf .print-note {
    margin-bottom: 14px;
    color: var(--text-2);
  }

  .page-print-pdf .button-row {
    justify-content: center;
  }

  .page-print-pdf #printSuccessMessage {
    max-width: 500px;
    margin: 10px auto 0;
  }

  .page-print-pdf.minimal-mode .pdf-container {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  /* Handy: Knöpfe über die ganze Breite (wie auf den App-Seiten) */
  @media (max-width: 559.98px) {
    .page-print-etikett .button-container {
      align-self: stretch;
    }

    .page-print-etikett .button-container .btn {
      flex: 1 1 140px;
      min-width: 0;
    }

    .page-print-pdf .button-row {
      flex-direction: column;
    }

    .page-print-pdf .button-row .btn {
      width: 100%;
    }
  }
}

/* Grundlayout der PDF-Seite wie bisher (gilt auch beim Drucken der Seite selbst) */
.page-print-pdf {
  margin: 0;
  padding: 20px;
  text-align: center;
}

.page-print-pdf .container {
  max-width: 800px;
  margin: 0 auto;
}

.page-print-pdf .pdf-container {
  width: 100%;
  height: 600px;
  margin: 20px auto;
  border: 1px solid #ddd;
}

.page-print-pdf .print-actions {
  margin: 20px 0;
}

#printSuccessMessage {
  display: none;
}

.minimal-mode .no-print {
  display: none;
}

.minimal-mode .container {
  padding: 0;
  margin: 0;
}

.minimal-mode .pdf-container {
  margin: 0;
  height: 100vh;
}

/* 13  Hilfsklassen, Bewegung, Druck -------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1099.98px) {
  .label-desktop {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
}

.text-muted {
  color: var(--text-2);
}

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

  /* Lade-Kreisel drehen weiter (sonst fehlt die Rückmeldung), nur langsamer */
  .loading,
  .btn-busy:disabled::after {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}

@media print {
  /* Weißer Grund, auch wenn im Druckdialog „Hintergrundgrafiken“ an ist */
  html,
  body {
    background: #fff !important;
  }

  .no-print,
  .app-header,
  .tabbar,
  .sheet,
  .toast-region,
  .skip-link,
  .edit-controls {
    display: none !important;
  }
}
