/* =========================================================================
   Firma App - Design-System
   Ein einziges Stylesheet, keine Build-Tools, keine externen Abhängigkeiten.
   ========================================================================= */

:root {
  /* Marke */
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --brand-ring: rgba(37, 99, 235, .25);

  /* Neutral */
  --ink: #0f172a;
  --ink-soft: #1e293b;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --bg: #f6f8fb;
  --surface: #ffffff;

  /* Status */
  --ok: #059669;       --ok-bg: #ecfdf5;   --ok-line: #a7f3d0;
  --warn: #d97706;     --warn-bg: #fffbeb; --warn-line: #fde68a;
  --bad: #dc2626;      --bad-bg: #fef2f2;  --bad-line: #fecaca;
  --info: #0891b2;     --info-bg: #ecfeff;
  --violet: #7c3aed;   --violet-bg: #f5f3ff;

  /* Sidebar */
  --nav-bg: #0d1526;
  --nav-item: #94a3b8;
  --nav-item-hover: #e2e8f0;

  --r-xl: 18px;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, .14), 0 4px 12px rgba(15, 23, 42, .07);

  --nav-w: 240px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { flex: none; }
img { max-width: 100%; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 4px; }
.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* =========================================================================
   Layout
   ========================================================================= */

#app { min-height: 100%; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--nav-w);
  flex: none;
  background: linear-gradient(180deg, #111c33 0%, var(--nav-bg) 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 3px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.02em;
}
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .4);
}
.brand small { display: block; font-size: 10px; font-weight: 500; color: var(--muted-light); letter-spacing: .04em; text-transform: uppercase; }

.nav { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  padding: 18px 10px 6px; font-size: 10px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase; color: #64748b;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: var(--nav-item); font-weight: 500; font-size: 13.5px;
  cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: var(--nav-item-hover); text-decoration: none; }
.nav-item.active {
  background: linear-gradient(90deg, var(--brand), #3b82f6);
  color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}
.nav-item .badge-count {
  margin-left: auto; background: var(--bad); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
}
.nav-item.active .badge-count { background: rgba(255, 255, 255, .25); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 28px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid transparent;
  transition: border-color .2s, background .2s;
}
.topbar.stuck { border-color: var(--line); background: rgba(246, 248, 251, .88); backdrop-filter: blur(8px); }
.topbar h1 { font-size: 22px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.content { padding: 4px 28px 40px; flex: 1; }
.content.narrow { max-width: 900px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; position: relative;
  transition: background .13s, color .13s;
}
.icon-btn:hover { background: #fff; color: var(--ink); border-color: var(--line); }
.icon-btn .dot {
  position: absolute; top: 5px; right: 5px; min-width: 15px; height: 15px;
  border-radius: 999px; background: var(--bad); color: #fff;
  font-size: 9.5px; font-weight: 700; display: grid; place-items: center;
  padding: 0 3px; border: 2px solid var(--bg);
}

.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px;
  border-radius: 999px; cursor: pointer; border: 1px solid transparent;
}
.user-chip:hover { background: #fff; border-color: var(--line); }
.user-chip .name { font-weight: 600; font-size: 13px; line-height: 1.15; }

.avatar {
  width: 34px; height: 34px; border-radius: 999px; flex: none;
  display: grid; place-items: center; color: #fff;
  font-weight: 650; font-size: 12.5px; letter-spacing: .02em;
  background: var(--brand);
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

/* =========================================================================
   Karten
   ========================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { flex: 1; }
.card-body { padding: 18px 20px; }
.card-body.tight { padding: 8px 20px 14px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line-soft); }

.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }

/* Kennzahlen-Karte */
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 18px 20px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 12px;
  transition: transform .14s, box-shadow .14s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat .top { display: flex; align-items: flex-start; gap: 14px; }
.stat .tile {
  width: 46px; height: 46px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
}
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin-top: 2px; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat .link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; color: var(--brand); cursor: pointer;
}
.stat .link:hover { gap: 8px; }

.tile.blue { background: var(--brand-soft); color: var(--brand); }
.tile.green { background: var(--ok-bg); color: var(--ok); }
.tile.amber { background: var(--warn-bg); color: var(--warn); }
.tile.violet { background: var(--violet-bg); color: var(--violet); }
.tile.red { background: var(--bad-bg); color: var(--bad); }
.tile.cyan { background: var(--info-bg); color: var(--info); }
.tile.slate { background: var(--line-soft); color: var(--muted); }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, box-shadow .13s, transform .06s;
}
.btn:hover { background: var(--line-soft); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .28);
}
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn.soft:hover { background: #dbeafe; }
.btn.block { width: 100%; }
.btn.lg { padding: 13px 20px; font-size: 15px; border-radius: 12px; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* =========================================================================
   Badges
   ========================================================================= */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--line-soft); color: var(--muted); border: 1px solid transparent;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.badge.info { background: var(--brand-soft); color: var(--brand); border-color: #bfdbfe; }
.badge.violet { background: var(--violet-bg); color: var(--violet); }
.badge .dot-sm { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-bad { color: var(--bad); }

/* =========================================================================
   Tabellen & Listen
   ========================================================================= */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 10.5px; font-weight: 650;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted-light);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: #fafcff; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data.compact th, table.data.compact td { padding: 10px 9px; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 20px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; transition: background .1s;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: #fafcff; }
.list-item .title { font-weight: 600; font-size: 13.5px; }
.list-item .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.list-item .thumb {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--line-soft); color: var(--muted);
}

.empty {
  padding: 46px 20px; text-align: center; color: var(--muted);
}
.empty .ring {
  width: 56px; height: 56px; border-radius: 999px; margin: 0 auto 14px;
  background: var(--line-soft); display: grid; place-items: center; color: var(--muted-light);
}
.empty h3 { margin-bottom: 4px; color: var(--ink); }

/* =========================================================================
   Formulare
   ========================================================================= */

.field { margin-bottom: 15px; }
.field > label, .field-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 6px;
}
.field .help { font-size: 12px; color: var(--muted); margin: -2px 0 7px; }
.req { color: var(--bad); margin-left: 2px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color .13s, box-shadow .13s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
input::placeholder, textarea::placeholder { color: var(--muted-light); }
textarea { resize: vertical; min-height: 80px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px;
}
input:disabled, select:disabled, textarea:disabled { background: var(--line-soft); color: var(--muted); }

.input-group { position: relative; }
.input-group .suffix {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 12.5px; color: var(--muted); pointer-events: none;
}
.input-group input { padding-right: 46px; }

.search-box { position: relative; flex: 1; min-width: 180px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-light); }
.search-box input { padding-left: 36px; }

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

/* Auswahl-Optionen (Radio / Checkbox als Karten) */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: var(--r-md); cursor: pointer; background: var(--surface);
  transition: border-color .12s, background .12s;
  font-size: 14px;
}
.choice:hover { border-color: #cbd5e1; background: #fcfdff; }
.choice input { display: none; }
.choice .mark {
  width: 19px; height: 19px; border-radius: 999px; flex: none;
  border: 2px solid var(--line); display: grid; place-items: center;
  transition: border-color .12s, background .12s;
}
.choice.box .mark { border-radius: 6px; }
.choice .mark svg { opacity: 0; color: #fff; }
.choice.selected { border-color: var(--brand); background: var(--brand-soft); }
.choice.selected .mark { background: var(--brand); border-color: var(--brand); }
.choice.selected .mark svg { opacity: 1; }
.choice.selected.tone-ok { border-color: var(--ok); background: var(--ok-bg); }
.choice.selected.tone-ok .mark { background: var(--ok); border-color: var(--ok); }
.choice.selected.tone-warn { border-color: var(--warn); background: var(--warn-bg); }
.choice.selected.tone-warn .mark { background: var(--warn); border-color: var(--warn); }
.choice.selected.tone-bad { border-color: var(--bad); background: var(--bad-bg); }
.choice.selected.tone-bad .mark { background: var(--bad); border-color: var(--bad); }

/* Prüfpunkt: i.O. / Mangel / n.z. */
.checkline {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.checkline:last-of-type { border-bottom: 0; }
.checkline .cl-label { flex: 1; font-size: 14px; }
.seg { display: inline-flex; background: var(--line-soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--muted); padding: 5px 11px; border-radius: 7px; cursor: pointer;
  transition: background .12s, color .12s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); box-shadow: var(--shadow-sm); }
.seg button.on[data-v=ok] { color: var(--ok); }
.seg button.on[data-v=minor] { color: var(--warn); }
.seg button.on[data-v=defect] { color: var(--bad); }
.seg button.on[data-v=na] { color: var(--muted); }

/* Tabs */
.tabs {
  display: inline-flex; background: var(--line-soft); padding: 4px;
  border-radius: 11px; gap: 3px; overflow-x: auto; max-width: 100%;
}
.tabs button {
  border: 0; background: transparent; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

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

/* Fotos */
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.photo {
  width: 84px; height: 84px; border-radius: var(--r-md); overflow: hidden;
  position: relative; border: 1px solid var(--line); background: var(--line-soft);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border-radius: 999px; border: 0; background: rgba(15, 23, 42, .65); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.photo-add {
  width: 84px; height: 84px; border-radius: var(--r-md);
  border: 1.5px dashed var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--brand); font-size: 11px; font-weight: 600; cursor: pointer;
}
.photo-add:hover { border-color: var(--brand); background: var(--brand-soft); }

/* Dateiauswahl - statt des Standardfelds des Browsers, das englisch beschriftet ist */
.file-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 22px 18px; border: 1.5px dashed var(--line); border-radius: var(--r-md);
  background: var(--surface); cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.over { border-color: var(--brand); background: var(--brand-soft); }
.file-drop .ring {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 4px;
}
.file-drop .t { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.file-drop .n { font-size: 12px; color: var(--muted); }
.file-drop.filled { border-style: solid; border-color: var(--ok-line); background: var(--ok-bg); }
.file-drop.filled .ring { background: #fff; color: var(--ok); }

/* Unterschrift */
.sign-pad {
  border: 1.5px dashed var(--line); border-radius: var(--r-md);
  background: var(--surface); touch-action: none; width: 100%; height: 160px; display: block;
}

/* =========================================================================
   Wizard (Formular ausfüllen)
   ========================================================================= */

.wizard { max-width: 720px; margin: 0 auto; }
.wizard-head {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: 16px 0 12px; margin-bottom: 4px;
}
.progress { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #3b82f6);
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
}
.wizard-foot {
  display: flex; gap: 10px; position: sticky; bottom: 0;
  background: linear-gradient(180deg, rgba(246, 248, 251, 0), var(--bg) 35%);
  padding: 16px 0 20px;
}
.wizard-foot .btn { flex: 1; }

/* =========================================================================
   Modal, Drawer, Toast
   ========================================================================= */

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }

.modal {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 14px; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 4px 22px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 22px; border-top: 1px solid var(--line-soft);
}

.toasts {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 16px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); font-size: 13.5px;
  animation: rise .22s cubic-bezier(.2, .8, .3, 1);
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--bad); }
.toast.info { border-left: 3px solid var(--brand); }
.toast .t-title { font-weight: 650; }

/* =========================================================================
   Login
   ========================================================================= */

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 500px at 15% -5%, #dbeafe 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 100%, #e0f2fe 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 410px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow-lg); padding: 34px 32px;
}
.auth-card .brand { padding: 0 0 22px; color: var(--ink); }
.auth-hint {
  margin-top: 18px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--brand-soft); color: #1e40af; font-size: 12.5px; line-height: 1.55;
}

/* =========================================================================
   Donut / Diagramme
   ========================================================================= */

.donut-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.donut { position: relative; width: 168px; height: 168px; flex: none; }
.donut .mid {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.donut .mid b { font-size: 30px; font-weight: 700; letter-spacing: -.03em; display: block; line-height: 1.1; }
.donut .mid span { font-size: 11.5px; color: var(--muted); }
.legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; }
.legend-row {
  display: flex; align-items: center; gap: 11px; padding: 11px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
}
.legend-row:last-child { border-bottom: 0; }
.legend-row b { font-size: 19px; font-weight: 700; min-width: 26px; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 12px; font-size: 13px; }
.bar-track { height: 9px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #60a5fa, var(--brand)); }

/* =========================================================================
   Detailseiten
   ========================================================================= */

.detail-head {
  display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap;
  padding: 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.detail-head .hero {
  width: 74px; height: 74px; border-radius: var(--r-lg); flex: none;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 16px 20px; }
.kv .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kv .v { font-size: 14px; font-weight: 600; margin-top: 2px; word-break: break-word; }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--line-soft); }
.tl-item:last-child { border-bottom: 0; }
.tl-item .tl-icon {
  width: 32px; height: 32px; border-radius: 999px; flex: none;
  display: grid; place-items: center; background: var(--line-soft); color: var(--muted);
}
.tl-item .tl-body { flex: 1; min-width: 0; }
.tl-item .tl-when { font-size: 11.5px; color: var(--muted-light); white-space: nowrap; }

.qr-box {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--line-soft);
}
.qr-box img { width: 132px; height: 132px; border-radius: var(--r-md); background: #fff; padding: 6px; }

/* =========================================================================
   Scanner
   ========================================================================= */

.scanner { position: fixed; inset: 0; background: #0b1220; z-index: 150; display: flex; flex-direction: column; }
.scanner-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px;
  color: #fff; font-weight: 650;
}
.scanner-head .icon-btn { color: #cbd5e1; }
.scanner-head .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; border-color: transparent; }
.scanner-view { flex: 1; position: relative; overflow: hidden; display: grid; place-items: center; }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; width: min(64vw, 260px); aspect-ratio: 1;
  border-radius: 20px; box-shadow: 0 0 0 100vmax rgba(11, 18, 32, .6);
}
.scan-frame i {
  position: absolute; width: 32px; height: 32px; border: 3px solid #4ade80;
}
.scan-frame i:nth-child(1) { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.scan-frame i:nth-child(2) { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.scan-frame i:nth-child(3) { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.scan-frame i:nth-child(4) { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.scanner-foot { padding: 20px 18px 28px; color: #cbd5e1; text-align: center; }
.scanner-foot .manual { margin-top: 14px; display: flex; gap: 8px; max-width: 340px; margin-inline: auto; }
.scanner-foot input { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); color: #fff; }
.scanner-foot input::placeholder { color: #64748b; }

/* =========================================================================
   Mobile
   ========================================================================= */

.mobile-nav { display: none; }
.mobile-header { display: none; }

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.split { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar { display: none; }

  /* Kopfzeile: Titelzeile oben, Aktionen darunter in einer eigenen Reihe */
  .topbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; row-gap: 10px; }
  .topbar h1 {
    font-size: 18px; line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .topbar .sub { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar #page-actions {
    order: 10; width: 100%; overflow-x: auto; gap: 8px;
    scrollbar-width: none;
  }
  .topbar #page-actions::-webkit-scrollbar { display: none; }
  .topbar #page-actions:empty { display: none; }
  .topbar #page-actions > .btn { flex: 1 0 auto; justify-content: center; }
  .user-chip { padding: 0; }
  .user-chip .col, .user-chip > svg { display: none; }
  .icon-btn { width: 34px; height: 34px; }
  .content { padding: 0 16px 92px; }
  .grid { gap: 14px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stat { padding: 14px; }
  .stat .value { font-size: 25px; }
  .stat .tile { width: 40px; height: 40px; border-radius: 11px; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .list-item { padding-left: 16px; padding-right: 16px; }
  table.data th, table.data td { padding: 10px; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; margin-top: auto; max-height: 92vh; }
  .overlay { padding: 0; align-items: flex-end; }
  .toasts { left: 16px; right: 16px; bottom: 86px; max-width: none; }

  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav button {
    flex: 1; border: 0; background: none; font-family: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; color: var(--muted-light); font-size: 10.5px; font-weight: 600;
    cursor: pointer; border-radius: 10px; position: relative;
  }
  .mobile-nav button.on { color: var(--brand); }
  .mobile-nav button .pip {
    position: absolute; top: 4px; right: 50%; margin-right: -16px;
    width: 7px; height: 7px; border-radius: 999px; background: var(--bad);
  }
  .wizard-foot {
    bottom: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: 14px;
  }
  .donut { width: 140px; height: 140px; }
  .bar-row { grid-template-columns: 96px 1fr 38px; }
}

/* Prüfpunkte auf schmalen Geräten untereinander statt nebeneinander */
@media (max-width: 560px) {
  .checkline { flex-wrap: wrap; gap: 8px; padding: 12px 0; }
  .checkline .cl-label { flex: 1 0 100%; font-size: 14px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1; padding: 8px 4px; font-size: 12px; }
}

@media (max-width: 420px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
}

/* Utility: Skeleton während des Ladens */
.skeleton {
  background: linear-gradient(90deg, var(--line-soft) 25%, #e9eef5 37%, var(--line-soft) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media print {
  .sidebar, .topbar, .mobile-nav, .btn { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* bp-connect: Logo als Bild */
.brand .logo { background: none; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; display: block; border-radius: inherit; }
