:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #1b2230;
  --muted: #64708a;
  --border: #d9dfe9;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --in: #2e9e5b;
  --out: #d9532b;
  --danger: #c93a3a;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(20, 30, 60, 0.08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420;
    --surface: #182033;
    --surface-2: #212b42;
    --text: #e8ecf5;
    --muted: #97a3bd;
    --border: #2d3852;
    --accent: #4b8cf5;
    --in: #43b872;
    --out: #f0703f;
    --danger: #e35d5d;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 6px;
  font-weight: 700; font-size: 1.1rem; color: var(--accent); border-radius: 8px;
}
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: 0.95rem; flex: none;
}
.link { background: none; border: 0; color: var(--accent); padding: 4px 6px; font-weight: 500; text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 1.6rem; margin: 6px 0 4px; }
h2 { font-size: 1.25rem; margin: 18px 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }

/* Kacheln */
.tiles {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin-top: 16px;
}
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 150px; padding: 18px 12px; border: 2px solid transparent; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: 1.15rem; text-align: center;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.tile:hover { border-color: var(--accent); }
.tile:active { transform: scale(0.97); }
.tile .avatar { width: 64px; height: 64px; font-size: 1.6rem; }
.tile.add { border: 2px dashed var(--border); background: transparent; color: var(--muted); box-shadow: none; }
.tile.action { min-height: 190px; font-size: 1.35rem; }
.tile.action svg { width: 56px; height: 56px; }
.tile.action.in  { color: var(--in); }
.tile.action.out { color: var(--out); }
.tile.action.search { color: var(--accent); }
.tile.action.map { color: #8a5ad0; }
.tiles.actions { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile small { font-weight: 400; color: var(--muted); font-size: 0.9rem; }

/* Karten & Formulare */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-top: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 0.95rem; }
.field .hint { color: var(--muted); font-size: 0.85rem; }
input[type="text"], input[type="number"], input[type="search"], input[type="password"], input[type="url"], input[type="date"], textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; }
.loc-inputs { display: flex; gap: 8px; align-items: center; }
.loc-inputs input { text-align: center; font-weight: 700; font-size: 1.3rem; text-transform: uppercase; }
.loc-inputs .sep { color: var(--muted); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  font-weight: 600; min-height: 48px;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.in { background: var(--in); color: #fff; border-color: var(--in); }
.btn.out { background: var(--out); color: #fff; border-color: var(--out); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.big { width: 100%; font-size: 1.15rem; min-height: 58px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.back { margin-bottom: 8px; }

/* Ergebnisliste */
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  width: 100%; text-align: left; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface);
}
.item:hover { border-color: var(--accent); }
.item.empty-stock { opacity: 0.7; }
.loc {
  display: inline-grid; place-items: center; min-width: 58px; height: 52px; padding: 0 8px;
  border-radius: 10px; background: var(--surface-2); font-weight: 800; font-size: 1.15rem; letter-spacing: 0.5px;
}
.item .name { font-weight: 700; }
.item .meta { color: var(--muted); font-size: 0.88rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.item .desc { color: var(--muted); font-size: 0.9rem; }
.qty { font-weight: 800; font-size: 1.25rem; text-align: right; }
.qty small { display: block; font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; color: #fff; }
.tag.in { background: var(--in); }
.tag.out { background: var(--out); }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

/* Detail */
.detail-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.detail-head .loc { min-width: 80px; height: 72px; font-size: 1.6rem; }
.detail-head h1 { margin: 0; }
.stock { font-size: 1.05rem; margin-top: 4px; }
.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.history li:last-child { border-bottom: 0; }
.history .when { color: var(--muted); font-size: 0.85rem; text-align: right; white-space: nowrap; }

/* Menge-Stepper */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 52px; height: 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: 1.5rem; font-weight: 700; }
.stepper input { width: 90px; text-align: center; font-size: 1.4rem; font-weight: 700; }

/* Lagerplan */
.map-wrap { overflow: auto; margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.map { border-collapse: collapse; font-size: 0.8rem; }
.map th, .map td { border: 1px solid var(--border); min-width: 36px; height: 34px; text-align: center; padding: 0; }
.map th { background: var(--surface-2); position: sticky; font-weight: 700; }
.map thead th { top: 0; z-index: 2; }
.map tbody th { left: 0; z-index: 1; }
.map td button { width: 100%; height: 100%; border: 0; background: color-mix(in srgb, var(--accent) 22%, transparent); font-weight: 700; color: var(--text); }
.map td button:hover { background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 32px); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; }
.toast-action {
  flex: none; background: none; border: 2px solid currentColor; color: inherit; border-radius: 10px;
  padding: 6px 12px; font-weight: 700; font-size: 0.95rem;
}
.undo-link { font-size: 0.85rem; padding: 0 4px; }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tiles.actions { grid-template-columns: 1fr; }
  .tile { min-height: 130px; }
  .tile.action { min-height: 120px; flex-direction: row; justify-content: flex-start; padding-left: 22px; }
  .tile.action small { display: none; }
}

/* ---------- Erweiterung: Plätze, Scan, Etiketten ---------- */
.loc small { display: block; font-weight: 500; font-size: 0.65rem; letter-spacing: 0; color: var(--muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-link { border: 0; cursor: pointer; font-family: inherit; color: inherit; }
.loc-link:hover { outline: 2px solid var(--accent); }
.cat { display: inline-block; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-size: 0.8rem; font-weight: 700; margin-right: 6px; }
.tile.action.scan { color: #d0409a; }
details.card summary { cursor: pointer; }
.qr-box { text-align: center; flex: none; }
.qr-box svg { width: 110px; height: 110px; background: #fff; border-radius: 8px; padding: 4px; }
.qr-box .code { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: 1px; font-size: 0.9rem; margin-top: 4px; }

/* Scan */
.scan-layout { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 720px) { .scan-layout { grid-template-columns: 1fr; } }
.video-wrap { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-wrap video { width: 100%; height: 100%; object-fit: cover; }
.video-wrap .frame { position: absolute; inset: 15%; border: 3px solid rgba(255,255,255,0.8); border-radius: 14px; pointer-events: none; box-shadow: 0 0 0 999px rgba(0,0,0,0.25); }
.scan-status { font-size: 0.85rem; color: var(--muted); margin: 8px 2px; }
.scan-status.error { color: var(--danger); font-weight: 600; }
.manual { display: flex; gap: 8px; }
.manual input { flex: 1; text-transform: uppercase; }
.scan-state { border-left: 6px solid var(--border); }
.scan-state.mode-in { border-left-color: var(--in); }
.scan-state.mode-out { border-left-color: var(--out); }
.scan-state .mode-title { font-size: 1.15rem; margin-bottom: 6px; }
.scan-state p { margin: 8px 0; }
.howto { margin: 6px 0 0; padding-left: 0; list-style: none; }
.howto li { margin: 8px 0; }

/* Etiketten */
.label-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(7cm, 1fr)); gap: 0.4cm; margin-top: 10px; }
.label {
  display: grid; grid-template-columns: 3cm 1fr; gap: 0.3cm; align-items: center;
  height: 3.6cm; padding: 0.25cm; border: 1px dashed #999; border-radius: 4px; background: #fff; color: #000;
  break-inside: avoid; page-break-inside: avoid; overflow: hidden;
}
.label svg { width: 3cm; height: 3cm; }
.label .txt { min-width: 0; line-height: 1.2; }
.label .addr { font-size: 1.7rem; font-weight: 900; letter-spacing: 1px; }
.label .nm { font-weight: 700; font-size: 1rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.label .ct { font-size: 0.8rem; color: #444; }
.label .ds { font-size: 0.75rem; color: #666; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.label .cd { font-family: ui-monospace, monospace; font-size: 0.8rem; letter-spacing: 1px; margin-top: 2px; }
.label.blank .line { border-bottom: 1px solid #999; height: 0.8cm; }
.labels.small { grid-template-columns: repeat(auto-fill, minmax(5cm, 1fr)); }
.labels.small .label { grid-template-columns: 2cm 1fr; height: 2.5cm; }
.labels.small .label svg { width: 2cm; height: 2cm; }
.labels.small .label .addr { font-size: 1.2rem; }
.labels.small .label .nm { font-size: 0.8rem; }
.labels.small .label .ds { display: none; }

/* Auswertung */
.chip {
  padding: 8px 14px; min-height: 40px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-weight: 600; font-size: 0.9rem;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 12px 0 4px; }
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius); text-align: left;
  background: var(--surface); box-shadow: var(--shadow); border: 1px solid transparent; color: var(--text);
}
button.kpi:hover { border-color: var(--accent); }
.kpi-v { font-size: 1.7rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-v small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.kpi-l { font-size: 0.85rem; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.stats-grid .card { margin-top: 14px; }
.card-title { margin-top: 0; }
.card-title small, h2 small.hint { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; width: 100%;
  padding: 7px 6px; border: 0; border-radius: 8px; background: none; text-align: left; color: var(--text);
}
.bar-row:not(:disabled):hover { background: var(--surface-2); }
.bar-row:disabled { cursor: default; opacity: 1; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.bar-label small { color: var(--muted); font-weight: 500; }
.bar-track { height: 10px; }
.bar { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.bar-value small { color: var(--muted); font-weight: 500; }
.stale-list { display: flex; flex-direction: column; margin-top: 8px; }
.stale-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 6px; border: 0; border-bottom: 1px solid var(--border);
  background: none; text-align: left; color: var(--text);
}
.stale-row:hover { background: var(--surface-2); }
.stale-row .name { font-weight: 700; }
.stale-row .meta { grid-column: 1; color: var(--muted); font-size: 0.85rem; }
.stale-row .when { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.place-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.place-chips .chip { min-height: 34px; padding: 4px 10px; font-family: ui-monospace, monospace; }
/* Import-Vorschau */
.imp-summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; max-height: 50vh; }
.imp-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.imp-table th, .imp-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.imp-table th { position: sticky; top: 0; background: var(--surface-2); }
.tile.action.adm-transfer { color: #e0883d; }

/* Fotos */
.item-main { display: flex; gap: 12px; align-items: center; min-width: 0; }
.item-main > span { min-width: 0; }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.scan-thumb { width: 56px; height: 56px; float: right; margin-left: 10px; }
.photo-box {
  flex: none; width: 96px; height: 96px; border-radius: 14px; overflow: hidden; padding: 0;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-box.empty { border: 2px dashed var(--border); display: grid; place-content: center; font-size: 1.8rem; color: var(--muted); }
.photo-box.empty small { font-size: 0.8rem; }
.photo-pick { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.photo-pick .thumb { width: 56px; height: 56px; }
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.88); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 16px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: calc(100vh - 80px); border-radius: 10px; }
.lightbox-cap { color: #fff; font-size: 0.9rem; opacity: 0.8; }

/* Administration */
.btn.admin-btn { border-color: #8a5ad0; color: #8a5ad0; }
.btn.admin-btn svg { flex: none; }
.tile.action.adm-persons { color: var(--accent); }
.tile.action.adm-wh { color: var(--in); }
.tile.action.adm-keys { color: #8a5ad0; }
.warn-text { color: var(--out); font-weight: 600; }
.tile.action.adm-backup { color: #3a9c9c; }
.shop-actions a.link { padding: 4px 0; font-size: 0.88rem; }
label.btn { cursor: pointer; }

/* Anmeldung & Konto */
.tile.picked { border-color: var(--accent); }
.login-form { max-width: 460px; margin-left: auto; margin-right: auto; }
.login-who { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 1.1rem; }
.who-account { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 2px 4px; font-weight: 600; border-radius: 999px; }
.who-account:hover { background: var(--surface-2); }
.avatar.mini { width: 28px; height: 28px; font-size: 0.75rem; }
.wh-opt span .avatar.mini { margin-left: -2px; }
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; overflow-x: auto; font-size: 0.85rem; }
.key-created { border: 2px solid var(--in); }
.key-box { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.key-box code { flex: 1 1 260px; padding: 12px; background: var(--surface-2); border-radius: 10px; word-break: break-all; font-size: 0.95rem; user-select: all; }
.key-row .btn { flex: none; }

/* Einkaufsliste */
.tile.action.shop { color: #e0883d; }
.badge {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px;
  background: var(--out); color: #fff; font-size: 0.85rem; font-weight: 800; vertical-align: middle;
}
.tag.cons { background: #8a5ad0; }
.tag.shop { background: #e0883d; }
.check-row { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 16px; cursor: pointer; }
.check-row input { width: 24px; height: 24px; margin-top: 2px; flex: none; }
.check-row small { display: block; color: var(--muted); font-size: 0.85rem; }
.shop-add { display: flex; gap: 8px; flex-wrap: wrap; }
.shop-add input[name="name"] { flex: 1 1 200px; }
.shop-add input[name="quantity"] { width: 80px; text-align: center; }
.share-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.share-bar .btn { flex: 1 1 130px; text-decoration: none; color: inherit; }
.share-bar .btn.wa { background: #25d366; border-color: #25d366; color: #fff; }
.shop-list { padding: 6px 14px; }
.shop-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.shop-row:last-of-type { border-bottom: 0; }
.shop-check {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--border); background: var(--surface);
  position: relative;
}
.shop-check:hover { border-color: var(--in); }
.shop-check.on, .shop-row.checked .shop-check { background: var(--in); border-color: var(--in); }
.shop-check.on::after, .shop-row.checked .shop-check::after {
  content: ''; position: absolute; left: 10px; top: 5px; width: 8px; height: 14px;
  border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.shop-row.checked .name { text-decoration: line-through; color: var(--muted); }
.shop-main { flex: 1; min-width: 0; }
.shop-main .name { font-weight: 700; }
.shop-main .meta { color: var(--muted); font-size: 0.85rem; }
.shop-note { font-size: 0.9rem; font-style: italic; }
.shop-actions { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.shop-actions .link { padding: 4px 0; font-size: 0.88rem; }
.danger-link { color: var(--danger) !important; }
.shop-qty { display: flex; align-items: center; gap: 4px; flex: none; }
.shop-qty button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 1.3rem; font-weight: 700;
}
.shop-qty span { min-width: 30px; text-align: center; font-weight: 800; font-size: 1.15rem; }
.shop-list.done .name { text-decoration: line-through; color: var(--muted); font-weight: 500; }

/* Lager */
/* Lager-Knopf in der Kopfzeile */
.wh-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 0;
  padding: 4px 12px 4px 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-weight: 600;
}
.wh-chip .wh-code {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 0.9rem;
}
.wh-chip .wh-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28vw; }
.wh-chip svg { flex: none; color: var(--muted); }

/* Auswahlfenster */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 15, 30, 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background 0.2s;
}
.sheet-backdrop.open { background: rgba(10, 15, 30, 0.45); }
.sheet {
  width: 100%; max-height: 80vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
  transform: translateY(100%); transition: transform 0.2s ease;
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet h2 { margin: 6px 4px 12px; }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 6px; }
.sheet-list { display: flex; flex-direction: column; gap: 8px; }
.sheet-opt {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 8px 14px; text-align: left;
  border: 2px solid var(--border); border-radius: 14px; background: var(--surface);
}
.sheet-opt .loc { min-width: 52px; height: 46px; }
.sheet-opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.sheet-opt.on svg { color: var(--accent); margin-left: auto; flex: none; }
.sheet-txt { display: flex; flex-direction: column; min-width: 0; }
.sheet-txt strong { font-size: 1.1rem; }
.sheet-txt small { color: var(--muted); }
@media (min-width: 600px) {
  .sheet-backdrop { align-items: flex-start; padding-top: 70px; }
  .sheet { max-width: 420px; border-radius: 18px; transform: translateY(-12px); opacity: 0; transition: transform 0.15s, opacity 0.15s; }
  .sheet-backdrop.open .sheet { opacity: 1; }
  .sheet-grip { display: none; }
}

/* Lagerwahl im Formular */
.wh-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.wh-opt { position: relative; cursor: pointer; }
.wh-opt input { position: absolute; opacity: 0; pointer-events: none; }
.wh-opt span {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 16px 6px 6px;
  border: 2px solid var(--border); border-radius: 999px; background: var(--surface-2); font-weight: 600;
}
.wh-opt b {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 999px;
  background: var(--surface); font-weight: 800;
}
.wh-opt input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.wh-opt input:checked + span b { background: var(--accent); color: var(--accent-text); }
.wh-opt input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.wh-row .name { font-weight: 700; font-size: 1.1rem; }
.wh-row .meta { color: var(--muted); font-size: 0.88rem; }
.wh-row .p-edit { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
@media (max-width: 480px) { .topbar .brand span { display: none; } }

/* Personen verwalten */
.person-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.person-head .avatar { width: 46px; height: 46px; font-size: 1.1rem; }
.person-row .name { font-weight: 700; font-size: 1.1rem; }
.person-row .meta { color: var(--muted); font-size: 0.88rem; }
.person-row.archived { opacity: 0.75; }
.person-row .p-edit, .person-row .p-merge { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; box-shadow: 0 0 0 1px var(--border); }
.swatch.on { border-color: var(--surface); box-shadow: 0 0 0 3px var(--text); }
.swatches input[type="color"] { width: 48px; height: 40px; }
select { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }

/* 3D-Druck */
.p3d { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(280px, 1.3fr); gap: 16px; align-items: start; }
.p3d > .card { margin-top: 0; }
@media (max-width: 720px) { .p3d { grid-template-columns: 1fr; } }
.p3d-preview { position: sticky; top: 72px; text-align: center; }
.p3d-preview svg { width: 100%; max-height: 60vh; }
.p3d-preview .hint { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }
.p3d-warn { color: var(--danger); font-size: 0.9rem; font-weight: 600; text-align: left; margin-top: 8px; }
.p3d-warn div { margin-top: 4px; }
.p3d-check { flex: 1 1 140px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.95rem; }
.p3d-check input { width: 22px; height: 22px; }
input[type="color"] { width: 100%; height: 48px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; }

@media print {
  @page { margin: 1cm; }
  body { background: #fff; }
  .topbar, .no-print, .toast { display: none !important; }
  .container { max-width: none; padding: 0; }
  .labels { gap: 0.3cm; }
}
@media (max-width: 420px) { #who-name { display: none; } }

/* Behälter */
.tag.box { background: #3a9c9c; }
.in-box { color: var(--muted); font-size: 0.88rem; }
.in-box::before { content: '↳ '; }
p.in-box::before { content: ''; }
.list.nested { margin: -4px 0 4px 26px; padding-left: 12px; border-left: 3px solid color-mix(in srgb, #3a9c9c 45%, transparent); gap: 8px; }

/* Haltbarkeit */
.tag.exp.ok { background: #64708a; }
.tag.exp.soon { background: #e0883d; }
.tag.exp.expired { background: #d0443b; }
.exp-note { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; font: inherit; font-weight: 600;
  cursor: pointer; margin: 0 0 16px; border: 2px solid #e0883d; color: inherit; }
.exp-note.expired { border-color: #d0443b; }
.exp-note span { white-space: nowrap; color: var(--muted); }

/* KI-Assistent */
.tile.action.ai, .tile.action.adm-ai { color: #7a5ad0; }
#ai-tile .tile { width: 100%; margin-bottom: 14px; }
.src { color: var(--muted); font-size: 0.8rem; }
.ai-fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%;
  border: 0; background: #7a5ad0; color: #fff; display: grid; place-content: center; cursor: pointer; z-index: 20;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); }
.ai-fab:hover { filter: brightness(1.08); }
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-tools { display: flex; gap: 14px; align-items: center; }
.ai-toggle { display: flex; gap: 6px; align-items: center; font-size: 0.9rem; cursor: pointer; }
.ai-context { background: color-mix(in srgb, #7a5ad0 12%, transparent); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: 0.92rem; }
.ai-chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 150px; }
.ai-hello { color: var(--muted); }
.ai-hello ul { padding-left: 20px; margin: 6px 0; }
.ai-msg { display: flex; flex-direction: column; max-width: 88%; gap: 6px; }
.ai-msg.user { align-self: flex-end; align-items: flex-end; }
.ai-msg.bot { align-self: flex-start; }
.ai-bubble { padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.user .ai-bubble { background: var(--accent); color: #fff; border-color: transparent; border-bottom-right-radius: 4px; }
.ai-msg.bot .ai-bubble { border-bottom-left-radius: 4px; }
.ai-msg.error .ai-bubble { border-color: #d0443b; color: #d0443b; }
.ai-photos { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ai-photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; }
.ai-bookings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ai-bookings li { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; background: color-mix(in srgb, var(--in) 10%, transparent);
  border-left: 3px solid var(--in); padding: 6px 10px; border-radius: 8px; font-size: 0.92rem; }
.ai-bookings li.undone { opacity: 0.55; text-decoration: line-through; border-left-color: var(--muted); }
.ai-bookings small { color: var(--muted); white-space: nowrap; }
.ai-confirm { border: 2px solid #e0883d; border-radius: 12px; padding: 10px 14px; background: var(--surface); }
.ai-confirm ul { margin: 6px 0 10px; padding-left: 20px; }
.ai-confirm.done { border-color: var(--border); opacity: 0.75; }
.ai-confirm small { color: var(--muted); }
.typing { display: flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ai-dot 1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--bg); border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.ai-composer > * { max-width: 900px; margin: 0 auto; }
.ai-row { display: flex; gap: 8px; align-items: flex-end; }
.ai-row textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; margin: 0; }
.ai-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 1.2rem; cursor: pointer; color: inherit; }
.ai-btn.send { background: var(--accent); color: #fff; border-color: transparent; }
.ai-btn.rec { background: #d0443b; color: #fff; border-color: transparent; animation: ai-pulse 1.2s infinite; }
@keyframes ai-pulse { 0% { box-shadow: 0 0 0 0 rgba(208, 68, 59, 0.5); } 100% { box-shadow: 0 0 0 14px rgba(208, 68, 59, 0); } }
.ai-previews { display: flex; gap: 8px; margin-bottom: 8px; }
.ai-prev { position: relative; }
.ai-prev img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; display: block; }
.ai-prev small { position: absolute; left: 4px; bottom: 4px; background: #000a; color: #fff; font-size: 0.65rem; padding: 0 4px; border-radius: 4px; }
.ai-prev button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #333; color: #fff; font-size: 0.7rem; cursor: pointer; }
