/*
 * Presto identity, as in the supplier portal.
 * Colour method: white page and white cards on a very light grey; one brand colour (Presto red) used only
 * for the main buttons, the current tab and the place codes; a soft amber tint for table headers and
 * place pills; green and red only for state (found / missing, in stock / not in stock). No large coloured blocks.
 * Fonts: Somar Sans for text (Arabic and Latin), Afacad for numbers and place codes.
 */
@font-face { font-family: 'Somar Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/SomarSans-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Somar Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/SomarSans-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Somar Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/SomarSans-Bold.woff2') format('woff2'); }
@font-face { font-family: 'Afacad'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('../fonts/Afacad-variable-latin.woff2') format('woff2'); }

:root {
  --red: #ff3000;          /* brand mark */
  --red-cta: #e32b00;      /* buttons, white text 4.55:1 */
  --red-ink: #d12800;      /* red text on white 5.23:1 */
  --red-soft: #ffeae4;
  --amber-tint: #fff2e1;
  --bg: #f6f6f6;
  --surface: #ffffff;
  --fg: #111111;
  --ink-2: #4a4a4a;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --ok: #157351;
  --ok-soft: #e8f3ee;
  --error: #d12800;
  --font-text: 'Somar Sans', 'Segoe UI', Tahoma, sans-serif;
  --font-num: 'Afacad', 'Somar Sans', 'Segoe UI', sans-serif;
  font-family: var(--font-text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: 16px; line-height: 1.6; }
[dir="rtl"] body { line-height: 1.65; }
h1, h2 { font-weight: 700; line-height: 1.4; }
h1 { margin: 0; font-size: 22px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 700; }
[x-cloak] { display: none !important; }

/* Header */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.brand img { height: 30px; width: auto; display: block; }
.brand .app { color: var(--muted); font-weight: 500; font-size: 15px; padding-inline-start: 10px; border-inline-start: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who form { margin: 0; }
.lang { color: var(--ink-2); text-decoration: none; font-size: 14px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; }
.lang:hover { border-color: var(--red-ink); color: var(--red-ink); }
.nav { display: flex; gap: 16px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 2px; border-bottom: 2px solid transparent; }
.nav a.current, .nav a:hover { color: var(--fg); border-bottom-color: var(--red); }

/* Layout */
.page { padding: 24px 16px; }
.page > .stack-lg { max-width: 1100px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.card {
  max-width: 720px; margin: 0 auto; padding: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.card.narrow { max-width: 420px; }
.page .card { max-width: none; margin: 0; }
.page > .card.narrow { max-width: 420px; margin: 24px auto; }
.card h2 { margin: 0; font-size: 17px; }
.card.warn { border-color: #f3c2b6; background: #fff7f4; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline .input { width: auto; }
.inline.grow { flex: 1; min-width: 200px; }
.inline.grow .input { width: 100%; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-3 label, .parts label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.parts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

/* Forms and buttons */
.label { font-size: 14px; color: var(--muted); }
.input {
  width: 100%; padding: 10px 12px; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.input-lg { padding: 14px; font-size: 19px; }
.input:focus { outline: 2px solid var(--red-cta); outline-offset: 1px; border-color: transparent; }
.btn {
  padding: 11px 18px; font: inherit; font-weight: 700; color: #fff;
  background: var(--red-cta); border: 0; border-radius: 10px; cursor: pointer;
}
.btn:hover { background: var(--red-ink); }
.btn.ghost { background: var(--surface); color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--ink-2); }
.btn.danger { background: var(--error); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn:focus-visible, .link:focus-visible, .tab:focus-visible, .lang:focus-visible { outline: 2px solid var(--red-cta); outline-offset: 2px; }
a.btn { text-decoration: none; display: inline-block; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--red-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.danger-text { color: var(--error); }
.error { color: var(--error); font-size: 14px; }
.notice { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 10px 14px; }
.problem { background: var(--red-soft); color: var(--red-ink); border-radius: 10px; padding: 10px 14px; }

/* Numbers and codes */
.code { font-family: var(--font-num); letter-spacing: .03em; direction: ltr; unicode-bidi: isolate; }
.input.code { text-transform: uppercase; }
.w-short { width: 5.5em; }

/* Pills */
.pill { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.pill.off { background: #f1f1f1; color: var(--muted); }
.pill.bad { background: var(--red-soft); color: var(--red-ink); }
.pill.place { background: var(--amber-tint); color: var(--red-ink); font-family: var(--font-num); font-weight: 700; letter-spacing: .04em; direction: ltr; }
.pill.big { font-size: 18px; padding: 4px 14px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: 13px; color: var(--red-ink); font-weight: 700; background: var(--amber-tint); }
thead th:first-child { border-start-start-radius: 8px; }
thead th:last-child { border-start-end-radius: 8px; }
td.actions { white-space: nowrap; text-align: end; }
td.actions .link + .link { margin-inline-start: 12px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }

/* Admin home */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--red); }
.tile .num { font-family: var(--font-num); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px; font: inherit; color: var(--muted); cursor: pointer; }
.tab.current { color: var(--fg); border-bottom-color: var(--red); font-weight: 700; }
.tab .count { font-family: var(--font-num); font-size: 13px; background: var(--amber-tint); color: var(--red-ink); border-radius: 999px; padding: 0 8px; margin-inline-start: 4px; }

/* Scanning */
.scan-field { display: flex; flex-direction: column; gap: 6px; }
.scan-row { display: flex; gap: 8px; }
.scan-row .input { flex: 1; min-width: 0; }
.camera { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.camera-view { position: relative; width: 100%; max-width: 480px; margin: 0 auto; background: #222; border-radius: 10px; overflow: hidden; }
.camera-view video { display: block; width: 100%; height: auto; min-height: 200px; }
/* the frame matches the band the camera reads (FRAME in scan.js: 10% / 30% / 80% / 40%) */
.camera-frame { position: absolute; left: 10%; top: 30%; width: 80%; height: 40%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }

/* Product rows */
.results { display: flex; flex-direction: column; gap: 8px; }
.product-row { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.product-row .product-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.thumb { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: var(--bg); flex: none; }
.thumb.empty { border: 1px dashed var(--line); }

/* Putter */
.choose-place { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; }
.choose-place summary { cursor: pointer; color: var(--red-ink); }
.choose-place[open] { display: flex; flex-direction: column; gap: 10px; }
.numbered { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; }
.move { white-space: nowrap; font-family: var(--font-num); direction: ltr; }
.target, .swap-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.swap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.swap-side { flex-direction: column; align-items: flex-start; }
.swap-arrow { font-size: 26px; color: var(--muted); }

/* Picker */
.where { gap: 10px; }
.where .product-row { border: 0; padding: 0; }
.where-place { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 0 2px; border-top: 1px solid var(--line); }
.place-code { font-family: var(--font-num); font-weight: 700; font-size: 46px; line-height: 1.1; letter-spacing: .05em; color: var(--red-ink); direction: ltr; }
.place-code.small-code { font-size: 22px; }

/* Auditor */
.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.check-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.audit-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.audit-lists h2 { font-size: 15px; margin: 0 0 6px; }

/* Narrow screens: phones and handheld scanners */
@media (max-width: 760px) {
  .grid-2, .grid-3, .tiles, .audit-lists { grid-template-columns: 1fr 1fr; }
  .audit-lists { grid-template-columns: 1fr; }
  .page { padding: 16px 12px; }
  .card { padding: 16px; }
  .brand .app { display: none; }
}
@media (max-width: 480px) {
  .grid-2, .grid-3, .tiles { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; }
  .nav { gap: 12px; font-size: 15px; width: 100%; order: 3; }
  .tab { padding: 8px 8px; font-size: 15px; }
  .place-code { font-size: 40px; }
  .product-row { align-items: flex-start; flex-wrap: wrap; }
  .product-row .product-text { flex-basis: calc(100% - 68px); }
  .product-row > .btn, .product-row > .place-code, .product-row > .move, .product-row > .link { margin-inline-start: 68px; }
}

/* Quick wins: busy indicator, scan flash, big confirmation */
.scan-row { align-items: center; }
.busy { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--red-cta); animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.confirmed { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; border-radius: 12px; background: var(--ok-soft); border: 1px solid #bfe0cf; animation: pop .35s ease-out; }
.confirmed .check { font-size: 30px; color: var(--ok); line-height: 1; }
.confirmed .place-code { color: var(--ok); font-size: 40px; }
@keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: scale(1); opacity: 1; } }
body.flash-ok .page { animation: flash-ok .45s ease-out; }
body.flash-warn .page { animation: flash-warn .6s ease-out; }
body.flash-error .page { animation: flash-error .6s ease-out; }
@keyframes flash-ok { from { box-shadow: inset 0 0 0 6px #2fa36b; } to { box-shadow: inset 0 0 0 0 transparent; } }
@keyframes flash-warn { from { box-shadow: inset 0 0 0 6px #ff9200; } to { box-shadow: inset 0 0 0 0 transparent; } }
@keyframes flash-error { from { box-shadow: inset 0 0 0 6px #d12800; } to { box-shadow: inset 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) {
  .busy, .confirmed, body.flash-ok .page, body.flash-warn .page, body.flash-error .page { animation: none; }
}

/* Medium group: fill / task bar, undo, keyboard hints, pilot progress */
.mode-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.mode-bar .btn { margin-inline-start: auto; }
.notice.with-undo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.confirmed .undo { margin-inline-start: auto; }
.btn.undo { padding: 6px 12px; }
kbd { font-family: var(--font-num); font-size: 12px; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--ink-2); }
.shortcuts { display: none; text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px 20px; }
@media (hover: hover) and (pointer: fine) {
  .shortcuts { display: block; }
  .results { counter-reset: pick; }
  .results [data-pick] { counter-increment: pick; }
  .results > :nth-child(-n+9) [data-pick]::after { content: "Alt+" counter(pick); margin-inline-start: 8px; font-family: var(--font-num); font-size: 12px; opacity: .8; }
}
.progress { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.progress-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.progress-line .num { font-family: var(--font-num); font-size: 30px; font-weight: 700; line-height: 1.1; }
.card h3 { margin: 4px 0 0; font-size: 15px; }
.btn .busy { width: 16px; height: 16px; border-width: 2px; vertical-align: middle; }

/* Group A: connection banner, keyboard switch */
.net-banner { position: sticky; top: 0; z-index: 20; margin: 0; padding: 10px 16px; text-align: center; font-weight: 700; background: var(--red-soft); color: var(--red-ink); border-bottom: 1px solid #f5c9bd; }
.net-banner[hidden] { display: none; }
.keyboard-toggle { min-width: 48px; }
/* phones: the switch shows only ⌨, so the scan field keeps its width */
@media (max-width: 480px) {
  .keyboard-toggle .small { display: none; }
  .scan-row { gap: 6px; }
  .scan-row .btn { padding-inline: 12px; }
}
