:root {
  --beige: #EEEAE0;
  --paper: #FAF8F3;
  --sage: #5B7769;
  --sage-dark: #475E53;
  --slate: #557087;
  --ink: #1F242D;
  --muted: #6B7280;
  --line: #D9D3C4;
  --red: #B4413C;
  --amber: #C98A1B;
  --green: #2F7D4F;
  --radius: 14px;
  --tap: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--beige);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--beige); }
body { font-size: 18px; line-height: 1.35; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; border-radius: var(--radius); min-height: 48px; padding: 0 18px; background: var(--paper); border: 1px solid var(--line); }
button:active { transform: scale(.98); }
button.primary { background: var(--sage); color: #fff; border-color: var(--sage); font-weight: 600; }
button.primary:hover { background: var(--sage-dark); }
button.danger { background: #fff; color: var(--red); border-color: var(--red); }
button.ghost { background: transparent; border-color: transparent; }
button.big { min-height: var(--tap); font-size: 20px; padding: 0 24px; }
button:disabled { opacity: .45; cursor: default; }
input, select { font: inherit; min-height: 52px; border-radius: 10px; border: 1px solid var(--line); padding: 0 14px; background: #fff; width: 100%; }

/* header */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--sage); color: #fff; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: .02em; }
.bar nav { display: flex; gap: 6px; flex: 1; }
.bar .tab { background: transparent; border-color: transparent; color: #fff; opacity: .8; min-height: 44px; }
.bar .tab.on { background: rgba(255,255,255,.18); opacity: 1; }
.who { display: flex; align-items: center; gap: 10px; margin-left: auto; white-space: nowrap; }
.who .ghost { color: #fff; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #9aa; display: inline-block; }
.dot.on { background: #7CE3A1; box-shadow: 0 0 0 3px rgba(124,227,161,.3); }
.dot.off { background: #F08A84; }

/* invisible but focusable scan input */
#scan { position: fixed; left: -1000px; top: 0; width: 10px; height: 10px; opacity: 0; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 26px; margin: 4px 0 14px; }
h2 { font-size: 20px; margin: 18px 0 10px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* login */
.login { max-width: 900px; margin: 4vh auto; text-align: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 18px; }
.tile { min-height: 120px; font-size: 22px; font-weight: 600; background: var(--paper); }
.tile .ini { display: block; width: 52px; height: 52px; line-height: 52px; margin: 0 auto 8px; border-radius: 50%; background: var(--slate); color: #fff; font-size: 22px; }
.pin { max-width: 380px; margin: 0 auto; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; min-height: 22px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--sage); }
.pin-dots span.f { background: var(--sage); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pad button { min-height: 76px; font-size: 28px; font-weight: 600; }

/* queue */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.seg button { border: 0; border-radius: 0; min-height: 52px; }
.seg button.on { background: var(--slate); color: #fff; }
.hint { padding: 14px 16px; border-radius: var(--radius); background: #fff; border: 2px dashed var(--sage); font-size: 20px; margin-bottom: 14px; }
.hint b { color: var(--sage-dark); }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.entry { text-align: left; display: block; width: 100%; padding: 14px 16px; border-left: 8px solid var(--line); min-height: 110px; }
.entry.overdue { border-left-color: var(--red); }
.entry.today { border-left-color: var(--amber); }
.entry.later { border-left-color: var(--sage); }
.entry.locked { opacity: .65; }
.entry .top { display: flex; gap: 8px; align-items: baseline; }
.entry .ref { font-weight: 700; font-size: 20px; }
.entry .items { margin-top: 6px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.badge { font-size: 14px; padding: 3px 9px; border-radius: 999px; background: var(--beige); border: 1px solid var(--line); white-space: nowrap; }
.badge.red { background: #FBE6E4; border-color: #E7B7B3; color: var(--red); }
.badge.amber { background: #FBF0D9; border-color: #E8CF97; color: #8a5d0c; }
.badge.green { background: #E1EFE6; border-color: #B4D3C0; color: var(--green); }
.badge.slate { background: #E3EAF0; border-color: #BCCBD8; color: var(--slate); }

/* pack view */
.pack-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.progress { flex: 1; min-width: 200px; height: 18px; background: #fff; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--sage); transition: width .25s; }
.count { font-size: 30px; font-weight: 700; }
.lines { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.line { display: flex; flex-direction: column; gap: 10px; border-width: 3px; }
.line.done { border-color: var(--green); background: #F1F8F3; }
.line .img { width: 100%; aspect-ratio: 4/3; border-radius: 10px; background: #fff center/contain no-repeat; border: 1px solid var(--line); }
.line .name { font-size: 22px; font-weight: 700; }
.line .qty { font-size: 34px; font-weight: 800; }
.line.done .qty { color: var(--green); }
.lots { display: flex; gap: 6px; flex-wrap: wrap; }
.lot { font-size: 15px; padding: 4px 10px; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.lot.sugg { border-color: var(--sage); background: #E9F1EC; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.next { font-size: 24px; font-weight: 700; padding: 16px 18px; border-radius: var(--radius); background: #fff; border: 3px solid var(--slate); margin-bottom: 14px; }
.next.label { border-color: var(--green); background: #EAF5EE; }

/* status */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* toast + flash */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(90vw, 720px); padding: 16px 22px; border-radius: var(--radius); font-size: 20px; font-weight: 600; color: #fff; background: var(--ink); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; text-align: center; }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }
#toast.ok { background: var(--green); }
.flash-ok { animation: fok .5s; }
.flash-err { animation: ferr .6s; }
@keyframes fok { 0% { box-shadow: inset 0 0 0 9999px rgba(47,125,79,.25); } 100% { box-shadow: none; } }
@keyframes ferr { 0%, 40% { box-shadow: inset 0 0 0 9999px rgba(180,65,60,.25); } 100% { box-shadow: none; } }

.shipped { text-align: center; padding: 8vh 16px; }
.shipped .check { width: 140px; height: 140px; line-height: 140px; margin: 0 auto 18px; border-radius: 50%; background: var(--green); color: #fff; font-size: 84px; }
.shipped h1 { font-size: 34px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(31,36,45,.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal[hidden] { display: none; }
.sheet { background: var(--paper); border-radius: var(--radius); padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.choice { display: grid; gap: 10px; margin: 14px 0; }
.choice button { text-align: left; min-height: 60px; }
textarea { font: inherit; width: 100%; min-height: 110px; border-radius: 10px; border: 1px solid var(--line); padding: 12px; }

@media (max-width: 700px) {
  body { font-size: 17px; }
  .bar { flex-wrap: wrap; }
  .bar nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .list, .lines { grid-template-columns: 1fr; }
  main { padding: 12px; }
}
@media (min-width: 1200px) {
  .lines { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
