:root {
  --bg: #f2f3f7;
  --card: #ffffff;
  --card-2: #f7f8fa;
  --text: #15171c;
  --muted: #6b7180;
  --line: #e6e8ee;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #e9eefe;
  --danger: #d93636;
  --danger-soft: #fdecec;
  --ok: #138a4b;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1013;
    --card: #1a1b20;
    --card-2: #22242a;
    --text: #f1f2f5;
    --muted: #9298a5;
    --line: #2a2c33;
    --accent: #6b8cff;
    --accent-ink: #0b1020;
    --accent-soft: #1d2540;
    --danger: #f06363;
    --danger-soft: #3a1c1f;
    --ok: #3ccf82;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; }

/* Icons (SVG-Sprite aus Material Symbols Rounded) */
.ic { width: 1.25em; height: 1.25em; fill: currentColor; flex-shrink: 0; vertical-align: -0.25em; }
.ic.lg { width: 28px; height: 28px; }
.ic.xl { width: 44px; height: 44px; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.topbar h1 { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; margin: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.topbar h1 .brand { color: var(--accent); }
.spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: none; border: 0; color: var(--accent); cursor: pointer;
}
.icon-btn:active { background: var(--accent-soft); }
.icon-btn .ic { width: 24px; height: 24px; }

main { max-width: 720px; margin: 0 auto; padding: 12px 16px; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted);
  margin: 26px 4px 10px;
}
.section-title .count { font-weight: 600; color: var(--muted); background: var(--card-2); border-radius: 999px; padding: 1px 8px; text-transform: none; }

/* Suche */
.search { position: sticky; top: calc(64px + env(safe-area-inset-top)); z-index: 5; }
.search-field { position: relative; }
.search-field .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 22px; height: 22px; }
.search-field input { padding-left: 46px; box-shadow: var(--shadow); border-color: transparent; }

/* Formularelemente */
input, textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 52%, calc(100% - 15px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 2px 6px; }

.check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow); margin-top: 10px; color: var(--text); font-weight: 500; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--accent); -webkit-appearance: checkbox; appearance: auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; border: 0; border-radius: var(--radius-sm); padding: 13px 16px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-align: center; min-height: 48px;
  transition: transform .08s, filter .15s; white-space: nowrap;
}
.btn:active { transform: scale(.98); filter: brightness(.95); }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:active { background: var(--danger-soft); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.actions.single { grid-template-columns: 1fr; }

/* Listen */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--text); position: relative; }
.list-item + .list-item::before { content: ""; position: absolute; top: 0; right: 0; left: 74px; border-top: 1px solid var(--line); }
.list-item:active { background: var(--card-2); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.list-item .sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.list-item .sub .ic { width: 16px; height: 16px; }
.list-item .chev { color: var(--muted); opacity: .6; }
.thumb {
  width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
}
.thumb .ic { width: 26px; height: 26px; }
.thumb.loc { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge { font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); text-align: center; padding: 28px 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 15px; }
.empty .ic { width: 36px; height: 36px; opacity: .5; }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px;
  border-radius: 999px; border: 0; background: var(--card); color: var(--text); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tag .ic { width: 16px; height: 16px; color: var(--accent); }
.tag .n { color: var(--muted); font-weight: 600; font-size: 12px; }
.tag .x { display: grid; place-items: center; width: 22px; height: 22px; margin-right: -6px; border-radius: 50%; border: 0; background: var(--card-2); color: var(--muted); cursor: pointer; padding: 0; }
.tag .x .ic { width: 14px; height: 14px; color: inherit; }
.tag.toggle { box-shadow: none; background: var(--card-2); color: var(--muted); }
.tag.toggle.on { background: var(--accent); color: var(--accent-ink); }
.tag.toggle.on .ic { color: inherit; }
.tags.mini { gap: 4px; margin-top: 4px; }
.tags.mini .tag { height: 22px; padding: 0 8px; font-size: 12px; box-shadow: none; background: var(--card-2); color: var(--muted); cursor: inherit; }
.add-tag { display: grid; grid-template-columns: 1fr 48px; gap: 8px; margin-top: 10px; }
.add-tag .btn { padding: 0; }

/* Fotos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--card-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo .ai {
  position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px;
  border: 0; border-radius: 999px; padding: 5px 10px 5px 8px; font-size: 12px; font-weight: 700;
  background: rgba(15, 16, 20, .66); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); cursor: pointer;
}
.photo .ai .ic { width: 15px; height: 15px; }

/* Inhalt einer Kiste */
.item-row { display: flex; align-items: center; gap: 12px; padding: 11px 8px 11px 14px; position: relative; }
.item-row + .item-row::before { content: ""; position: absolute; top: 0; right: 0; left: 62px; border-top: 1px solid var(--line); }
.item-row .qty { min-width: 36px; text-align: center; font-weight: 700; font-size: 14px; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 3px 6px; }
.item-row .name { flex: 1; font-weight: 500; }
.item-row .cat { color: var(--muted); font-size: 13px; font-weight: 400; }
.item-row .del { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: none; border: 0; color: var(--muted); cursor: pointer; }
.item-row .del:active { background: var(--danger-soft); color: var(--danger); }
.item-row .del .ic { width: 20px; height: 20px; }
.add-item { display: grid; grid-template-columns: 1fr 68px 48px; gap: 8px; margin-top: 10px; }
.add-item .btn { padding: 0; }

/* Kopf einer Kiste */
.hero { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.hero .qr { width: 76px; height: 76px; background: #fff; border-radius: 10px; padding: 4px; flex-shrink: 0; border: 1px solid var(--line); }
.hero .code { font-size: 30px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.hero .name { font-weight: 600; margin-top: 2px; }
.hero .where { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; margin-top: 4px; }
.hero .where .ic { width: 16px; height: 16px; }
.notes { color: var(--muted); margin: 12px 4px 0; white-space: pre-wrap; }

/* Dialog: auf dem Handy als Bottom-Sheet */
dialog {
  border: 0; border-radius: 22px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: 88vh;
  background: var(--card); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10, 12, 16, .45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
@media (max-width: 600px) {
  dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  dialog[open] { animation: sheet .22s ease-out; }
  @keyframes sheet { from { transform: translateY(40px); opacity: .4; } }
}
#modalBody { padding: 22px 18px 18px; overflow: auto; max-height: 88vh; }
#modalBody h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 19px; letter-spacing: -.01em; }
#modalBody h3 .ic { color: var(--accent); }
#modalBody p { margin: 4px 0 8px; }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: -10px auto 14px; }
.choice { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border: 0; border-radius: var(--radius-sm); background: var(--card-2); color: var(--text); text-align: left; cursor: pointer; margin-top: 8px; }
.choice .thumb { width: 44px; height: 44px; }
.choice .t { font-weight: 600; }
.choice .s { color: var(--muted); font-size: 14px; }
.suggestion { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.suggestion:last-child { border-bottom: 0; }
.suggestion input[type=checkbox] { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--accent); -webkit-appearance: checkbox; appearance: auto; }
.suggestion .s-name { flex: 1; padding: 9px 11px; }
.suggestion .s-qty { width: 64px; padding: 9px; text-align: center; }
.name-suggestion { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--accent-soft); border-radius: var(--radius-sm); margin: 10px 0 4px; font-size: 15px; }
.name-suggestion input { width: 22px; height: 22px; accent-color: var(--accent); -webkit-appearance: checkbox; appearance: auto; }
.viewer img { width: 100%; border-radius: var(--radius-sm); display: block; }
.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 8px 0 4px; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(16px);
  background: #15171c; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; box-shadow: var(--shadow-lg); z-index: 30;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

.spinner { width: 20px; height: 20px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.fab {
  position: fixed; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 20;
  display: inline-flex; align-items: center; gap: 6px; height: 56px; padding: 0 22px 0 18px; border-radius: 18px; border: 0;
  font-weight: 700; font-size: 16px; color: var(--accent-ink); background: var(--accent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent); cursor: pointer;
}
.fab .ic { width: 26px; height: 26px; }
.fab:active { transform: scale(.97); }

/* Login */
.login { max-width: 360px; margin: 14vh auto 0; text-align: center; }
.login .logo { display: inline-grid; place-items: center; width: 76px; height: 76px; border-radius: 22px; background: var(--accent); color: var(--accent-ink); margin-bottom: 12px; box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 40%, transparent); }
.login .logo .ic { width: 42px; height: 42px; }
.login h2 { margin: 0 0 22px; font-size: 24px; letter-spacing: -.02em; }
.login form { text-align: left; }

/* Etiketten */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.label { background: #fff; color: #000; border: 1px dashed #b8bcc6; border-radius: 10px; padding: 10px; display: flex; gap: 10px; align-items: center; break-inside: avoid; }
.label img { width: 90px; height: 90px; }
.label .l-code { font-size: 26px; font-weight: 800; }
.label .l-name { font-size: 13px; }
.label input { width: 20px; height: 20px; -webkit-appearance: checkbox; appearance: auto; }
.label.unselected { opacity: .35; }
@media print {
  .topbar, .no-print, .fab, #toast { display: none !important; }
  body, main { background: #fff; padding: 0; max-width: none; }
  .label { border: 1px solid #000; opacity: 1; }
  .label.unselected { display: none; }
  .label input { display: none; }
}
