@import url("./fonts.css");

/* BlueBird Receiving: iPad first, readable outdoors.
   Brand Guidelines v1.1 (March 2023) palette: Cool Blue #F1F8FB, Slate #EFEFEF, Sky #5FB4FF,
   Bright Blue #3982FF, BlueBird Blue #0E57E0, Navy #07074E, Yellow #FFD100 (accent only).
   Type: Poppins Bold / Medium / Regular; Verdana where Poppins is unavailable.
   Good / short / damaged keep their own status colors; the guide has none. */
:root {
  color-scheme: light;
  --navy: #07074e;
  --blue: #0e57e0;
  --bright-blue: #3982ff;
  --sky: #5fb4ff;
  --cool-blue: #f1f8fb;
  --slate: #efefef;
  --blue-dark: var(--navy);
  --blue-tint: var(--cool-blue);
  --yellow: #ffd100;
  --yellow-tint: #fff4b8;
  --page: var(--cool-blue);
  --surface: #ffffff;
  --sunk: var(--slate);
  --line: #d6e0ea;
  --line-strong: #a9b8ca;
  --text: var(--navy);
  --muted: #4c5a72;
  --quiet: #6b7890;
  --good: #0b6b3a;
  --good-tint: #e5f4eb;
  --good-line: #b6dcc5;
  --short: #8a4b00;
  --short-tint: #fff0da;
  --short-line: #efcf9f;
  --damaged: #b3261e;
  --damaged-tint: #fdecea;
  --damaged-line: #f2b8b2;
  --r-card: 16px;
  --r-ctl: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html { background: var(--page); -webkit-text-size-adjust: 100%; scroll-padding-top: calc(76px + var(--safe-top)); }
body { margin: 0; min-width: 320px; color: var(--text); background: var(--page); font: 16px/1.5 var(--font-ui, Verdana, sans-serif); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .5; }
img { max-width: 100%; }
svg { flex-shrink: 0; vertical-align: middle; }
h1, h2, h3 { color: var(--navy); margin: 0; }
p { margin: 0; }
strong { font-weight: 700; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; }
.skip-link { position: fixed; z-index: 200; top: -80px; left: 12px; padding: 12px 18px; border-radius: 10px; background: var(--navy); color: #fff; text-decoration: none; }
.skip-link:focus { top: calc(12px + var(--safe-top)); }
.text-red { color: var(--damaged) !important; }
.text-green { color: var(--good) !important; }
.text-amber { color: var(--short) !important; }
.muted { color: var(--muted); }

.loading-state, .fatal { display: grid; place-content: center; gap: 8px; min-height: 100vh; min-height: 100dvh; padding: 24px; text-align: center; }
.loading-state img { margin: 0 auto 6px; }
.loading-state h1 { font-size: 22px; }
.loading-state p, .fatal p { color: var(--muted); }

/* Header */
.topbar { position: sticky; top: 0; z-index: 30; padding-top: var(--safe-top); background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 10px; max-width: 720px; min-height: 62px; margin: 0 auto; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-right: auto; padding: 0; border: 0; background: none; text-align: left; }
.brand img { display: block; }
.brand-logo { display: none !important; width: 250px; height: auto; }
.brand-mark { width: 40px; height: auto; }
.brand-text { display: grid; line-height: 1.2; }
.brand-name { color: var(--navy); font-size: 17px; font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; }
/* Full horizontal logo (min. 250 px wide) once there is room; the mark alone on phones. */
@media (min-width: 640px) {
  .brand { gap: 14px; }
  .brand-logo { display: block !important; }
  .brand-mark, .brand-sub { display: none !important; }
  .brand-text { padding-left: 14px; border-left: 1px solid var(--line); }
  .brand-name { color: var(--blue); font-weight: 500; }
}
.save-state { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.save-state.ok { color: var(--good); }
.save-state.pending { color: var(--muted); }
.save-state.error { padding: 4px 10px; border-radius: 999px; background: var(--damaged-tint); color: var(--damaged); font-weight: 500; }
.nav-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--navy); font-size: 15px; font-weight: 500; }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--navy); color: #fff; font-size: 12px; font-weight: 500; }

/* Step bar */
.stepbar { max-width: 720px; margin: 0 auto; padding: 10px 16px 0; }
.stepbar ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; padding: 0; list-style: none; }
.stepbar button { display: grid; gap: 6px; width: 100%; min-height: 44px; padding: 4px 0; border: 0; background: none; color: var(--quiet); text-align: left; font-size: 13px; font-weight: 500; }
.step-track { display: block; height: 5px; border-radius: 3px; background: var(--line); }
.step-label { display: inline-flex; align-items: center; gap: 5px; }
.step-n { font-variant-numeric: tabular-nums; }
.stepbar .done button { color: var(--muted); }
.stepbar .done .step-track { background: var(--blue); opacity: .45; }
.stepbar .current button { color: var(--navy); }
.stepbar .current .step-track { background: var(--blue); }

/* Page */
.main { max-width: 720px; margin: 0 auto; padding: 14px 16px calc(112px + var(--safe-bottom)); }
.view-head { margin: 6px 0 16px; }
.view-head h1 { font-size: 25px; line-height: 1.25; letter-spacing: -.3px; }
.view-head h1:focus { outline: none; }
.view-head p { margin-top: 4px; color: var(--muted); font-size: 15px; }
.view-head .context { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.view-head .context strong { color: var(--navy); }
.sample-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 28px; color: var(--quiet); font-size: 13px; }

/* Order cards */
.order-list { display: grid; gap: 10px; }
.order-card { display: grid; gap: 4px; width: 100%; padding: 14px 16px; border: 2px solid var(--line); border-radius: var(--r-card); background: var(--surface); text-align: left; transition: border-color .15s, background-color .15s; }
.order-card:hover { border-color: var(--line-strong); }
.order-card.selected { border-color: var(--blue); background: var(--cool-blue); }
.order-card.other { border-style: dashed; background: transparent; }
.order-card.other.selected { border-style: solid; background: var(--cool-blue); }
.order-top { display: flex; align-items: center; gap: 12px; }
.order-supplier { flex: 1; color: var(--navy); font-size: 17px; font-weight: 700; line-height: 1.35; }
.order-check { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--sunk); color: var(--muted); }
.order-card.selected .order-check { background: var(--blue); color: #fff; }
.order-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--muted); font-size: 14px; }
.due.today { padding: 1px 9px; border-radius: 999px; background: var(--yellow-tint); color: var(--navy); font-weight: 500; }
.order-items { color: var(--text); font-size: 15px; }
.order-items strong { color: var(--navy); }
.order-items .more { color: var(--muted); }

/* Panels and fields */
.panel { margin-top: 16px; padding: 18px 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.panel > h2 { margin-bottom: 14px; font-size: 19px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.panel-head h2 { font-size: 19px; }
.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > .label { color: var(--navy); font-size: 15px; font-weight: 500; }
.label-aside { margin-left: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
.label-aside.required { color: var(--damaged); font-weight: 500; }
.hint { color: var(--muted); font-size: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row .field { margin-bottom: 0; }
input:not([type=file]), select, textarea { width: 100%; min-height: 56px; padding: 0 14px; border: 1.5px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); color: var(--text); font-size: 17px; }
textarea { min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #7d8aa0; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid rgb(14 87 224 / 22%); outline-offset: 0; }
select { appearance: none; padding-right: 44px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2307074E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
#duplicate-notice:not(:empty) { margin-bottom: 18px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 20px; border: 2px solid var(--blue); border-radius: var(--r-ctl); background: var(--blue); color: #fff; font-size: 16px; font-weight: 700; line-height: 1.25; text-align: center; transition: background-color .15s, border-color .15s; }
.btn:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { border-color: var(--line-strong); background: var(--surface); color: var(--navy); }
.btn.secondary:hover { border-color: var(--navy); background: var(--surface); }
.btn.ghost { border-color: transparent; background: var(--blue-tint); color: var(--blue); }
.btn.ghost:hover { background: var(--slate); }
.btn.good { border-color: var(--good); background: var(--good); color: #fff; }
.btn.good:hover { border-color: #08532d; background: #08532d; }
.btn.outline { border-color: var(--line-strong); background: var(--surface); color: var(--navy); }
.btn.outline:hover { border-color: var(--navy); background: var(--surface); }
.btn.outline[data-action="short-line"] svg { color: var(--short); }
.btn.outline[data-action="damaged-line"] svg { color: var(--damaged); }
.btn.danger { border-color: var(--damaged); background: var(--damaged); color: #fff; }
.btn.small-btn { min-height: 44px; margin-top: 10px; padding: 0 14px; font-size: 15px; }
.btn.full { width: 100%; }
.btn.grow { flex: 1; }
.btn.square { width: 56px; padding: 0; }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.text-button { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--blue); font-size: 15px; font-weight: 500; text-decoration: none; cursor: pointer; }
.text-button.danger { color: var(--damaged); }
.icon-btn { display: inline-grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--navy); }
.icon-btn:hover { background: var(--sunk); }

/* Hidden file inputs inside their labels */
.capture input, .photo-add input, .text-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Packing slip */
.capture { position: relative; display: flex; align-items: center; gap: 14px; padding: 16px; border: 2px dashed var(--sky); border-radius: 14px; background: var(--cool-blue); cursor: pointer; }
.capture:hover { border-color: var(--blue); }
.capture-icon { display: grid; place-items: center; flex: 0 0 52px; height: 52px; border-radius: 50%; background: var(--blue); color: #fff; }
.capture-text { display: grid; gap: 2px; }
.capture-text strong { color: var(--navy); font-size: 16px; }
.capture-text span { color: var(--muted); font-size: 14px; }
.photo-row { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--good-line); border-radius: 14px; background: var(--good-tint); }
.photo-row-text { display: grid; gap: 0; min-width: 0; }
.photo-row-text strong { display: inline-flex; align-items: center; gap: 6px; color: var(--good); }
.photo-row-text > span { color: var(--muted); font-size: 14px; }
.photo-row-actions { display: flex; gap: 18px; }
.photo-thumb { display: block; width: 64px; height: 64px; border: 1px solid var(--line); border-radius: 9px; background: #fff; object-fit: cover; cursor: zoom-in; }
.photo-thumb.slip-thumb { width: 80px; height: 80px; flex: 0 0 80px; }

/* Notices */
.notice { display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--sunk); color: var(--text); font-size: 15px; }
.notice > svg { margin-top: 2px; }
.notice.error { border-color: var(--damaged-line); background: var(--damaged-tint); color: #7a1a14; }
.notice.blue { border-color: var(--sky); background: var(--blue-tint); color: var(--navy); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice-wrap { margin-bottom: 14px; }
.modal-error { margin-bottom: 12px; }
.line-card > .notice { font-size: 14px; }

/* Item cards */
.line-list { display: grid; gap: 12px; }
.line-card { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.line-card.done { border-color: var(--good-line); }
.line-head { display: flex; align-items: flex-start; gap: 12px; }
.line-titles { flex: 1; min-width: 0; }
.line-titles h3, .review-line h3 { font-size: 17px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.line-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; color: var(--muted); font-size: 15px; }
.line-meta strong { color: var(--navy); }
.tag { padding: 1px 8px; border-radius: 6px; background: var(--sunk); color: var(--navy); font-size: 13px; font-weight: 500; }
.line-paper { margin-top: 2px; color: var(--muted); font-size: 14px; }
.line-pending { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--short); font-size: 14px; font-weight: 500; }
.done-mark { display: grid; place-items: center; flex: 0 0 32px; height: 32px; border-radius: 50%; background: var(--good); color: #fff; }
.line-note { padding: 10px 12px; border-radius: 10px; background: var(--sunk); font-size: 15px; overflow-wrap: anywhere; }
.line-note strong { margin-right: 6px; color: var(--navy); }
.thumb-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.line-card > .text-button { justify-self: start; }

/* Results: good / short / damaged */
.result-row { display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); }
.result { display: grid; justify-items: center; gap: 0; padding: 10px 6px; border-left: 1px solid var(--line); text-align: center; }
.result:first-child { border-left: 0; }
.result-num { color: var(--quiet); font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.result-label { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.25; }
.result.good.has { background: var(--good-tint); }
.result.good.has .result-num { color: var(--good); }
.result.short.has { background: var(--short-tint); }
.result.short.has .result-num { color: var(--short); }
.result.damaged.has { background: var(--damaged-tint); }
.result.damaged.has .result-num { color: var(--damaged); }
.result-row.big .result-num { font-size: 34px; }
.result-row.compact .result { padding: 7px 6px; }
.result-row.compact .result-num { font-size: 20px; }

/* Progress and lists */
.progress { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress-text { color: var(--navy); font-size: 15px; font-weight: 500; white-space: nowrap; }
.progress-track { flex: 1; height: 8px; overflow: hidden; border-radius: 4px; background: var(--line); }
.progress-track span { display: block; height: 100%; border-radius: 4px; background: var(--blue); transition: width .25s; }
.search-box { position: relative; margin-bottom: 14px; }
.search-box svg { position: absolute; top: 50%; left: 14px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.search-box input { padding-left: 44px; min-height: 52px; }
.add-item { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 60px; margin-top: 12px; padding: 0 16px; border: 2px dashed var(--line-strong); border-radius: 14px; background: transparent; color: var(--blue); font-size: 16px; font-weight: 500; }
.add-item:hover { border-color: var(--blue); background: var(--cool-blue); }
.empty { display: grid; justify-items: center; gap: 6px; padding: 28px 18px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 4px; border-radius: 50%; background: var(--blue-tint); color: var(--blue); }
.empty h2 { font-size: 18px; }
.empty p { color: var(--muted); font-size: 15px; }
.inline-empty { padding: 18px; color: var(--muted); text-align: center; }
.fine-print { display: flex; gap: 8px; margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.fine-print svg { margin-top: 3px; }

/* Review */
.summary-hero { padding: 18px 16px; border: 1px solid var(--good-line); border-radius: var(--r-card); background: var(--good-tint); }
.summary-hero.problem { border-color: var(--short-line); background: var(--short-tint); }
.summary-headline { margin-bottom: 12px; color: var(--navy); font-size: 19px; font-weight: 700; line-height: 1.35; }
.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary-stats div { padding: 10px; border-radius: 10px; background: var(--surface); }
.summary-stats strong { display: block; color: var(--navy); font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.summary-stats span { color: var(--muted); font-size: 13px; line-height: 1.3; }
.details { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 8px 0 0; }
.details dt { color: var(--muted); font-size: 13px; font-weight: 500; }
.details dd { margin: 0; color: var(--navy); font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.slip-review { display: flex; align-items: center; gap: 12px; margin-top: 16px; color: var(--muted); font-size: 15px; }
.review-line { display: grid; gap: 10px; padding: 14px 0; }
.review-line + .review-line { border-top: 1px solid var(--line); }
.review-line:last-child { padding-bottom: 0; }
.review-line-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.review-line-head .icon-btn { margin: -8px -8px 0 0; }
.saved-hero { display: flex; gap: 14px; margin: 6px 0 16px; padding: 18px 16px; border: 1px solid var(--good-line); border-radius: var(--r-card); background: var(--surface); }
.saved-icon { display: grid; place-items: center; flex: 0 0 48px; height: 48px; border-radius: 50%; background: var(--good); color: #fff; }
.saved-hero h1 { margin-bottom: 4px; font-size: 23px; }
.saved-hero h1:focus { outline: none; }
.saved-hero p { color: var(--muted); font-size: 15px; }
.saved-hero .text-button { margin-top: 6px; }

/* Receipts list */
.segmented { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 4px; margin-bottom: 14px; padding: 4px; border-radius: var(--r-ctl); background: var(--slate); }
.segmented button { min-height: 44px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 15px; font-weight: 500; }
.segmented button span { color: var(--quiet); font-weight: 500; }
.segmented button.active { background: var(--surface); color: var(--navy); box-shadow: 0 1px 3px rgb(7 7 78 / 14%); }
.history-list { display: grid; gap: 10px; }
.history-card { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 76px; padding: 14px 12px 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted); text-align: left; }
.history-card:hover { border-color: var(--line-strong); }
.history-main { display: grid; flex: 1; gap: 2px; min-width: 0; }
.history-title { color: var(--navy); font-size: 16px; font-weight: 700; }
.history-meta { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 14px; }
.history-issue { color: var(--short); font-weight: 500; }
.status { padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.status.saved { background: var(--good-tint); color: var(--good); }
.status.draft { background: var(--short-tint); color: var(--short); }

/* Action bar */
.actionbar { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; padding: 12px 16px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.actionbar-inner { display: flex; gap: 10px; max-width: 688px; margin: 0 auto; }

/* Toast: under the header, never over the action bar or keypad */
.toast { position: fixed; z-index: 90; top: calc(72px + var(--safe-top)); left: 50%; max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 12px; background: var(--navy); color: #fff; font-size: 15px; font-weight: 500; opacity: 0; transform: translate(-50%, -8px); transition: opacity .18s, transform .18s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Sheets */
.sheet-backdrop { position: fixed; z-index: 100; inset: 0; display: flex; align-items: flex-end; justify-content: center; background: rgb(7 7 78 / 45%); }
.sheet { display: flex; flex-direction: column; width: 100%; max-height: 100vh; max-height: 100dvh; border-radius: 20px 20px 0 0; background: var(--surface); }
.sheet-count { height: 100vh; height: 100dvh; border-radius: 0; padding-top: var(--safe-top); }
.sheet-catalog { height: 92vh; height: 92dvh; }
.sheet-header { display: flex; align-items: flex-start; gap: 10px; padding: 14px 10px 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-titles { flex: 1; min-width: 0; padding-top: 4px; }
.sheet-header h2 { font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.sheet-header p { margin-top: 2px; color: var(--muted); font-size: 15px; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 18px; }
.sheet-footer { display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.confirm-text { font-size: 16px; line-height: 1.6; }
.photo-view { display: block; width: 100%; border-radius: 12px; }

/* The count screen: the tally counter */
.counter { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.counter-field { display: grid; padding: 10px 14px 12px; border: 2px solid var(--line-strong); border-radius: 14px; background: var(--surface); cursor: text; transition: background-color .12s, border-color .12s; }
.counter-field label { color: var(--navy); font-size: 15px; font-weight: 500; cursor: text; }
.counter-field input { width: 100%; min-height: 0; height: 62px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--navy); font-size: 50px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; caret-color: var(--navy); }
.counter-field input:focus { outline: none; }
.counter-field input::placeholder { color: #b3bfcf; }
.counter-hint { color: var(--muted); font-size: 13px; }
.counter-field.active { border-color: var(--navy); background: var(--yellow); }
.counter-field.active input::placeholder { color: rgb(7 7 78 / 35%); }
.counter-field.active .counter-hint { color: var(--navy); }
.counter-field:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
.count-result { min-height: 86px; margin-bottom: 12px; }
.count-msg { display: flex; align-items: center; gap: 8px; padding: 14px; border-radius: var(--r-ctl); background: var(--sunk); color: var(--muted); font-size: 15px; }
.count-msg.error { background: var(--damaged-tint); color: var(--damaged); font-weight: 500; }
.count-msg.warn { margin-top: 8px; background: var(--short-tint); color: var(--short); font-weight: 500; }
.photo-callout { position: relative; display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 12px 14px; border: 1px solid var(--damaged-line); border-radius: var(--r-ctl); background: var(--damaged-tint); color: #7a1a14; font-size: 15px; cursor: pointer; }
.photo-callout strong { margin-right: 4px; }
.number-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.number-pad button { min-height: 60px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--sunk); color: var(--navy); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.number-pad button.key-soft { background: var(--surface); font-size: 16px; }
.number-pad button:active { border-color: var(--navy); background: var(--navy); color: #fff; }
.photo-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-tile { position: relative; }
.photo-tile .photo-thumb { width: 76px; height: 76px; }
.photo-remove { position: absolute; top: -8px; right: -8px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--navy); color: #fff; }
.photo-add { position: relative; display: grid; place-content: center; justify-items: center; gap: 2px; width: 76px; height: 76px; border: 2px dashed var(--line-strong); border-radius: 10px; color: var(--blue); font-size: 13px; font-weight: 500; cursor: pointer; }
.photo-add:hover { border-color: var(--blue); }

/* Catalog */
.catalog-results { display: grid; gap: 8px; }
.catalog-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); color: var(--blue); text-align: left; }
.catalog-item:hover { border-color: var(--blue); }
.catalog-text { display: grid; flex: 1; gap: 3px; justify-items: start; }
.catalog-title { color: var(--navy); font-size: 15px; font-weight: 700; }
.catalog-sub { color: var(--muted); font-size: 14px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--sunk); color: var(--navy); font-size: 12px; font-weight: 500; }
.pill.amber { background: var(--short-tint); color: var(--short); }
.pill.green { background: var(--good-tint); color: var(--good); }
.pill.red { background: var(--damaged-tint); color: var(--damaged); }

@media (max-width: 359px) {
  .brand-sub, .save-state span { display: none; }
  .field-row { grid-template-columns: 1fr; gap: 18px; }
  .counter-field input { font-size: 40px; }
}
@media (min-width: 720px) {
  .main { padding-top: 22px; }
  .view-head h1 { font-size: 28px; }
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; max-height: 92vh; border-radius: 20px; }
  .sheet-count, .sheet-catalog { height: auto; padding-top: 0; }
  .sheet-catalog { height: 80vh; }
  .line-card { padding: 18px 20px; }
  .panel { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Printable receipt (Save as PDF) */
#print-root { display: none; }
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff; }
  body > :not(#print-root) { display: none !important; }
  #print-root { display: block; color: #07074e; font: 11pt/1.45 var(--font-ui, Verdana, sans-serif); }
  .p-head { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 2px solid #07074e; }
  .p-head img { width: 250px; height: auto; }
  .p-head h1 { color: #07074e; font-size: 20pt; line-height: 1.1; }
  .p-head h1 { margin-left: auto; }
  .p-status { margin-left: auto; padding: 4px 12px; border: 2px solid #07074e; border-radius: 6px; color: #07074e; font-weight: 700; }
  .p-headline { margin: 12px 0; font-size: 13pt; font-weight: 700; }
  .p-details, .p-lines { width: 100%; margin-bottom: 14px; border-collapse: collapse; }
  .p-details th, .p-details td, .p-lines th, .p-lines td { padding: 6px 8px; border: 1px solid #9aa5b5; text-align: left; vertical-align: top; }
  .p-details th { width: 32%; background: #f1f4f8; font-weight: 500; }
  .p-lines th { border-bottom: 2px solid #07074e; color: #07074e; font-weight: 700; }
  #print-root { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-lines td:nth-child(n+2) { white-space: nowrap; }
  .p-good { color: #0b6b3a; font-weight: 700; }
  .p-short { color: #8a4b00; font-weight: 700; }
  .p-damaged { color: #b3261e; font-weight: 700; }
  .p-note { color: #444; }
  .p-fine { color: #555; font-size: 9pt; }
  .p-photos h2 { margin: 16px 0 8px; color: #07074e; font-size: 13pt; }
  .p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .p-grid figure { margin: 0; break-inside: avoid; }
  .p-grid img { display: block; width: 100%; max-height: 95mm; border: 1px solid #ccc; object-fit: contain; }
  .p-grid figcaption { margin-top: 3px; font-size: 9pt; color: #444; }
}
.counter-field input::selection { background: var(--navy); color: var(--yellow); }
.spec-check { margin-bottom: 16px; padding: 14px; border: 1px solid var(--sky); border-radius: 14px; background: var(--blue-tint); }
.spec-title { display: flex; align-items: center; gap: 8px; color: var(--navy); font-size: 15px; font-weight: 700; }
.spec-detail { margin: 4px 0 12px; color: var(--text); font-size: 14px; }
.spec-check .field { margin-bottom: 0; }
.spec-check textarea { min-height: 80px; }

/* v2 refinements after screen review */
.text-button { text-align: left; }
.change-order { margin-top: 4px; }
.field-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.field-row input { min-width: 0; }
.line-titles h3, .review-line h3, .sheet-header h2 { overflow-wrap: break-word; }
.summary-hero .summary-headline { margin-bottom: 4px; }
.summary-sub { color: var(--text); font-size: 15px; }
@media (max-width: 479px) { .brand-sub { display: none; } }

.result-row.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 419px) {
  .topbar-inner { gap: 12px; }
  .nav-pill { padding: 0 12px; }
  .nav-pill > svg { display: none; }
}
@media (max-width: 359px) {
  .stepbar button { font-size: 12px; }
  .step-label { white-space: nowrap; }
  .step-n { display: none; }
}

/* Office sharing */
.saved-hero.warn { border-color: var(--short-line); }
.saved-hero.warn .saved-icon { background: var(--short); }
.saved-hero p + p { margin-top: 6px; }
.hero-links { display: flex; flex-wrap: wrap; gap: 0 18px; margin-top: 4px; }
.status.conflict { background: var(--damaged-tint); color: var(--damaged); }
.sharing { margin-top: 18px; }
.sharing-text { color: var(--text); font-size: 15px; }
/* Sign-in (v3.2): the warehouse account opens the app. */
.main.signin { display: grid; place-content: center; min-height: 100vh; min-height: 100dvh; max-width: 480px; }
.signin-panel { display: grid; gap: 12px; padding: 28px 22px; }
.signin-logo { width: 250px; height: auto; margin-bottom: 8px; }
.signin-panel h1 { font-size: 22px; }
.signin-panel .context-text { margin-top: -6px; color: var(--muted); }
.signin-panel form { display: grid; gap: 4px; }
.signin-panel .btn.full { margin-top: 8px; }
.account-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; color: var(--muted); font-size: 14px; }
.account-line span { flex: 1; min-width: 180px; }
.account-line .btn { margin-top: 0; }
.sharing-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sharing-actions .btn.small-btn { margin-top: 12px; }

/* ===== v3: iPad first ===== */
.tag.nonstock { background: var(--slate); color: var(--navy); }
.line-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; }
.tag-note { color: var(--muted); font-size: 14px; }
.line-meta .tag { margin-left: 2px; }
.pack-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 12px; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--sunk); font-size: 15px; }
.pack-row .btn.small-btn { margin-top: 0; }
.text-button { min-width: 44px; }
/* 44 px touch area, smaller visual dot */
.photo-remove { top: -14px; right: -14px; width: 44px; height: 44px; border: 0; background: transparent; }
.photo-remove::before { content: ""; position: absolute; inset: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--navy); }
.photo-remove svg { position: relative; }
.editor-pane { display: none; }
.pane-idle { display: grid; justify-items: center; gap: 8px; padding: 32px 22px; text-align: center; }
.pane-idle h2 { font-size: 19px; line-height: 1.35; }
.pane-idle p { color: var(--muted); font-size: 15px; }
.pane-idle .empty-icon.done { background: var(--good-tint); color: var(--good); }
.pane-idle .btn { margin-top: 8px; }
.pane-idle.next { justify-items: stretch; text-align: left; }
.pane-kicker { color: var(--blue) !important; font-weight: 500; }
.pane-actions { display: grid; gap: 10px; margin-top: 10px; }
.pane-actions .btn { margin-top: 0; }

@media (min-width: 768px) {
  .topbar-inner, .stepbar { max-width: 1180px; padding-left: 24px; padding-right: 24px; }
  .main { max-width: 760px; padding-left: 24px; padding-right: 24px; }
  .main.wide { max-width: 1180px; }
  .order-list { grid-template-columns: 1fr 1fr; }
  .order-card.other { grid-column: 1 / -1; }
  .check-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 440px); gap: 20px; align-items: start; }
  .editor-pane { position: sticky; top: calc(74px + var(--safe-top)); display: flex; flex-direction: column; max-height: calc(var(--vvh, 100vh) - 74px - var(--safe-top) - 100px - var(--safe-bottom)); overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
  .kb-open .editor-pane { max-height: calc(var(--vvh, 100vh) - 84px); }
  .kb-open .actionbar { display: none; }
  /* While a count is open (landscape and portrait), its own Save/Cancel replace the bottom bar,
     and the step bar is hidden, so the whole keypad stays on screen. */
  body:has(.dock) .actionbar, body:has(.dock) .stepbar { display: none; }
  .dock { display: flex; flex-direction: column; min-height: 100%; }
  .dock .sheet-header { padding: 14px 8px 12px 18px; }
  .dock .sheet-body { flex: 1; overflow: visible; padding: 14px 18px 16px; }
  .dock .sheet-footer { position: sticky; bottom: 0; z-index: 1; padding-bottom: 12px; background: var(--surface); }
  .dock .counter-field input { font-size: 46px; height: 56px; }
  .dock .number-pad button { min-height: 58px; }
  .line-card.editing { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
  .actionbar.wide .actionbar-inner { max-width: 1132px; justify-content: flex-end; }
  .actionbar.wide .btn.grow { flex: 0 1 360px; }
}
@media (min-width: 1100px) {
  .check-layout { grid-template-columns: minmax(0, 1fr) 460px; gap: 24px; }
}
@media (min-width: 768px) and (max-width: 1099px) {
  .check-layout { grid-template-columns: minmax(0, 1fr) minmax(340px, 380px); gap: 16px; }
  .dock .sheet-body { padding: 12px 14px 14px; }
  .dock .counter { gap: 8px; }
  .dock .number-pad { gap: 6px; }
}
/* iPad landscape (1024 x 768, 1180 x 820): the whole keypad and Save fit without scrolling.
   While a count is open its own Save/Cancel replace the bottom bar. Keys stay at least 44 px. */
@media (min-width: 768px) and (max-height: 820px) {
  .dock .sheet-header { padding: 10px 6px 8px 16px; }
  .dock .sheet-titles { padding-top: 2px; }
  .dock .sheet-header h2 { overflow: hidden; font-size: 17px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
  .dock .msg-more { display: none; }
  .dock .sheet-header p { font-size: 14px; }
  .dock .sheet-body { padding: 10px 14px 10px; }
  .dock .counter { margin-bottom: 8px; }
  .dock .counter-field { padding: 6px 12px 8px; }
  .dock .counter-field input { font-size: 38px; height: 44px; }
  .dock .counter-hint { display: none; }
  .dock .count-result { min-height: 60px; margin-bottom: 8px; }
  .dock .count-msg { padding: 10px 12px; font-size: 14px; }
  .dock .count-msg.warn { margin-top: 6px; padding: 6px 10px; font-size: 13px; }
  .dock .result-row.big .result { padding-top: 4px; padding-bottom: 4px; }
  .dock .result-row.big .result-num { font-size: 26px; }
  .dock .photo-callout { margin-top: 6px; padding: 6px 10px; font-size: 13px; line-height: 1.3; }
  .dock .number-pad { margin-bottom: 12px; }
  .dock .number-pad button { min-height: 48px; font-size: 24px; }
  .dock .sheet-footer { padding-top: 8px; padding-bottom: 8px; }
}
/* iPad portrait (768 x 1024; about 940 px in Safari): one-line notes keep the keypad on screen. */
@media (min-width: 768px) and (max-height: 1000px) {
  .dock .msg-more { display: none; }
  .dock .count-msg.warn { margin-top: 6px; padding: 6px 10px; font-size: 13px; }
  .dock .photo-callout { margin-top: 6px; padding: 6px 10px; font-size: 13px; line-height: 1.3; }
}
/* Safari on a 1024 x 768 iPad, with its address and tab bars, leaves about 670 px. */
@media (min-width: 768px) and (max-height: 700px) {
  body:has(.dock) .topbar { display: none; }
  body:has(.dock) .editor-pane { top: calc(12px + var(--safe-top)); }
  .dock .counter-field input { font-size: 34px; height: 38px; }
  .dock .counter-field { padding: 4px 12px 6px; }
  .dock .count-result { min-height: 52px; }
  .dock .number-pad { gap: 4px; margin-bottom: 8px; }
  .dock .number-pad button { min-height: 44px; font-size: 22px; }
}

/* v3.3: where the open orders came from, and the server's warnings on an uploaded receipt. */
.orders-source { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.orders-source .fine-print { margin: 0; }
.warning-list { margin: 6px 0 10px 20px; padding: 0; }
.warning-list li { margin: 2px 0; }

/* v3.3: phones. iPhone held sideways: keep content clear of the notch and rounded corners. */
body { padding-left: var(--safe-left); padding-right: var(--safe-right); }
.actionbar { padding-left: calc(16px + var(--safe-left)); padding-right: calc(16px + var(--safe-right)); }
.sheet-count { padding-left: var(--safe-left); padding-right: var(--safe-right); }

/* Short phones held upright (iPhone SE 375 x 667, small Android 360 x 740): the whole keypad
   and Save fit without scrolling, even with the over-delivery and photo notes. Keys stay 52 px. */
@media (max-width: 767px) and (max-height: 760px) {
  .sheet-count .sheet-header { padding: 8px 6px 8px 16px; }
  .sheet-count .sheet-titles { padding-top: 2px; }
  .sheet-count .sheet-header h2 { overflow: hidden; font-size: 17px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
  .sheet-count .sheet-header p { font-size: 14px; }
  .sheet-count .sheet-body { padding: 10px 14px 12px; }
  .sheet-count .counter { gap: 8px; margin-bottom: 8px; }
  .sheet-count .counter-field { padding: 6px 12px 8px; }
  .sheet-count .counter-field input { font-size: 38px; height: 44px; }
  .sheet-count .counter-hint, .sheet-count .msg-more { display: none; }
  .sheet-count .count-result { min-height: 56px; margin-bottom: 8px; }
  .sheet-count .count-msg { padding: 10px 12px; font-size: 14px; }
  .sheet-count .count-msg.warn { margin-top: 6px; padding: 6px 10px; font-size: 13px; }
  .sheet-count .result-row.big .result { padding-top: 4px; padding-bottom: 4px; }
  .sheet-count .result-row.big .result-num { font-size: 26px; }
  .sheet-count .photo-callout { margin-top: 6px; padding: 6px 10px; font-size: 13px; line-height: 1.3; }
  .sheet-count .number-pad { gap: 6px; margin-bottom: 14px; }
  .sheet-count .number-pad button { min-height: 52px; font-size: 26px; }
  .sheet-count .sheet-footer { padding-top: 8px; padding-bottom: calc(8px + var(--safe-bottom)); }
}

/* Phones held sideways (667 x 375 up to 932 x 430): a full-screen count with the counts on the
   left and the keypad on the right, so every key and Save fit. Keys stay at least 44 px. */
@media (max-height: 500px) {
  .sheet-backdrop:has(.sheet-count) { align-items: stretch; padding: 0; }
  .sheet-count { max-width: none; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; }
  .sheet-count .sheet-header { padding: 6px 6px 6px 16px; }
  .sheet-count .sheet-titles { display: flex; align-items: baseline; gap: 10px; min-width: 0; padding-top: 0; }
  .sheet-count .sheet-header h2 { overflow: hidden; flex: 0 1 auto; font-size: 16px; white-space: nowrap; text-overflow: ellipsis; }
  .sheet-count .sheet-header p { overflow: hidden; flex: 0 1000 auto; margin: 0; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
  /* Left half: counts, notes, photos, note. Right half: the keypad, pinned at the top. */
  .sheet-count .sheet-body { position: relative; padding: 8px 14px; }
  .sheet-count .sheet-body > * { width: calc(50% - 8px); }
  .sheet-count .sheet-body > .number-pad { position: absolute; top: 8px; right: 14px; width: calc(50% - 22px); gap: 6px; margin: 0; }
  .sheet-count .number-pad button { min-height: 44px; font-size: 22px; }
  .sheet-count .counter { gap: 8px; margin-bottom: 6px; }
  .sheet-count .counter-field { padding: 4px 10px 6px; }
  .sheet-count .counter-field label { font-size: 14px; }
  .sheet-count .counter-field input { font-size: 32px; height: 36px; }
  .sheet-count .counter-hint, .sheet-count .msg-more { display: none; }
  .sheet-count .count-result { min-height: 0; margin-bottom: 8px; }
  .sheet-count .count-msg { padding: 8px 10px; font-size: 13px; }
  .sheet-count .count-msg.warn { margin-top: 4px; padding: 4px 8px; }
  .sheet-count .result-row.big .result { padding-top: 2px; padding-bottom: 2px; }
  .sheet-count .result-row.big .result-num { font-size: 22px; }
  .sheet-count .photo-callout { margin-top: 4px; padding: 4px 8px; font-size: 13px; line-height: 1.3; }
  .sheet-count .sheet-footer { padding-top: 6px; padding-bottom: calc(6px + var(--safe-bottom)); }
  .actionbar { padding-top: 6px; padding-bottom: calc(6px + var(--safe-bottom)); }
}
