:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1b1a17; --muted: #6b675f; --line: #e3dfd6;
  --accent: #8a5a2b; --pass: #1f7a45; --pass-bg: #e6f3ea; --fail: #b3261e; --fail-bg: #fbe9e7;
  --warn: #9a6700; --warn-bg: #fff4d6; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--ink); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: .2px; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); font-family: Georgia, serif; font-size: 18px; }
.who { font-size: 13px; opacity: .8; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 120px; }
.pad { padding: 16px 0; }
.muted { color: var(--muted); }
h1 { font-size: 24px; margin: 4px 0 4px; }
h2 { font-size: 18px; margin: 24px 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { display: block; padding: 18px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; font-weight: 600; font-size: 17px; }
.tile small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 10px 0; }
a.card { display: block; text-decoration: none; }
a.card:active { transform: scale(.99); }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.deal { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.prod { font-size: 18px; font-weight: 600; margin-top: 2px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.badge.rework { background: var(--fail-bg); color: var(--fail); }
.badge.qty { background: #efe9df; color: var(--accent); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
details.upcoming summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
details.upcoming li { margin: 4px 0; color: var(--muted); font-size: 14px; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; }
.gate h3, .block h3 { margin: 0 0 8px; font-size: 17px; }
.gate ul { margin: 0 0 12px; padding-left: 20px; color: #3b3832; }
.gate li { margin: 4px 0; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; }
button, .btn { appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 12px;
  font: inherit; font-weight: 600; padding: 14px 16px; min-height: 52px; cursor: pointer; }
button[aria-pressed="true"].pass { background: var(--pass-bg); border-color: var(--pass); color: var(--pass); }
button[aria-pressed="true"].na { background: #eee; border-color: #999; }
button[aria-pressed="true"].no { background: var(--fail-bg); border-color: var(--fail); color: var(--fail); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.checks label { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.checks input { width: 22px; height: 22px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.slot { position: relative; aspect-ratio: 1; max-width: 100%; border: 2px dashed #c9c2b4; border-radius: 12px; background: #faf8f4;
  display: grid; place-items: center; text-align: center; overflow: hidden; cursor: pointer; }
.slot.done { border-style: solid; border-color: var(--pass); }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot .lbl { position: relative; z-index: 1; font-weight: 600; font-size: 14px; padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,.85); }
.slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.slot .state { position: absolute; bottom: 6px; right: 6px; z-index: 1; font-size: 12px; background: rgba(0,0,0,.65); color: #fff; padding: 2px 6px; border-radius: 6px; }
textarea { width: 100%; min-height: 90px; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.actions { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom)); background: rgba(246,244,239,.96); border-top: 1px solid var(--line); z-index: 6; }
.actions .inner { display: flex; gap: 10px; max-width: 760px; margin: 0 auto; width: 100%; }
.actions button { flex: 1; }
.btn-pass { background: var(--pass); color: #fff; border-color: var(--pass); }
.btn-fail { background: #fff; color: var(--fail); border-color: var(--fail); }
.btn-pass:disabled { opacity: .5; }
.problems { background: var(--fail-bg); color: var(--fail); border-radius: 12px; padding: 12px 16px; }
.problems ul { margin: 6px 0 0; padding-left: 18px; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
.hist li { margin: 6px 0; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 12px; z-index: 10; max-width: calc(100% - 32px); }
.qr-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center; break-inside: avoid; }
.qr-card svg { width: 100%; max-width: 220px; height: auto; }
.qr-card .st { font-size: 22px; font-weight: 700; margin-top: 8px; }
.qr-card .hint { color: var(--muted); font-size: 13px; }
@media print {
  .top, .noprint, .actions { display: none !important; }
  body, main { background: #fff; padding: 0; max-width: none; }
  .qr-sheet { grid-template-columns: repeat(2, 1fr); }
  .qr-card { border: 2px solid #000; page-break-inside: avoid; min-height: 45vh; display: flex; flex-direction: column; justify-content: center; }
  .qr-card svg { max-width: 300px; margin: 0 auto; }
  .qr-card .st { font-size: 32px; }
}
.slot .state:empty { display: none; }

/* intake */
.intake-tile { margin-bottom: 14px; border-color: var(--accent); background: #fbf6ef; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tags span { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #efe9df; color: var(--accent); font-weight: 600; }
.form label { display: block; font-weight: 600; margin: 0 0 14px; }
.form input:not([type=radio]) { display: block; width: 100%; box-sizing: border-box; margin-top: 6px; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.form textarea { margin-top: 6px; box-sizing: border-box; font-weight: 400; }
.form fieldset { border: 0; padding: 0; margin: 0 0 14px; }
.form legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.req { color: var(--fail); }
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.form .choice { display: flex; gap: 10px; align-items: center; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 500; }
.form .choice:has(input:checked) { border-color: var(--pass); background: var(--pass-bg); }
.form .choice input { width: 20px; height: 20px; }

/* per-item photo */
.slots.mini { margin-top: 10px; grid-template-columns: 1fr; }
.slots.mini .slot { display: flex; align-items: center; aspect-ratio: auto; min-height: 0; padding: 8px 12px; flex-direction: row; justify-content: flex-start; gap: 10px; border-width: 1px; }
.slots.mini .slot img { position: static; width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.slots.mini .slot .lbl { background: none; padding: 0; font-weight: 500; }
.slots.mini .slot .state { position: static; }

/* editor */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.tabs button { min-height: 40px; padding: 8px 14px; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.field { display: block; font-weight: 600; margin: 10px 0; }
.field input, .field select, input.plain { display: block; width: 100%; box-sizing: border-box; margin-top: 6px; font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field textarea { margin-top: 6px; box-sizing: border-box; font-weight: 400; min-height: 110px; }
.itemed .tools { display: flex; gap: 6px; }
.itemed .tools button { min-height: 36px; min-width: 40px; padding: 4px 10px; }
.ticks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.tick { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.tick input { width: 18px; height: 18px; }
.addrow { display: flex; flex-wrap: wrap; gap: 8px; }
.addrow button { min-height: 40px; padding: 8px 12px; }
button.linkish { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }
code { background: #efe9df; padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* units, stock and printed tags */
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
table.kv { border-collapse: collapse; width: 100%; }
table.kv th { text-align: left; font-weight: 600; color: var(--muted); padding: 5px 12px 5px 0; white-space: nowrap; vertical-align: top; width: 1%; }
table.kv td { padding: 5px 0; }
table.kv.big th, table.kv.big td { font-size: 17px; padding: 7px 14px 7px 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.steps span { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #efe9df; color: var(--muted); }
.steps span.done { background: var(--pass-bg); color: var(--pass); }
.steps span.here { background: var(--ink); color: #fff; font-weight: 700; }
.tag { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin: 16px 0; text-align: center; }
.tag-top { font-size: 13px; letter-spacing: 1px; color: var(--accent); font-weight: 700; }
.tag-id { font-size: 40px; font-weight: 800; letter-spacing: 1px; margin: 4px 0 12px; }
.tag-qr svg { width: 260px; max-width: 70%; height: auto; }
.tag table.kv { max-width: 380px; margin: 14px auto 0; text-align: left; }
.tag-foot { margin-top: 16px; font-size: 12px; color: var(--muted); }
@media print {
  .tag { border: 0; page-break-after: always; margin: 0; padding: 0; }
  .tag:last-child { page-break-after: auto; }
  .tag-qr svg { width: 3.2in; }
}
