/* Warehouse Discrepancies — mobile-first, high-contrast, no external assets. */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #0f1722;
  --muted: #4a5568;
  --line: #c9d1dc;
  --brand: #14213d;
  --primary: #0b5cad;
  --primary-ink: #ffffff;
  --missing: #b45309;      /* amber/orange */
  --missing-bg: #fff4e0;
  --excess: #5b21b6;       /* purple */
  --excess-bg: #f1eaff;
  --ok: #146c2e;
  --ok-bg: #e3f6e8;
  --warn: #8a5300;
  --warn-bg: #fff3d6;
  --err: #b42318;
  --err-bg: #fde8e7;
  --focus: #ffbf00;
  --radius: 10px;
  --mono: ui-monospace, "SFMono-Regular", "Roboto Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--sans); }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0; }
code { font-family: var(--mono); background: #e7ebf0; padding: 0 .25em; border-radius: 4px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.ico { width: 1.4em; height: 1.4em; vertical-align: middle; flex: none; }
.ico-sm { width: 1.1em; height: 1.1em; }
.ico-xl { width: 48px; height: 48px; }

/* ---------- top bar ---------- */
/* Sticky only on wide screens: on a PDA the wrapped header would eat a third of the viewport. */
.topbar { position: relative; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; background: var(--brand); color: #fff; }
.brand { font-weight: 700; letter-spacing: .02em; margin-right: auto; }
.who { display: flex; gap: 6px; align-items: center; font-size: .9rem; order: 5; width: 100%; }
.who-name { font-weight: 700; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-name::after { content: " (self-reported)"; font-weight: 400; opacity: .75; font-size: .8em; }
.who-role { background: rgba(255,255,255,.18); border-radius: 999px; padding: 1px 8px; font-size: .8rem; }
.top-actions { display: flex; gap: 6px; order: 6; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.12); }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: #3ddc84; }
.conn-offline .dot { background: #ff5a4f; }
.conn-offline { background: #7a1d16; }
.conn-syncing .dot { background: #5ab0ff; }
.conn-attention .dot { background: #ffbf00; }
.conn-attention { background: #6b4a00; }

.banner { padding: 10px 14px; font-weight: 600; }
.banner-info { background: #dbeafe; color: #102a5c; }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner-error { background: var(--err-bg); color: var(--err); }

main { max-width: 760px; margin: 0 auto; padding: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.stack > * + * { margin-top: 10px; }
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0 0; }
.field-error { color: var(--err); font-weight: 600; margin: 4px 0 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: .95rem; min-height: 44px; }
.check input { width: 22px; height: 22px; }
label { font-weight: 600; display: block; }
.label-lg { font-size: 1.1rem; }
.opt { font-weight: 400; color: var(--muted); }

/* ---------- inputs & buttons ---------- */
.input, .input-xl, .select { width: 100%; border: 2px solid #8795a8; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; padding: 10px 12px; min-height: 48px; }
.input-xl { font-size: 1.5rem; padding: 12px 14px; min-height: 60px; }
.input-xl[aria-invalid="true"] { border-color: var(--err); background: #fff8f7; }
textarea.input { resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 8px 14px; border-radius: 8px; border: 2px solid #8795a8; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-ghost { background: transparent; }
.topbar .btn { color: #fff; border-color: rgba(255,255,255,.5); background: transparent; }
.btn-small { min-height: 40px; padding: 6px 10px; font-size: .9rem; }
.btn-icon { padding: 6px; }
.btn-xl { width: 100%; min-height: 60px; font-size: 1.25rem; }
.btn-wide { width: 100%; margin-top: 10px; }
.row { display: flex; gap: 8px; }
.row > .btn { flex: 1; }

/* ---------- landing ---------- */
.role-cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
@media (min-width: 480px) { .role-cards { grid-template-columns: 1fr 1fr; } }
.role-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 12px; min-height: 140px; border: 3px solid var(--brand); border-radius: 14px; background: #f6f8fb; color: var(--brand); font: inherit; cursor: pointer; touch-action: manipulation; }
.role-card:active { transform: scale(.99); }
.role-title { font-size: 1.5rem; font-weight: 800; }
.role-sub { color: var(--muted); }

/* ---------- scanner ---------- */
.scan-row { display: flex; align-items: center; gap: 8px; }
.scan-ico { width: 36px; height: 36px; color: var(--brand); }
.ack { border-radius: var(--radius); padding: 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; border: 2px solid; font-size: 1.05rem; }
.ack-detail { font-size: 1rem; }
.ack-sending { border-color: #5ab0ff; background: #e8f3ff; }
.ack-saved { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); flex-direction: row; flex-wrap: wrap; align-items: center; }
.ack-queued { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.ack-duplicate, .ack-error { border-color: var(--err); background: var(--err-bg); color: var(--err); }
.queue-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.queue-head h2 { margin-right: auto; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #e7ebf0; font-size: .85rem; font-weight: 700; }
.pill-info { background: #dbeafe; color: #102a5c; }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.queue-list { list-style: none; margin: 8px 0 0; padding: 0; }
.queue-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.q-loc { font-weight: 700; }
.q-state { font-weight: 700; text-align: right; }
.q-meta, .q-err { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }
.q-err { color: var(--err); }
.q-duplicate .q-state, .q-validation .q-state { color: var(--err); }
.q-server_error .q-state, .q-auth_paused .q-state { color: var(--warn); }
.queue-item .btn { grid-column: 1 / -1; justify-self: start; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,15,25,.6); display: flex; align-items: flex-end; justify-content: center; padding: 8px; overflow-y: auto; }
@media (min-width: 600px) { .modal { align-items: center; } }
.modal-box { width: 100%; max-width: 560px; background: var(--surface); border-radius: 14px; padding: 16px; outline: none; }
.modal-box:focus-visible { outline: 3px solid var(--focus); }
.modal-loc { font-size: 1.6rem; font-weight: 800; text-align: center; margin: 0 0 6px; }
.modal h2 { text-align: center; margin-bottom: 12px; }
.type-choices { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 420px) { .type-choices { grid-template-columns: 1fr 1fr; } }
.type-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 130px; border-radius: 14px; border: 4px solid; font: inherit; font-size: 1.3rem; font-weight: 800; cursor: pointer; touch-action: manipulation; padding: 12px; }
.type-btn small { font-size: .85rem; font-weight: 500; }
.type-missing { background: var(--missing-bg); border-color: var(--missing); color: #7a3a00; border-style: dashed; }
.type-excess { background: var(--excess-bg); border-color: var(--excess); color: var(--excess); }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 12px; padding: 12px; background: #f6f8fb; border-radius: 10px; border: 1px solid var(--line); }
.summary dt { color: var(--muted); font-weight: 600; }
.summary dd { margin: 0; font-weight: 700; word-break: break-word; }
.summary-loc { font-size: 1.4rem; }
.optional label { margin-top: 8px; }
.offline-note { background: var(--warn-bg); color: var(--warn); padding: 10px; border-radius: 8px; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.type-tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.type-tag-missing { background: var(--missing-bg); color: #7a3a00; border: 2px dashed var(--missing); }
.type-tag-excess { background: var(--excess-bg); color: var(--excess); border: 2px solid var(--excess); }

/* ---------- mover ---------- */
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.counter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; text-align: center; }
.counter-n { display: block; font-size: 1.6rem; font-weight: 800; }
.counter-l { font-size: .8rem; color: var(--muted); }
.mover-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.mover-tools .select { max-width: 220px; }
.stale { background: var(--warn-bg); color: var(--warn); font-weight: 700; padding: 10px; border-radius: 8px; margin-bottom: 8px; border: 2px solid var(--warn); }
.task-list.is-stale .task { opacity: .75; }
.aisle-group { margin-bottom: 8px; }
@media (min-width: 900px) { .topbar { position: sticky; top: 0; } .aisle-head { top: 56px !important; } }
.aisle-head { position: sticky; top: 0; z-index: 5; margin: 0; padding: 6px 10px; background: var(--brand); color: #fff; font-size: .95rem; border-radius: 6px; }
.tasks { list-style: none; margin: 4px 0 0; padding: 0; }
.task { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "loc btn" "type btn"; gap: 4px 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; transition: opacity .4s, background .3s; }
.task-loc { grid-area: loc; font-size: 1.2rem; font-weight: 800; white-space: nowrap; }
@media (min-width: 400px) { .task-loc { font-size: 1.35rem; } }
.task .type-tag { grid-area: type; justify-self: start; }
.btn-resolve { grid-area: btn; min-height: 56px; min-width: 120px; background: var(--ok); border-color: var(--ok); color: #fff; font-size: 1rem; }
.task.done { background: var(--ok-bg); opacity: .6; }
.task.gone { opacity: .35; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
@media (min-width: 560px) {
  .task { grid-template-columns: 1fr auto auto; grid-template-areas: "loc type btn"; }
}

.help ul { padding-left: 1.2em; }
.help li { margin-bottom: 6px; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60; max-width: 92vw; padding: 12px 16px; border-radius: 10px; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast-info { background: #1e293b; color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-warn { background: #8a5300; color: #fff; }
.toast-error { background: var(--err); color: #fff; }

/* ---------- supervisor ---------- */
.sup main { max-width: 1280px; }
.sup .topbar .brand::after { content: " · Supervisor"; font-weight: 400; opacity: .8; }
.login { max-width: 420px; margin: 40px auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tab[aria-selected="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
@media (min-width: 800px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi-n { font-size: 1.8rem; font-weight: 800; display: block; }
.kpi-l { color: var(--muted); font-size: .85rem; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 2fr 1fr; } }
.filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; align-items: end; }
@media (min-width: 800px) { .filters { grid-template-columns: repeat(5, 1fr); } }
.filters label { font-size: .8rem; color: var(--muted); }
.filters .input, .filters .select { min-height: 40px; padding: 6px 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f6f8fb; position: sticky; top: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover, tr.clickable:focus { background: #f1f5fb; }
.status-OPEN { color: var(--err); font-weight: 700; }
.status-RESOLVED { color: var(--ok); font-weight: 700; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.feed li { border-bottom: 1px solid var(--line); padding: 6px 0; font-size: .9rem; }
.feed .ev { font-weight: 700; }
.badge-live { font-size: .8rem; color: var(--muted); }
.drawer { position: fixed; inset: 0; z-index: 50; background: rgba(10,15,25,.5); display: flex; justify-content: flex-end; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-box { width: 100%; max-width: 640px; height: 100%; overflow-y: auto; background: var(--surface); padding: 16px; outline: none; }
.detail { display: grid; grid-template-columns: 180px 1fr; gap: 4px 12px; font-size: .92rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--line); padding: 4px 0 8px 10px; margin-left: 4px; }
.timeline pre { white-space: pre-wrap; word-break: break-word; background: #f6f8fb; padding: 6px; border-radius: 6px; font-size: .8rem; margin: 4px 0 0; }
.notice { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; padding: 10px; }
legend { font-weight: 700; padding: 0 4px; }
.bars { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.bars li { display: grid; grid-template-columns: 70px 1fr 40px; gap: 6px; align-items: center; margin: 2px 0; }
.bar { height: 10px; background: var(--primary); border-radius: 3px; }
.bar-0 { width: 0; } .bar-1 { width: 10%; } .bar-2 { width: 20%; } .bar-3 { width: 30%; } .bar-4 { width: 40%; } .bar-5 { width: 50%; }
.bar-6 { width: 60%; } .bar-7 { width: 70%; } .bar-8 { width: 80%; } .bar-9 { width: 90%; } .bar-10 { width: 100%; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
