:root {
  --bg: #f4f6f8; --card: #fff; --fg: #14202b; --muted: #5d6b78; --line: #d8dee4;
  --brand: #0f3d5e; --brand-fg: #fff; --ok: #1b7f4b; --err: #b3261e; --warn: #b26a00;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #10161c; --card: #19222b; --fg: #e8eef3; --muted: #9aa8b5; --line: #2c3946;
          --brand: #4aa3df; --brand-fg: #06141f; --ok: #5fcf92; --err: #ff8a80; --warn: #ffb74d; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto; padding: 12px 14px 24px; }
h1 { font-size: 1.4rem; margin: 8px 0 12px; }
h2 { font-size: 1.05rem; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--brand); }
.muted { color: var(--muted); font-size: .9rem; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  background: var(--brand); color: var(--brand-fg); }
.top .brand { color: inherit; font-weight: 700; text-decoration: none; }
.top form { margin: 0; }
button.link { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; padding: 8px; }

.stack > * + * { margin-top: 12px; }
label { display: block; font-weight: 600; font-size: .95rem; }
label .muted { font-weight: 400; }
input, select, textarea { width: 100%; margin-top: 4px; padding: 12px; font: inherit; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
input[type=file] { padding: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
fieldset > * + * { margin-top: 12px; }
legend { font-weight: 700; padding: 0 6px; }

.btn { display: block; width: 100%; text-align: center; padding: 14px; font: inherit; font-weight: 600;
  background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; cursor: pointer; margin-top: 10px; }
.btn.primary { background: var(--brand); color: var(--brand-fg); border-color: var(--brand); }
.btn[disabled] { opacity: .6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 .btn, .grid3 .btn { margin-top: 0; }

.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin-top: 10px; color: inherit; text-decoration: none; }
.card.row, .row { display: flex; gap: 12px; align-items: center; }
.grow { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.alignr { text-align: right; }
.card .btn { margin-top: 8px; }

.qty { display: inline-block; min-width: 2.4em; text-align: center; padding: 4px 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); font-weight: 700; }
.qty.low { background: var(--err); color: #fff; border-color: var(--err); }
.qty.big { font-size: 1.6rem; padding: 4px 16px; margin-left: 6px; }
.bigqty > * + * { margin-top: 6px; }
.delta { font-weight: 700; }
.delta.pos { color: var(--ok); }
.delta.neg { color: var(--err); }

.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumbwrap { display: block; text-align: center; font-size: .8rem; color: var(--muted); text-decoration: none; }
.thumbwrap.empty { display: flex; align-items: center; justify-content: center; min-height: 90px;
  border: 1px dashed var(--line); border-radius: 10px; }
.thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.thumb.small { width: 64px; height: 64px; flex: none; }
.thumb.broken { visibility: hidden; }

.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 8px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }

.flash { padding: 12px; border-radius: 10px; margin-bottom: 10px; border: 1px solid var(--line); background: var(--card); }
.flash.ok { border-color: var(--ok); }
.flash.error { border-color: var(--err); color: var(--err); font-weight: 600; }
.flash.info { border-color: var(--warn); }
.scan-msg { display: block; margin-top: 4px; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; text-align: center; padding: 8px 2px 6px; text-decoration: none; color: var(--muted);
  font-size: 1.15rem; line-height: 1.1; }
.tabbar a span { display: block; font-size: .7rem; margin-top: 2px; }
.tabbar a.on { color: var(--brand); font-weight: 700; }
.badge { background: var(--err); color: #fff; border-radius: 999px; padding: 0 6px; font-size: .7rem; }
