:root {
  --navy: #0f2744;
  --navy-2: #17365c;
  --ink: #132033;
  --muted: #5c6b7b;
  --line: #d5dde6;
  --bg: #f4f6f8;
  --card: #fff;
  --accent: #c45c16;
  --accent-ink: #fff;
  --good: #1b6b3a;
  --warn-bg: #fff4e5;
  --err-bg: #fdecea;
  --err: #9b1c1c;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 32, 54, .08), 0 8px 20px rgba(16, 32, 54, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--navy-2); }
.top {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  position: sticky; top: 0; z-index: 20;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.text-btn, .logout-form { margin: 0; }
.text-btn {
  background: none; border: 0; color: #d7e4f5; font: inherit; font-size: 15px;
  padding: 8px 0 8px 12px; cursor: pointer; text-decoration: none;
}
.main { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.45rem; margin: 0 0 .3rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; color: var(--navy); }
.sub, .fine, .status { color: var(--muted); }
.fine { font-size: .82rem; margin-top: 18px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0);
}

.login-card { margin-top: 28px; background: var(--card); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow); }
.pin-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.pin {
  font-size: 2rem; letter-spacing: .45em; text-align: center;
  padding: 14px 10px; border: 2px solid var(--line); border-radius: 12px;
  font-variant-numeric: tabular-nums; width: 100%;
}
.pin:focus { outline: 2px solid var(--navy); border-color: var(--navy); }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px;
  padding: 14px 16px; font: inherit; font-weight: 650; font-size: 1.05rem;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.search { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; position: relative; }
.field span { font-size: .78rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select {
  font: inherit; font-size: 1.05rem; padding: 12px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; width: 100%;
}
.field input:focus { outline: 2px solid var(--navy); border-color: var(--navy); }
.year-field { flex: 0 0 5.6rem; }
.grow { flex: 1; }

.lookup-form { display: flex; flex-direction: column; gap: 12px; }
.lookup-ymm, .lookup-extra { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.lookup-form .model-field { flex: 1 1 8rem; min-width: 0; }
.lookup-form .part-field { flex: 1 1 100%; } /* own row on phones so it stays wide */
.lookup-form .stock-field { flex: 1 1 12rem; }
.lookup-form .btn { flex: 1 1 100%; }
.lookup-stock-row {
  display: flex; gap: 10px; align-items: end;
  flex: 1 1 100%; width: 100%; min-width: 0;
}
.lookup-stock-row .stock-field { flex: 1 1 auto; min-width: 0; }
.lookup-stock-row #scan-btn {
  flex: 0 0 auto; width: auto; min-width: 7.6rem; min-height: 48px;
  padding-left: 14px; padding-right: 14px;
}

.suggest {
  list-style: none; margin: 4px 0 0; padding: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); position: absolute; left: 0; right: 0; top: 100%;
  z-index: 15; max-height: 240px; overflow: auto;
}
.suggest li { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.suggest li:last-child { border-bottom: 0; }
.suggest li:active, .suggest li.active { background: #eef3f9; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 12px; font: inherit; font-size: .92rem; cursor: pointer;
}
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.results { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; width: 100%; }
.loc-group, .cards-only { width: 100%; }
.card {
  display: block; width: 100%; max-width: 100%; box-sizing: border-box;
  background: var(--card); border-radius: var(--radius);
  padding: 14px 14px 12px; box-shadow: var(--shadow); text-decoration: none; color: inherit;
}
.card.has-thumb {
  display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 10px; align-items: start;
  width: 100%;
}
.card-thumb {
  width: 88px; height: 88px; object-fit: cover; border-radius: 8px; background: #d8dee6;
}
.thumb-wrap { position: relative; display: inline-block; line-height: 0; }
.card.has-thumb .thumb-wrap {
  display: block; width: 88px; border-radius: 8px; overflow: hidden;
}
.card.has-thumb .thumb-wrap .card-thumb { border-radius: 0; }
.photo-src-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(15, 39, 68, .84); color: #fff;
  font-size: .62rem; font-weight: 700; letter-spacing: .02em; line-height: 1.2;
  text-align: center; padding: 3px 4px;
}
.results-table .thumb-wrap { width: 48px; border-radius: 6px; overflow: hidden; display: block; }
.results-table .thumb-wrap .thumb { border-radius: 0; }
.results-table .photo-src-label { font-size: .5rem; padding: 2px 2px; }
.gallery-main-wrap { position: relative; display: block; }
.gallery-main-wrap .photo-src-label {
  font-size: .8rem; padding: 5px 8px; border-radius: 0 0 10px 10px;
}
.card-body { min-width: 0; width: 100%; }
.card .kicker {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; font-size: .8rem; color: var(--muted);
  flex-wrap: nowrap;
}
.card .kicker > span { white-space: nowrap; }
.card h2 { margin: 4px 0 2px; font-size: 1.12rem; }
.card .meta { margin: 0; font-size: .95rem; }
.card .row2 { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; font-size: .92rem; }
.badge {
  display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: .75rem; font-weight: 700;
  background: #e8eef6; color: var(--navy);
}
.badge.exact { background: #e3f5e9; color: var(--good); }
.badge.res { background: var(--warn-bg); color: #8a4b00; }
.badge.out { background: #eee; color: #555; }

.banner { background: #eef3f9; border-radius: 10px; padding: 10px 12px; }
.banner.err { background: var(--err-bg); color: var(--err); }
.banner.warn { background: var(--warn-bg); color: #8a4b00; }
.status { margin: 10px 0 0; }

.detail .lede { color: var(--muted); margin: 0 0 14px; }
.facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
  background: var(--card); padding: 14px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
.facts dd { margin: 2px 0 0; font-size: 1.02rem; font-weight: 600; }
.fits { margin: 0; padding-left: 1.1rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92rem; word-break: break-word; }
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-grid img { width: 100%; border-radius: 10px; background: #ddd; }
.gallery-main-btn { display: block; width: 100%; padding: 0; border: 0; background: none; }
.gallery-main { width: 100%; border-radius: 10px; background: #ddd; display: block; }
.gallery-thumbs { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.gallery-thumbs button {
  flex: 0 0 64px; padding: 0; border: 2px solid transparent; border-radius: 8px; background: none;
}
.gallery-thumbs button[aria-current="true"] { border-color: var(--navy); }
.gallery-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; display: block; background: #ddd; }
.lightbox {
  position: fixed; inset: 0; background: rgba(10,16,24,.92); z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 80px); border-radius: 8px; }
.lightbox-close {
  align-self: flex-end; margin-bottom: 8px; background: transparent; color: #fff;
  border: 0; font: inherit; font-weight: 700;
}
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

/* Header with app name */
.top { gap: 10px; }
.top .brand { flex: 0 0 auto; }
.app-name { font-weight: 650; font-size: .95rem; color: #d7e4f5; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.btn.secondary { background: #e8eef6; color: var(--navy); width: auto; }
.status.err { color: var(--err); }
.status.ok { color: var(--good); }

/* Home tiles — compact 2-col phone, 3–4-col tablet/desktop */
.home { padding-top: 2px; }
.home h1 { font-size: 1.2rem; margin: 0 0 .1rem; }
.home .lede { color: var(--muted); margin: 0 0 10px; font-size: .84rem; line-height: 1.3; }
.app-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.app-tile {
  display: flex; flex-direction: column; align-items: flex-start;
  background: var(--card); border-radius: 14px;
  padding: 12px 12px 10px; box-shadow: var(--shadow); text-decoration: none; color: inherit;
  border: 1px solid transparent; aspect-ratio: 1 / 1; min-height: 0; overflow: hidden;
}
.app-tile:hover, .app-tile:focus { border-color: var(--navy); outline: none; }
.tile-icon { font-size: 1.65rem; line-height: 1; margin-bottom: 8px; }
.app-tile h2 {
  margin: 0 0 4px; font-size: 1.02rem; color: var(--navy); line-height: 1.2;
  font-weight: 700;
}
.app-tile p {
  margin: 0; margin-top: auto; color: var(--muted); font-size: .75rem; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}

/* Results table (desktop) */
.results-table-wrap { overflow-x: auto; margin-top: 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.results-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.results-table th, .results-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.results-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.results-table th[aria-sort="asc"]::after { content: " \2191"; }
.results-table th[aria-sort="desc"]::after { content: " \2193"; }
.results-table tbody tr { cursor: pointer; }
.results-table tbody tr:hover { background: #eef3f9; }
.results-table a { color: inherit; text-decoration: none; font-weight: 650; }
.results-table .thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: #d8dee6; display: block; }
.cards-only { display: flex; flex-direction: column; gap: 10px; }
.table-only { display: none; }

.rnum { display: inline-block; margin-left: .4rem; font-weight: 650; color: var(--navy); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
h1 .rnum { display: block; margin: 6px 0 0; font-size: 1.05rem; color: var(--muted); font-weight: 650; }
.facts .span-2 { grid-column: 1 / -1; }

.edit-location { margin-top: 18px; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.location-form { display: flex; flex-direction: column; gap: 12px; }
.scanner { margin-top: 14px; background: #111; border-radius: var(--radius); overflow: hidden; padding: 0 0 12px; color: #ddd; }
.scanner video { width: 100%; max-height: 320px; background: #000; display: block; object-fit: cover; }
.scanner .fine, .scanner .text-btn { color: #ddd; padding: 0 12px; }
.locate-actions { align-items: stretch; }
.locate-actions .btn { flex: 1; width: auto; }

@media (min-width: 800px) {
  .main { max-width: 1200px; padding: 24px 28px; }
  .login-card { max-width: 420px; margin: 48px auto 0; }
  .app-grid { grid-template-columns: repeat(3, minmax(0, 220px)); gap: 14px; }
  .app-tile { padding: 16px 14px 12px; }
  .tile-icon { font-size: 1.85rem; }
  .app-tile h2 { font-size: 1.12rem; }
  .lookup-form .year-field { flex: 0 0 5.6rem; }
  .lookup-form .model-field { flex: 0 1 16rem; max-width: 18rem; }
  .lookup-form .part-field { flex: 1 1 22rem; } /* same row as model, much wider */
  .lookup-form .stock-field { flex: 1 1 20rem; }
  .lookup-form .lookup-stock-row { flex: 1 1 auto; width: auto; }
  .lookup-form .lookup-stock-row #scan-btn { min-width: 140px; }
  .lookup-form .btn { flex: 0 0 auto; width: auto; min-width: 140px; }
  /* locate form stays simpler */
  .locate-form.search { display: flex; flex-direction: row; flex-wrap: wrap; align-items: end; }
  .locate-form .field { flex: 1 1 280px; }
  .locate-form .locate-actions { flex: 0 0 auto; }
  .btn { width: auto; display: inline-block; min-width: 140px; }
  .pin-form .btn, .location-form .btn { width: 100%; display: block; }
  .cards-only { display: none; }
  .table-only { display: block; }
  .detail.has-gallery {
    display: grid; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr); gap: 28px; align-items: start;
  }
  .detail-photos h2:first-child { margin-top: 0; }
  .location-form { flex-direction: row; align-items: end; }
  .location-form .btn { width: auto; }
  .facts { grid-template-columns: 1fr 1fr 1fr; }
  .scanner video { max-height: 420px; }
}

@media (min-width: 1100px) {
  .app-grid { grid-template-columns: repeat(4, minmax(0, 220px)); }
}
@media (min-width: 1200px) {
  .main { max-width: 1280px; }
}

/* Bulk scan & set location */
.locate-bulk-btn { margin-top: 10px; text-align: center; text-decoration: none; display: block; }
.locate-bulk-hint { margin-top: 8px; }
.scan-stage {
  position: relative;
  margin: 12px 0;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 220px;
}
.scan-stage video {
  width: 100%;
  max-height: min(62vh, 560px);
  min-height: 220px;
  background: #000;
  display: block;
  object-fit: cover;
}
.scan-overlay-status {
  position: absolute; left: 0; right: 0; bottom: 0;
  margin: 0; padding: 8px 12px;
  color: #f2f5f8; font-size: .9rem;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
}
.result-banner {
  position: absolute; left: 10px; right: 10px; top: 10px;
  z-index: 5;
  display: flex; align-items: center; gap: 10px;
  background: #e8f6ee; color: var(--ink);
  border-radius: 12px; padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 1.05rem; font-weight: 650;
  line-height: 1.3;
}
.result-banner[hidden] { display: none !important; }
.result-banner.err { background: var(--err-bg); color: var(--err); }
.result-banner.warn { background: var(--warn-bg); color: #8a4b00; }
.result-banner .banner-body { flex: 1; min-width: 0; }
.result-banner .banner-loc { margin-top: 4px; font-size: 1.2rem; }
.result-banner .banner-ymm { font-weight: 500; color: var(--muted); font-size: .92rem; }
.result-banner .banner-undo { flex: 0 0 auto; min-width: 0; width: auto; padding: 10px 14px; }
.scan-toolbar { display: flex; gap: 10px; margin: 10px 0 14px; }
.scan-toolbar .btn { flex: 1; width: auto; text-align: center; }
.file-btn { display: flex; align-items: center; justify-content: center; margin: 0; }
.sticky-toggle {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: .95rem; margin: 8px 0;
}
.sticky-toggle input { width: 22px; height: 22px; margin-top: 2px; flex: 0 0 auto; }
.sticky-field { margin: 6px 0 14px; }
.confirm-panel {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin: 14px 0;
  border: 2px solid var(--accent);
}
.confirm-actions { margin-top: 10px; }
.confirm-actions .btn { flex: 1; width: auto; }
.session { margin-top: 18px; }
.session h2 .muted { color: var(--muted); font-weight: 500; }
.session-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.session-list li {
  background: var(--card); border-radius: 12px; padding: 10px 12px;
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  font-size: .95rem;
}
.session-list .sess-r { font-weight: 700; color: var(--navy); }
.session-list .sess-part { color: var(--muted); text-align: right; }
.session-list .sess-loc { grid-column: 1 / -1; font-weight: 650; }
.session-list li.skip .sess-loc, .session-list li.skipped .sess-loc { font-weight: 500; color: var(--muted); }
.session-list li.undo .sess-loc { color: var(--muted); }
@media (min-width: 800px) {
  .scan-stage video { max-height: 520px; }
  .locate-bulk-btn { display: inline-block; width: auto; min-width: 240px; }
}

.entry-panel {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin: 14px 0;
  border: 2px solid var(--navy);
}
.entry-panel .field input {
  font-size: 1.45rem; letter-spacing: .06em; text-transform: uppercase;
  font-weight: 700; padding: 14px 12px;
}
.unknown-bar {
  margin-top: 12px; padding: 12px; border-radius: 12px;
  background: var(--warn-bg); color: #8a4b00;
}
.unknown-bar p { margin: 0 0 10px; }
.unknown-bar .btn { width: 100%; }

/* Manual R# on the bulk scan page */
.manual-r-form {
  display: flex;
  gap: 10px;
  align-items: end;
  margin: 0 0 14px;
}
.manual-r-form .field { flex: 1; min-width: 0; }
.manual-r-form .btn { width: auto; flex: 0 0 auto; }

/* After a scan, collapse the camera and pin the location form to the
   top of the visual viewport so the keyboard cannot cover the input. */
body.scan-entry-open {
  overflow: hidden;
  overscroll-behavior: none;
}
body.scan-entry-open .top,
body.scan-entry-open .page-title,
body.scan-entry-open .lede,
body.scan-entry-open .scan-stage,
body.scan-entry-open .scan-toolbar,
body.scan-entry-open .manual-r-form,
body.scan-entry-open .sticky-toggle,
body.scan-entry-open .sticky-field,
body.scan-entry-open .session {
  display: none !important;
}
body.scan-entry-open .main {
  padding-top: 0;
}
body.scan-entry-open .entry-panel {
  position: fixed;
  z-index: 50;
  margin: 0;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: 16px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  box-sizing: border-box;
}
body.scan-entry-open .entry-panel .field input {
  font-size: 1.5rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 16px 14px;
}
body.scan-entry-open .entry-panel .confirm-actions {
  flex-direction: column;
  margin-top: 14px;
  gap: 10px;
}
body.scan-entry-open .entry-panel .confirm-actions .btn {
  width: 100%;
}
body.scan-entry-open .entry-panel .btn.primary {
  min-height: 56px;
  font-size: 1.2rem;
  font-weight: 750;
}
body.scan-entry-open .entry-panel .confirm-summary {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.35;
}
body.scan-entry-open .entry-panel .banner-loc {
  margin-top: 4px;
  font-size: 1.1rem;
}

/* Torch / flashlight toggle on camera scanners */
.scan-video-wrap { position: relative; }
.torch-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 8;
  width: auto;
  min-width: 72px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .75);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.torch-btn[hidden] { display: none !important; }
.torch-btn.is-on {
  background: #f5d76e;
  color: #1a1404;
  border-color: #f5d76e;
}
.scanner .torch-btn,
.pp-scanner .torch-btn,
.dp-scanner .torch-btn,
.scan-stage .torch-btn,
.muap-scan-box .torch-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 8;
}
.scanner.is-overlay .torch-btn,
.pp-scanner.is-overlay .torch-btn,
.dp-scanner.is-overlay .torch-btn,
.scan-stage.is-overlay .torch-btn,
.muap-scan-box.is-overlay .torch-btn {
  top: 12px;
  right: 12px;
  z-index: 8;
}

/* Full-viewport scanner overlay (shared). No scrolling to reach flash/close.
   Cycle count and other apps should add .is-overlay via presentScannerOverlay. */
body.scanner-open {
  overflow: hidden;
  overscroll-behavior: none;
}
body.scanner-open .top { visibility: hidden; }
.scanner.is-overlay,
.pp-scanner.is-overlay,
.dp-scanner.is-overlay,
.scan-stage.is-overlay,
.muap-scan-box.is-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  margin: 0;
  border-radius: 0;
  min-height: 0;
  max-height: none;
  width: auto;
  display: flex;
  flex-direction: column;
  background: #000;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow: hidden;
  color: #ddd;
}
.scanner.is-overlay .scan-video-wrap,
.muap-scan-box.is-overlay .scan-video-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
.scanner.is-overlay video,
.pp-scanner.is-overlay video,
.dp-scanner.is-overlay video,
.scan-stage.is-overlay video,
.muap-scan-box.is-overlay video {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  object-fit: cover;
  display: block;
}
.scanner.is-overlay .scan-chrome,
.muap-scan-box.is-overlay .scan-chrome {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 12px;
  background: #111;
}
.scanner.is-overlay .scan-chrome .fine,
.scanner.is-overlay .scan-chrome .text-btn,
.muap-scan-box.is-overlay .scan-chrome .fine,
.muap-scan-box.is-overlay .scan-chrome .text-btn {
  padding: 0;
  margin: 0;
  color: #ddd;
}
.scanner.is-overlay .scan-chrome .btn,
.scan-overlay-close,
.muap-scan-box.is-overlay .scan-chrome .btn {
  width: 100%;
  min-height: 48px;
}
.scan-overlay-close {
  display: none;
  z-index: 4;
}
.scan-stage.is-overlay .scan-overlay-close {
  display: block;
  position: relative;
  flex: 0 0 auto;
  margin: 10px 16px 12px;
  width: auto;
}
.pp-scanner.is-overlay .pp-close,
.dp-scanner.is-overlay .dp-close {
  position: absolute;
  z-index: 4;
}

/* Look up by location, inside Part Location */
.locate-by-loc {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.locate-by-loc h2 { margin-top: 0; }
.locate-by-loc .lede, .locate-by-loc > .fine { margin: 0 0 12px; }
.mode-toggle {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  width: 100%;
}
.mode-toggle .mode-btn {
  flex: 1;
  width: auto;
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--navy);
  font: inherit;
  font-weight: 650;
  font-size: 1rem;
  padding: 12px 10px;
  cursor: pointer;
}
.mode-toggle .mode-btn + .mode-btn { border-left: 1.5px solid var(--line); }
.mode-toggle .mode-btn[aria-pressed="true"] {
  background: var(--navy);
  color: #fff;
}
.loc-group { margin: 16px 0 10px; }
.loc-group-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--navy);
}
.loc-group-h .loc-code { font-size: 1.05rem; }
.loc-group-h .loc-count { font-size: .85rem; font-weight: 650; color: var(--muted); }
.loc-search-more { margin: 14px 0 4px; }

/* Scan next / Search next: fixed footer so they don't cover Save location */
body.locate-detail .main {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.next-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 16px rgba(16, 32, 54, .08);
  z-index: 12;
}
.next-actions .btn {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 52px;
  font-size: 1.12rem;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (min-width: 800px) {
  .next-actions { padding-left: 28px; padding-right: 28px; }
  body.locate-detail .main { max-width: 1200px; }
  .locate-by-loc .mode-toggle { width: auto; max-width: 320px; }
  .locate-by-loc .btn.primary { width: auto; min-width: 180px; }
}


/* History for a tag that is not in sellable inventory (Part Location + Cycle Count). */
.ph-card {
  background: var(--card);
  border-left: 8px solid #9b1c1c;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin: 10px 0;
  color: var(--ink);
}
.ph-card.ph-returned { border-left-color: #c27d14; }
.ph-card.ph-sold { border-left-color: #c27d14; }
.ph-card.ph-deleted { border-left-color: #9b1c1c; }
.ph-card.ph-unknown, .ph-card.ph-nostock { border-left-color: #6b7280; }
.ph-kicker { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ph-title { font-size: 1.25rem; font-weight: 800; margin: 4px 0 8px; color: var(--navy); }
.ph-summary { font-size: 1.05rem; line-height: 1.45; }
.ph-meta { margin-top: 8px; color: var(--muted); font-size: .95rem; }
.scan-page .result-banner .banner-loc { white-space: normal; }
.cn-resolve { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.cn-resolve .cn-note { flex: 1 1 160px; min-height: 44px; font-size: 1rem; padding: 8px 10px; }
.cc-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 16px; }
.cc-tiles .cc-missing-link { margin: 0; }
.cc-notfound-link { background: #fdecec; border-color: #f0b4b4; color: #7a1c1c; }
.cc-notfound-link strong { color: #9b1c1c; }

/* Full-width part details sheet + timeline */
body.ph-sheet-open { overflow: hidden; }
.ph-sheet {
  position: fixed; inset: 0; z-index: 80;
  background: #f4f6f8;
  display: flex; flex-direction: column;
}
.ph-sheet[hidden] { display: none !important; }
.ph-sheet-inner {
  flex: 1; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}
.ph-sheet-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0)) 16px 10px;
  background: var(--navy, #0f2744); color: #fff;
  min-height: 52px;
}
.ph-sheet-head .ph-sheet-close {
  color: #fff; font-weight: 700; min-height: 44px; padding: 8px 4px;
  background: none; border: 0; font-size: 1rem;
}
.ph-sheet-title { margin: 0; font-size: 1.05rem; font-weight: 800; letter-spacing: .02em; flex: 1; color: #fff; }
.ph-sheet-body { padding: 12px 16px 32px; max-width: 720px; margin: 0 auto; }

.ph-confirm {
  background: var(--card, #fff);
  border: 2px solid var(--navy, #0f2744);
  border-radius: 12px;
  padding: 14px 14px 12px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
}
.ph-confirm-btn { width: 100%; min-height: 56px; font-size: 1.15rem; margin: 0; }
.ph-confirm-note { margin: 8px 0 0; font-size: .92rem; color: var(--muted); line-height: 1.35; }
.ph-confirm-err { margin: 8px 0 0; }
.ph-tl-item.ph-tl-cycle_confirmed::before { background: #5b3d8f; }

.ph-photos {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -4px 14px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.ph-photo { flex: 0 0 auto; scroll-snap-align: start; display: block; }
.ph-photo img {
  display: block; height: 220px; width: auto; max-width: 86vw;
  object-fit: cover; border-radius: 10px; background: #dfe6ee;
}
.ph-d-title { margin: 0 0 4px; font-size: 1.45rem; color: var(--navy); }
.ph-d-vehicle { margin: 0 0 12px; color: var(--muted); font-size: 1.05rem; }
.ph-facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
  margin: 0 0 20px; background: var(--card, #fff);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
}
.ph-facts div { min-width: 0; }
.ph-facts dt { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ph-facts dd { margin: 0; font-weight: 700; font-size: 1.02rem; word-break: break-word; }
.ph-tl-h { margin: 8px 0 10px; font-size: 1.1rem; }
.ph-tl { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 3px solid #d5dee8; }
.ph-tl-item { position: relative; padding: 0 0 16px 16px; }
.ph-tl-item::before {
  content: ""; position: absolute; left: -9px; top: 4px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #8aa0b5; border: 2px solid #fff; box-shadow: 0 0 0 1px #d5dee8;
}
.ph-tl-item.ph-tl-created::before { background: #2e9d57; }
.ph-tl-item.ph-tl-moved::before { background: #2a6fbf; }
.ph-tl-item.ph-tl-sold::before, .ph-tl-item.ph-tl-returned::before { background: #c27d14; }
.ph-tl-item.ph-tl-deleted::before { background: #9b1c1c; }
.ph-tl-item.ph-tl-cycle_missed::before,
.ph-tl-item.ph-tl-cycle_scanned::before,
.ph-tl-item.ph-tl-cycle_found::before,
.ph-tl-item.ph-tl-cycle_moved::before,
.ph-tl-item.ph-tl-cycle_sighting::before { background: #5b3d8f; }
.ph-tl-kind { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ph-tl-when { font-size: .92rem; color: var(--muted); }
.ph-tl-title { font-weight: 800; font-size: 1.05rem; margin-top: 1px; }
.ph-tl-detail { margin-top: 2px; font-size: .98rem; line-height: 1.4; }
.cc-card.cc-tap { cursor: pointer; }
.cc-card.cc-tap:focus { outline: 2px solid var(--navy); outline-offset: 2px; }

/* Print tag button (print-tag.js) */
.print-tag { margin: 12px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.print-tag .print-tag-btn { margin: 0; min-height: 48px; }
.print-tag-printers { display: flex; gap: 6px; flex-wrap: wrap; }
.print-tag-printers .chip { padding: 7px 11px; font-size: .88rem; }
.print-tag-status { flex-basis: 100%; margin: 0; font-size: .92rem; }
