/* ORCLE Einkauf – Clean & Apple-like (light) */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f2f2f7;            /* iOS grouped background */
  --card: #ffffff;
  --text: #1c1c1e;
  --text2: #8e8e93;        /* secondary label */
  --text3: #c7c7cc;
  --sep: rgba(60,60,67,0.10);
  --green: #34c759;
  --green-tint: rgba(52,199,89,0.14);
  --blue: #007aff;
  --red: #ff3b30;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Helvetica Neue", system-ui, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 620px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* ---------- Header ---------- */
.hdr { padding-top: 8px; }
.hdr-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hdr h1 {
  font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
}
.hdr-sub { color: var(--text2); font-size: 15px; margin-top: 2px; min-height: 18px; }

.scan-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--green); color: #fff; border: none;
  font-size: 15px; font-weight: 600; font-family: var(--font);
  padding: 9px 15px 9px 13px; border-radius: 100px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(52,199,89,0.35);
  transition: transform .12s ease, filter .12s ease;
}
.scan-pill:active { transform: scale(0.95); filter: brightness(0.96); }

/* Segmented control */
.seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: rgba(118,118,128,0.10); border-radius: 10px;
  padding: 3px; margin: 18px 0 6px; height: 40px;
}
.seg-btn {
  position: relative; z-index: 2; border: none; background: none; cursor: pointer;
  font-family: var(--font); font-size: 15px; font-weight: 600; color: var(--text);
  border-radius: 8px; transition: color .2s;
}
.seg-btn:not(.active) { color: var(--text2); }
.seg-thumb {
  position: absolute; z-index: 1; top: 3px; left: 3px;
  width: calc(50% - 3px); height: calc(100% - 6px);
  background: var(--card); border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10), 0 0 1px rgba(0,0,0,0.10);
  transition: transform .28s cubic-bezier(.3,.9,.3,1);
}
.seg[data-active="inv"] .seg-thumb { transform: translateX(100%); }

/* ---------- Views ---------- */
.view { display: none; padding-top: 14px; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Add bar */
.addbar { display: flex; gap: 10px; margin-bottom: 16px; }
.addbar input {
  flex: 1; background: var(--card); border: none; border-radius: 12px;
  padding: 14px 16px; font-size: 17px; font-family: var(--font); color: var(--text);
  outline: none; box-shadow: var(--shadow);
}
.addbar input::placeholder { color: var(--text2); }
.addbar button {
  flex: 0 0 50px; background: var(--green); color: #fff; border: none; border-radius: 12px;
  font-size: 28px; font-weight: 300; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 14px rgba(52,199,89,0.30); transition: transform .12s;
}
.addbar button:active { transform: scale(0.94); }

/* Sortier-Umschalter */
.sortrow { display: inline-flex; gap: 3px; background: rgba(118,118,128,0.10); border-radius: 100px; padding: 3px; margin-bottom: 14px; }
.sp { border: none; background: none; color: var(--text2); font-family: var(--font); font-size: 14px; font-weight: 600; padding: 7px 16px; border-radius: 100px; cursor: pointer; }
.sp.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.10); }

/* Kategorie-Überschrift in der Liste */
.catsep { list-style: none; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--text2); margin: 16px 4px 4px; }
.catsep:first-child { margin-top: 2px; }
.catsep .cse { font-size: 17px; }

/* ---------- Cards / items ---------- */
.cards { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius); padding: 10px 12px;
  box-shadow: var(--shadow); animation: pop .28s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.99); } to { opacity: 1; transform: none; } }

.thumb {
  flex: 0 0 50px; width: 50px; height: 50px; border-radius: 12px;
  background: #f2f2f7 center/cover no-repeat; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #b7b7be; user-select: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.it-main { flex: 1; min-width: 0; }
.it-name { font-size: 16.5px; font-weight: 500; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it-sub { font-size: 13px; color: var(--text2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.qty {
  flex: 0 0 auto; background: var(--green-tint); color: #248a3d;
  font-size: 14px; font-weight: 700; padding: 3px 9px; border-radius: 100px;
}

.check {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--text3); background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  transition: background .18s, border-color .18s, transform .12s;
}
.check svg { width: 16px; height: 16px; opacity: 0; transform: scale(.5); transition: .18s; }
.check.on { background: var(--green); border-color: var(--green); }
.check.on svg { opacity: 1; transform: none; }
.check:active { transform: scale(0.86); }

/* stepper inside inventory item */
.mini-step { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }
.mini-step button {
  width: 30px; height: 30px; border-radius: 8px; border: none; cursor: pointer;
  background: #f2f2f7; color: var(--text); font-size: 19px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.mini-step button:active { background: #e5e5ea; }
.mini-step .n { min-width: 26px; text-align: center; font-size: 16px; font-weight: 700; }

/* done list */
.cards.done .item { opacity: .6; box-shadow: none; background: rgba(255,255,255,0.6); }
.cards.done .it-name { text-decoration: line-through; color: var(--text2); }
.badge-new { display:inline-block; background: var(--green); color:#fff; font-size:10px; font-weight:800; padding:1px 6px; border-radius:6px; margin-left:7px; vertical-align: middle; letter-spacing: .02em; }

/* done header */
.done-wrap { margin-top: 24px; }
.done-head {
  width: 100%; display: flex; align-items: center; gap: 8px; background: none; border: none;
  color: var(--text2); font-family: var(--font); font-size: 15px; font-weight: 600;
  cursor: pointer; padding: 6px 4px;
}
.done-head .chev { display: inline-block; transition: transform .2s; font-size: 18px; }
.done-head.open .chev { transform: rotate(90deg); }
.done-head .spacer { flex: 1; }
.done-head .clear { color: var(--blue); font-weight: 500; }

/* empty */
.empty { text-align: center; padding: 64px 24px; }
.empty-emoji { font-size: 46px; margin-bottom: 14px; }
.empty-title { font-size: 19px; font-weight: 700; }
.empty-sub { color: var(--text2); font-size: 14.5px; margin-top: 5px; line-height: 1.4; }

/* footer */
.foot { display: flex; justify-content: center; gap: 20px; margin-top: 34px; }
.foot a { color: var(--text2); font-size: 13px; text-decoration: none; }
.foot a:active { color: var(--blue); }

/* ---------- Scanner overlay ---------- */
.scanner { position: fixed; inset: 0; z-index: 300; background: #000; overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-veil { position: absolute; inset: 0; background: radial-gradient(ellipse at center 42%, transparent 120px, rgba(0,0,0,0.55) 320px); }
.scan-ui { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: max(18px, env(safe-area-inset-top)) 20px calc(30px + env(safe-area-inset-bottom)); }
.scan-top { width: 100%; display: flex; align-items: center; justify-content: space-between; color: #fff; }
.scan-title { font-size: 17px; font-weight: 600; }
.scan-close { width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255,255,255,0.2); color: #fff; font-size: 17px; cursor: pointer; backdrop-filter: blur(8px); }
.frame { position: relative; width: min(72vw, 300px); aspect-ratio: 1 / 0.72; margin: auto 0; }
.br { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; }
.br.tl { top: 0; left: 0; border-right: none; border-bottom: none; border-radius: 12px 0 0 0; }
.br.tr { top: 0; right: 0; border-left: none; border-bottom: none; border-radius: 0 12px 0 0; }
.br.bl { bottom: 0; left: 0; border-right: none; border-top: none; border-radius: 0 0 0 12px; }
.br.br2 { bottom: 0; right: 0; border-left: none; border-top: none; border-radius: 0 0 12px 0; }
.scanline { position: absolute; left: 8px; right: 8px; height: 2px; background: linear-gradient(90deg, transparent, var(--green), transparent); box-shadow: 0 0 12px var(--green); top: 8px; animation: scan 2s ease-in-out infinite; }
@keyframes scan { 0%,100% { top: 8px; } 50% { top: calc(100% - 10px); } }
.scan-hint { color: rgba(255,255,255,0.85); font-size: 14px; text-align: center; margin-top: 8px; }
.scan-result {
  min-height: 76px; width: 100%; max-width: 380px; margin-top: 18px;
  display: flex; align-items: center; gap: 12px; padding: 0 4px;
  opacity: 0; transform: translateY(10px); transition: .3s;
}
.scan-result.show { opacity: 1; transform: none; animation: srin .45s cubic-bezier(.2,.9,.2,1); }
@keyframes srin { 0% { opacity: 0; transform: translateY(16px) scale(.82); } 58% { opacity: 1; transform: translateY(0) scale(1.05); } 100% { transform: scale(1); } }

/* grüner Erfolgs-Flash + Rahmen-Puls beim Abhaken */
.scan-flash { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 42%, rgba(52,199,89,0.5), transparent 60%); }
.scan-flash.go { animation: sflash .6s ease-out; }
@keyframes sflash { 0% { opacity: 0; transform: scale(1.12); } 20% { opacity: 1; } 100% { opacity: 0; transform: scale(1); } }
.frame.hit .br { animation: brhit .5s ease-out; }
@keyframes brhit { 0% { border-color: #fff; } 40% { border-color: var(--green); box-shadow: 0 0 20px var(--green); transform: scale(1.06); } 100% { border-color: #fff; } }
.scan-result .rimg { animation: imgpop .4s cubic-bezier(.2,.9,.2,1); }
@keyframes imgpop { 0% { transform: scale(.6); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
.scan-result .rimg { width: 52px; height: 52px; border-radius: 12px; background: #333 center/cover; flex: 0 0 52px; display:flex;align-items:center;justify-content:center;font-size:24px; }
.scan-result .rtext { color: #fff; }
.scan-result .rt1 { font-size: 16px; font-weight: 600; }
.scan-result .rt2 { font-size: 13px; color: rgba(255,255,255,0.7); margin-top: 2px; }
.scan-result.ok .rt1::before { content: "✓ "; color: var(--green); }

/* ---------- Bottom sheet (edit) ---------- */
.sheet { position: fixed; inset: 0; z-index: 400; display: flex; align-items: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.35); animation: fade .2s; z-index: 1; }
.sheet-card {
  position: relative; z-index: 2; width: 100%; max-width: 620px; margin: 0 auto;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0,0,0,0.2); animation: up .3s cubic-bezier(.2,.8,.3,1);
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: #d1d1d6; margin: 0 auto 14px; }
.sheet-media { width: 74px; height: 74px; border-radius: 16px; margin: 0 auto 14px; background: #f2f2f7 center/cover no-repeat; display:flex;align-items:center;justify-content:center;font-size:30px;font-weight:700;color:#b7b7be; overflow:hidden; }
.sheet-media img { width:100%;height:100%;object-fit:cover; }
.sheet-media { cursor: pointer; }
.sheet-cam {
  display: block; width: 100%; margin: 0 auto 14px; padding: 13px;
  background: rgba(52,199,89,0.12); color: #248a3d; border: 1px solid rgba(52,199,89,0.3);
  border-radius: 14px; font-size: 15.5px; font-weight: 700; font-family: var(--font); cursor: pointer;
}
.sheet-cam:disabled { opacity: 0.7; }
.sheet-cam:active { background: rgba(52,199,89,0.2); }
.sheet-name {
  width: 100%; text-align: center; border: none; outline: none; background: none;
  font-size: 21px; font-weight: 700; font-family: var(--font); color: var(--text); margin-bottom: 14px;
}
.sheet-cats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; max-height: 132px; overflow-y: auto; }
.scat {
  border: 1px solid var(--border); background: var(--bg); color: var(--text2);
  border-radius: 100px; padding: 8px 13px; font-size: 13.5px; font-weight: 600; font-family: var(--font); cursor: pointer; white-space: nowrap;
}
.scat.on { background: var(--green); color: #fff; border-color: var(--green); }
.stepper { display: flex; align-items: center; justify-content: center; gap: 22px; margin-bottom: 22px; }
.stepper button { width: 46px; height: 46px; border-radius: 50%; border: none; background: #f2f2f7; font-size: 24px; color: var(--text); cursor: pointer; }
.stepper button:active { background: #e5e5ea; }
.stepper span { font-size: 24px; font-weight: 700; min-width: 40px; text-align: center; }
.sheet-actions { display: flex; gap: 12px; }
.btn-del, .btn-save { flex: 1; padding: 15px; border-radius: 14px; border: none; font-size: 17px; font-weight: 600; font-family: var(--font); cursor: pointer; }
.btn-del { background: #f2f2f7; color: var(--red); }
.btn-save { background: var(--green); color: #fff; }
.btn-save:active, .btn-del:active { filter: brightness(0.96); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(140%);
  background: rgba(30,30,32,0.94); color: #fff; padding: 11px 18px; border-radius: 14px;
  font-size: 14.5px; font-weight: 500; z-index: 500; max-width: 88%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  transition: transform .32s cubic-bezier(.2,.8,.3,1), opacity .25s ease;
  backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- Lightbox (Bild vergrößern) ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,0.82); backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .2s ease;
}
.lightbox img {
  max-width: 92vw; max-height: 82vh; border-radius: 20px; background: #fff;
  object-fit: contain; box-shadow: 0 30px 90px rgba(0,0,0,0.5);
  animation: lbin .32s cubic-bezier(.2,.9,.2,1);
}
@keyframes lbin { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }
.thumb img { cursor: zoom-in; }

[hidden] { display: none !important; }
