/* ──────────────────────────────────────────────────────────────────────────
   Nobel BioCare — Dispatch Scanner (mobile)

   Built thumb-first: one job per screen, targets no smaller than 44px, the
   primary action pinned within reach at the bottom. Colours follow the ERP
   (pine / brass) so it reads as the same product.
   ────────────────────────────────────────────────────────────────────────── */

:root {
    --pine:       #12514e;
    --pine-dark:  #0a2b2c;
    --brass:      #c19a5b;
    --ok:         #1a7f37;
    --bad:        #b42318;
    --warn:       #8a6d3b;
    --ink:        #16211f;
    --muted:      #6f7d7c;
    --line:       #e2e8e7;
    --bg:         #f3f6f5;
    --radius:     16px;
    --safe-b:     env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg); color: var(--ink);
    font-size: 16px; line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(84px + var(--safe-b));
}
a { color: var(--pine); }

/* ── App bar ─────────────────────────────────────────────────────────── */
.appbar {
    position: sticky; top: 0; z-index: 50;
    background: linear-gradient(150deg, var(--pine) 0%, var(--pine-dark) 90%);
    color: #fff; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: 0 2px 12px rgba(10,43,44,.22);
}
.appbar h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: .2px; }
.appbar .sub { font-size: 11.5px; opacity: .72; margin-top: 1px; }
.appbar .spacer { margin-left: auto; }
.appbar a, .appbar button {
    color: #fff; background: rgba(255,255,255,.14); border: none;
    width: 40px; height: 40px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 17px; text-decoration: none;
}
.appbar a:active, .appbar button:active { background: rgba(255,255,255,.26); }

.wrap { padding: 14px; max-width: 640px; margin: 0 auto; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; margin-bottom: 12px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
           color: var(--muted); margin: 0 0 10px; font-weight: 700; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 52px; border-radius: 14px; border: none;
    font-size: 16px; font-weight: 650; cursor: pointer; text-decoration: none;
    background: var(--pine); color: #fff; padding: 0 18px;
}
.btn:active { transform: scale(.985); }
.btn.brass  { background: var(--brass); color: #241a06; }
.btn.ghost  { background: #fff; color: var(--pine); border: 1.5px solid var(--line); }
.btn.danger { background: #fff; color: var(--bad); border: 1.5px solid #f3c6c2; }
.btn[disabled] { opacity: .45; }
.btn.sm { min-height: 42px; font-size: 14px; border-radius: 12px; }

/* ── Scan input / camera ─────────────────────────────────────────────── */
.scanwrap { position: relative; }
#reader {
    width: 100%; aspect-ratio: 4/3; background: #0c1615; border-radius: var(--radius);
    overflow: hidden; position: relative; display: none;
}
#reader.on { display: block; }
#reader video { width: 100%; height: 100%; object-fit: cover; }
.reticle {
    position: absolute; inset: 18% 12%; border: 3px solid rgba(255,255,255,.85);
    border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35);
    pointer-events: none;
}
.reticle::after {
    content: ''; position: absolute; left: 6%; right: 6%; height: 2px;
    background: var(--brass); top: 50%; animation: sweep 2.2s ease-in-out infinite;
}
@keyframes sweep { 0%,100% { top: 12%; } 50% { top: 86%; } }

input.serial {
    width: 100%; min-height: 54px; border-radius: 14px; border: 1.5px solid var(--line);
    padding: 0 14px; font-family: ui-monospace, "Courier New", monospace;
    font-size: 19px; letter-spacing: 1px; text-transform: uppercase; background: #fff;
}
input.serial:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px rgba(18,81,78,.12); }
input.txt, select.txt {
    width: 100%; min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line);
    padding: 0 12px; font-size: 16px; background: #fff; color: var(--ink);
    /* 16px and a 48px box: anything smaller makes iOS zoom the page on focus. */
    -webkit-appearance: none; appearance: none;
}
select.txt {
    /* The native arrow goes with -webkit-appearance, so draw one back. */
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%236f7d7c' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
    background-size: 12px; padding-right: 36px;
}
select.txt:disabled { background-color: #f3f6f5; color: var(--muted); }
input.txt:focus, select.txt:focus { outline: none; border-color: var(--pine); }
label.fl { display: block; font-size: 12px; font-weight: 650; color: var(--muted);
           text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 5px; }

/* ── Verdict ─────────────────────────────────────────────────────────── */
.verdict {
    border-radius: var(--radius); padding: 18px 16px; text-align: center;
    border: 2px solid var(--line); background: #fff; margin-bottom: 12px;
}
.verdict .big { font-size: 26px; font-weight: 800; line-height: 1.1; }
.verdict .ser { font-family: ui-monospace, "Courier New", monospace; font-size: 13px;
                margin-top: 5px; color: var(--muted); word-break: break-all; }
.verdict .det { font-size: 14px; margin-top: 8px; }
.verdict .note { margin-top: 10px; font-size: 13px; color: var(--warn);
                 background: #fbf5ea; border-radius: 10px; padding: 8px 10px; }
.verdict.ok  { border-color: var(--ok);  background: #eaf6ed; }
.verdict.ok .big  { color: var(--ok); }
.verdict.bad { border-color: var(--bad); background: #fdeceb; }
.verdict.bad .big { color: var(--bad); }
.verdict.dup { border-color: var(--brass); background: #fbf5ea; }
.verdict.dup .big { color: var(--warn); }
.verdict.idle .big { color: var(--muted); font-size: 18px; font-weight: 650; }

/* ── Counters ────────────────────────────────────────────────────────── */
.counts { display: flex; gap: 10px; margin-bottom: 12px; }
.counts div { flex: 1; background: #fff; border: 1px solid var(--line);
              border-radius: 14px; padding: 12px 6px; text-align: center; }
.counts b { display: block; font-size: 24px; line-height: 1; }
.counts small { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.counts .a b { color: var(--ok); } .counts .r b { color: var(--bad); } .counts .d b { color: var(--muted); }

/* ── Scan list ───────────────────────────────────────────────────────── */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
    background: #fff; border: 1px solid var(--line); border-left-width: 4px;
    border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
    animation: pop .22s ease;
}
.feed li.ok  { border-left-color: var(--ok); }
.feed li.bad { border-left-color: var(--bad); }
.feed li.dup { border-left-color: var(--brass); }
.feed .s { font-family: ui-monospace, "Courier New", monospace; font-size: 12.5px; font-weight: 650; }
.feed .p { font-size: 13px; color: var(--ink); }
.feed .m { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ── Bottom action bar ───────────────────────────────────────────────── */
.dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    padding: 10px 14px calc(10px + var(--safe-b));
    display: flex; gap: 10px; max-width: 640px; margin: 0 auto;
}

/* ── Sheet (finish run) ──────────────────────────────────────────────── */
.sheet-bg { position: fixed; inset: 0; background: rgba(10,22,21,.55); z-index: 70; display: none; }
.sheet-bg.on { display: block; }
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    background: #fff; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
    max-width: 640px; margin: 0 auto; transform: translateY(100%);
    transition: transform .25s ease; max-height: 88vh; overflow: auto;
}
.sheet.on { transform: none; }
.sheet .grab { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
.sheet .lead { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

.err { color: var(--bad); font-size: 13.5px; margin-top: 10px; }
.muted { color: var(--muted); font-size: 12.5px; }
.center { text-align: center; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 10px;
        border-radius: 20px; background: #eef3f2; color: var(--pine); }

/* ── Mode switch ─────────────────────────────────────────────────────────
   Dispatch and Return are the same job in two directions, so they sit side by
   side rather than behind a menu — an operator holding a carton should be able
   to see which way the scan is about to go without opening anything. */
.modes {
    display: flex; gap: 6px; margin-bottom: 12px;
    background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 5px;
}
.modes a {
    flex: 1 1 0; min-height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14.5px; font-weight: 650; text-decoration: none; color: var(--muted);
}
.modes a.on { background: var(--pine); color: #fff; }
.modes a:active { background: var(--line); }
.modes a.on:active { background: var(--pine-dark); }