:root {
  --bg: #0f1420;
  --card: #1a2130;
  --card-2: #222c3f;
  --line: #2d3850;
  --text: #eef2f8;
  --muted: #93a0b8;
  --accent: #ffcf00;   /* LEGO yellow */
  --accent-2: #d01012; /* LEGO red */
  --green: #2ecc71;
  --radius: 14px;
}

* { box-sizing: border-box; }
/* Ensure the HTML `hidden` attribute always wins over class display rules
   (e.g. .overlay/.capture-controls use display:flex, which would otherwise
   override the browser's default [hidden]{display:none}). */
[hidden] { display: none !important; }
/* Clip sideways overflow on BOTH. Use `clip` (not `hidden`) so it does NOT
   create a scroll container — otherwise `position: sticky` (detail panel)
   breaks and the panel no longer follows the scroll. */
html, body {
  margin: 0; width: 100%; max-width: 100%;
  overflow-x: clip;
}
body {
  background: radial-gradient(1200px 600px at 50% -10%, #182238 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: 40px;
  -webkit-text-size-adjust: 100%;
}
img, canvas, video, table { max-width: 100%; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px;
  background: rgba(15,20,32,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.total-pill { flex-shrink: 0; }
.stud {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 0 0 3px rgba(255,207,0,.15);
  position: relative;
}
.stud::after {
  content: ""; position: absolute; inset: 5px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff6c2, var(--accent));
}
.total-pill {
  background: var(--card-2); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; color: var(--muted);
  white-space: nowrap;
}
.total-pill strong { color: var(--accent); font-size: 15px; }
.stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stat {
  background: var(--card-2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); white-space: nowrap;
}
.stat b { color: var(--text); font-weight: 700; }
.stat.total strong { color: var(--accent); font-size: 15px; }
.search-wrap { flex: 1 1 240px; max-width: 460px; margin: 0 16px; min-width: 0; position: relative; }
.search {
  width: 100%;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 9px 16px; font-size: 14px;
}
.search::placeholder { color: var(--muted); }
.search:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  max-height: 65vh; overflow: auto; z-index: 30; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.sr-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.sr-item:hover { background: var(--card-2); }
.sr-item img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 6px; flex: 0 0 auto; }
.sr-main { flex: 1; min-width: 0; }
.sr-name { font-size: 13px; color: var(--text); }
.sr-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.sr-badge { font-size: 10px; background: var(--card-2); border: 1px solid var(--line); border-radius: 99px; padding: 3px 8px; color: var(--accent); white-space: nowrap; }
.sr-empty { padding: 12px; color: var(--muted); font-size: 13px; }

/* grid-template-columns: minmax(0,1fr) lets the column shrink below its content's
   intrinsic width — without it a wide table forces every card past the viewport. */
main { max-width: none; margin: 0; padding: 16px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }

/* Camera / preview */
.viewport {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto; aspect-ratio: 4/3;
  background: #05070c; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.viewport img { width: 100%; height: 100%; object-fit: contain; }
.btn.big { font-size: 16px; padding: 15px 22px; }
.capture-controls .big { flex: 1 1 auto; justify-content: center; }
.cam-idle {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center;
}
.cam-idle .or { color: var(--muted); font-size: 12px; }
.capture-controls { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.basis-note { font-size: 10px; color: #ffb454; font-weight: 400; margin-top: 2px; }

/* Loading overlay */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: rgba(9, 13, 22, .72); backdrop-filter: blur(3px);
}
.overlay .spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 5px solid rgba(255, 207, 0, .25); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.overlay-msg { color: var(--text); font-size: 15px; font-weight: 600; text-align: center; padding: 0 24px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal (copy dialog) */
.modal { z-index: 70; }
.modal-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; width: min(400px, 92vw); display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-title { font-weight: 700; font-size: 17px; }
.modal-sub { color: var(--muted); font-size: 13px; margin-top: -8px; }
.modal-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.modal-field select, .modal-field input {
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px; font-size: 15px; width: 100%;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2);
  color: var(--text); padding: 11px 16px; border-radius: 10px; font-size: 14px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
}
.btn:hover:not(:disabled) { border-color: #3c4a68; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #201a00; border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: #ffd830; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 12px; }
.file-btn { position: relative; }

.status { margin: 10px 2px 0; min-height: 18px; font-size: 13px; color: var(--muted); }
.status.err { color: #ff8a8a; }
.status.busy { color: var(--accent); }

/* Candidates */
.candidates { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.cand {
  border: 2px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer;
  background: var(--card-2); text-align: center; transition: border-color .15s ease;
}
.cand:hover { border-color: #45557a; }
.cand.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,207,0,.15); }
.cand img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 8px; }
.cand .nm { font-size: 12px; margin-top: 6px; line-height: 1.25; }
.cand .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.cand .score { color: var(--green); }

.pick-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.color-auto { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.color-auto strong { color: var(--text); }
.color-auto .swatch { width: 16px; height: 16px; }
.addfield { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.addfield input { width: 96px; background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
.dup-warn {
  margin-top: 12px; padding: 12px 16px; border: 3px solid var(--accent-2); border-radius: 10px;
  background: rgba(208, 16, 18, .14); color: #ffdada; font-weight: 800; font-size: 15px; line-height: 1.4;
}
.dup-warn .fach { color: var(--accent); }
select {
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 10px; font-size: 14px; min-width: 190px;
}

/* Table */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.list-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sortlbl { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.sortlbl select { min-width: 140px; }
.fach-input { width: 72px; background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; text-align: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
.pname { color: #a7c4ff; font-weight: 600; cursor: pointer; }
.pname:hover { text-decoration: underline; }
.c-name a.ext { color: var(--muted); text-decoration: none; font-weight: 400; margin-left: 6px; }
.c-name a.ext:hover { color: var(--accent); }
.detail-hint { color: var(--accent); cursor: pointer; }
td.c-img { width: 88px; }
tbody img { width: 74px; height: 74px; max-width: none; object-fit: contain; background: #fff; border-radius: 6px; cursor: zoom-in; }
#imgZoom {
  position: fixed; width: 240px; height: 240px; object-fit: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,.55); z-index: 60; pointer-events: none;
}
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(255,255,255,.25); }
/* Kategorie-Filter (Torsos / Beine / Koepfe ...) ---------------------------- */
.catfilter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.catfilter .cf {
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 99px; padding: 5px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.catfilter .cf:hover { color: var(--text); border-color: var(--accent); }
.catfilter .cf.on { background: var(--accent); border-color: var(--accent); color: #201a00; }

/* Bau-Check: baubare Figuren ------------------------------------------------ */
.build-progress { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.build-bar { height: 6px; background: var(--card-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.build-bar span { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }
.build-sec { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; margin: 16px 0 8px; }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.build-card {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; text-align: center; cursor: pointer;
}
.build-card:hover { border-color: var(--accent); }
.build-card img { width: 100%; height: 90px; object-fit: contain; background: #fff; border-radius: 6px; }
.build-card .bc-name { font-size: 12px; font-weight: 600; margin-top: 6px; line-height: 1.3; }
.build-card .bc-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.build-card .bc-copies { color: var(--accent); font-weight: 700; }
.build-card .bc-build { margin-top: 6px; width: 100%; font-size: 11px; padding: 5px 6px; }
.build-card.bc-done { opacity: .5; }
.build-card.almost .bc-miss {
  font-size: 11px; color: #e0a040; margin-top: 4px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.build-card .bc-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.qty-input {
  width: 72px; text-align: center; background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 14px;
  font-variant-numeric: tabular-nums;
  /* Native Spinner weg: die +/- Buttons machen den Job, die Pfeile klauen nur Platz. */
  -moz-appearance: textfield; appearance: textfield;
}
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .qty-input { width: 60px; padding: 6px 4px; }
.step {
  width: 34px; height: 34px; flex: 0 0 34px; padding: 0;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 8px; font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.step:active { background: var(--accent); color: #201a00; }
.colcell { white-space: nowrap; }
.row-color {
  max-width: 132px; min-width: 0; font-size: 12px; padding: 5px 6px; margin-top: 2px;
}
.row-sum { font-weight: 700; color: var(--accent); }
.del {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; padding: 4px 6px; border-radius: 6px;
}
.del:hover { color: var(--accent-2); background: rgba(208,16,18,.12); }
.copybtn {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; padding: 4px 6px; border-radius: 6px; margin-right: 2px;
}
.copybtn:hover { color: var(--accent); background: rgba(255,207,0,.12); }
.c-del { white-space: nowrap; }
tfoot td { border-top: 2px solid var(--line); border-bottom: none; font-weight: 700; padding-top: 12px; }
#footTotal { color: var(--accent); font-size: 16px; }

.empty-hint { color: var(--muted); font-size: 13px; text-align: center; padding: 10px 0; }
.price-warn { color: #ffb454; font-size: 11px; }

/* List selector bar */
.listbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  max-width: 1040px; margin: 12px auto 0; padding: 0 16px;
}
.listbar label { color: var(--muted); font-size: 13px; }
.listbar select { min-width: 150px; }
.tabs-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ltab {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.ltab:hover { border-color: #3c4a68; }
.ltab.active { border-color: var(--accent); background: rgba(255, 207, 0, .12); }
.ltab.active .ltab-name { color: var(--accent); font-weight: 700; }
.ltab-close { font-size: 12px; opacity: .6; }
.ltab-close:hover { color: var(--accent-2); opacity: 1; }
.listbar .sync { color: var(--muted); font-size: 12px; margin-left: auto; }
.listbar .sync.on { color: var(--green); }

/* Layout: left column (cam + list) + right detail area (multiple cards) */
.layout { display: flex; gap: 16px; align-items: flex-start; }
/* Fixed list width so the table never resizes when the panel opens; the detail
   area fills the remaining (wide) desktop space to the right. */
.col-main { flex: 0 0 960px; max-width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.detail-area { flex: 1 1 0; min-width: 340px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.detail { max-height: none; overflow: visible; }
.fig-stack { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.figcard { padding: 12px; }
.fc-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
.fc-img { width: 54px; height: 54px; object-fit: contain; background: #fff; border-radius: 6px; cursor: zoom-in; flex: 0 0 auto; }
.fc-body { margin-top: 8px; }
.fc-price { color: var(--accent); font-weight: 600; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.detail-title { font-weight: 700; font-size: 15px; }
.detail-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tab { background: transparent; border: none; color: var(--muted); padding: 8px 10px; font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; padding: 6px 0; }
.appears-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.appears-card { text-align: center; cursor: pointer; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--card-2); transition: border-color .15s; text-decoration: none; color: var(--text); display: block; }
.appears-card:hover { border-color: var(--accent); }
.appears-card img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 6px; }
.appears-card .nm { font-size: 11px; margin-top: 5px; line-height: 1.25; max-height: 3.8em; overflow: hidden; }
.appears-card .meta { font-size: 10px; color: var(--muted); margin-top: 2px; }
.appears-card .ap-price { font-size: 12px; color: var(--accent); font-weight: 700; margin-top: 3px; min-height: 14px; }
.ap-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.ap-bar label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.ap-bar select { background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.ap-progress { font-size: 11px; }
.inv-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.inv-row img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 6px; }
.inv-row .nm { font-size: 12px; flex: 1; min-width: 0; }
.inv-row .qty { font-weight: 700; color: var(--accent); font-size: 13px; white-space: nowrap; }
.inv-price { font-size: 12px; color: var(--text); white-space: nowrap; min-width: 54px; text-align: right; }
.inv-total { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 9px 2px 2px; margin-top: 4px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.inv-total strong { color: var(--accent); font-size: 15px; }
.inv-total .cmp { font-size: 11px; }
.inv-row.have { background: rgba(46, 204, 113, .08); border-radius: 6px; }
.inv-check { width: 18px; height: 18px; accent-color: var(--green); flex: 0 0 auto; cursor: pointer; }
.fc-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tag { font-size: 10px; padding: 2px 7px; border-radius: 99px; background: var(--card-2); color: var(--muted); margin-left: 6px; }
.inv-row.have .tag { background: var(--green); color: #04210f; }
/* "✓ hast du" always on its own line under the part name (not trailing behind it) */
.inv-row .nm a { display: block; }
.inv-row .nm .tag { display: inline-block; margin-left: 0; margin-top: 3px; }
/* Figure card highlighted green when you own every part of it */
.figcard.fc-complete { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), 0 0 20px -6px var(--green); }
.complete-badge { font-size: 11px; font-weight: 700; color: #04210f; background: var(--green); padding: 2px 8px; border-radius: 99px; margin-left: 8px; vertical-align: middle; white-space: nowrap; }
/* Live price preview in the scan pick-row (shown before adding to the list) */
.cand-price { font-size: 15px; font-weight: 700; color: var(--accent); white-space: nowrap; min-width: 64px; text-align: right; align-self: center; }
.cand-price.loading { color: var(--muted); font-weight: 500; }
.cand-price.none { color: var(--muted); font-size: 12px; font-weight: 500; }
/* Pending scans — shared live across devices (phone -> PC) */
.pending-scans .ps-hint { font-size: 11px; font-weight: 400; color: var(--muted); }
.pending-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.pending-scan { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card-2); }
.pending-scan img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 6px; flex: 0 0 auto; }
.pending-scan .ps-info { flex: 1; min-width: 0; }
.pending-scan .ps-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-scan .ps-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pending-scan .ps-actions { display: flex; gap: 6px; flex-wrap: wrap; flex: 0 0 auto; }
tbody tr[data-row] { cursor: pointer; transition: background .12s ease; }
tbody tr[data-row]:hover { background: rgba(255, 255, 255, .045); }
tbody tr.flash { background: rgba(255, 207, 0, .2) !important; }
#imgZoom { width: 300px; height: 300px; }
@media (max-width: 1360px) {
  .layout { flex-direction: column; }
  .col-main { flex-basis: auto; width: 100%; }
  .detail-area { flex-basis: auto; width: 100%; position: static; max-height: none; overflow: visible; }
  .fig-stack { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}
/* Desktop: no big camera box — a simple button is enough. */
@media (min-width: 901px) {
  .capture .viewport { display: none; }
  .capture .capture-controls { margin-top: 0; justify-content: flex-start; }
  .capture-controls .big { flex: 0 0 auto; }
}

/* Mobile */
@media (max-width: 600px) {
  .brand h1 { font-size: 15px; }
  .search-wrap { order: 5; flex-basis: 100%; margin: 8px 0 0; }
  .total-pill { font-size: 12px; padding: 6px 10px; }
  main { padding: 12px; gap: 12px; }
  .card { padding: 12px; border-radius: 12px; }
  .candidates { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); }
  select { min-width: 0; }
  .listbar select { min-width: 120px; }

  /* List: turn the table rows into stacked cards so nothing overflows. */
  #partsTable, #partsTable tbody { display: block; width: 100%; }
  #partsTable thead, #partsTable tfoot { display: none; }
  #partsTable tbody tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px;
  }
  #partsTable td { border: none !important; padding: 0; }
  .c-img { order: 1; }
  .c-img img { width: 46px; height: 46px; }
  .c-name { order: 2; flex: 1 1 55%; min-width: 0; }
  .c-del { order: 3; margin-left: auto; }
  #partsTable tbody tr::after { content: ""; order: 4; flex-basis: 100%; height: 0; }
  .c-color { order: 5; }
  .c-color .swatch { display: none; }
  .c-price { order: 6; text-align: left !important; }
  .c-price::before { content: "Stück: "; color: var(--muted); font-size: 10px; }
  .c-qty { order: 7; }
  .c-sum { order: 8; margin-left: auto; text-align: right !important; }
  .c-sum::before { content: "Summe: "; color: var(--muted); font-size: 10px; font-weight: 400; }
  .c-fach { order: 9; }
  .c-fach::before { content: "Fach: "; color: var(--muted); font-size: 10px; }
  .c-fach .fach-input { width: 90px; }
  .row-color { max-width: 160px; }
  .step { width: 38px; height: 38px; flex-basis: 38px; }
}

/* --- Login screen (public / magic-link mode) ------------------------------- */
.login-screen {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  background: radial-gradient(1200px 600px at 50% -10%, #182238 0%, var(--bg) 60%);
}
/* Landing: demo reel + login card. Centred when it fits, scrolls when taller. */
.landing {
  min-height: 100%; box-sizing: border-box; margin: 0 auto; max-width: 1000px;
  padding: 28px 20px; display: grid; gap: 26px; grid-template-columns: 1fr;
  align-content: center; justify-items: center;
}
.landing-demo { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.landing-lead { display: flex; flex-direction: column; align-items: inherit; gap: 10px; }
.landing-head { font-size: clamp(24px, 6vw, 34px); font-weight: 900; letter-spacing: -.5px; line-height: 1.05; text-wrap: balance; }
.landing-sub { margin: 0; color: var(--muted, #9fb0c8); font-size: 15px; line-height: 1.5; max-width: 44ch; }
.landing-steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; font-size: 13px; font-weight: 700; color: var(--muted, #9fb0c8); }
.landing-steps span { background: var(--card-2); border: 1px solid var(--line); border-radius: 99px; padding: 5px 11px; }
.phone-embed {
  width: min(320px, 82vw); aspect-ratio: 9 / 16; border-radius: 24px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.phone-embed iframe { width: 100%; height: 100%; border: 0; display: block; background: transparent; }
.login-card-title { font-size: 20px; font-weight: 900; letter-spacing: -.2px; }
@media (min-width: 900px) {
  .landing { grid-template-columns: minmax(0, 1fr) 380px; align-items: center; justify-items: stretch; gap: 46px; }
  .landing-demo { align-items: flex-start; text-align: left; }
  .landing-steps { justify-content: flex-start; }
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 26px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand h1 { font-size: 22px; margin: 0; letter-spacing: .3px; }
.login-tag { margin: 0; color: var(--muted, #9fb0c8); font-size: 14px; line-height: 1.4; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted, #9fb0c8); }
.login-field input {
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font-size: 16px;
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-card .btn.big { width: 100%; padding: 13px; font-size: 15px; }
.login-msg { margin: 0; font-size: 13px; min-height: 18px; }
.login-msg.ok { color: #4ade80; }
.login-msg.err { color: #ff7a7a; }
.login-hint { margin: 0; color: var(--muted, #7f8ca3); font-size: 12px; line-height: 1.4; }

/* logged-in user chip in the list bar */
.user-chip { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.user-email { font-size: 12px; color: var(--muted, #9fb0c8); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Webcam capture modal (desktop live camera) ---------------------------- */
.cam-modal{max-width:560px; width:92vw}
.cam-live{border-radius:12px; overflow:hidden; background:#000; aspect-ratio:4/3;
  display:grid; place-items:center; margin-bottom:12px}
.cam-live video{width:100%; height:100%; object-fit:cover}

/* Lazy per-row colour picker (perf: the 200-option <select> is only built on click) */
.color-pick{display:inline-flex;align-items:center;gap:6px;max-width:170px;background:var(--card-2);color:var(--text);border:1px solid var(--line);border-radius:8px;padding:5px 8px;font-size:13px;cursor:pointer;text-align:left}
.color-pick .cname{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.color-pick .cchev{margin-left:auto;color:var(--muted);font-size:10px}
.color-pick:hover{border-color:var(--accent)}

/* Pager / Blätter-Funktion for long lists */
.pager{display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;padding:12px 4px 2px}
.pager-info{color:var(--muted);font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}

/* Katalog-Textsuche (Teil per Name/Nr. finden) */
.text-search{display:flex;gap:8px;margin-top:10px}
.text-search input{flex:1;min-width:0;background:var(--card-2);border:1px solid var(--line);color:var(--text);border-radius:10px;padding:10px 14px;font-size:14px}
.text-search input:focus{outline:none;border-color:var(--accent)}
