/* Scanner and goods receipt; kept separate from app.css on purpose */
.scanner { display: flex; flex-direction: column; gap: .6rem; }
.scanner-view { display: none; position: relative; border-radius: 12px; overflow: hidden; background: #18181b; aspect-ratio: 4 / 3; }
.scanner.is-scanning .scanner-view { display: block; }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; display: block; cursor: crosshair; }
.scanner-frame { position: absolute; inset: 18% 22%; border: 3px solid #fff; border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.scanner-actions { display: flex; gap: .5rem; }
.scanner-actions button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; flex: 1; }
.scanner-start svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.scanner .scanner-stop { display: none; flex: 0 0 auto; }
.scanner.is-scanning .scanner-stop { display: inline-flex; }
.scanner.is-scanning .scanner-start { display: none; }
.scanner-manual { font-size: .85rem; margin: 0; }
.scanner-status:empty { display: none; }
.scanner-status { margin: 0; font-size: .9rem; font-weight: 600; }
.scan-result { border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; }
.scan-result.ok { background: rgba(21, 128, 61, .12); }
.scan-result.warn { background: rgba(194, 65, 12, .14); }
.scan-result:empty { display: none; }
.receipt-form { display: grid; gap: .8rem; }
.receipt-form .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.receipt-form label { margin: 0; }
/* Open delivery note: stays in view while booking its packs */
.ls-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
          padding: .6rem; border-radius: 10px; background: var(--neutral-bg); }
.ls-bar-text { flex: 1 1 100%; min-width: 0; display: flex; flex-direction: column; text-decoration: none; line-height: 1.3; }
.ls-bar-text span { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.ls-bar > .button, .ls-bar form { flex: 1; margin: 0; }
.ls-bar .button, .ls-bar button { width: 100%; min-height: 44px; padding: .3rem .8rem; font-size: .9rem; }
.ls-links { margin-top: .8rem; font-size: .9rem; }
.receipt-recent { margin: 0; padding-left: 1.1rem; font-size: .9rem; line-height: 1.7; }

/* NFS quick withdrawal */
.withdraw-form { display: grid; gap: .8rem; }
.withdraw-form .card { display: grid; gap: .8rem; }
.withdraw-form label { margin: 0; }
.withdraw-lines { display: grid; gap: .6rem; }
.withdraw-line { display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem; gap: .5rem; }
.withdraw-line[hidden], .withdraw-lines[hidden], .med-picker[hidden] { display: none; }
.med-picker { display: grid; gap: .6rem; }
.med-picker .list-search { margin: 0; }
.med-chosen, .med-results { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.med-chosen:empty, .med-results:empty { display: none; }
/* Name and stepper on top, the batch row below over the full width (no cut-off expiry on phones) */
.med-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .4rem .6rem; padding: .5rem .6rem;
            border-radius: 10px; background: var(--bg); }
.med-item .med-name { font-weight: 600; overflow-wrap: anywhere; }
.med-batch { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; min-width: 0; font-size: .85rem; }
.med-batch select { margin: 0; min-height: 44px; flex: 1 1 100%; min-width: 0; width: 100%; font-size: .9rem; }
.med-batch button { min-height: 44px; padding: .3rem .8rem; font-size: .9rem; flex: 1 1 auto; }
.batch-confirmed { color: var(--ok); font-weight: 600; }
/* Refilled bag: one tap when the medication belongs in several bags */
.med-bag { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; min-width: 0; font-size: .85rem; color: var(--muted); }
.med-bag button { min-height: 44px; padding: .3rem .7rem; font-size: .85rem; font-weight: 600; flex: 0 1 auto;
                  background: var(--card); color: var(--text); border: 1px solid var(--line-strong); }
.med-bag button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
/* Reason per line: consumption | broken while taking out | replaces a breakage (three equal segments, fits 360px) */
.med-reason { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0;
              border: 1px solid var(--line-strong); border-radius: var(--control); overflow: hidden; }
.med-reason button { min-height: 44px; margin: 0; padding: .25rem .3rem; border: 0; border-radius: 0; font-size: .8rem; font-weight: 600;
                     line-height: 1.15; background: var(--card); color: var(--text); overflow-wrap: anywhere; }
.med-reason button + button { border-left: 1px solid var(--line-strong); }
.med-reason button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.med-note { grid-column: 1 / -1; margin: 0; padding: .3rem .5rem; border-radius: 8px; font-size: .85rem; font-weight: 600;
            background: var(--yellow-bg); color: var(--yellow); }
.med-item.unconfirmed { outline: 2px solid rgba(194, 65, 12, .55); }
.med-item .stepper { display: flex; align-items: center; gap: .3rem; }
.med-item .stepper button { width: 44px; min-height: 44px; font-size: 1.2rem; }
.med-item output { min-width: 2ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.med-hit { width: 100%; min-height: 48px; display: flex; justify-content: space-between; align-items: center; gap: .6rem; text-align: left;
           background: transparent; color: inherit; border: 1px solid var(--line-strong); border-radius: 10px; padding: .5rem .8rem; font-weight: 400; }
.med-hit .med-name { flex: 1; min-width: 0; }
.withdraw-line select, .withdraw-line input { margin: 0; min-height: 48px; }
.withdraw-line select[name^="reason_"] { grid-column: 1 / -1; }

/* Ampoule scan (one side at a time, held still) */
.ampoule-progress { display: none; list-style: none; margin: 0; padding: 0; gap: .4rem; flex-wrap: wrap; }
.ampoule-scanner.is-scanning .ampoule-progress { display: flex; }
.ampoule-progress li { padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--line-strong); font-size: .85rem;
                       color: var(--muted); overflow-wrap: anywhere; }
.ampoule-progress li.seen { border-color: transparent; background: var(--yellow-bg); color: var(--yellow); font-weight: 600; }
.ampoule-progress li.seen::before { content: "? "; }
.ampoule-progress li.done { border-color: transparent; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.ampoule-progress li.done::before { content: "✓ "; }
.ampoule-scanner .scanner-frame { inset: 12% 30%; transition: border-color .25s; }
.ampoule-scanner.captured .scanner-frame { border-color: var(--ok); transition: none; }
/* Steadiness: fills while the picture is still and sharp, a frame is taken when full */
.ampoule-steady { position: absolute; top: 10px; left: 10px; width: 30px; height: 30px; border-radius: 50%;
  background: conic-gradient(#fff calc(var(--steady, 0) * 1turn), rgba(255, 255, 255, .25) 0);
  -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%); mask: radial-gradient(circle, transparent 52%, #000 54%); }
.ampoule-torch { position: absolute; top: 6px; right: 6px; width: 48px; min-height: 48px; padding: 0; border-radius: 50%;
                 background: rgba(0, 0, 0, .45); border: 0; color: #fff; }
.ampoule-torch[hidden] { display: none; }
.ampoule-torch svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }
.ampoule-torch[aria-pressed="true"] { background: #fff; color: #18181b; }
.ampoule-hint { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: .45rem .8rem; background: rgba(0, 0, 0, .65);
                color: #fff; font-weight: 700; text-align: center; }
.ampoule-hint:empty { display: none; }
.ampoule-scanner .scanner-actions { flex-wrap: wrap; }
.ampoule-scanner .ampoule-photo, .ampoule-scanner .ampoule-manual { display: none; }
.ampoule-scanner.is-scanning .scanner-actions button { padding: 0 12px; }
.ampoule-scanner.is-scanning .ampoule-photo { display: inline-flex; flex: 1 1 0; }
.ampoule-scanner.is-scanning .ampoule-manual { display: inline-flex; flex: 0 0 auto; }
.ampoule-photo svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.ampoule-scanner.is-stuck .ampoule-photo { background: var(--card); color: var(--text); border-color: var(--line-strong); }
.ampoule-scanner.is-stuck .ampoule-manual { background: var(--primary); color: var(--on-primary); border-color: var(--primary);
                                            box-shadow: 0 0 0 3px var(--yellow-bg); }
.ampoule-scanner.is-evaluating .scanner-status::after { content: ""; display: inline-block; width: .8em; height: .8em; margin-left: .4em;
  vertical-align: -1px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ampoule-spin .8s linear infinite; }
@keyframes ampoule-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ampoule-scanner.is-evaluating .scanner-status::after { animation: none; } }
.scan-confirm { display: grid; gap: .8rem; }
.bag-select { display: flex; gap: .5rem; align-items: end; }
.bag-select label { flex: 1; margin: 0; }
.scan-confirm[hidden] { display: none; }
.scan-confirm label { margin: 0; }
.scan-quantity { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.scan-quantity > span { flex: 1 1 100%; font-size: .85rem; color: var(--muted); }
.scan-quantity .stepper { display: flex; align-items: center; gap: .3rem; }
.scan-quantity .stepper button { width: 48px; min-height: 48px; padding: 0; font-size: 1.3rem; }
.scan-quantity input { width: 4.5rem; min-height: 48px; margin: 0; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.scan-quantity [data-add-pack] { min-height: 48px; }
.scan-confirm .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.scan-table tr.is-short .counted { color: var(--red); font-weight: 700; }
.scan-table tr.is-ok .counted { font-weight: 700; }
.scan-table tr.is-ok .counted::before { content: "✓ "; }
.table-wrap table.scan-table { min-width: 0; }
.scan-table .num { white-space: nowrap; }

/* Counting in packs (packs.js) */
.pack-bar { display: flex; align-items: center; gap: .5rem; margin-top: .4rem; }
.pack-bar[hidden] { display: none; }
.pack-bar button { min-height: 44px; padding: .3rem .8rem; flex: 0 0 auto; }
.pack-note { flex: 1; text-align: center; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.count-row .pack-bar { flex-basis: 100%; }
.new-batch-fields .pack-bar { grid-column: 1 / -1; }

/* Vehicle check confirm: known lots as choices, unrefrigerated since */
.known-lots { display: grid; gap: .4rem; }
.known-lots[hidden], .cold-since[hidden] { display: none; }
.known-lots > span { font-size: .85rem; color: var(--muted); }
.known-lots > div { display: flex; flex-wrap: wrap; gap: .4rem; }
.known-lots button { min-height: 44px; padding: .3rem .7rem; font-size: .9rem; font-variant-numeric: tabular-nums; }
.known-lots button.is-current { border-color: var(--ok); color: var(--ok); font-weight: 700; }
.known-lots button.is-current::before { content: "✓ "; }
.cold-since { display: grid; gap: .3rem; }
.cold-since label { margin: 0; }
