:root {
  --bg: #f4f6f8; --card: #fff; --ink: #1b2430; --muted: #6b7786; --line: #dde3ea;
  --blue: #1565c0; --blue-dark: #0d47a1; --red: #c62828; --green: #2e7d32; --amber: #b26a00;
  --pending: #fff7d6;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body { margin: 0; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; }
h1, h2 { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.error { color: var(--red); margin: .5rem 0 0; }
.ok { color: var(--green); margin: .5rem 0 0; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; text-decoration: underline; }

.top { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.navbtn { background: none; border: 1px solid transparent; padding: .35rem .7rem; border-radius: 6px; cursor: pointer; color: var(--ink); }
.navbtn.active { background: var(--bg); border-color: var(--line); font-weight: 600; }
.who { margin-left: auto; color: var(--muted); display: flex; gap: .6rem; align-items: center; }

#main { padding: 1rem; max-width: 1200px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }
form label { display: block; margin: .75rem 0; font-weight: 600; }
form label input, form label select { display: block; width: 100%; margin-top: .25rem; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 6px; font-weight: 400; }
form.inline { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
form.inline label { flex: 1 1 160px; margin: 0; }
button.primary { background: var(--blue); color: #fff; border: 0; padding: .6rem 1rem; border-radius: 6px; cursor: pointer; font-weight: 600; }
button.primary:hover { background: var(--blue-dark); }
button.primary:disabled { opacity: .5; cursor: default; }
button.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); padding: .55rem .9rem; border-radius: 6px; cursor: pointer; }
button.danger { color: var(--red); border-color: var(--red); }
form button.primary { margin-top: .75rem; width: 100%; }

.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.toolbar input[type=search] { flex: 1 1 260px; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; }
.toolbar select { padding: .55rem; border: 1px solid var(--line); border-radius: 6px; }
.chk { display: flex; gap: .3rem; align-items: center; color: var(--muted); white-space: nowrap; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; position: sticky; top: 0; }
th.qty, td.qty { text-align: right; width: 64px; font-variant-numeric: tabular-nums; }
th.img, td.img { width: 56px; }
td.img img { width: 44px; height: 44px; object-fit: contain; border-radius: 4px; background: #fff; border: 1px solid var(--line); }
td.sku { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; white-space: nowrap; }
td.title { max-width: 520px; }
.badge { display: inline-block; font-size: .7rem; padding: .1rem .4rem; border-radius: 4px; background: #eceff1; color: var(--muted); margin-left: .4rem; vertical-align: middle; }
.badge.hidden { background: #ffe0b2; color: var(--amber); }
td.qty.dash { color: var(--muted); }
td.qty.zero { color: var(--red); font-weight: 600; }
td.qty .hid { font-size: .7rem; color: var(--amber); display: block; }
td.new input { width: 92px; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; text-align: right; font-variant-numeric: tabular-nums; }
td.new input.pending { background: var(--pending); border-color: var(--amber); }
td.new .mode { display: inline-flex; margin-left: .3rem; }
td.new .mode button { border: 1px solid var(--line); background: var(--card); padding: .3rem .45rem; cursor: pointer; font-size: .8rem; }
td.new .mode button:first-child { border-radius: 6px 0 0 6px; }
td.new .mode button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
td.new .mode button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
tr.pending-row { background: #fffdf3; }

.bar { position: sticky; bottom: 0; display: flex; gap: .6rem; align-items: center; justify-content: flex-end; padding: .75rem 1rem; margin-top: .75rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 -2px 12px rgba(0,0,0,.06); }
.bar span { margin-right: auto; font-weight: 600; }
#review-progress { margin-top: 1rem; }
#review-progress progress { width: 100%; }
#review-result ul { padding-left: 1.2rem; }
.st-ok { color: var(--green); } .st-failed { color: var(--red); } .st-stale, .st-unverified { color: var(--amber); }
td.delta-up { color: var(--green); } td.delta-down { color: var(--red); }

#toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 20; max-width: 90vw; }

@media (max-width: 720px) {
  #main { padding: .5rem; }
  th.sku, td.sku { display: none; }
  td.title { max-width: 220px; font-size: .9rem; }
  td.new input { width: 72px; }
  .top { gap: .5rem; }
  .who { width: 100%; margin-left: 0; justify-content: flex-end; }
}

/* Phone: give the title room; quantities and the input stay compact. */
@media (max-width: 720px) {
  th, td { padding: .4rem .35rem; }
  th.qty, td.qty { width: 36px; }
  th.img, td.img { width: 40px; }
  td.img img { width: 32px; height: 32px; }
  td.title { min-width: 140px; max-width: none; font-size: .85rem; }
  th.new { font-size: .65rem; }
  td.new { white-space: nowrap; }
  td.new input { width: 58px; padding: .35rem .3rem; }
  td.new .mode button { padding: .3rem .35rem; }
  .toolbar input[type=search] { font-size: 16px; } /* stops iOS zooming into the field */
}

#syncing { position: fixed; inset: 0; background: rgba(244,246,248,.85); z-index: 15; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.syncing-card { display: flex; gap: 1rem; align-items: center; max-width: 420px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#sync-info.stale { color: var(--amber); font-weight: 600; }

/* Completion banner on the review screen: visible from across the room. */
.done-banner { display: flex; gap: 1rem; align-items: center; padding: 1.25rem 1.5rem; border-radius: 12px; margin: .5rem 0 1rem; color: #fff; }
.done-banner > div:last-child { min-width: 0; overflow-wrap: anywhere; }
.done-list li { overflow-wrap: anywhere; }
@media (max-width: 720px) { .done-banner { padding: 1rem; gap: .75rem; } .done-title { font-size: 1.25rem; } .done-icon { width: 44px; height: 44px; font-size: 1.5rem; } }
.done-banner.good { background: var(--green); }
.done-banner.warn { background: var(--amber); }
.done-icon { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; flex: none; }
.done-title { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.done-sub { opacity: .95; margin-top: .2rem; }
.done-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.done-list li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
button.primary.big { font-size: 1.1rem; padding: .85rem 1.5rem; width: 100%; }

.badge.low { background: #ffe0b2; color: var(--amber); }
button.link.small { font-size: .8rem; }
