:root {
  color-scheme: light dark;
  --bg: #f6f3ec;
  --surface: #ffffff;
  --ink: #1d2420;
  --dim: #5c665f;
  --line: #d9d4c7;
  --accent: #2f6b3f;
  --on-accent: #ffffff;
  --danger: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141815;
    --surface: #1f2521;
    --ink: #eef2ec;
    --dim: #a3ada5;
    --line: #353d37;
    --accent: #7fce94;
    --on-accent: #0d1a11;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 system-ui, sans-serif;
}
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
.dim { color: var(--dim); margin: 0; font-size: 0.9rem; }
.error { color: var(--danger); margin: 0; min-height: 1.4em; }

input, button { font: inherit; color: inherit; }
input:not([type=checkbox], [type=range]) {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
button {
  min-height: 48px;
  padding: 0 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: default; }
button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
  font-weight: 700;
}
button.danger { color: var(--danger); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
label, .label { display: block; margin: 14px 0 6px; font-weight: 600; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; }

#login {
  max-width: 340px;
  margin: 18vh auto 0;
  padding: 0 16px;
  display: grid;
  gap: 8px;
}

#app { max-width: 1100px; margin: 0 auto; padding: 16px 16px 110px; }
header { display: grid; gap: 10px; grid-template-columns: 1fr; }
.check { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
#status { color: var(--dim); margin: 24px 0; }
#status:empty { display: none; }

#list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}
.card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  text-align: left;
}
.card.empty { opacity: 0.55; }
.thumb {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--bg);
}
.text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar::before { content: ""; display: block; height: 100%; width: var(--pct); background: var(--accent); }

.fab {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  min-height: 60px;
  font-size: 1.15rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}

dialog {
  width: min(100%, 460px);
  max-width: 100%;
  max-height: 100dvh;
  margin: auto auto 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  border: 0;
  border-radius: 18px 18px 0 0;
}
dialog::backdrop { background: rgb(0 0 0 / 0.55); }
dialog video {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-top: 12px;
  background: #000;
  border-radius: 12px;
  object-fit: cover;
}
#scanner-close, #item .primary { width: 100%; margin-top: 12px; }
#item .row { margin-top: 10px; justify-content: space-between; }
.product { display: flex; gap: 12px; align-items: center; }
.product img { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: var(--surface); }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 72px; min-height: 64px; font-size: 2rem; line-height: 1; }
.stepper output { flex: 1; text-align: center; font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; height: 44px; accent-color: var(--accent); }

@media (min-width: 720px) {
  header { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px; }
  .fab { left: auto; right: 24px; bottom: 24px; padding: 0 32px; }
  dialog { margin: auto; border-radius: 18px; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: transform 0.1s; }
  button:active:not(:disabled) { transform: scale(0.97); }
}
