:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #5d6b7a;
  --line: #dde3ea;
  --brand: #005eb8;
  --brand-dark: #003d78;
  --ok: #1b7f3b;
  --ok-bg: #e3f4e8;
  --low: #8a5a00;
  --low-bg: #fff1cc;
  --out: #b3261e;
  --out-bg: #fde4e2;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); font-size: .9rem; }
a { color: var(--brand); }

header.top { background: var(--brand-dark); color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; padding: .5rem 1rem; }
header.top .brand { font-weight: 700; font-size: 1.1rem; margin-right: .5rem; }
header.top nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
header.top a, header.top button.link { color: #fff; text-decoration: none; padding: .4rem .7rem; border-radius: 6px; background: none; border: 0; font: inherit; cursor: pointer; }
header.top a:hover, header.top a.active, header.top button.link:hover { background: rgba(255,255,255,.18); }
header.top .who { font-size: .85rem; opacity: .9; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.banner { border-radius: 10px; padding: .9rem 1rem; margin: .75rem 0 1rem; font-weight: 600; display: flex; align-items: center; gap: .6rem; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.low { background: var(--low-bg); color: var(--low); }
.banner.out { background: var(--out-bg); color: var(--out); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; }
.tile { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-left: 8px solid var(--ok); border-radius: 10px; padding: .85rem 1rem; }
.tile:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.tile.low { border-left-color: #e0a100; background: #fffaf0; }
.tile.out { border-left-color: var(--out); background: #fff6f5; }
.tile h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.tile .status-line { font-weight: 600; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.low { background: var(--low-bg); color: var(--low); }
.pill.out { background: var(--out-bg); color: var(--out); }
.stale { color: var(--out); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.rows > .row { display: grid; grid-template-columns: 56px minmax(120px, 1fr) auto auto auto; gap: .4rem .8rem; align-items: center; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.rows > .row:last-child { border-bottom: 0; }
.rows > .row.low { background: #fffaf0; }
.rows > .row.out { background: #fff6f5; }
.row .name { font-weight: 600; background: none; border: 0; padding: 0; text-align: left; font: inherit; font-weight: 600; color: var(--brand); cursor: pointer; }
.row .name:hover { text-decoration: underline; }
.row .qty { text-align: right; min-width: 6.5rem; }
.row .qty strong { font-size: 1.15rem; }
.row .check-inputs { display: flex; gap: .5rem; align-items: end; }
.row .check-inputs label { font-size: .75rem; color: var(--muted); display: flex; flex-direction: column; }
.row .check-inputs input { width: 5.2rem; }

.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #e9eef3; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.3rem; }
.thumb-btn { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 8px; line-height: 0; }
.thumb.big { width: 100%; height: auto; max-height: 340px; object-fit: contain; background: #fff; }

input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #b9c3cf; border-radius: 6px; background: #fff; color: var(--ink); max-width: 100%; }
textarea { width: 100%; min-height: 110px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #ffbf47; outline-offset: 1px; }
label.field { display: block; margin: .6rem 0; font-weight: 600; font-size: .92rem; }
label.field input, label.field select { display: block; width: 100%; margin-top: .2rem; font-weight: 400; }
label.field textarea { margin-top: .2rem; font-weight: 400; }
label.field input[type=checkbox] { display: inline-block; width: auto; margin: 0 .4rem 0 0; }
[hidden] { display: none !important; }

.bc-list > .bc-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: .4rem 1rem; align-items: center; padding: .7rem .9rem; border-bottom: 1px solid var(--line); border-left: 8px solid var(--ok); }
.bc-list > .bc-row:last-child { border-bottom: 0; }
.bc-row.low { border-left-color: #e0a100; background: #fffaf0; }
.bc-row.out { border-left-color: var(--out); background: #fff6f5; }
.bc-row .name { font-weight: 600; background: none; border: 0; padding: 0; text-align: left; font: inherit; font-weight: 600; color: var(--brand); cursor: pointer; }
.bc-row .name:hover { text-decoration: underline; }
.bc-row .actions { margin: 0; }
.bc-row .issue { color: var(--out); font-weight: 600; }
@media (max-width: 640px) { .bc-list > .bc-row { grid-template-columns: 1fr; } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

.btn { font: inherit; font-weight: 600; padding: .55rem 1rem; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; }
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: #eef5fc; }
.btn.danger { background: var(--out); border-color: var(--out); }
.btn.small { padding: .3rem .65rem; font-size: .88rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; align-items: center; }

table.admin { width: 100%; border-collapse: collapse; }
table.admin th, table.admin td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.admin th { font-size: .8rem; text-transform: uppercase; color: var(--muted); }
table.admin td input[type=number] { width: 5rem; }

.overlay { position: fixed; inset: 0; background: rgba(15,25,35,.55); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 1.5rem .75rem; z-index: 10; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; padding: 1.1rem 1.2rem 1.3rem; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal.wide { max-width: 860px; }
.modal h2 { margin-top: 0; }
.modal .close { float: right; }
.instructions { white-space: pre-wrap; background: #f1f6fb; border-left: 5px solid var(--brand); padding: .7rem .9rem; border-radius: 6px; }

.login { max-width: 380px; margin: 12vh auto; padding: 1.5rem; }
.err { color: var(--out); font-weight: 600; margin: .5rem 0; }

#toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #1d2733; color: #fff; padding: .6rem 1rem; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--out); }

/* Wall display */
.display-board { background: #0e1a26; color: #fff; min-height: 100vh; padding: 1.5rem; }
.display-board h1 { font-size: 2.2rem; }
.display-board .big-row { display: flex; align-items: center; gap: 1rem; padding: .8rem 1rem; margin: .5rem 0; border-radius: 10px; font-size: 1.5rem; }
.display-board .big-row.low { background: #5c4300; }
.display-board .big-row.out { background: #7a1a15; }
.display-board .big-row .loc { opacity: .8; font-size: 1.1rem; }
.display-board .all-good { font-size: 2rem; color: #7be39a; margin-top: 3rem; }

@media (max-width: 640px) {
  .rows > .row { grid-template-columns: 48px 1fr auto; }
  .rows > .row .target, .rows > .row .last { grid-column: 2 / 4; }
  .two { grid-template-columns: 1fr; }
  .thumb { width: 48px; height: 48px; }
}

/* v1.2 additions */
label.inline { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .92rem; }
.step-tick { display: flex; align-items: center; font-weight: 400; font-size: 1rem; }
.step-tick input[type=checkbox] { transform: scale(1.4); margin: 0 .7rem 0 .2rem; }
.step-edit { display: grid; grid-template-columns: 1fr auto auto; gap: .4rem; margin: .4rem 0; align-items: center; }
.step-edit input { width: 100%; }
td.wrap { white-space: normal; max-width: 460px; word-break: break-word; }

.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem; text-align: center; }
.qr-card h3 { margin: 0 0 .5rem; }
.qr-cta { font-weight: 700; font-size: 1.1rem; margin: .4rem 0; }

.rep-wrap { max-width: 760px; margin: 0 auto; padding: 1rem; }
.rep-head { background: var(--brand-dark); color: #fff; padding: .8rem 1rem; font-weight: 700; font-size: 1.15rem; }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .7rem; margin: .8rem 0; }
.rep-card { background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.rep-card.low { border-color: #e0a100; background: #fffaf0; }
.rep-card.out { border-color: var(--out); background: #fff6f5; }
.rep-card .thumb { width: 100%; height: 110px; object-fit: contain; background: #fff; }
.rep-card .btns { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.rep-card .btns .btn { padding: .6rem .3rem; font-size: .95rem; }
.rep-card .btn.on { background: var(--brand-dark); color: #fff; }
.rep-card.out .btn.on { background: var(--out); border-color: var(--out); color: #fff; }
.rep-thanks { text-align: center; padding: 3rem 1rem; }
.rep-thanks h1 { font-size: 1.8rem; }

@media print {
  header.top, .no-print, #toast, .overlay { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .qr-card { page-break-inside: avoid; border: 2px solid #000; }
}

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: #e6f0fb; border: 1px solid #b9d3f0; border-radius: 999px; padding: .2rem .3rem .2rem .7rem; font-size: .9rem; }
.chip-x { border: 0; background: none; font-size: 1.1rem; line-height: 1; cursor: pointer; padding: .1rem .4rem; color: var(--brand-dark); }

.card.pad { padding: .9rem 1rem; margin-top: 1rem; }
tr.row-bad td { background: #fff6f5; }
.ek-row { display: flex; flex-wrap: wrap; gap: .4rem .7rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.ek-row > input[type=text], .ek-row > input:not([type]) { flex: 1 1 220px; min-width: 0; }
