:root {
  --bg: #0b0f14;
  --panel: #151b23;
  --panel-2: #1d2530;
  --text: #e8edf2;
  --muted: #8b98a5;
  --accent: #3b82f6;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --nav-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Noto Sans Hebrew", sans-serif;
  font-size: 16px;
  overscroll-behavior: none;
}

/* ---------- chrome ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(11,15,20,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid #232d3a;
}
/* one line, so the bar keeps the 53 px the sticky toolbars below assume */
#app-title {
  flex: 0 1 auto; min-width: 0; font-weight: 700; font-size: 17px;
  white-space: nowrap; overflow: hidden; text-overflow: clip; unicode-bidi: isolate;
}
@media (max-width: 359px) { #app-title { font-size: 15px; } }
#topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
/* the gear: a 44 px target that takes the bar's 32 px row */
#btn-gear {
  width: 44px; height: 44px; margin-block: -6px; margin-inline-end: -8px; padding: 0;
  background: none; border: none; border-radius: 999px; font-size: 20px; line-height: 1;
}
#btn-gear:active { background: var(--panel-2); }
/* the legacy list's counter and sync belong to the legacy screens */
body:not(.mode-legacy) #pick-counter, body:not(.mode-legacy) #sync-chip { display: none; }
#outbox-pill {
  background: rgba(245,158,11,.15); color: var(--warn); border: 1px solid rgba(245,158,11,.45);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700;
}
#pick-counter {
  background: rgba(34,197,94,.14); color: var(--good); border: 1px solid rgba(34,197,94,.4);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700;
}
#sync-chip {
  background: var(--panel-2); color: var(--text); border: 1px solid #2c3948;
  border-radius: 999px; padding: 7px 14px; font-size: 14px;
}
#sync-chip.busy { opacity: .6; }

main { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); }

#bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(13,18,24,.96); backdrop-filter: blur(8px);
  border-top: 1px solid #232d3a;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; color: var(--muted); font-size: 20px;
}
.nav-btn span { font-size: 11px; }
.nav-btn.active { color: var(--accent); }
/* the admin's nav follows the page's language (3.4), its labels 14 px like the owner area */
body.mode-admin .nav-btn span { font-size: 14px; }

button { font-family: inherit; font-size: 16px; color: var(--text); cursor: pointer; }

/* ---------- scan ---------- */
#view-scan { display: flex; flex-direction: column; height: calc(100dvh - 118px - var(--nav-h)); min-height: 420px; }
#cam-wrap { position: relative; flex: 1; background: #000; overflow: hidden; }
#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform-origin: center; transition: transform .2s; }
#aim { position: absolute; inset: 0; pointer-events: none; }
#aim-band {
  position: absolute; left: 6%; right: 6%; top: 50%; height: 34%;
  transform: translateY(-50%);
  border: 2px solid rgba(255,255,255,.75); border-radius: 12px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.35);
}
#aim-band::after {
  content: ""; position: absolute; left: 4%; right: 4%; top: 50%; height: 2px;
  background: rgba(239,68,68,.85);
}
#cam-controls {
  position: absolute; left: 0; right: 0; bottom: 14px; z-index: 5;
  display: flex; justify-content: center; gap: 12px;
}
#cam-controls button {
  border: 1px solid rgba(255,255,255,.35); border-radius: 999px;
  background: rgba(13,18,24,.72); color: #fff;
  padding: 13px 22px; font-size: 16px; font-weight: 600;
  backdrop-filter: blur(6px);
}
#cam-controls button:active { background: rgba(59,130,246,.85); }
#cam-idle {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center;
  background: radial-gradient(ellipse at center, #10161e 0%, #0b0f14 100%);
  padding: 20px;
}
#manual-form { display: flex; gap: 8px; padding: 10px 12px; background: var(--panel); }
#manual-form input {
  flex: 1; padding: 13px 14px; border-radius: var(--radius); border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 16px;
}
#manual-form button {
  padding: 0 20px; border-radius: var(--radius); border: none; background: var(--accent); font-weight: 600;
}
#manual-input.pulse {
  animation: pulse-glow 1.4s ease-out 2;
  border-color: var(--warn);
}
@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(245,158,11,.65); }
  100% { box-shadow: 0 0 0 14px rgba(245,158,11,0); }
}

/* ---------- list ---------- */
#list-toolbar { padding: 10px 12px 6px; background: var(--bg); position: sticky; top: 53px; z-index: 10; border-bottom: 1px solid #1c2530; }
#list-search {
  width: 100%; padding: 11px 14px; border-radius: var(--radius); border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 16px;
}
#list-filters { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.chip {
  border: 1px solid #2c3948; background: var(--panel); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 14px; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#list-progress { margin-top: 8px; font-size: 13px; color: var(--muted); }

.dept-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px 6px; font-weight: 700; font-size: 15px; color: #c9d4de;
}
.dept-header .bar { flex: 1; height: 5px; background: #232d3a; border-radius: 3px; margin: 0 10px; overflow: hidden; }
.dept-header .bar i { display: block; height: 100%; background: var(--good); }
.subdept-header { padding: 6px 14px 2px; font-size: 13px; color: var(--muted); }
.prod {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid #161e28; min-height: 52px;
}
.prod:active { background: var(--panel); }
.prod .status-ico { width: 26px; text-align: center; font-size: 17px; flex: none; }
.prod .p-main { flex: 1; min-width: 0; }
.prod .p-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.prod .p-sub { font-size: 12.5px; color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.prod .p-qty { font-size: 13px; color: var(--muted); flex: none; }
.prod.st-found .status-ico { color: var(--good); }
.prod.st-missing .status-ico { color: var(--bad); }

/* ---------- scout (legacy list, until older scouts are sent) ---------- */
#scout-toolbar {
  position: sticky; top: 53px; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--bg); border-bottom: 1px solid #1c2530;
}
#scout-actions { display: flex; gap: 8px; }
#scout-actions button {
  padding: 9px 16px; border-radius: 999px; border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 14px;
}
.scout-item {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid #161e28;
}
.scout-item:active { background: var(--panel); }
.scout-thumb {
  width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--panel-2); border: 1px solid #2c3948;
}
.scout-thumb.placeholder { display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--muted); }
.scout-main { flex: 1; min-width: 0; }
.scout-name { font-size: 15px; unicode-bidi: plaintext; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scout-sub { font-size: 12.5px; color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.scout-note { font-size: 12.5px; color: var(--warn); unicode-bidi: plaintext; }
.scout-state { flex: none; font-size: 15px; }
.scout-state.sent { color: var(--good); }
.scout-state.pending { color: var(--warn); }

/* ---------- settings ---------- */
#view-settings { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
#view-settings h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 2px; }
#view-settings label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); }
#view-settings label.row-label { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
#view-settings input[type="text"], #view-settings input[type="url"], #view-settings select {
  padding: 11px 12px; border-radius: 10px; border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 15px;
}
#view-settings input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
#view-settings button {
  padding: 13px; border-radius: var(--radius); border: 1px solid #2c3948; background: var(--panel-2);
}
#view-settings button.big { background: var(--accent); border: none; font-weight: 700; }
#view-settings button.danger { color: var(--bad); border-color: #3a2328; }
/* the page language (O10): the two choices side by side, the current one
   (aria-pressed, set by app.js) in accent */
.lang-choices { display: flex; gap: 8px; }
.lang-choices button { flex: 1; }
#view-settings .lang-choices button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
#advanced-settings, #legacy-settings { border: 1px solid #232d3a; border-radius: var(--radius); background: var(--panel); }
#advanced-settings summary, #legacy-settings > summary {
  padding: 13px 14px; font-size: 14px; color: var(--muted); cursor: pointer;
  list-style: none; user-select: none;
}
#advanced-settings summary::before, #legacy-settings > summary::before { content: "▸ "; }
#advanced-settings[open] summary::before, #legacy-settings[open] > summary::before { content: "▾ "; }
/* closed, the marker points along the line; ▸ and ◂ are not mirrored by the
   browser, so right to left takes its own (open, ▾ fits both) */
:root[dir="rtl"] #advanced-settings:not([open]) summary::before,
:root[dir="rtl"] #legacy-settings:not([open]) > summary::before { content: "◂ "; }
#advanced-settings > *:not(summary) { margin: 0 12px 12px; }
#advanced-settings label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); }
/* Legacy (3.10): the 2.4.0 screens and their Checklist, Results and Advanced */
.legacy-body { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px; }
#legacy-links { display: flex; flex-wrap: wrap; gap: 8px; }
.legacy-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1px solid #2c3948; background: var(--panel-2);
  color: var(--text); font-size: 15px; text-decoration: none;
}

.card-block { background: var(--panel); border: 1px solid #232d3a; border-radius: var(--radius); padding: 12px; font-size: 14px; }
.card-block h3 { margin: 0 0 6px; font-size: 14px; }
.card-block ul { margin: 6px 0; padding-inline-start: 18px; }
.card-block .warn { color: var(--warn); }
.card-block .bad { color: var(--bad); }
.card-block .ok { color: var(--good); }
.map-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.map-row span { width: 84px; color: var(--muted); font-size: 13px; flex: none; }
/* a select is as wide as its longest option (the long A1 title cell);
   min-width: 0 lets it shrink to the phone width instead */
.map-row select { flex: 1; min-width: 0; }

/* ---------- generic ---------- */
.big { padding: 16px 22px; border-radius: var(--radius); border: none; background: var(--accent); font-size: 18px; font-weight: 700; }
.hint { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.hint.pad { padding: 18px; text-align: center; }
.error { color: var(--bad); font-size: 14px; }

/* ---------- result bottom sheet ---------- */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; }
#result-card {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--panel); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 78dvh; overflow-y: auto;
  animation: slide-up .18s ease-out;
}
@keyframes slide-up { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }

.rc-status { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.rc-status.good { color: var(--good); }
.rc-status.warn { color: var(--warn); }
.rc-status.bad { color: var(--bad); }
.rc-name { font-size: 19px; font-weight: 700; margin: 2px 0 4px; unicode-bidi: plaintext; }
.rc-meta { color: var(--muted); font-size: 14px; margin-bottom: 4px; unicode-bidi: plaintext; }
.rc-code { font-family: ui-monospace, Consolas, monospace; color: var(--muted); font-size: 14px; direction: ltr; unicode-bidi: isolate; }
.rc-prev { margin-top: 8px; font-size: 14px; color: var(--warn); }
.rc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.rc-actions button { padding: 16px 8px; border-radius: var(--radius); border: none; font-size: 17px; font-weight: 700; }
.rc-actions .act-found { background: var(--good); color: #04220f; }
.rc-actions .act-missing { background: var(--bad); color: #2b0606; }
.rc-actions .act-wide { grid-column: 1 / -1; background: var(--panel-2); border: 1px solid #2c3948; font-weight: 500; font-size: 15px; }
.rc-actions .act-skip { background: var(--panel-2); border: 1px solid #2c3948; color: var(--text); font-weight: 500; }
.rc-note { width: 100%; margin-top: 10px; padding: 11px 12px; border-radius: 10px; border: 1px solid #2c3948; background: var(--panel-2); color: var(--text); font-size: 15px; }
.rc-sugg { margin-top: 10px; }
.rc-sugg .prod { border: 1px solid #232d3a; border-radius: 10px; margin-top: 6px; }
.rc-multi { border: 1px dashed #2c3948; border-radius: 10px; padding: 8px 10px; margin-top: 8px; }

/* ---------- login gate ---------- */
body.mode-login #topbar, body.mode-login #bottombar,
body.mode-manager #topbar, body.mode-manager #bottombar { display: none; }
/* the owner in a department: its header replaces the admin topbar, and the
   nav goes too, so the floating add button sits over nothing (3.10 item 3) */
body.mode-deptview #topbar { display: none; }
body.mode-deptview #bottombar { display: none; }
body.mode-login main, body.mode-manager main, body.mode-deptview main { padding-bottom: 20px; }

#view-login {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
#login-box { width: 100%; max-width: 340px; text-align: center; }
#login-logo { font-size: 54px; }
#login-box h1 { margin: 6px 0 4px; font-size: 26px; }
#login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
#login-form input {
  padding: 15px 16px; border-radius: var(--radius); border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 22px; text-align: center;
  letter-spacing: 2px;
}
#login-error { margin-top: 14px; }

/* ---------- manager view ---------- */
#mgr-topbar, #ph-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(11,15,20,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid #232d3a;
}
/* a department name keeps its own direction, so a long one loses its end, not its start */
#mgr-title, #ph-title { font-weight: 700; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
#mgr-right, #ph-right { display: flex; align-items: center; gap: 8px; }
#mgr-pending, #ph-pending {
  background: rgba(245,158,11,.15); color: var(--warn); border: 1px solid rgba(245,158,11,.45);
  border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 700;
}
#ph-pending.bad, #mgr-pending.bad { background: rgba(239,68,68,.14); color: var(--bad); border-color: rgba(239,68,68,.5); }
#ph-pending { min-height: 34px; white-space: nowrap; }
#mgr-refresh, #mgr-back, #ph-refresh {
  background: var(--panel-2); color: var(--text); border: 1px solid #2c3948;
  border-radius: 999px; padding: 7px 14px; font-size: 15px;
}
/* רק בלי תשובה, next to the title */
#mgr-open {
  flex: none; min-height: 36px; padding: 5px 12px; border-radius: 999px; border: 1px solid #2c3948;
  background: var(--panel); color: var(--muted); font-size: 14px; white-space: nowrap;
}
#mgr-open.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#mgr-chips { display: flex; gap: 6px; padding: 10px 12px 0; overflow-x: auto; }
#mgr-progress { padding: 10px 14px 4px; font-size: 14px; color: var(--muted); }
#mgr-body { padding-bottom: 96px; }

.mgr-cat {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 14px 6px; font-weight: 700; font-size: 16px; color: #c9d4de;
}
.mgr-cat small { color: var(--muted); font-weight: 400; font-size: 13px; }
.mgr-card {
  background: var(--panel); border: 1px solid #232d3a; border-radius: var(--radius);
  margin: 8px 12px; padding: 12px 14px;
}
.mgr-card.approved { border-color: rgba(34,197,94,.55); background: rgba(34,197,94,.07); }
.mgr-card.declined { opacity: .62; }
.mgr-name { font-size: 16px; font-weight: 700; unicode-bidi: plaintext; }
.mgr-code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.mgr-meta { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.mgr-sapnote { font-size: 12.5px; color: var(--warn); margin-top: 3px; unicode-bidi: plaintext; }
.mgr-actions { display: flex; gap: 8px; margin-top: 10px; }
.mgr-yes {
  flex: 2; padding: 13px 8px; border-radius: 12px; border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 17px; font-weight: 800;
}
.mgr-yes.on { background: var(--good); border-color: var(--good); color: #04220f; }
.mgr-no {
  flex: 1; padding: 13px 8px; border-radius: 12px; border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--muted); font-size: 15px; font-weight: 600;
}
.mgr-no.on { background: var(--bad); border-color: var(--bad); color: #2b0606; }
.mgr-note {
  width: 100%; margin-top: 8px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid #2c3948; background: var(--panel-2); color: var(--text); font-size: 14px;
}
#mgr-add {
  position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 25; padding: 14px 26px; border-radius: 999px; border: none;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.mgr-exit { display: block; margin: 26px auto 30px; background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; }

/* ---------- product photos ---------- */
body.mode-photoview #topbar { display: none; }
body.mode-photographer main { padding-bottom: 20px; }
/* fixed height, so the sticky toolbar below can sit exactly under it */
#ph-topbar { height: calc(58px + env(safe-area-inset-top)); }
#ph-refresh.busy { opacity: .5; }
#ph-toolbar {
  position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 10;
  padding: 10px 12px 6px; background: var(--bg); border-bottom: 1px solid #1c2530;
}
#ph-search-row { display: flex; gap: 8px; }
#ph-search {
  flex: 1; min-width: 0; padding: 11px 14px; border-radius: var(--radius); border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 16px;
}
#ph-scan {
  flex: none; padding: 0 16px; border-radius: var(--radius); border: none;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 700;
}
#ph-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#ph-filters .chip { min-height: 36px; }
#ph-filters #ph-instock.active { background: var(--good); border-color: var(--good); color: #04220f; }
#ph-filters #ph-reshoot.active { background: var(--bad); border-color: var(--bad); color: #2b0606; }
.chip-n {
  display: inline-block; min-width: 20px; margin-inline-start: 6px; padding: 0 6px;
  border-radius: 999px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px;
}
#ph-reshoot.active .chip-n { background: #2b0606; }
#ph-progress { margin-top: 8px; font-size: 13px; color: var(--muted); }
#ph-body { padding-bottom: 24px; }

.ph-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid #161e28; min-height: 62px; cursor: pointer;
}
.ph-row:active { background: var(--panel); }
.ph-row.nostock { opacity: .55; }
.ph-badge {
  flex: none; width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid #2c3948; color: var(--muted);
  font-size: 18px; font-weight: 800;
}
.ph-row.has .ph-badge { background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.5); color: var(--good); }
.ph-row.queued .ph-badge { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.6); color: var(--warn); }
.ph-row.failed .ph-badge { background: rgba(239,68,68,.12); border-color: var(--bad); color: var(--bad); }
.ph-main { flex: 1; min-width: 0; }
.ph-name { font-size: 15px; font-weight: 600; unicode-bidi: plaintext; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.ph-code { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, Consolas, monospace; }
.ph-tag {
  padding: 1px 8px; border-radius: 999px; border: 1px solid; font-size: 12px; font-weight: 700; line-height: 18px;
}
.ph-tag.new { color: var(--accent); border-color: rgba(59,130,246,.55); background: rgba(59,130,246,.12); }
.ph-tag.reshoot { color: var(--bad); border-color: rgba(239,68,68,.55); background: rgba(239,68,68,.12); }
/* stage 3 statuses (core.js STAGE_TAGS): on the way to the site muted, on the site green like a photo count */
.ph-tag.files_uploaded, .ph-tag.draft_created { color: var(--muted); border-color: #2c3948; background: var(--panel-2); }
.ph-tag.live { color: var(--good); border-color: rgba(34,197,94,.5); background: rgba(34,197,94,.14); }

/* search offer: a code nothing on the list has */
.ph-offer {
  display: flex; align-items: center; gap: 8px; width: calc(100% - 24px); margin: 12px 12px 4px;
  min-height: 52px; padding: 10px 14px; border-radius: var(--radius);
  border: 1px dashed rgba(59,130,246,.7); background: rgba(59,130,246,.1);
  color: var(--text); font-size: 16px; font-weight: 700; text-align: start;
}
.ph-offer:active { background: rgba(59,130,246,.22); }
.ph-offer-plus { color: var(--accent); font-size: 20px; }
.ph-offer .ph-code { font-weight: 600; overflow-wrap: anywhere; }

/* product card: new product, code check, reshoot */
.ph-card-new { color: var(--accent); font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.rc-code.ph-code-lg { font-size: 19px; color: var(--text); overflow-wrap: anywhere; }
.ph-check { margin-top: 8px; font-size: 14.5px; font-weight: 600; }
.ph-check.ok { color: var(--good); }
.ph-check.warn { color: var(--warn); }
.ph-confirm {
  display: flex; align-items: center; gap: 12px; margin-top: 10px; min-height: 50px; padding: 10px 14px;
  border-radius: 12px; border: 1px dashed rgba(245,158,11,.7); background: rgba(245,158,11,.08);
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.ph-confirm input { flex: none; width: 24px; height: 24px; accent-color: var(--warn); }
.ph-reshoot {
  margin-top: 8px; padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(239,68,68,.5);
  background: rgba(239,68,68,.1); color: var(--bad); font-size: 14.5px; font-weight: 600; unicode-bidi: plaintext;
}
.rc-actions button:disabled { opacity: .4; }

.ph-grid-head { margin-top: 12px; font-size: 14px; color: var(--muted); }
.ph-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.ph-tile {
  position: relative; aspect-ratio: 1; padding: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid #2c3948; background: var(--panel-2);
}
.ph-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-tile.queued { border-color: rgba(245,158,11,.75); }
.ph-tile.failed { border-color: var(--bad); }
.ph-tile-ph { font-size: 26px; color: var(--muted); }
.ph-tile-name, .ph-tile-state {
  position: absolute; bottom: 4px; padding: 1px 6px; border-radius: 6px;
  background: rgba(0,0,0,.62); color: #fff; font-size: 12px;
}
/* the photo number at the tile's start corner, the upload state at its end
   one; the number's own direction is pinned ltr, which would make a logical
   inset always the left one, so its corner comes from <html dir> */
.ph-tile-name { left: 4px; direction: ltr; unicode-bidi: isolate; }
:root[dir="rtl"] .ph-tile-name { left: auto; right: 4px; }
.ph-tile-state { inset-inline-end: 4px; }

#ph-viewer { position: fixed; inset: 0; z-index: 44; display: flex; flex-direction: column; background: #000; }
#ph-viewer-img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
#ph-viewer-bar { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--panel); }
#ph-viewer-name { margin-bottom: 10px; font-size: 13px; color: var(--muted); unicode-bidi: plaintext; }
#ph-viewer-actions { display: flex; gap: 8px; }
#ph-viewer-actions button {
  flex: 1; padding: 13px 8px; border-radius: 12px; border: 1px solid #2c3948;
  background: var(--panel-2); font-size: 15px; font-weight: 600;
}
#ph-viewer-actions #ph-viewer-del { color: var(--bad); border-color: #3a2328; }

.ph-admin { margin: 22px 12px 30px; padding: 12px; border: 1px solid #232d3a; border-radius: var(--radius); background: var(--panel); }
.ph-admin h3 { margin: 0 0 6px; font-size: 14px; }
.ph-admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ph-admin-btn {
  padding: 10px 14px; border-radius: 999px; border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 14px; text-decoration: none;
}

/* ---------- data lines at the page's start edge ----------
   Names, codes and notes keep their own order inside the line (unicode-bidi:
   plaintext, or a direction: ltr pin), so text-align: start would follow
   each text and zig-zag down a card. They take the page's start edge from
   <html dir> instead: left in English, right in Hebrew (decision O10). */
:root[dir="ltr"] #mgr-title, :root[dir="ltr"] #ph-title,
:root[dir="ltr"] .mgr-name, :root[dir="ltr"] .mgr-code, :root[dir="ltr"] .mgr-sapnote,
:root[dir="ltr"] .ph-name, :root[dir="ltr"] .rc-name, :root[dir="ltr"] .rc-code,
:root[dir="ltr"] .rc-meta, :root[dir="ltr"] .ph-reshoot, :root[dir="ltr"] #ph-viewer-name { text-align: left; }
:root[dir="rtl"] #mgr-title, :root[dir="rtl"] #ph-title,
:root[dir="rtl"] .mgr-name, :root[dir="rtl"] .mgr-code, :root[dir="rtl"] .mgr-sapnote,
:root[dir="rtl"] .ph-name, :root[dir="rtl"] .rc-name, :root[dir="rtl"] .rc-code,
:root[dir="rtl"] .rc-meta, :root[dir="rtl"] .ph-reshoot, :root[dir="rtl"] #ph-viewer-name { text-align: right; }

/* scanning to find a product for the photos page */
#photo-scan-bar {
  display: none; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--panel); font-size: 14px; color: var(--muted);
}
#photo-scan-back {
  background: var(--panel-2); color: var(--text); border: 1px solid #2c3948;
  border-radius: 999px; padding: 9px 16px; font-size: 15px;
}
body.photo-scan #photo-scan-bar { display: flex; }
body:not(.photo-scan) .photo-only { display: none; }
body.photo-scan #view-scan { height: calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom) - 8px); }
body.mode-photographer.photo-scan #view-scan { height: calc(100dvh - 20px); }

/* ---------- depts (admin) ---------- */
#view-depts { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
#view-depts h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 2px; }
#view-depts button.big { padding: 14px; border-radius: var(--radius); border: none; }
.dept-row, .access-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid #232d3a;
}
.dept-row:last-child, .access-row:last-child { border-bottom: none; }
.dept-row .d-name, .access-row .a-main { flex: 1; min-width: 0; unicode-bidi: plaintext; }
.access-row .a-main .a-phone { font-size: 12.5px; color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.access-row .a-main .a-depts { font-size: 12.5px; color: var(--accent); unicode-bidi: plaintext; }
.dept-row button, .access-row button {
  padding: 8px 14px; border-radius: 999px; border: 1px solid #2c3948;
  background: var(--panel-2); color: var(--text); font-size: 14px;
}
.access-row button.a-del { color: var(--bad); border-color: #3a2328; }
.rc-check { display: flex; align-items: center; gap: 10px; padding: 9px 2px; font-size: 15px; }
.rc-check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- desktop / wide screens ----------
   The app stays a phone-shaped column, centered, instead of stretching
   edge to edge. Fixed/sticky bars get matching side padding so their
   contents line up with the column. */
@media (min-width: 768px) {
  main {
    max-width: 760px; margin: 0 auto;
    border-inline: 1px solid #1a2330; min-height: 100dvh;
  }
  #topbar {
    padding-left: max(14px, calc(50vw - 366px));
    padding-right: max(14px, calc(50vw - 366px));
  }
  #bottombar {
    padding-left: max(0px, calc(50vw - 380px));
    padding-right: max(0px, calc(50vw - 380px));
  }
  #bottombar .nav-btn { max-width: 152px; }
  #result-card { max-width: 620px; margin: 0 auto; }
  #view-scan { min-height: 520px; }
  #toast { bottom: calc(var(--nav-h) + 34px); }
}

/* ---------- the admin from 1024 px (docs/ecom-ops-contract.md 3.3) ----------
   The nav becomes a fixed rail at the inline start (the right edge in
   Hebrew, the left in English), 200 px wide, icon and label in a row, the
   active entry in accent; main takes the rest up to 1280 px (owner.css lays
   out #view-owner in it), while the screens of app.js keep their 760 px
   column; the bottom sheet is a centered dialog of at most 620 px, and the
   toast and the update chip are centered over the same area. A department
   as the owner has no nav, so it keeps the whole width. */
@media (min-width: 1024px) {
  body.mode-admin:not(.mode-deptview) { padding-inline-start: 200px; }
  body.mode-admin #bottombar {
    top: 0; bottom: 0; inset-inline-start: 0; inset-inline-end: auto; width: 200px; height: auto;
    flex-direction: column; gap: 4px;
    padding: calc(env(safe-area-inset-top) + 12px) 10px calc(env(safe-area-inset-bottom) + 12px);
    border-top: none; border-inline-end: 1px solid #232d3a;
  }
  body.mode-admin #bottombar .nav-btn {
    flex: none; max-width: none; min-height: 48px; padding: 0 14px;
    flex-direction: row; justify-content: flex-start; gap: 12px;
    border-radius: 12px; font-size: 20px;
  }
  body.mode-admin #bottombar .nav-btn span { font-size: 15px; }
  body.mode-admin #bottombar .nav-btn.active { background: rgba(59,130,246,.14); }
  body.mode-admin main { max-width: 1280px; padding-bottom: 24px; }
  body.mode-admin main > .view:not(#view-owner) { max-width: 760px; margin-inline: auto; }
  body.mode-admin:not(.mode-deptview) #topbar {
    padding-left: max(14px, calc((100vw - 200px - 1280px) / 2 + 14px));
    padding-right: max(14px, calc((100vw - 200px - 1280px) / 2 + 14px));
  }
  body.mode-admin #view-scan { height: calc(100dvh - 118px); }
  body.mode-admin.photo-scan #view-scan { height: calc(100dvh - 16px); }
  body.mode-admin #result-card {
    top: 50%; bottom: auto; translate: 0 -50%; border-radius: 18px;
    max-height: 86dvh; padding-bottom: 16px;
  }
  body.mode-admin:not(.mode-deptview) #result-card { inset-inline-start: 200px; }
  body.mode-admin #toast { bottom: 24px; }
  /* translateX(-50%) is physical, so left takes the middle of the area
     beside the rail per direction: (100% + 200px) / 2 with the rail on the
     left (English), (100% - 200px) / 2 with it on the right (Hebrew) */
  body.mode-admin:not(.mode-deptview) #toast,
  body.mode-admin:not(.mode-deptview) #update-chip { left: calc((100% + 200px) / 2); }
  :root[dir="rtl"] body.mode-admin:not(.mode-deptview) #toast,
  :root[dir="rtl"] body.mode-admin:not(.mode-deptview) #update-chip { left: calc((100% - 200px) / 2); }
}

/* the owner area when owner.js could not load (app.js showOwnerScreen) */
.owner-fault { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-bottom: 20px; }
#flash { position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: 0; }
#flash.good { background: var(--good); }
#flash.warn { background: var(--warn); }
#flash.bad { background: var(--bad); }
#flash.on { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .55; } 100% { opacity: 0; } }

/* as wide as its message, at most 620 px and 16 px clear of each screen
   edge, then it wraps; each message takes the direction of its own text */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%);
  width: max-content; max-width: min(620px, calc(100% - 32px));
  background: #26303d; color: var(--text); padding: 10px 18px; border-radius: 999px;
  font-size: 14.5px; z-index: 45; box-shadow: 0 4px 18px rgba(0,0,0,.4); unicode-bidi: plaintext;
}

/* under the top bar of every mode; a card's backdrop covers it */
#update-chip {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 66px); transform: translateX(-50%);
  z-index: 26; padding: 8px 16px; border-radius: 999px; border: none;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 700;
  white-space: nowrap; box-shadow: 0 4px 18px rgba(0,0,0,.45);
}
#update-chip:disabled { opacity: .6; }
