:root {
  --red: #c00000; --bg: #f4f4f5; --card: #fff; --text: #1f1f23; --muted: #6b6b75;
  --line: #e2e2e6; --yellow: #fff2cc; --done: #e9f7ee; --done-line: #9ad3ad;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17171a; --card: #232328; --text: #ececf0; --muted: #a0a0aa; --line: #3a3a42;
          --yellow: #3d3520; --done: #1d3326; --done-line: #2f6a45; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
       background: var(--bg); color: var(--text); padding-bottom: 90px; }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
       background: var(--red); color: #fff; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; }
.save-state { font-size: 13px; opacity: .9; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 19px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.error { color: #d33; min-height: 1em; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
        padding: 16px; margin-bottom: 12px; color: inherit; text-decoration: none; }
.narrow { max-width: 360px; margin: 40px auto; }
.info { margin-bottom: 14px; font-size: 15px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
       background: var(--card); color: var(--text); border-radius: 10px; padding: 10px 16px; font-size: 16px;
       font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 15px; font-size: 17px; }
input[type=password], input[type=number] { font: inherit; font-size: 20px; padding: 10px; border-radius: 10px;
       border: 1px solid var(--line); background: var(--card); color: var(--text); width: 100%; }
#login input { margin: 8px 0; text-align: center; letter-spacing: 4px; }

.line .head { display: flex; gap: 14px; align-items: center; }
.line img, .line .noimg { width: 84px; height: 84px; object-fit: contain; border-radius: 10px; background: #fff; flex: none; }
.noimg { display: flex; align-items: center; justify-content: center; font-size: 36px; }
.line .name { font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.line.done { background: var(--done); border-color: var(--done-line); }
.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stepper span, .sum span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.stepper div { display: flex; gap: 6px; }
.stepper input { text-align: center; background: var(--yellow); min-width: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.btn.step { width: 46px; flex: none; padding: 0; font-size: 24px; }
.sum { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center;
       border-top: 1px solid var(--line); padding-top: 10px; }
.sum span { margin: 0; font-size: 15px; }
.sum b { font-size: 20px; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center;
          gap: 10px; background: var(--card); border-top: 1px solid var(--line); padding: 12px 16px;
          padding-bottom: max(12px, env(safe-area-inset-bottom)); }

.hist { display: flex; justify-content: space-between; align-items: center; }
.n { text-align: right; white-space: nowrap; }
.report table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 15px; }
.report th { background: var(--red); color: #fff; padding: 8px; font-size: 13px; text-align: left; }
.report td { border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: middle; }
.report td.img img, .report td.img .noimg { width: 56px; height: 56px; object-fit: contain; font-size: 24px; }
.report tfoot td { font-weight: 700; border-top: 2px solid var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

@media (max-width: 420px) {
  .line img, .line .noimg { width: 68px; height: 68px; }
  .report th:nth-child(4), .report td:nth-child(4) { display: none; }
}
@media print {
  :root { --bg: #fff; --card: #fff; --text: #000; --line: #bbb; }
  .top, .noprint, .bottom { display: none !important; }
  body { padding: 0; }
  main { max-width: none; padding: 0; }
  .report th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.btn.bag { margin-top: 6px; padding: 5px 10px; font-size: 14px; font-weight: 600; }
dialog.edit { border: none; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px));
              background: var(--card); color: var(--text); }
dialog.edit::backdrop { background: rgba(0,0,0,.5); }
dialog.edit form { padding: 18px; }
dialog.edit label { display: block; font-weight: 600; margin-bottom: 14px; }
dialog.edit input { font: inherit; font-size: 17px; width: 100%; padding: 10px; margin-top: 4px; border-radius: 10px;
                    border: 1px solid var(--line); background: var(--bg); color: var(--text); }
dialog.edit small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }
svg.ean { display: block; width: 150px; height: auto; margin: 6px 0 2px; border-radius: 4px; }
.report svg.ean { width: 120px; }
.ean-preview svg.ean { width: 190px; margin-top: 8px; }
.mail { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 0; font-size: 15px; }
.btn.danger { color: #d33; margin-left: auto; }
