:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #d97706;
  --accent-dark: #b45309;
  --accent-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --nav-h: 64px;

  /* Flechen, die im dunklen Modus andere Werte brauchen (siehe Theme-Block am Ende) */
  --surface-2: #fafafa;   /* Tabellenkopf, Zeilen beim Ueberfahren */
  --line-strong: #d1d5db; /* Rand beim Ueberfahren */
  --warn-soft: #fef3c7;   /* Warnung: Grund (offline, Angebots-Badge) */
  --warn-line: #fde68a;
  --warn-bg: #fffbeb;     /* Report-Zeile in der Zeiterfassung */
  --warn-text: #92400e;
  --ok-soft: #dcfce7;     /* Badge "Report" */
  --ok-bg: #ecfdf3;       /* Drucker-Symbol: Angebot ist gedruckt */
  --ok-strong: #15803d;
  --danger-dark: #b91c1c;
  --chip-bg: #ffffff;     /* Hintergrund hinter der dunklen Wortmarke */
  --focus-ring: var(--accent-soft);
}

/* Eigene Farbwerte fuer native Elemente (Datumsfeld, Scrollbalken, Auswahl-Pfeile) */
:root { color-scheme: light; }
html[data-theme='dark'] { color-scheme: dark; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* Kacheln (table-wrap) duerfen die View nie ueberlaufen lassen */
}

.hidden { display: none !important; }
/* hidden-Attribute darf nie von display-Regeln ueberstimmt werden */
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none;
}
.brand-logo { height: 34px; width: auto; display: block; }
.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.topbar-user .icon-btn { width: 34px; height: 34px; }

/* ---------- Layout ---------- */
.view { padding: 16px; padding-bottom: calc(var(--nav-h) + 28px); max-width: 960px; margin: 0 auto; }

.bottomnav {
  position: fixed; bottom: env(safe-area-inset-bottom); left: 0; right: 0; z-index: 30;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
}

.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500;
}
.bottomnav a.active { color: var(--accent); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-title .icon { color: var(--accent); }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Breadcrumb ---------- */
.crumb { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-width: 0; }
.crumb-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer;
}
.crumb-btn:hover { background: var(--bg); }
.crumb-btn .icon { width: 16px; height: 16px; color: var(--accent); }
.crumb-sep { color: var(--muted); font-size: 14px; flex: none; }
/* Lange Namen werden gekürzt, damit die Breadcrumb eine Zeile bleibt:
   Text-Segmente schrumpfen mit Ellipse, der Button bleibt fix */
.crumb-site, .crumb-name { flex: 0 1 auto; min-width: 0; }
.crumb-name {
  font-size: 16px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb-site {
  font-size: 14px; font-weight: 600; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; cursor: pointer;
}
.crumb-site:hover { color: var(--text); }
.crumb-site > span {
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb-site .icon { width: 16px; height: 16px; color: var(--accent); flex: none; }
.crumb-name { font-size: 16px; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; border-radius: 10px; padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff;
  transition: background .15s;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-dark); }
.btn.sm { padding: 7px 12px; font-size: 13px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; transition: all .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.icon-btn:disabled { opacity: .5; cursor: default; }
/* gedruckte Tageszettel: Drucker-Button gruen */
.icon-btn.printed { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.print-frame { display: none; }

/* ---------- Paging (Tageszettel-Liste) ---------- */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.pager span { color: var(--muted); font-size: 13px; }
.pager .btn:last-child { margin-left: auto; }

/* ---------- Tageszettel: Auswahl + Aktionen ---------- */
.tz-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.tz-bar .count { color: var(--muted); font-size: 13px; margin-right: auto; }
/* Buttons nur mit Symbolen: Abstand zwischen zwei Icons */
.tz-bar .btn svg + svg { margin-left: 6px; }
.cell-check { width: 34px; text-align: center; }
.cell-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); z-index: 25;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 4px 14px rgba(217,119,6,.4);
  display: flex; align-items: center; justify-content: center;
}
.fab .icon { width: 24px; height: 24px; }
.fab:hover { background: var(--accent-dark); }

/* ---------- Search ---------- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px; margin-bottom: 14px; color: var(--muted);
}
.search-box input { border: none; outline: none; padding: 10px 0; flex: 1; font-size: 15px; background: transparent; color: var(--text); }

/* ---------- Card / Table ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; max-width: 100%; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td .cell-main { font-weight: 600; }
td .cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
.row-actions .icon-btn .icon { width: 16px; height: 16px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); color: var(--accent-dark);
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}

/* ---------- Expand / Details ---------- */
.cell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.row-thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none; background: var(--bg); }
/* Baustellenuebersicht: Bild und Anlegedatum links in der Zeile, ohne Bild ein Platzhalter */
.row-left { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.row-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row-thumb-empty { display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--muted); border: 1px solid var(--border); }
.row-thumb-empty .icon { width: 20px; height: 20px; }
#site-list .row-thumb { width: 40px; height: 40px; }
#site-list .row-thumb-empty .icon { width: 22px; height: 22px; }
/* Zeiterfassungs-Zusammenfassung rueckt unter den Namen, weil links das Bild steht */
#site-list .site-summary { padding-left: 48px; }
.cell-sub { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.cell-sub span { display: inline-flex; align-items: center; gap: 5px; }
.cell-sub .icon { width: 14px; height: 14px; flex: none; }
.entry-day { margin-bottom: 14px; }
.entry-day-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.entry-day-head .icon { width: 15px; height: 15px; flex: none; }
.entry-day-head .badge { margin-left: auto; }
.entry-day-head .day-pdf { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.entry-day-head .day-pdf .icon { width: 16px; height: 16px; }
.entry-report td { background: var(--warn-bg); }
.entry-report .cell-main { color: var(--warn-text); }
.expand-btn { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.expand-btn .icon { width: 16px; height: 16px; transition: transform .15s ease; }
.expand-btn.open .icon { transform: rotate(180deg); }
.cell-details { margin-top: 8px; padding: 8px 12px; background: var(--bg); border-radius: 8px; }
.detail-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); padding: 2px 0; }
.detail-line .dv { color: var(--text); font-weight: 500; text-align: right; word-break: break-word; }
.cell-details .row-actions { margin-top: 8px; }

/* ---------- Offline banner ---------- */
.offline-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--warn-soft); color: var(--warn-text);
  font-size: 13px; font-weight: 600;
  padding: 8px 14px;
  border-bottom: 1px solid var(--warn-line);
}
.offline-banner .icon { width: 16px; height: 16px; }
.badge.report { background: var(--ok-soft); color: var(--ok-strong); }
.badge.neutral { background: var(--bg); color: var(--muted); }

.empty {
  padding: 40px 20px; text-align: center; color: var(--muted);
}
.empty .icon { width: 40px; height: 40px; opacity: .4; margin-bottom: 10px; }

/* Site info card */
.info-card { position: relative; padding: 16px 16px 56px; margin-bottom: 14px; }
.info-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.info-head .icon-btn { width: 34px; height: 34px; }
/* "Neu" unten rechts im Feld, damit dafuer keine eigene Knopfzeile noetig ist */
.info-new { position: absolute; right: 14px; bottom: 12px; }
.info-card h2 { margin: 0 0 8px; font-size: 19px; }
.info-row { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 14px; margin-top: 6px; }
.info-row .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--accent); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.tabs a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 10px; border-radius: 9px; text-decoration: none;
  color: var(--muted); font-size: 14px; font-weight: 600;
}
.tabs a.active { background: var(--accent-soft); color: var(--accent-dark); }
.tabs .icon { width: 17px; height: 17px; }
/* Zahl am Reiter: nur Symbol + Anzahl, kein Text (erklaert der title-Tooltip) */
.tabs .tab-n { font-size: 12px; font-weight: 600; opacity: .75; }

/* ---------- Filter bar ---------- */
.user-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.user-row select { flex: 1; }
.add-user-row { margin-top: 2px; }
.filter-bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-bar select {
  flex: 1; min-width: 130px;
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-size: 14px; color: var(--text);
}
.filter-search { display: flex; flex: 2; min-width: 190px; }
.filter-search select { flex: 1; border-radius: 10px 0 0 10px; }
.filter-search input {
  width: 96px; flex: none;
  padding: 9px 10px; border: 1px solid var(--border); border-left: none;
  border-radius: 0 10px 10px 0; background: var(--surface); font-size: 14px; color: var(--text);
}
/* Suchfeld ueber einem Select (Modal) */
.field .select-search { margin-bottom: 6px; }

/* ---------- Sum bar ---------- */
.sum-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent-soft); color: var(--accent-dark);
  border-radius: 10px; padding: 10px 14px; margin-top: 12px;
  font-size: 14px; font-weight: 600;
}
.sum-bar .icon { width: 18px; height: 18px; }

/* ---------- Documents grid ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }

/* ---------- Ordner (Fotos/Videos & Dokumente) ---------- */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.folder-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow);
}
.folder-card:active { background: var(--bg); }
.folder-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.folder-icon { display: flex; color: var(--accent); flex: none; }
.folder-icon .icon { width: 20px; height: 20px; }
.folder-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-actions { display: flex; gap: 2px; flex: none; }
.folder-actions .icon-btn { width: 26px; height: 26px; border-radius: 6px; }
.folder-actions .icon-btn .icon { width: 14px; height: 14px; }
.folder-count { font-size: 12px; color: var(--muted); margin-top: 6px; }
.folder-crumbs {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  margin-bottom: 10px; font-size: 13px;
}
.folder-crumbs a { color: var(--accent-dark); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.folder-crumbs a .icon { width: 14px; height: 14px; }
.folder-crumbs .sep { color: var(--muted); }
.folder-crumbs .cur { font-weight: 600; }

/* ---------- Ordner-Suche ---------- */
.fs-results { margin-top: 10px; }
.fs-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--border);
}
.fs-row:last-child { border-bottom: none; }
.fs-icon { display: flex; color: var(--muted); flex: none; }
.fs-icon .icon { width: 18px; height: 18px; }
.fs-info { flex: 1; min-width: 0; }
.fs-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-path { font-size: 12px; color: var(--muted); }
/* ---------- Notizen im Auftrag ---------- */
.note-card { padding: 12px 14px; margin-bottom: 10px; }
.note-text { font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.note-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.note-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--muted); min-width: 0; }
.note-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.note-meta .icon { width: 13px; height: 13px; flex: none; }
.note-actions { display: flex; gap: 4px; flex: none; }

.doc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; position: relative; text-decoration: none; color: var(--text);
  display: block;
}
.doc-thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg);
}
.doc-open { cursor: zoom-in; }
/* "Play"-Symbol auf Video-Vorschaubildern der Galerie; Klicks gehen an die Karte */
.doc-play {
  position: absolute; top: 0; left: 0; width: 100%; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.doc-play .icon {
  width: 24px; height: 24px; padding: 5px; box-sizing: content-box;
  color: #fff; background: rgb(0 0 0 / .45); border-radius: 50%;
}
.doc-card.dragging { opacity: .5; }
.folder-card.drag-over { outline: 2px solid var(--accent); outline-offset: 2px; }
a.drag-over { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
/* Touch-Drag-Clone: folgt dem Finger. pointer-events: none, damit
   elementFromPoint die clone ueberspringt und das Ziel darunter findet. */
.touch-drag-clone {
  position: fixed; z-index: 1200; margin: 0;
  pointer-events: none; opacity: .9; box-shadow: 0 8px 24px rgb(0 0 0 / .35);
}
/* iOS: Langzeit-Tipp soll kein "Bild speichern"-Menue / Lupe ausloesen */
.doc-card img { -webkit-touch-callout: none; user-select: none; }
.doc-thumb-icon {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--muted);
}
.doc-thumb-icon .icon { width: 32px; height: 32px; }
.doc-name-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 6px 8px 0; }
.doc-name {
  font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted);
}
.doc-card .expand-btn { width: 24px; height: 24px; border-radius: 6px; }
.doc-card .expand-btn .icon { width: 14px; height: 14px; }
.doc-card .cell-details { margin: 0; border-radius: 0; padding: 4px 8px 8px; }
.doc-card .detail-line { font-size: 11px; }
.doc-card .row-actions .icon-btn { width: 28px; height: 28px; border-radius: 6px; }
.doc-card .row-actions .icon-btn .icon { width: 14px; height: 14px; }

.upload-row { display: flex; gap: 8px; margin-bottom: 4px; }
.upload-row .btn { flex: 1; }
.upload-hint { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

/* Upload-Fortschritt: fester Balken ueber der Navigation, weil er ein
   Neuladen von #view (Live-Update, Seitenwechsel) ueberstehen muss */
#upload-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 14px); z-index: 55;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: var(--shadow); font-size: 13px;
}
#upload-bar .ub-track { flex: 1; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
#upload-bar .ub-track i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
#upload-bar span { max-width: 46%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0;
  max-height: 92vh; display: flex; flex-direction: column;
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 0;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 18px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.modal-foot .btn { flex: 1; }
.scanner-foot { flex-direction: column; align-items: stretch; gap: 12px; }
.scanner-foot .field { margin: 0; }
.scanner-foot-btns { display: flex; gap: 10px; }
.scanner-foot-btns .btn { flex: 1; }

/* ---------- Dokument-Scanner ---------- */
.scanner-modal { max-width: 640px; }
.scanner-stage { position: relative; }
.shutter-btn {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  width: 58px; height: 58px; border-radius: 50%;
  border: 4px solid #fff; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.shutter-btn .icon { width: 26px; height: 26px; }
.shutter-btn:disabled { opacity: 0.5; }
#scanner-flash {
  position: absolute; inset: 0; background: #fff;
  opacity: 0; pointer-events: none; border-radius: 10px; z-index: 4;
}
#scanner-flash.flash { animation: scanner-flash 0.4s ease-out; }
@keyframes scanner-flash {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}
#scanner-video {
  display: block; width: 100%; height: auto;
  border-radius: 10px; background: #111;
}
#scanner-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; border-radius: 10px;
}
#scanner-camera { display: flex; flex-direction: column; gap: 10px; }
#scanner-canvas {
  width: 100%; height: auto; max-height: 50vh; object-fit: contain;
  display: block; border-radius: 10px; background: #fff;
}
#scanner-preview-row { display: flex; align-items: flex-start; gap: 10px; }
.scanner-badge {
  flex: none; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok-strong);
}
.scanner-badge.warn { background: var(--accent-soft); color: var(--accent-dark); }
.scanner-actions { display: flex; gap: 8px; margin-top: 10px; }
.scanner-actions .btn { flex: 1; }
.scanner-count { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 16px; }
}

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; color: var(--text); background: var(--surface);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.checkbox-field {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; cursor: pointer; margin-bottom: 14px;
}
.checkbox-field input { width: 20px; height: 20px; accent-color: var(--accent); }
.checkbox-field span { font-size: 14px; font-weight: 600; }
.wt-assign-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.wt-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; font-size: 14px;
}
.wt-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.mp-group { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---------- Auswahl-Modal (Angebot oder Auftrag anlegen) ---------- */
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-btn { justify-content: flex-start; }

/* ---------- Angebot: Positionen im Modal ---------- */
.q-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.q-row {
  display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 6px 8px; align-items: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.q-row .q-name { grid-column: 1 / -1; font-size: 13px; font-weight: 600; }
.q-num span { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.q-num input {
  width: 100%; padding: 9px 10px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
.q-sum { font-size: 13px; font-weight: 600; white-space: nowrap; }
.q-add { display: flex; align-items: flex-end; gap: 8px; }
.q-add .field { flex: 1; margin-bottom: 0; }
/* Auswahl-Feld mit Plus-Knopf daneben (neuer Kunde aus dem Angebots-Dialog) */
.pick-row { display: flex; align-items: flex-end; gap: 8px; }
.pick-row .field { flex: 1; }
.pick-row .icon-btn { flex: none; width: 45px; height: 45px; margin-bottom: 14px; }
/* klebt am unteren Rand des scrollenden Dialog-Inhalts, die Summe bleibt sichtbar */
.q-total {
  position: sticky; bottom: -14px; z-index: 1;
  display: flex; justify-content: space-between; gap: 10px;
  margin: 12px -18px -14px; padding: 12px 18px;
  background: var(--surface); border-top: 1px solid var(--border);
  font-size: 14px; font-weight: 600;
}

/* ---------- Einstellungen: Menu ---------- */
.menu-list { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 10px;
  text-decoration: none; color: var(--text);
}
.menu-item:hover { background: var(--bg); }
.menu-icon {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
}
.menu-icon .icon { width: 20px; height: 20px; }
.menu-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.menu-title { font-weight: 600; font-size: 15px; }
.menu-desc { font-size: 12px; color: var(--muted); }
.menu-item > .icon { width: 18px; height: 18px; color: var(--muted); flex: none; }

/* ---------- System-Einstellungen ---------- */
.settings-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 0; }
.settings-head .icon { color: var(--accent); }
.settings-head h3 { margin: 0; font-size: 16px; }
.settings-desc { padding: 0 16px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.info-list { padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.settings-card form { padding: 14px 16px 16px; }
.form-foot { display: flex; justify-content: flex-end; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 28px 24px;
}
.login-logo {
  margin: 0 auto 16px; max-width: 180px; text-align: center;
}
.login-logo img { max-width: 100%; height: auto; display: inline-block; }
.login-card h1 { text-align: center; font-size: 20px; margin: 0 0 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-err {
  background: var(--danger-soft); color: var(--danger);
  font-size: 13px; font-weight: 500; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px;
}
.login-card .btn { width: 100%; padding: 12px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 380px); }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #1f2937; color: #fff;
  border-radius: 12px; padding: 11px 14px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast .icon { width: 17px; height: 17px; color: #4ade80; }
.toast.err .icon { color: #f87171; }

/* ---------- Mobile table -> cards ---------- */
@media (max-width: 640px) {
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    border: 1px solid var(--border); border-radius: 12px;
    margin-bottom: 10px; background: var(--surface);
    box-shadow: var(--shadow); overflow: hidden;
  }
  .table-wrap td {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--border); padding: 10px 14px;
  }
  .table-wrap td:last-child { border-bottom: none; }
  .table-wrap td::before {
    content: attr(data-label);
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 600; flex: none;
  }
  .table-wrap td[data-expand-target] { display: block; }
  .table-wrap td[data-expand-target] .cell-head { width: 100%; }
}

/* ---------- Lightbox (Fotos/Videos im Vollbild) ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .95);
  display: flex; align-items: center; justify-content: center;
}
.lightbox .lb-stage { max-width: 100vw; max-height: 100vh; display: flex; align-items: center; justify-content: center; }
.lightbox img, .lightbox video { max-width: 100vw; max-height: 100vh; object-fit: contain; display: block; }
.lightbox .lb-close { position: absolute; top: 12px; right: 12px; z-index: 2; background: rgba(0, 0, 0, .5); color: #fff; border-color: transparent; }
.lightbox .lb-prev, .lightbox .lb-next {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  background: rgba(0, 0, 0, .4); color: #fff; border-color: transparent;
}
.lightbox .lb-prev { left: 10px; }
.lightbox .lb-next { right: 10px; }
.lightbox .lb-caption {
  position: absolute; bottom: 14px; left: 0; right: 0; z-index: 1;
  text-align: center; color: #fff; font-size: 14px; padding: 0 64px; pointer-events: none;
}
.lightbox .lb-counter { position: absolute; top: 16px; left: 16px; z-index: 2; color: #fff; opacity: .8; font-size: 13px; }
.lightbox iframe { width: 100vw; height: 100vh; border: 0; background: #fff; }
.lightbox .lb-fallback { display: flex; flex-direction: column; align-items: center; gap: 14px; color: #fff; padding: 0 24px; }
.lightbox .lb-fallback .lb-fallback-name { font-size: 15px; max-width: 80vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Darkmode ----------
   Der Modus steht als data-theme am <html>: ein bewusster Knopfwert ueberstimmt
   die Systemeinstellung, ohne Wert entscheidet das Betriebssystem. */
html[data-theme='dark'] {
  --bg: #12161d;
  --surface: #1b212b;
  --text: #e6e9ee;
  --muted: #9aa5b4;
  --accent: #e0870f;
  --accent-dark: #f7c67c;   /* Text auf akzentfarbigem Grund */
  --accent-soft: #3a2c17;
  --danger: #ef4444;
  --danger-soft: #3a1d1d;
  --danger-dark: #dc2626;
  --ok: #34d17a;
  --border: #2b323d;
  --shadow: 0 1px 3px rgba(0,0,0,.5), 0 6px 20px rgba(0,0,0,.4);

  --surface-2: #232a35;
  --line-strong: #3c4553;
  --warn-soft: #332913;
  --warn-line: #4a3a18;
  --warn-bg: #2b2413;
  --warn-text: #f0c674;
  --ok-soft: #1d3527;
  --ok-bg: #16281e;
  --ok-strong: #7ee2a0;
  --focus-ring: rgba(224,135,15,.3);
}

/* Wortmarke ist fast schwarz: im dunklen Modus heller Hintergrund hinter dem Logo */
html[data-theme='dark'] .brand-logo,
html[data-theme='dark'] .login-logo img { background: var(--chip-bg); border-radius: 8px; padding: 3px 8px; }
