/* StAN-Explorer 2.0 — App-Chrome. Neutral & white-label-fähig.
   Farben kommen aus Branding-Variablen (--brand-*) mit Fallbacks. */

:root {
  --primary: var(--brand-primary, #f68e13);
  --accent:  var(--brand-accent, #f68e13);
  --bg:      var(--brand-bg, #f0f2f7);
  --text:    var(--brand-text, #1a2235);
  --card:    #ffffff;
  --line:    #d8dee9;
  --muted:   #6b7280;
  --green:   #16a34a;
  --danger:  #b91c1c;
  --danger-bg: #fff5f5;
  --radius:  4px;
  --shadow:  0 1px 4px rgba(0, 0, 0, .07);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  flex-wrap: nowrap;
  position: relative;
}
/* Burger — nur sichtbar, wenn die Navigation nicht in eine Reihe passt */
.nav-burger {
  display: none; flex: 0 0 auto;
  width: 38px; height: 38px; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text);
  cursor: pointer; padding: 0;
}
.nav-burger:hover { border-color: var(--accent); color: var(--accent); }
.app-header.nav-collapsed .nav-burger { display: inline-flex; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
}
.brand-logo { height: 34px; width: auto; display: block; }
.brand-logo-emoji { font-size: 28px; line-height: 1; }
.brand-name { letter-spacing: -.01em; }

.app-nav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: nowrap; overflow: hidden; min-width: 0; }
.app-nav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.app-nav a:hover { background: var(--bg); color: var(--text); }
.app-nav a.cur { background: var(--bg); color: var(--text); box-shadow: inset 0 -2px 0 var(--primary); }
/* Piktogramme in der Navigation */
.nav-ico { width: 18px; height: 18px; flex: 0 0 auto; object-fit: contain; display: block; }
.um-ico  { width: 17px; height: 17px; flex: 0 0 auto; object-fit: contain; vertical-align: -3px; margin-right: 7px; }
/* Eingeklappt: Navigation als Dropdown unter dem Burger */
.app-header.nav-collapsed .app-nav {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
  flex: none; flex-direction: column; overflow: visible; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-top: none;
  box-shadow: 0 10px 24px rgba(0,0,0,.14); padding: 6px; display: none;
}
.app-header.nav-collapsed .app-nav.open { display: flex; }
.app-header.nav-collapsed .app-nav a { padding: 10px 12px; }

.app-user { display: flex; align-items: center; gap: 10px; position: relative; flex: 0 0 auto; margin-left: auto; }
.user-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  max-width: 40vw;
}
.user-btn:hover { border-color: var(--accent); }
.user-btn .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-caret { flex: 0 0 auto; opacity: .7; }
.user-menu {
  position: absolute; top: 100%; right: 0; margin-top: 6px; min-width: 230px; z-index: 60;
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 12px 28px rgba(0,0,0,.16); padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.user-menu[hidden] { display: none; }
.um-head { display: flex; flex-direction: column; gap: 7px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.um-name { font-weight: 700; font-size: 14px; }
.um-head .user-role { align-self: flex-start; }
.um-item {
  display: block; width: 100%; text-align: left; box-sizing: border-box;
  padding: 9px 10px; border: none; background: none; border-radius: 6px;
  font: inherit; font-size: 14px; color: var(--text); text-decoration: none; cursor: pointer;
}
.um-item:hover { background: var(--bg); }
.um-danger { color: #b91c1c; }
.um-form { margin: 0; }
/* Hilfe-Fragezeichen im Header */
.help-toggle {
  width: 24px; height: 24px; flex: 0 0 24px;
  border: 1px solid var(--line); border-radius: 50%;
  background: #fff; color: var(--muted);
  font-size: 13px; font-weight: 800; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.help-toggle:hover { border-color: var(--accent); color: var(--accent); }
/* Hilfe-Modal */
.help-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; overflow: auto;
}
.help-overlay[hidden] { display: none; }
.help-dialog {
  background: #fff; color: var(--text);
  width: 100%; max-width: 640px;
  border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.help-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.help-head h2 { font-size: 17px; margin: 0; }
.help-close {
  border: none; background: none; cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--muted); padding: 0 4px;
}
.help-close:hover { color: var(--text); }
.help-body { padding: 16px 18px 20px; font-size: 14px; line-height: 1.6; }
.help-body h3 { font-size: 14px; margin: 16px 0 6px; }
.help-body ol, .help-body ul { padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }
.help-body p { margin-bottom: 6px; }
.user-name { font-weight: 600; }
.user-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}
.role-admin { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.role-redakteur { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

.logout-form { display: inline; }

/* ── Main / Footer ──────────────────────────────────────── */
.app-main { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 24px 20px 48px; }
.app-main > h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 20px; }
.app-main-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}
/* Ansichtsseite ohne App-Header: dichter an die Oberkante (Tablet quer). */
.app-main-bare { padding-top: 12px; }
/* Ansichtsseite: Kopfleiste normalerweise aus (Tablet/Handy — mehr Platz),
   auf großen Monitoren aber sichtbar und beim Scrollen oben stehen bleibend. */
body.is-view .app-header { display: none; }
@media (min-width: 1200px) {
  body.is-view .app-header { display: flex; position: sticky; top: 0; z-index: 50; }
  body.is-view .app-main-bare { padding-top: 20px; }
}
.app-footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.app-footer a { color: var(--muted); text-decoration: underline; }
.app-footer a:hover { color: var(--text); }

/* ── Karten & Buttons ───────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 16px; font-weight: 800; margin-bottom: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 4px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, background .15s;
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(.94); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(.94); }

/* ── Formulare ──────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=color],
.field input[type=number],
.field input[type=url],
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
.field input[type=color] { height: 44px; padding: 4px; cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Flash-Meldungen ────────────────────────────────────── */
.flash {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  font-weight: 600;
}
.flash-ok { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.flash-err { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.flash-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ── Login ──────────────────────────────────────────────── */
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 32px;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  text-align: center;
}
.login-brand .brand-logo { height: 48px; }
.login-brand .brand-logo-emoji { font-size: 44px; }
.login-brand h1 { font-size: 20px; font-weight: 800; }

/* ── Katalog ────────────────────────────────────────────── */
.catalog-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.catalog-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.catalog-search {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  min-width: 200px;
  background: #fff;
  color: var(--text);
}
.filter-chip {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.entity-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.entity-media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
/* „außer Dienst"-Badge (Kalender: aktuell nicht verfügbar) */
.entity-oos {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  background: #dc2626; color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; letter-spacing: .02em;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
/* Ampel je Fahrzeug/Gerät */
.entity-light {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.entity-light.light-green  { background: #24a148; }
.entity-light.light-yellow { background: #f1c21b; }
.entity-light.light-red    { background: #da1e28; }
/* Historie/Protokoll-Symbol unten rechts auf der Kachel */
.entity-hist {
  position: absolute; bottom: 10px; right: 10px; z-index: 2;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.94); color: #1f2b45;
  border: 1px solid rgba(0,0,0,.18); border-radius: 8px;
  box-shadow: 0 1px 5px rgba(0,0,0,.25); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.entity-hist:hover { background: #fff; border-color: var(--accent); color: var(--accent); }
.entity-hist:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.entity-hist.entity-hist-off { opacity: .4; cursor: default; color: #9ca3af; }
.entity-hist.entity-hist-off:hover { background: rgba(255,255,255,.94); border-color: rgba(0,0,0,.18); color: #9ca3af; }
.light-form { display: inline-flex; align-items: center; }
.light-select { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.light-select select { font: inherit; font-size: 12px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); color: var(--text); }
.entity-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.entity-typeicon { width: 96px; height: 72px; object-fit: contain; }
.entity-link { display: block; text-decoration: none; color: inherit; }
.entity-card:hover { border-color: var(--muted); box-shadow: 0 2px 10px rgba(0, 0, 0, .10); }
.entity-name { font-weight: 800; font-size: 16px; padding: 14px 16px 2px; }
/* Steckbrief-Kachel: Langname + KFZ-Kennzeichen */
.entity-subname {
  font-size: 13px; line-height: 1.35; color: var(--muted); padding: 0 16px 8px;
  /* Immer exakt 2 Zeilen hoch, damit Funkrufname/Kennzeichen auf allen Karten fluchten.
     min-height inkl. Padding (box-sizing: border-box); line-clamp kappt bei >2 Zeilen. */
  min-height: calc(2 * 1.35em + 8px);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.entity-callsign { font-size: 14px; font-weight: 600; padding: 0 16px 8px; }
.entity-callsign .cs-label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
@font-face {
  font-family: 'FE-Kennzeichen';
  src: url('../fonts/FE.TTF') format('truetype');
  font-weight: normal; font-style: normal; font-display: swap;
}
.cat-plate {
  position: relative;
  width: 150px; max-width: 100%;
  aspect-ratio: 857 / 217;
  margin: 2px 16px 14px;
  background: url('../icons/licenseplate.PNG') no-repeat center;
  background-size: 100% 100%;
  container-type: inline-size;
}
.cat-plate span {
  position: absolute; top: 0; bottom: 0; left: 17.5%; right: 3.5%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'FE-Kennzeichen', 'Arial Narrow', sans-serif;
  font-size: min(13cqw, 26px); line-height: 1;
  letter-spacing: .03em; text-transform: uppercase; color: #111;
}

/* ── Viewer-Steckbrief-Kopf (kompakt, passt mit Bild auf Tablet-Querformat) ── */
.view-steckbrief {
  display: flex; gap: 10px 14px; align-items: center;
  background: var(--card, #fff); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; flex-wrap: wrap;
}
.view-photo { flex: 0 0 84px; max-width: 100%; }
.view-photo img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); display: block;
}
.view-ident { flex: 1 1 240px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; }
.view-ident > * { flex: 0 0 auto; }
/* Kennzeichen + Status als Gruppe rechts im Steckbrief-Kopf */
.view-meta { flex: 0 0 auto; margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.view-status { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.view-status-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.view-status .entity-light { position: static; top: auto; right: auto; width: 14px; height: 14px; box-shadow: none; border-width: 2px; }
.view-name { font-size: 17px; font-weight: 800; margin: 0; flex: 1 1 100%; }
.view-sub { font-size: 13px; color: var(--muted); flex: 1 1 100%; margin: -2px 0 4px; }
.view-facts { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0; }
.view-fact { font-size: 14px; font-weight: 600; }
.view-fact .vf-label { display: block; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.view-plate { width: 150px; margin: 0; }
.view-notes-body { font-size: 14px; line-height: 1.6; }
.view-notes-body ul, .view-notes-body ol { padding-left: 22px; }
.view-doc-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.view-viewer { margin-top: 6px; }
/* 360°-Slider ausblenden — greift auch für bereits gespeicherte render.html (nur Pfeile). */
.view-viewer #v360-track { display: none !important; }
.view-viewer #v360-controls { justify-content: center !important; }

/* 360°-Steuerung als Overlay unten rechts IM Bild (Pfeile + Haus zum Dashboard) */
.v360-oc {
  position: absolute; right: 12px; bottom: 12px; z-index: 6;
  display: flex; align-items: center; gap: 8px;
}
.v360-oc #v360-prev,
.v360-oc #v360-next,
.v360-oc .v360-oc-home {
  width: 42px; height: 42px; margin: 0; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.94); border: 1px solid rgba(0,0,0,.18);
  border-radius: 9px; color: #1f2b45; cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.30);
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.v360-oc #v360-prev:hover,
.v360-oc #v360-next:hover,
.v360-oc .v360-oc-home:hover {
  background: #fff; border-color: var(--accent); color: var(--accent);
}
.v360-oc #v360-prev:active,
.v360-oc #v360-next:active,
.v360-oc .v360-oc-home:active { transform: translateY(1px); }
.v360-oc .v360-oc-home { margin-left: 4px; }
/* Hilfe-Button oben rechts im Bild (aus der unteren Leiste herausgelöst). */
.v360-help-tr {
  position: absolute; top: 12px; right: 12px; z-index: 6;
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.94); border: 1px solid rgba(0,0,0,.18);
  border-radius: 9px; color: #1f2b45; cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.30);
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.v360-help-tr:hover { background: #fff; border-color: var(--accent); color: var(--accent); }
.v360-help-tr:active { transform: translateY(1px); }

/* WOLKE(N)-Buttonreihe: unten links im Bild (Desktop-Overlay). Anzeige (display) schaltet JS. */
.view-viewer .wolke-strip {
  position: absolute; left: 12px; bottom: 12px; z-index: 6;
  flex-direction: row; gap: 8px; align-items: center;
  max-width: calc(100% - 24px); overflow: auto; padding: 2px;
}
/* Handy: Steuer- und WOLKE(N)-Buttons unter das Bild (in die Leiste unter der Stage). */
.view-viewer .v360-oc.v360-below,
.view-viewer .wolke-strip.v360-below {
  position: static; left: auto; right: auto; top: auto; bottom: auto;
  transform: none; max-width: 100%; justify-content: center;
}
.view-viewer .wolke-strip.v360-below { margin: 4px auto 0; width: 100%; }

/* Lade-Kreis: lädt beim Aufruf alle 360°-Frames, bevor der Viewer freigegeben wird */
.v360-preload {
  position: absolute; inset: 0; z-index: 7;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(255,255,255,.92); transition: opacity .45s ease;
}
.v360-preload.v360-preload-gone { opacity: 0; pointer-events: none; }
.v360-preload-spin {
  width: 42px; height: 42px; border: 3px solid rgba(0,0,0,.10);
  border-top-color: var(--accent); border-radius: 50%;
  animation: v360plspin .8s linear infinite;
}
@keyframes v360plspin { to { transform: rotate(360deg); } }
.v360-preload-txt { font-size: 12px; color: var(--muted); letter-spacing: .04em; }

/* Dezente, dauerhaft sichtbare Umrisse der klickbaren Polygone — greift auch für
   bereits gespeicherte render.html (höhere Spezifität schlägt das eingebettete !important). */
.view-viewer #v360-svg .hs {
  fill: rgba(255,140,0,.06) !important;
  stroke: rgba(255,140,0,.7) !important;
  stroke-width: 2.5px !important;
  stroke-dasharray: 6 4 !important;
}
/* Schwarzen Fokus-Rahmen des Hotspot-Ankers entfernen (Highlight bleibt über die Füllung). */
.view-viewer #v360-svg a,
.view-viewer #v360-svg a:focus,
.view-viewer #v360-svg a:focus-visible { outline: none !important; }
.view-viewer .spa .spp {
  fill: rgba(255,140,0,.06);
  stroke: rgba(255,140,0,.7);
  stroke-width: 2.5px;
  stroke-dasharray: 6 4;
}
.view-viewer .spa .spp.done {
  stroke: rgba(0,160,0,.6);
}

/* ── QR-Scanner-Modal ── */
.qrscan-overlay { position: fixed; inset: 0; z-index: 1200; background: rgba(15,23,42,.7); display: flex; align-items: center; justify-content: center; padding: 4vh 16px; }
.qrscan-overlay[hidden] { display: none; }
.qrscan-dialog { background: #111; color: #fff; width: 100%; max-width: 480px; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.qrscan-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.qrscan-head h3 { font-size: 16px; margin: 0; }
.qrscan-head .crop-close { border: none; background: none; color: #cbd5e1; font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.qrscan-head .crop-close:hover { color: #fff; }
.qrscan-stage { position: relative; background: #000; aspect-ratio: 1/1; max-height: 68vh; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.qrscan-stage video { width: 100%; height: 100%; object-fit: cover; }
.qrscan-status { padding: 12px 16px; font-size: 13px; text-align: center; color: #cbd5e1; }
@media (max-width: 600px){
  /* Steckbrief: Bild links, Text rechts daneben; Kennzeichen + Status in einer Zeile darunter. */
  .view-steckbrief { align-items: flex-start; gap: 8px 12px; }
  .view-photo { flex: 0 0 84px; }
  .view-ident { flex: 1 1 0; min-width: 0; align-items: flex-start; align-content: flex-start; }
  .view-name { font-size: 16px; }
  .view-meta { flex: 1 1 100%; margin-left: 0; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
  .view-status { align-items: flex-start; }
}
/* Typ-/Status-Badges an den unteren Kartenrand ziehen → direkt über die Buttons,
   dadurch liegen sie über alle Karten hinweg auf einer Linie (einheitlicher Look). */
.entity-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 0 16px; margin-top: auto; }
.entity-meta + .entity-actions { margin-top: 0; }
.badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--line);
}
.badge-draft { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge-published { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-type { background: var(--bg); color: var(--muted); }
.entity-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 16px 16px; margin-top: auto; }

/* ── Tabellen ───────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:hover td { background: var(--bg); }

.inline-actions { display: flex; gap: 6px; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty-state h2 { font-size: 18px; margin-bottom: 8px; color: var(--text); }

/* details/summary als sauberer Button (Benutzerverwaltung) */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 4px; }

/* ── Einstellungen ──────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* ── Einstellungen: Farbschema ──────────────────────────── */
.preset-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
/* Farben in gleichmäßigem Raster (gleicher Abstand) */
.color-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  align-items: start;
}
.color-row .field { margin-bottom: 0; }

/* ── Sticky Speichern-Leiste ────────────────────────────── */
.sticky-save {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -3px 14px rgba(0, 0, 0, .10);
  padding: 12px 20px;
}
.sticky-save[hidden] { display: none; }
.sticky-save-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.sticky-save-msg { flex: 1; font-weight: 600; }
body.has-sticky .app-main { padding-bottom: 96px; }

/* ── Einstellungen: Live-Vorschau ───────────────────────── */
.theme-preview {
  --tp-primary: var(--primary);
  --tp-accent: var(--accent);
  --tp-bg: var(--bg);
  --tp-text: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  background: var(--tp-bg);
  color: var(--tp-text);
}
.theme-preview .tp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.theme-preview .tp-logo {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 26px; padding: 0 8px;
  border: 1px dashed var(--line); border-radius: 4px;
  font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em;
}
.theme-preview .tp-title { font-weight: 800; color: var(--tp-text); flex: 1; }
.theme-preview .tp-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 5px;
  background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
}
.theme-preview .tp-body { padding: 16px; }
.theme-preview .tp-body p { margin-bottom: 12px; }
.theme-preview .tp-actions { display: flex; align-items: center; gap: 14px; }
.theme-preview .tp-btn-primary {
  background: var(--tp-primary); color: #fff;
  padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px;
}
.theme-preview .tp-hotspot {
  width: 40px; height: 40px; border-radius: 6px;
  background: color-mix(in srgb, var(--tp-accent) 35%, transparent);
  border: 2px solid var(--tp-accent);
}

@media (max-width: 700px) {
  .app-header { gap: 10px; padding: 10px 14px; }
}
/* Sehr schmal: Organisationsname ausblenden, nur Logo + Burger + Benutzer */
@media (max-width: 460px) {
  .app-header .brand-name { display: none; }
}

/* ── Fahrzeug-/Geräte-Historie (Protokoll-Seite) ── */
.hist-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.hist-title { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.hist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hist-item { display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.hist-item.hist-check { border-left-color: #24a148; }
.hist-item.hist-wolke { border-left-color: #3b82f6; }
.hist-item.hist-created { border-left-color: #6366f1; }
.hist-item.hist-loan { border-left-color: #f59e0b; }
.hist-item.hist-reset { border-left-color: #da1e28; }
.hist-when { flex: 0 0 132px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-body { flex: 1 1 auto; min-width: 0; }
.hist-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hist-badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.hist-badge-check { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.hist-badge-wolke { color: #1e40af; border-color: #bfdbfe; background: #eff6ff; }
.hist-badge-created { color: #3730a3; border-color: #c7d2fe; background: #eef2ff; }
.hist-badge-loan { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.hist-badge-reset { color: #991b1b; border-color: #fecaca; background: #fef2f2; }
.hist-user { font-weight: 600; font-size: 14px; }
.hist-count { font-size: 12px; color: var(--muted); }
.hist-count-warn { color: #b45309; font-weight: 600; }
.hist-measures { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.hist-measures li { margin: 2px 0; }
/* Werkzeugsuche: ganze Ergebniszeile klickbar */
.ts-row { cursor: pointer; }
.ts-row:hover > td { background: var(--bg); }
@media (max-width: 560px) { .hist-item { flex-direction: column; gap: 4px; } .hist-when { flex-basis: auto; } }
