/* Almayar Dispatch — operations UI. Logistics blue + dispatch orange, dense, RTL, mobile-first. */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #0f172a;
  --ink-2: #526074;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --brand-soft: #e8effd;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fff1e8;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #92400e;
  --warn-soft: #fef3dc;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 8px rgba(15, 23, 42, .04);
  --shadow-lg: 0 -8px 30px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #121a2b;
    --surface-2: #18223a;
    --ink: #e5e9f0;
    --ink-2: #9aa7bb;
    --line: #24314a;
    --line-2: #33425f;
    --brand: #7aa7ff;
    --brand-ink: #0b1120;
    --brand-soft: #172748;
    --accent: #fb923c;
    --accent-ink: #1a0d03;
    --accent-soft: #3a2212;
    --ok: #4ade80;
    --ok-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #33290a;
    --bad: #f87171;
    --bad-soft: #3a1515;
    --shadow: none;
    --shadow-lg: 0 -8px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
body.no-scroll { overflow: hidden; }
body.has-bulkbar .list { padding-bottom: 110px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: none; box-shadow: var(--ring); }
svg { flex: none; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.cur { font-size: .8em; color: var(--ink-2); font-weight: 500; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.note { color: var(--warn); font-weight: 600; }
.grow { flex: 1; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 12px 0;
}
.top > * { max-width: 760px; margin-inline: auto; }
.top-row { display: flex; align-items: center; gap: 6px; min-height: 48px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand > div { min-width: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 50%; background: var(--store, var(--brand)); color: #fff; display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; }
.top h1 { font-size: 17px; margin: 0; font-weight: 700; line-height: 1.2; }
.top .sub { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sub .err { color: var(--bad); font-weight: 600; }
.icon-btn {
  background: transparent; border: 1px solid transparent; color: var(--ink-2);
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .spinner { color: var(--brand); }

.search {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.search svg { width: 18px; height: 18px; color: var(--ink-2); }
.search input { flex: 1; border: 0; background: transparent; outline: none; min-height: 42px; font-size: 15px; min-width: 0; }
.search input::-webkit-search-cancel-button { cursor: pointer; }

.tabs { display: flex; gap: 2px; margin-top: 4px; overflow-x: auto; scrollbar-width: none; }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--ink-2); white-space: nowrap;
  padding: 10px 6px 11px; font-weight: 600; font-size: 15px; min-height: 44px;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count { display: inline-block; min-width: 22px; padding: 0 6px; margin-inline-start: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; line-height: 18px; color: var(--ink-2); }
.tab[aria-selected="true"] .count { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.tab.attn .count { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 10px; font-size: 14px; margin: 10px max(12px, calc((100% - 736px) / 2)) 0; }

/* ---------- stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  max-width: 760px; margin: 10px auto 0; padding: 0 12px;
}
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; min-height: 72px;
  box-shadow: var(--shadow); transition: border-color .15s;
}
.stat:hover { border-color: var(--line-2); }
.stat .label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.stat .value { font-size: 20px; font-weight: 700; line-height: 1.3; }
.stat .value .cur { font-size: 12px; }
.stat .hint { font-size: 12px; color: var(--ink-2); }
.stat.accent .value { color: var(--accent); }
.stat.warn { background: var(--warn-soft); border-color: transparent; }
.stat.warn .value, .stat.warn .label, .stat.warn .hint { color: var(--warn); }

/* ---------- toolbar + bulk bar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 10px auto 0; padding: 0 12px; }
.selall { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 14px; font-weight: 600; color: var(--ink-2); min-height: 44px; cursor: pointer; }
input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.bulkbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 6;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow-lg);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.bulkbar .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 8px; }
.bb-info { flex: 1; display: flex; flex-direction: column; font-size: 13px; color: var(--ink-2); line-height: 1.35; }
.bb-info b { font-size: 15px; color: var(--ink); }

/* ---------- order list ---------- */
.list { padding: 10px 12px 40px; display: grid; gap: 8px; max-width: 760px; margin: 0 auto; }
.empty { text-align: center; color: var(--ink-2); padding: 48px 16px; display: grid; justify-items: center; gap: 8px; }
.empty svg { width: 40px; height: 40px; opacity: .5; }
.skel { height: 84px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--line); margin-bottom: 8px; }
.skel.short { height: 56px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; transition: border-color .15s; }
.card.is-sel { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.card-row { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.card-row.with-sel { grid-template-columns: 40px 1fr auto; }
.sel { display: grid; place-items: center; align-self: stretch; padding-inline-start: 6px; cursor: pointer; }
.card-head {
  display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; min-width: 0;
  padding: 10px; background: none; border: 0; text-align: start;
}
.with-sel .card-head { padding-inline-start: 4px; }
.card-head:focus-visible { box-shadow: inset var(--ring); border-radius: var(--radius); }
.thumbs { position: relative; width: 48px; height: 48px; }
.thumbs img, .thumbs .ph { position: absolute; width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--surface-2); border: 2px solid var(--surface); }
.thumbs .ph { display: grid; place-items: center; color: var(--ink-2); }
.thumbs .ph svg { width: 20px; height: 20px; }
.thumbs img:nth-child(1) { top: 0; inset-inline-start: 0; z-index: 2; }
.thumbs img:nth-child(2) { bottom: 0; inset-inline-end: 0; z-index: 1; }
.thumbs .more { position: absolute; bottom: -2px; inset-inline-start: -2px; z-index: 3; font-size: 11px; background: var(--ink); color: var(--surface); border-radius: 99px; padding: 0 5px; }
.head-main { min-width: 0; }
.head-top { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.order-no { font-weight: 700; }
.cust { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; margin-top: 2px; min-width: 0; }
.line span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line svg { width: 14px; height: 14px; }
.line.ok { color: var(--ok); }
.line.warn { color: var(--warn); }
.line.bad { color: var(--bad); }
.line.muted { color: var(--ink-2); font-weight: 500; }
.head-end { text-align: end; padding: 8px 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.total { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 6px; line-height: 18px; white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.info { background: var(--brand-soft); color: var(--brand); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge.new { background: var(--brand-soft); color: var(--brand); }
.badge.sent { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.st-created, .badge.st-pickup, .badge.st-in-transit { background: var(--brand-soft); color: var(--brand); }
.badge.st-out-for-delivery { background: var(--accent-soft); color: var(--accent); }
.badge.st-delivered { background: var(--ok-soft); color: var(--ok); }
.badge.st-delivery-failed, .badge.st-returning, .badge.st-returned, .badge.st-rejected, .badge.st-cancelled { background: var(--bad-soft); color: var(--bad); }

.card-body { border-top: 1px solid var(--line); padding: 4px 12px 12px; }
.item { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.item:last-of-type { border-bottom: 0; }
.item img, .item .ph { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--ink-2); }
.item .ph svg { width: 22px; height: 22px; }
.item .t { font-weight: 600; font-size: 15px; }
.item .v { font-size: 13px; color: var(--ink-2); }
.item .p { text-align: end; font-size: 14px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0 10px; font-size: 14px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; }
.facts a { font-weight: 600; text-decoration: none; }
.sums { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.sums b { color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.actions:last-child { margin-bottom: 0; }
.actions .btn:not(.sm) { flex: 1; }
.actions.mid { justify-content: center; margin-top: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, opacity .15s, transform .1s;
}
.btn svg { width: 18px; height: 18px; }
.btn.sm { min-height: 44px; padding: 0 12px; font-size: 14px; }
.btn.xs { min-height: 32px; padding: 0 8px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.accent:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 88%, #000); }
.btn.danger-ghost { background: var(--surface); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); margin-top: 8px; }
.btn.danger-ghost:hover { background: var(--bad-soft); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn:not([disabled]):active { transform: scale(.98); }
.ship-btn { min-height: 40px; padding: 0 12px; }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; text-decoration: underline dotted; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login / setup ---------- */
.center { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 4px; font-size: 22px; }
.panel p { color: var(--ink-2); margin: 0 0 18px; }
.panel ul { padding-inline-start: 20px; }
.logo { width: 56px; height: 56px; margin-bottom: 12px; }

/* ---------- modal (bottom sheet on phone, dialog on desktop) ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); animation: fade .2s ease-out; }
.dialog {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  animation: up .22s ease-out; padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 720px) {
  .modal { align-items: center; }
  .dialog { border-radius: 18px; max-height: 86dvh; }
}
.m-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 12px; border-bottom: 1px solid var(--line); }
.m-head h2 { flex: 1; font-size: 17px; margin: 0; padding-inline-start: 4px; }
.m-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.m-icon.warn { background: var(--warn-soft); color: var(--warn); }
.m-icon.bad { background: var(--bad-soft); color: var(--bad); }
.m-icon svg { width: 20px; height: 20px; }
.req { color: var(--bad); }
#cancelForm .check { margin-bottom: 10px; min-height: 32px; }
.m-body { padding: 12px 14px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.m-foot { display: flex; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

.qs { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.qs-row { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 9px 12px; font-size: 15px; }
.qs-row + .qs-row { border-top: 1px solid var(--line); }
.qs-row .k { color: var(--ink-2); font-size: 13px; padding-top: 2px; }
.qs-row a { font-weight: 600; text-decoration: none; }
.need { color: var(--warn); font-weight: 700; }
.moneybar { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 6px; margin-bottom: 10px; }
.moneybar > div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.moneybar span { font-size: 12px; color: var(--ink-2); }
.moneybar b { font-size: 17px; }
.moneybar .hl { background: var(--accent-soft); }
.moneybar .hl span, .moneybar .hl b, .moneybar .hl .cur { color: var(--accent); }
.moneybar .hl b { font-size: 20px; }
.fine { font-size: 13px; color: var(--ink-2); margin: 4px 0 0; }

.result { text-align: center; padding: 8px 0; }
.result > svg { width: 56px; height: 56px; }
.result.ok > svg { color: var(--ok); }
.result.warn > svg { color: var(--warn); }
.result .code { font-size: 32px; font-weight: 700; letter-spacing: 1px; margin: 2px 0 12px; }

.bulk-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.bulk-sum > div { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; }
.bulk-sum span { font-size: 12px; color: var(--ink-2); }
.bulk-sum b { font-size: 20px; }
.olist { list-style: none; margin: 0 0 10px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.olist li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 14px; min-height: 48px; }
.olist li + li { border-top: 1px solid var(--line); }
.olist .b { font-weight: 700; }
.olist small { display: block; color: var(--ink-2); font-size: 12px; }
.olist small.warn { color: var(--warn); font-weight: 600; }
.olist.run .ico { width: 22px; height: 22px; display: grid; place-items: center; }
.olist.run .ico svg { width: 20px; height: 20px; }
.olist.run .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.olist .st-busy { background: var(--brand-soft); }
.olist .st-busy .ico { color: var(--brand); }
.olist .st-ok .ico { color: var(--ok); }
.olist .st-partial .ico, .olist .st-skip .ico, .olist .st-stopped .ico { color: var(--warn); }
.olist .st-skip small, .olist .st-stopped small { color: var(--warn); }
.olist .st-fail .ico, .olist .st-fail small { color: var(--bad); }
.skipped { margin-bottom: 10px; }
.skipped summary { cursor: pointer; padding: 8px 0; color: var(--warn); font-weight: 600; font-size: 14px; min-height: 44px; display: flex; align-items: center; gap: 4px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: inherit; transition: width .3s ease-out; }
.progress-txt { font-size: 14px; color: var(--ink-2); margin: 8px 0 10px; }

/* ---------- full-screen sheet (edit form, manifest) ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; }
.sheet-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; }
.sheet-head h2 { font-size: 17px; margin: 0; flex: 1; }
.sheet-body { max-width: 680px; margin: 0 auto; padding: 12px 12px 110px; }
.sheet-foot { position: fixed; bottom: 0; inset-inline: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); z-index: 3; }
.sheet-foot .inner { max-width: 680px; margin: 0 auto; display: flex; gap: 8px; }

.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.section h3 { margin: 0 0 8px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 14px; font-weight: 600; }
.field .hint, .hint { font-size: 13px; color: var(--ink-2); }
.field .from { font-size: 13px; color: var(--ink-2); }
.field .from b { color: var(--ink); font-weight: 600; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%; min-height: 46px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); outline: none; font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 68px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: var(--ring); }
input.num { text-align: right; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; margin-bottom: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; align-items: end; margin-bottom: 12px; }
.row2 > .field, .row3 > .field { margin-bottom: 0; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-height: 40px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line-2);
  background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; font-size: 14px;
}
.chip small { font-weight: 500; color: var(--ink-2); font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .85; }
.picked { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.picked .ok { color: var(--ok); display: inline-flex; }
.picked .ok svg { width: 16px; height: 16px; }
.picked .need { color: var(--warn); }

.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; line-height: 1.6; }
.notice svg { width: 16px; height: 16px; vertical-align: -3px; margin-inline-end: 2px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--brand-soft); color: var(--brand); }
.notice.strong { font-size: 15px; border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }

.feebox { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; text-align: center; }
.feebox div { background: var(--surface-2); border-radius: 10px; padding: 8px 4px; }
.feebox > div > span { display: block; font-size: 12px; color: var(--ink-2); }
.feebox b { font-size: 17px; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { margin-top: 3px; }

/* manifest */
.m-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.m-controls label { font-weight: 600; font-size: 14px; }
.m-controls input { max-width: 200px; }
.print-title { display: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.manifest { width: 100%; border-collapse: collapse; font-size: 14px; }
.manifest th { text-align: start; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 8px 10px; background: var(--surface-2); white-space: nowrap; }
.manifest td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.manifest tr.gone td { color: var(--ink-2); text-decoration: line-through; }
.manifest tr.gone small { text-decoration: none; }

.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); inset-inline: 16px; max-width: 480px; margin: 0 auto; z-index: 40; background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 10px; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: up .2s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
body.has-bulkbar .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  body { background: #fff; color: #000; }
  #app, #modal, #toast, .sheet-head, .sheet-foot, .no-print, .fine { display: none !important; }
  .sheet { position: static; overflow: visible; background: #fff; }
  .sheet-body { padding: 0; max-width: none; }
  .print-title { display: block; font-size: 16px; margin-bottom: 10px; }
  .bulk-sum > div { background: none; border: 1px solid #999; }
  .table-wrap { border: 0; overflow: visible; }
  .manifest th { background: #eee; color: #000; }
  .manifest td, .manifest th { border: 1px solid #999; }
  .linkish { color: #000; text-decoration: none; }
}

/* ---------- phone tuning ---------- */
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .stat { padding: 6px 8px; min-height: 0; border-radius: 10px; }
  .stat .label { font-size: 11px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .stat .value { font-size: 17px; }
  .stat .hint { display: none; }
}
@media (max-width: 420px) {
  .with-sel .card-head { grid-template-columns: 1fr; }
  .with-sel .thumbs { display: none; }
  .head-end { padding: 8px 8px 8px 10px; }
  .ship-btn { padding: 0 10px; }
}
@media (max-width: 420px) {
  .manifest th:first-child, .manifest td:first-child { display: none; }
  .manifest th, .manifest td { padding: 8px 6px; }
}

/* ---------- store switcher (parent level, above the order tabs) ---------- */
.brand-mark .mono { font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.stores { display: flex; justify-content: center; gap: 8px; margin: 4px auto 6px; overflow-x: auto; scrollbar-width: none; }
.stores[hidden] { display: none; }
.store-pill {
  flex: 1 1 0; min-width: 0; max-width: 280px; display: flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 4px 10px 4px 6px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: 14px;
  transition: background-color .15s, border-color .15s, color .15s;
}
.store-pill:hover { border-color: var(--line-2); color: var(--ink); }
.store-pill .avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--c); font-size: 12px; font-weight: 700; letter-spacing: .5px;
  border: 2px solid transparent;
}
.store-pill .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: start; }
.store-pill .pill-count { min-width: 24px; padding: 0 7px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 12px; line-height: 22px; text-align: center; }
.store-pill .pill-tag { font-size: 11px; padding: 0 6px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); line-height: 20px; white-space: nowrap; }
.store-pill.active { background: color-mix(in srgb, var(--c) 10%, var(--surface)); border-color: var(--c); color: var(--ink); box-shadow: 0 0 0 1px var(--c); }
.store-pill.active .avatar { background: var(--c); color: #fff; }
.store-pill.off .avatar { opacity: .55; }
@media (prefers-color-scheme: dark) {
  .store-pill .avatar { color: color-mix(in srgb, var(--c) 55%, #fff); }
}

.setup-card { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 16px; }
.setup-card h2 { font-size: 17px; margin: 0 0 6px; }
.setup-card p { margin: 0 0 8px; color: var(--ink-2); }
.setup-card ol { margin: 0 0 8px; padding-inline-start: 20px; display: grid; gap: 6px; }

/* ---------- manage-order menu ---------- */
.m-icon.info { background: var(--brand-soft); color: var(--brand); }
.manage-sum { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
.manage-sum b { color: var(--ink); }
.menu { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px;
  background: var(--surface); border: 0; text-align: start; color: var(--ink); text-decoration: none;
  transition: background-color .15s;
}
.menu-item + .menu-item { border-top: 1px solid var(--line); }
.menu-item:hover:not([disabled]) { background: var(--surface-2); }
.menu-item[disabled] { cursor: not-allowed; }
.menu-item[disabled] .mi-ico, .menu-item[disabled] b { opacity: .5; }
.mi-ico { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--brand); }
.mi-ico svg { width: 20px; height: 20px; }
.mi-txt { display: flex; flex-direction: column; min-width: 0; }
.mi-txt b { font-size: 15px; }
.mi-txt small { font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.menu-item.danger .mi-ico { background: var(--bad-soft); color: var(--bad); }
.menu-item.danger b { color: var(--bad); }

/* ---------- warnings above an order ---------- */
.flag { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); }
.flag svg { width: 15px; height: 15px; }
.flag.warn { background: var(--warn-soft); color: var(--warn); }
.flag.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- bulk: print option ---------- */
.print-opt { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.print-opt span { display: flex; flex-direction: column; gap: 2px; }
.print-opt small { font-size: 12px; color: var(--ink-2); line-height: 1.5; }

/* ---------- settings ---------- */
.set-store { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }
.set-store-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.set-store-head > div { flex: 1; min-width: 0; }
.set-store-head .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.set-store .row2 { margin-bottom: 8px; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
input[type=color] { width: 100%; min-height: 46px; padding: 4px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; }
.provider { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0 12px; }
.chk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.adv { margin: 8px 0; }
.adv summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); min-height: 40px; display: flex; align-items: center; }
.label-preview-wrap { display: grid; place-items: center; padding: 16px; margin: 10px 0; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line-2); }
#labelPreview .lbl { box-shadow: 0 1px 6px rgba(0, 0, 0, .25); border-radius: 3px; }

/* ---------- pickup ---------- */
.pk-all { margin: 4px 0 8px; }
.pk-list li { padding: 0; }
.pk-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; min-height: 52px; cursor: pointer; }
.pk-row .warn { color: var(--warn); font-weight: 600; }
.pk-tabs { padding: 0 14px; border-bottom: 1px solid var(--line); margin-top: 0; }
.pk-hist li.pk-h { flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 12px; }
.pk-h-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pk-h small { display: block; overflow-wrap: anywhere; }
.pk-cancel { margin-top: 6px; }
.pk-cancel .notice { margin-bottom: 8px; }
.pk-cancel .actions { display: flex; gap: 8px; justify-content: flex-end; }
.store-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-inline-end: 4px; vertical-align: 1px; }
.chips .chip input { margin: 0; accent-color: var(--brand); }
.chips label.chip:has(input:checked) { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
/* grid columns must be allowed to shrink below their content (long hints / inputs) */
.row2 > *, .row3 > * { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; }

/* ---------- alert banners (prices / WhatsApp) ---------- */
.banner.alert { display: flex; align-items: center; gap: 8px; width: calc(100% - 24px); max-width: 736px; text-align: start; border: 0; font-size: 14px; cursor: pointer; }
.banner.alert svg { width: 18px; height: 18px; flex: none; }
.banner.alert span { flex: 1; }
.banner.alert > b { font-size: 13px; text-decoration: underline; white-space: nowrap; }
.banner.alert.warn { background: var(--warn-soft); color: var(--warn); }
.banner.alert.bad { background: var(--bad-soft); color: var(--bad); }
.banner.alert.info { background: var(--brand-soft); color: var(--brand); }
.banner.alert.ok { background: var(--ok-soft); color: var(--ok); }
.m-icon.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- shipping prices screen ---------- */
.rates-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rates-head > div { flex: 1; min-width: 0; }
.rates-sub { font-size: 15px; margin: 16px 0 6px; }
.rates-table td.b { font-weight: 700; color: var(--accent); }
.rates-table tr.st-mismatch td, .rates-table tr.st-missing-in-store td { background: var(--warn-soft); }
.rates-prop .price { min-width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; flex: none; }
.rates-prop small { display: block; color: var(--ink-2); font-size: 12px; line-height: 1.5; }
.rates-prop li.act-delete { opacity: .7; }
.rates-prop li { align-items: flex-start; }
.steps ol { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; font-size: 14px; }
.rates-row { align-items: end; }

/* ---------- customer messages ---------- */
.test-mail { display: flex; gap: 8px; margin-top: 10px; }
.test-mail input { flex: 1; min-width: 0; min-height: 46px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); }
.wa-list li { align-items: flex-start; }
.wa-text { white-space: pre-line; margin-top: 4px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); color: var(--ink) !important; }
.wa-btns { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
/* the price tables reuse the list style but must keep their first column (area name) on phones */
.rates-table th:first-child, .rates-table td:first-child { display: table-cell !important; }

/* ---------- orders tab: filters, sorting, "new" tag ---------- */
.filterbar { max-width: 760px; margin: 10px auto 0; padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.fchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.fchips .chip { min-height: 36px; padding: 4px 12px; font-size: 13px; white-space: nowrap; flex: none; }
.fsel { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sel-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; min-width: 0; }
.sel-wrap select { min-height: 36px; padding: 4px 8px; font-size: 14px; max-width: 150px; }
.fsel .btn { margin-inline-start: auto; }
.tag.new-tag { background: var(--accent); color: #fff; align-self: center; }
ul.plain { margin: 10px 0 0; padding-inline-start: 18px; font-size: 14px; line-height: 1.7; }

/* ---------- new order (Facebook / Instagram) ---------- */
.icon-btn.accent-btn { background: var(--accent); color: #fff; }
.icon-btn.accent-btn:hover { background: var(--accent); filter: brightness(1.08); color: #fff; }
.icon-btn.sm { width: 34px; height: 34px; min-width: 34px; min-height: 34px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.mo-h { font-size: 15px; margin: 16px 0 8px; }
.mo-search { margin: 0 0 8px; }
.mo-results { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px; margin-bottom: 10px; }
.mo-prod { display: flex; gap: 10px; padding: 8px 0; align-items: flex-start; }
.mo-prod + .mo-prod { border-top: 1px solid var(--line); }
.mo-prod img, .mo-prod .ph { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.mo-prod-main { min-width: 0; flex: 1; }
.mo-vars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mo-var { min-height: 36px; padding: 4px 10px; font-size: 13px; }
.mo-var:disabled { opacity: .45; cursor: not-allowed; }
.mo-cart li { gap: 8px; flex-wrap: wrap; }
.mo-cart img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.mo-line { min-width: 120px; }
.mo-line small { display: block; color: var(--ink-2); }
.mo-line small.warn { color: var(--warn); font-weight: 600; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .num { min-width: 22px; text-align: center; font-weight: 700; }
.mo-price { display: inline-flex; align-items: center; gap: 4px; }
.mo-price input { width: 74px; min-height: 36px; padding: 4px 6px; }
.empty-cart { padding: 10px 0; }
.mo-totals { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.mo-totals > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mo-totals .hint { display: block; }
.mo-ship-in { display: inline-flex; align-items: center; gap: 4px; }
.mo-ship-in input { width: 90px; min-height: 36px; padding: 4px 8px; }
.mo-total { border-top: 1px solid var(--line); padding-top: 8px; font-size: 16px; }
.mo-total b { color: var(--accent); }
.mo .err, .mo-totals .err { color: var(--bad); font-weight: 600; }
.mo-totals .warn { color: var(--warn); font-weight: 600; }

/* ---------- searchable list (city / area) ---------- */
.combo { position: relative; }
.combo-list {
  position: absolute; top: 100%; inset-inline: 0; z-index: 20; margin-top: 4px;
  max-height: 240px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.combo-opt { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; min-height: 44px; cursor: pointer; font-size: 14px; }
.combo-opt + .combo-opt { border-top: 1px solid var(--line); }
.combo-opt small { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.combo-opt:hover, .combo-opt.active { background: var(--brand-soft); }
.combo-more { padding: 8px 12px; }

/* ---------- product options: colour circles + named buttons ---------- */
.mo-prod-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mo-opt { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mo-opt-name { font-size: 12px; color: var(--ink-2); min-width: 44px; }
.mo-vals { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mo-var.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.mo-var svg { width: 16px; height: 16px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; padding: 0; cursor: pointer; position: relative; overflow: hidden;
  background: var(--sw); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2);
}
.swatch img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }
.swatch:disabled { cursor: not-allowed; opacity: .4; }
.swatch:disabled::after { content: ''; position: absolute; inset: 45% -10%; height: 2px; background: var(--bad); transform: rotate(-45deg); }
.swatch.clear, .sw-dot.clear { background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 50% / 10px 10px; }
.sw-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--sw); box-shadow: 0 0 0 1px var(--line-2); vertical-align: -2px; }
.mo-line-opts { display: flex !important; align-items: center; gap: 6px; }

/* shipments live in Almayar without a Shopify order */
.orphan { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.orphan:last-child { border-bottom: 0; }
.orphan small { display: block; margin-top: 2px; }

/* users, shipment tracking + Almayar chat */
.who { font-weight: 600; }
.tag.chat-tag { background: var(--brand); color: #fff; align-self: center; }
.btn.has-dot { position: relative; }
.btn.has-dot::after { content: ''; position: absolute; top: 4px; inset-inline-end: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ship-det h4 { margin: 16px 0 6px; font-size: 13px; color: var(--ink-2); }
.det-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.det-status small.ok { color: var(--ok); font-weight: 600; }
.person { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.person .actions { margin: 0; }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.msg { max-width: 85%; padding: 6px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); align-self: flex-end; }
.msg.store { align-self: flex-start; background: var(--brand-soft); border-color: transparent; }
.msg.driver { border-color: var(--accent); }
.msg-meta { font-size: 11px; color: var(--ink-2); margin-bottom: 2px; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.chat-box { display: flex; gap: 8px; margin-top: 8px; align-items: flex-end; }
.chat-box textarea { flex: 1; min-height: 44px; resize: vertical; }
.timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--line); }
.timeline li { position: relative; padding: 4px 14px 8px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; inset-inline-start: -6px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline li:first-child::before { background: var(--accent); }
.users { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.user-row.off { opacity: .55; }
.user-row .avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.u-main small { display: block; color: var(--ink-2); font-size: 12px; }
.modal.over-sheet { z-index: 35; }
