/* ==========================================================================
   InstaMart merchant — operational dashboard
   Vanilla CSS. Arabic-first / RTL. Denser than the storefront (VISUAL_DENSITY 6).
   Layout uses CSS logical properties, so `dir="rtl"` flips it correctly.
   ========================================================================== */
@font-face { font-family: "Cairo"; src: url("/merchant/fonts/cairo-arabic-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap; unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200E,U+2010-2011; }
@font-face { font-family: "Cairo"; src: url("/merchant/fonts/cairo-arabic-500-normal.woff2") format("woff2");
  font-weight: 500; font-display: swap; unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200E,U+2010-2011; }
@font-face { font-family: "Cairo"; src: url("/merchant/fonts/cairo-arabic-600-normal.woff2") format("woff2");
  font-weight: 600; font-display: swap; unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200E,U+2010-2011; }
@font-face { font-family: "Cairo"; src: url("/merchant/fonts/cairo-arabic-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap; unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200E,U+2010-2011; }
@font-face { font-family: "Cairo"; src: url("/merchant/fonts/cairo-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("/merchant/fonts/cairo-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("/merchant/fonts/cairo-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("/merchant/fonts/cairo-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap; }

/* Directional glyphs (next / back arrows) point the reading way. */
[dir="rtl"] svg.icon:has(use[href="#i-arrow"]) { transform: scaleX(-1); }
/* Technical values (SKU/GTIN/phone/colour hex/order numbers) stay LTR in both
   directions and isolate from the surrounding bidi run. */
.num, .stat-value, input[type="number"],
input[type="tel"], input#s-primary, input#s-secondary { direction: ltr; }
[dir="rtl"] .num, [dir="rtl"] .stat-value { unicode-bidi: isolate; }

/* Language switcher — sits in the sidebar foot; inherits sidebar colours. */
.lang-switch {
  align-self: stretch; padding: 6px 10px; margin-block-end: 2px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: transparent; color: var(--text-2);
  font: inherit; font-size: .75rem; font-weight: 600; cursor: pointer;
}
.lang-switch { transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.lang-switch:hover { background: var(--surface-sunk); color: var(--text); }
@media (max-width: 900px) { .lang-switch:not(.lang-switch--auth) { font-size: 0; padding: 6px; } .lang-switch:not(.lang-switch--auth)::before { content: "A / ع"; font-size: .7rem; } }
.lang-switch--auth {
  position: fixed; inset-block-start: 12px; inset-inline-end: 12px; z-index: 100;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
body:has(#app-view:not([hidden])) .lang-switch--auth { display: none; }

:root {
  --brand: #16a34a;
  --brand-strong: #12833c;
  --brand-tint: #e8f1ec;
  --brand-tint-soft: #f1f6f3;

  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-sunk: #f1efeb;
  --border: #e7e2da;
  --border-strong: #d9d3c8;

  --text: #1c1a17;
  --text-2: #5b564d;
  --text-3: #918a7f;

  --info: #2f6ab0; --info-tint: #e8eff8;
  --prep: #9a6a12; --prep-tint: #f7efdf;
  --ship: #6a4fb0; --ship-tint: #ede9f7;
  --ok: #16a34a;   --ok-tint: #e8f1ec;
  --bad: #b23b30;  --bad-tint: #f7ebe9;

  --r-sm: 7px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;
  --shadow-sm: 0 1px 2px rgba(28,26,23,.06);
  --shadow-md: 0 10px 34px -12px rgba(28,26,23,.2);
  --dur: 140ms; --ease: cubic-bezier(.2,.7,.2,1);
  --side-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Cairo", "SF Arabic", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
.hidden, [hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-sm);
}
.icon { inline-size: 1.15em; block-size: 1.15em; flex: 0 0 auto;
  stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle; }
#sprite { display: none; }
.muted { color: var(--text-3); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-block-size: 40px; padding: 0 18px; border-radius: var(--r-md);
  background: var(--brand); color: #fff; font-weight: 600; font-size: .875rem;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn-primary:hover { background: var(--brand-strong); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: var(--surface-sunk); color: var(--text-2); cursor: not-allowed; transform: none; }
.btn-primary.sm { min-block-size: 36px; padding: 0 14px; }
.btn-primary .icon { inline-size: 16px; block-size: 16px; }

.btn-ghost, button.secondary, .status-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-block-size: 36px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: .8125rem;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn-ghost:hover, button.secondary:hover, .status-btn:hover { background: var(--surface-sunk); }
.btn-ghost:active, button.secondary:active, .status-btn:active { transform: translateY(1px); }
.status-btn { border-color: var(--brand); color: var(--brand-strong); font-weight: 600; }
.status-btn:hover { background: var(--brand-tint); }
.status-btn.danger { border-color: var(--border-strong); color: var(--bad); }
.status-btn.danger:hover { background: var(--bad-tint); }
.status-btn .icon { inline-size: 14px; block-size: 14px; }

.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-block-size: 40px; padding: 0 18px; border-radius: var(--r-md);
  border: 1.5px solid var(--brand); background: transparent; color: var(--brand-strong);
  font-weight: 600; font-size: .875rem;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn-outline:hover { background: var(--brand-tint); }
.btn-outline:active { transform: translateY(1px); }
.btn-outline.sm { min-block-size: 36px; padding: 0 14px; }

.btn-destructive {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-block-size: 40px; padding: 0 18px; border-radius: var(--r-md);
  background: var(--bad); color: #fff; font-weight: 600; font-size: .875rem;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn-destructive:hover { background: color-mix(in srgb, var(--bad) 85%, #000); }
.btn-destructive:active { transform: translateY(1px); }
.btn-destructive.sm { min-block-size: 36px; padding: 0 14px; }

/* ==========================================================================
   Login
   ========================================================================== */
.login-view { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6); }
.login-card {
  inline-size: 100%; max-inline-size: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-8) var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-4);
  box-shadow: var(--shadow-sm);
}
.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1rem; }
.login-mark, .side-mark, .login-mark .icon {
  inline-size: 30px; block-size: 30px;
}
.login-mark, .side-mark {
  display: grid; place-items: center; border-radius: 8px;
  background: var(--brand); color: #fff;
}
.login-mark .icon, .side-mark .icon { inline-size: 17px; block-size: 17px; }
.login-mark { background: none; }
.login-mark img { inline-size: 100%; block-size: 100%; object-fit: contain; }
.login-card h1 { font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em; margin-block-end: 2px; }
.login-demo { font-size: .75rem; color: var(--text-3); text-align: center; }
/* sign-in <-> store registration switch + registration copy */
.login-card h1 + .login-sub { margin-block-start: calc(-1 * var(--s-3)); }
.login-sub { font-size: .8125rem; color: var(--text-2); line-height: 1.5; }
.login-card .field .hint { display: block; font-size: .75rem; color: var(--text-3); margin-block-start: 4px; }
.login-switch {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px;
  font-size: .8125rem; color: var(--text-2); padding-block-start: var(--s-3);
  border-block-start: 1px solid var(--border);
}
.login-switch a { color: var(--brand); font-weight: 600; min-block-size: 32px; display: inline-flex; align-items: center; }

/* ==========================================================================
   Shell: sidebar + work area
   ========================================================================== */
.shell { min-height: 100dvh; }
.side {
  background: var(--surface); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: var(--s-4) var(--s-5); font-weight: 700; font-size: 1rem;
  border-block-end: 1px solid var(--border);
}
.side-nav { display: flex; padding: var(--s-2); gap: 2px; }
.tab {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-md);
  color: var(--text-2); font-weight: 500; font-size: .875rem;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab-badge {
  margin-inline-start: auto;
  min-inline-size: 18px; block-size: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  background: var(--bad); color: #fff;
  font-size: .6875rem; font-weight: 700; line-height: 1;
}
.tab .icon { inline-size: 18px; block-size: 18px; }
.tab:hover { background: var(--surface-sunk); color: var(--text); }
.tab.active { background: var(--brand-tint); color: var(--brand-strong); font-weight: 600; }
.side-foot {
  margin-block-start: auto; padding: var(--s-4);
  border-block-start: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.side-who { font-size: .75rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.side-logout {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-2); font-size: .8125rem; font-weight: 500;
  padding: 6px 0;
}
.side-logout:hover { color: var(--bad); }
.side-logout .icon { inline-size: 16px; block-size: 16px; }

.work { padding: var(--s-6); }
.panel { max-width: 1080px; margin-inline: auto; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  margin-block-end: var(--s-5); flex-wrap: wrap;
}
.panel-head h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em; }
.sub-head { font-size: .9375rem; font-weight: 600; margin: var(--s-6) 0 var(--s-3); }
.head-tools { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.head-tools input {
  min-block-size: 36px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: var(--r-md); background: var(--surface); min-inline-size: 200px;
}
.head-counts { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: .8125rem; color: var(--text-2); }
.head-counts strong { color: var(--text); font-weight: 700; }

/* mobile: sidebar becomes a top bar */
@media (max-width: 899px) {
  .side {
    position: sticky; inset-block-start: 0; z-index: 20;
    border-inline-end: 0; border-block-end: 1px solid var(--border);
  }
  .side-brand { padding: var(--s-3) var(--s-4); }
  .side-nav {
    overflow-x: auto; scrollbar-width: none;
    border-block-start: 1px solid var(--border);
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .tab span { font-size: .8125rem; }
  .side-foot {
    position: absolute; inset-block-start: var(--s-3); inset-inline-end: var(--s-4);
    margin: 0; padding: 0; border: 0;
  }
  .side-who { display: none; }
  .side-logout span { display: none; }
  .side-logout { padding: 4px; }
  .work { padding: var(--s-4); }
  .panel-head h1 { font-size: 1.25rem; }
}
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .side { position: sticky; inset-block-start: 0; block-size: 100dvh; }
  .side-nav { flex-direction: column; padding: var(--s-3); gap: 2px; }
  .work { padding: var(--s-8); }
}

/* ==========================================================================
   Stat row (operational — small, dense, not decorative)
   ========================================================================== */
.stat-row {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3);
  margin-block-end: var(--s-5);
}
@media (min-width: 620px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s-3) var(--s-4);
  transition: border-color var(--dur) var(--ease);
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-3); font-size: .75rem; font-weight: 500; margin-block-start: 3px; }

/* ==========================================================================
   Rows / list items
   ========================================================================== */
.rows { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-3) var(--s-2);
  border-block-end: 1px solid var(--border);
}
.item:first-child { border-block-start: 1px solid var(--border); }
.item > div:first-child { min-width: 0; flex: 1 1 auto; }
.item strong { font-weight: 600; font-size: .9375rem; }
.item .meta {
  color: var(--text-3); font-size: .8125rem; margin-block-start: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item .actions { display: flex; gap: 6px; flex: 0 0 auto; }
.item .actions button .icon { inline-size: 14px; block-size: 14px; }
@media (max-width: 520px) {
  .item { flex-wrap: wrap; }
  .item .actions { inline-size: 100%; margin-block-start: var(--s-2); }
  .item .meta { white-space: normal; }
}
.rows > .muted { padding: var(--s-6) var(--s-2); text-align: center; }
.rows-empty, .rows-loading {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: var(--s-8) var(--s-2); text-align: center; color: var(--text-3);
}
.rows-empty strong, .rows-loading strong { color: var(--text-2); font-size: .9375rem; font-weight: 600; }
.rows-empty span, .rows-loading span { font-size: .8125rem; }
.rows-loading::before {
  content: ""; inline-size: 22px; block-size: 22px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-block-start-color: var(--brand);
  animation: spin .7s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .rows-loading::before { animation: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* status + label pills — text + tone + shape, never colour alone */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .6875rem; font-weight: 600; letter-spacing: .01em;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--surface-sunk); color: var(--text-2);
  border: 1px solid transparent;
}
.pill::before {
  content: ""; inline-size: 5px; block-size: 5px; border-radius: 50%;
  background: currentColor;
}
/* plain availability / active pills read as positive */
.item .pill:not(.off):not([class*="st-"]) { background: var(--ok-tint); color: var(--ok); }
.pill.off { background: var(--bad-tint); color: var(--bad); }
.pill.st-NEW { background: var(--info-tint); color: var(--info); }
.pill.st-CONFIRMED { background: var(--ok-tint); color: var(--ok); }
.pill.st-PREPARING { background: var(--prep-tint); color: var(--prep); }
.pill.st-OUT_FOR_DELIVERY { background: var(--ship-tint); color: var(--ship); }
.pill.st-DELIVERED { background: var(--ok-tint); color: var(--ok); }
.pill.st-CANCELLED { background: var(--bad-tint); color: var(--bad); }

/* ==========================================================================
   Chips (filters)
   ========================================================================== */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-block-end: var(--s-4); }
.order-search {
  width: 100%; max-width: 420px; margin-block-end: var(--s-3);
  padding: 8px 12px; border-radius: var(--r-md, 8px);
  border: 1px solid var(--border-strong); background: var(--surface);
  font: inherit; color: inherit;
}
.chip {
  padding: 6px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font-size: .8125rem; font-weight: 500;
  transition: background var(--dur) var(--ease);
}
.chip:hover { background: var(--surface-sunk); }
.comm-kv { width: 100%; border-collapse: collapse; margin-block: var(--s-3); font-size: .875rem; }
.comm-kv th { text-align: start; font-weight: 500; color: var(--text-2, inherit); padding: 4px 0; }
.comm-kv td { text-align: end; padding: 4px 0; }
.comm-kv tr.grand th, .comm-kv tr.grand td { font-weight: 700; border-block-start: 1px solid var(--border); }
.comm-custom { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: end; margin-block-end: var(--s-4); }
.comm-custom label { display: flex; flex-direction: column; gap: 4px; font-size: .8125rem; }
.comm-rates { font-size: .875rem; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.pager { display: flex; align-items: center; gap: var(--s-2); margin-block-start: var(--s-4); }

/* ==========================================================================
   Tables (order detail, import review)
   ========================================================================== */
.grid-table, .ord-table {
  inline-size: 100%; border-collapse: collapse; font-size: .8125rem;
  margin-block: var(--s-3);
}
.grid-table th, .ord-table th {
  text-align: start; font-weight: 600; color: var(--text-3);
  font-size: .6875rem; letter-spacing: .04em; text-transform: uppercase;
  padding: 8px 10px; border-block-end: 1px solid var(--border-strong);
}
.grid-table td, .ord-table td {
  padding: 9px 10px; border-block-end: 1px solid var(--border);
  vertical-align: middle;
}
.grid-table tr:last-child td, .ord-table tr:last-child td { border-block-end: 0; }
.grid-table select {
  min-block-size: 34px; padding: 0 8px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); background: var(--surface); font-size: .8125rem;
}
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.table-scroll .grid-table { margin: 0; }
.table-scroll .grid-table th, .table-scroll .grid-table td { padding-inline: 12px; }
.ord-totals { font-size: .875rem; color: var(--text-2); margin-block: var(--s-2); }
.ord-totals strong { color: var(--text); }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-block: var(--s-4); }
.wa-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-block-start: var(--s-3); padding-block-start: var(--s-3); border-block-start: 1px solid var(--border); }

/* ==========================================================================
   Merchant catalog (store_inventory) — filters, table, product detail
   ========================================================================== */
.sm { font-size: .8125rem; }
p.muted.sm { margin-block: 2px 0; }
.pill.warn { background: var(--prep-tint); color: var(--prep); }

.catalog-filters {
  display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-6);
  align-items: flex-start;
  padding: var(--s-3) 0 var(--s-4);
  border-block-end: 1px solid var(--border);
  margin-block-end: var(--s-2);
}
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label {
  font-size: .6875rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
}
.catalog-filters .chips { margin: 0; }
.catalog-filters select {
  min-block-size: 34px; padding: 0 10px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); background: var(--surface); font-size: .8125rem;
  max-inline-size: 220px;
}

.catalog-table td.num, .catalog-table th.num { text-align: end; font-variant-numeric: tabular-nums; }
.catalog-table .cell-name { font-weight: 600; }
.catalog-table td.cell-actions { white-space: nowrap; }
.catalog-table td.cell-actions button { padding: 4px 9px; font-size: .75rem; }

@media (max-width: 760px) {
  .catalog-table thead, .grid-table[data-collapse] thead, .ord-table[data-collapse] thead { display: none; }
  .catalog-table, .catalog-table tbody,
  .grid-table[data-collapse], .grid-table[data-collapse] tbody,
  .ord-table[data-collapse], .ord-table[data-collapse] tbody { display: block; }
  .catalog-table tr,
  .grid-table[data-collapse] tr, .ord-table[data-collapse] tr {
    display: block; border: 1px solid var(--border); border-radius: var(--r-md);
    margin-block-end: var(--s-3); padding: var(--s-2) var(--s-3); background: var(--surface);
  }
  .catalog-table td,
  .grid-table[data-collapse] td, .ord-table[data-collapse] td {
    display: flex; justify-content: space-between; align-items: center; gap: var(--s-4);
    border: 0; padding: 5px 0; text-align: end;
  }
  .catalog-table td::before,
  .grid-table[data-collapse] td::before, .ord-table[data-collapse] td::before {
    content: attr(data-label); color: var(--text-3);
    font-size: .6875rem; font-weight: 600; letter-spacing: .03em;
    text-transform: uppercase; text-align: start; flex: 0 0 auto;
  }
  .catalog-table td.cell-name { justify-content: flex-start; font-size: .9375rem; }
  .catalog-table td.cell-name::before { display: none; }
  .catalog-table td.cell-actions { flex-wrap: wrap; justify-content: flex-start; }
  .catalog-table td.cell-actions::before { flex-basis: 100%; }
}

.prod-detail { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); margin-block-start: var(--s-3); }
@media (max-width: 620px) { .prod-detail { grid-template-columns: 1fr; } }
.pd-global, .pd-store { min-width: 0; }
.pd-global { background: var(--surface-sunk); border-radius: var(--r-md); padding: var(--s-4); }
.pd-head {
  font-size: .75rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-2); margin-block-end: var(--s-3);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pd-img {
  inline-size: 100%; max-block-size: 160px; object-fit: contain;
  background: var(--surface); border-radius: var(--r-sm); margin-block-end: var(--s-3);
}
.pd-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--s-3); margin: 0; font-size: .8125rem; }
.pd-facts dt { color: var(--text-3); }
.pd-facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.pd-store .stack { margin-block-start: 0; }

/* product onboarding */
.onb-paths { display: grid; gap: var(--s-3); margin-block-start: var(--s-3); }
.onb-path {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: var(--s-4); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); background: var(--surface); text-align: start;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.onb-path:hover { border-color: var(--brand); background: var(--brand-tint-soft); }
.onb-path strong { font-size: .9375rem; }
.onb-path span { font-size: .8125rem; color: var(--text-3); }
.onb-results { display: flex; flex-direction: column; gap: 6px; margin-block: var(--s-3); max-block-size: 46vh; overflow-y: auto; }
.onb-result {
  display: flex; gap: var(--s-3); align-items: center; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); text-align: start;
}
.onb-result:hover { background: var(--surface-sunk); }
.onb-result img, .onb-result .onb-noimg {
  inline-size: 40px; block-size: 40px; object-fit: contain; flex: 0 0 auto;
  background: var(--surface-sunk); border-radius: 6px;
}
.onb-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.onb-meta strong { font-size: .875rem; }

/* ---- Self-Serve Catalog Builder ---- */
.cb-tools { display: flex; gap: var(--s-2); margin-block: var(--s-3); }
.cb-tools input { flex: 1 1 auto; }
.cb-tools select { flex: 0 0 auto; inline-size: auto; min-inline-size: 140px; }
.cb-results { display: flex; flex-direction: column; gap: 6px; max-block-size: 44vh; overflow-y: auto; }
.cb-row {
  display: flex; gap: var(--s-3); align-items: center; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
}
.cb-row.is-added { opacity: .6; }
.cb-row img, .cb-row .cb-noimg {
  inline-size: 38px; block-size: 38px; object-fit: contain; flex: 0 0 auto;
  background: var(--surface-sunk); border-radius: 6px;
}
.cb-row .cb-chk { inline-size: auto; min-block-size: 0; flex: 0 0 auto; }
.cb-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.cb-meta strong { font-size: .875rem; }
.cb-added { font-size: .75rem; color: var(--text-2); flex: 0 0 auto; }
.cb-bar {
  display: flex; gap: var(--s-2); align-items: center; margin-block-start: var(--s-3);
  padding-block-start: var(--s-3); border-block-start: 1px solid var(--border);
}
.cb-bar #cb-apply { margin-inline-start: auto; }
.cb-confirm { margin: var(--s-2) 0; padding-inline-start: 1.2em; font-size: .875rem; }
.biv-sep { border: 0; border-block-start: 1px solid var(--border); margin-block: var(--s-4); }
tr.cbm-matched td:last-child { color: var(--ok, #1f7a4d); font-weight: 600; }
tr.cbm-not_found td:last-child, tr.cbm-invalid td:last-child { color: var(--danger, #b3261e); }
tr.cbm-ambiguous td:last-child { color: #9a6700; }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: block; }
.field .label, label > .label { display: block; font-size: .8125rem; font-weight: 500; color: var(--text-2); margin-block-end: 5px; }
input, select, textarea, form.stack input, form.stack select {
  inline-size: 100%; min-block-size: 40px;
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); font-size: .875rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { min-block-size: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-soft);
}
form.stack { display: flex; flex-direction: column; gap: var(--s-3); margin-block-start: var(--s-2); }
form.stack label { display: flex; flex-direction: column; gap: 5px; font-size: .8125rem; color: var(--text-2); }
form.stack input[type="checkbox"], form.stack input[type="radio"] { inline-size: auto; min-block-size: 0; margin-inline-end: 6px; }
form.stack .theme-mode label { flex-direction: row; align-items: center; }
/* bare submit buttons inside modal forms get the primary treatment */
#modal-body form button[type="submit"], form.stack button[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center;
  min-block-size: 40px; padding: 0 18px; border-radius: var(--r-md);
  background: var(--brand); color: #fff; font-weight: 600; font-size: .875rem;
  transition: background var(--dur) var(--ease);
}
#modal-body form button[type="submit"]:hover, form.stack button[type="submit"]:hover { background: var(--brand-strong); }

.notice, .error {
  display: flex; align-items: center; gap: 7px;
  color: var(--bad); font-size: .8125rem; font-weight: 500;
  background: var(--bad-tint); border-radius: var(--r-md); padding: 9px 12px;
}
.notice .icon, .error .icon { inline-size: 16px; block-size: 16px; }
#login-error, #cat-err, #p-err, #map-error, #import-error { margin-block-start: var(--s-2); }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal { position: fixed; inset: 0; z-index: 40; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(28,26,23,.42); }
.modal-panel {
  position: relative; background: var(--surface);
  inline-size: calc(100% - 32px); max-inline-size: 440px;
  margin: 8vh auto 0; border-radius: var(--r-lg);
  padding: var(--s-6); max-block-size: 84dvh; overflow: auto;
  box-shadow: var(--shadow-md);
}
@media (prefers-reduced-motion: no-preference) {
  .modal:not(.hidden) .modal-panel { animation: modal-in var(--dur) var(--ease); }
}
@keyframes modal-in { from { transform: translateY(8px); opacity: .6; } }
.modal-close {
  position: absolute; inset-block-start: 10px; inset-inline-end: 12px;
  inline-size: 32px; block-size: 32px; display: grid; place-items: center;
  color: var(--text-3); border-radius: var(--r-sm);
}
.modal-close:hover { background: var(--surface-sunk); color: var(--text); }
.modal-body h3, #modal-body h3 { font-size: 1.0625rem; font-weight: 700; margin-block-end: var(--s-3);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-desc { color: var(--text-2); font-size: .8125rem; margin-block: -6px 0 var(--s-3); }
#modal-body p { margin-block: var(--s-2); }
#modal-body a { color: var(--brand-strong); text-decoration: none; font-weight: 500; }
#modal-body a:hover { text-decoration: underline; }
.scan-camera-btn { justify-content: center; min-block-size: 40px; }
.camera-scan {
  position: relative; overflow: hidden; border-radius: var(--r-lg);
  background: #111; color: #fff; padding: var(--s-3);
}
.camera-scan video {
  display: block; inline-size: 100%; max-block-size: min(52dvh, 360px);
  border-radius: var(--r-md); object-fit: cover; background: #000;
}
.camera-scan .scan-frame {
  position: absolute; inset-block-start: 22%; inset-inline: 14%; block-size: 32%;
  border: 2px solid rgba(255,255,255,.9); border-radius: var(--r-md);
  box-shadow: 0 0 0 999px rgba(0,0,0,.28); pointer-events: none;
}
.camera-scan p { color: rgba(255,255,255,.92); }
.camera-scan button { inline-size: 100%; justify-content: center; background: rgba(255,255,255,.12); color: #fff; }

/* ==========================================================================
   Import wizard
   ========================================================================== */
.wiz-steps {
  display: flex; gap: var(--s-2); list-style: none; padding: 0;
  margin: 0 0 var(--s-5); flex-wrap: wrap;
}
.wiz-steps li {
  display: flex; align-items: center; gap: 7px;
  font-size: .8125rem; font-weight: 500; color: var(--text-3);
}
.wiz-dot {
  inline-size: 22px; block-size: 22px; display: grid; place-items: center;
  border-radius: var(--r-pill); border: 1.5px solid var(--border-strong);
  font-size: .6875rem; font-weight: 700; color: var(--text-3);
}
.wiz-steps li.active { color: var(--text); }
.wiz-steps li.active .wiz-dot { border-color: var(--brand); color: var(--brand-strong); }
.wiz-steps li.done .wiz-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.wiz-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-5);
}
.wiz-hint { font-size: .8125rem; color: var(--text-2); margin-block-end: var(--s-3); }
.wiz-hint strong { color: var(--text); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: var(--s-8) var(--s-4);
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  cursor: pointer; text-align: center; color: var(--text-2);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.dropzone .icon { inline-size: 26px; block-size: 26px; color: var(--text-3); stroke-width: 1.5; }
.dropzone .dz-line { font-size: .875rem; }
.dropzone small { font-size: .75rem; color: var(--text-3); }
.dropzone.drag { border-color: var(--brand); background: var(--brand-tint-soft); }
.dropzone u { color: var(--brand-strong); }
.unknown-cats { margin-block: var(--s-3); font-size: .8125rem; }
.wiz-confirm {
  margin-block-start: var(--s-4); padding-block-start: var(--s-4);
  border-block-start: 1px solid var(--border);
}
.wiz-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-block-start: var(--s-4); }
.wiz-done { display: flex; align-items: center; gap: 10px; margin-block-end: var(--s-4); }
.done-mark {
  inline-size: 34px; block-size: 34px; display: grid; place-items: center;
  border-radius: var(--r-pill); background: var(--brand-tint); color: var(--brand-strong);
}
.done-mark .icon { inline-size: 18px; block-size: 18px; stroke-width: 2.2; }
.wiz-done h2 { font-size: 1.125rem; font-weight: 700; }

/* bulk inventory (catalog store) */
.biv-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-block: var(--s-3) var(--s-4); }
.biv-upload {
  display: inline-flex; align-items: center; gap: 6px;
  min-block-size: 38px; padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: .875rem; font-weight: 600; cursor: pointer;
}
.biv-upload:hover { background: var(--surface-sunk); }
#biv-summary:empty, #biv-report:empty, #biv-result:empty { display: none; }

/* import review table */
#review-table td .pill { white-space: nowrap; }
.pill.rv-VALID { background: var(--ok-tint); color: var(--ok); }
.pill.rv-WARNING { background: var(--prep-tint); color: var(--prep); }
.pill.rv-ERROR { background: var(--bad-tint); color: var(--bad); }
.pill.rv-DUPLICATE { background: var(--ship-tint); color: var(--ship); }
.cat-warn { display: inline-flex; vertical-align: middle; color: var(--prep); }
.cat-warn .icon { inline-size: 13px; block-size: 13px; }
.issue-cell { color: var(--text-2); font-size: .75rem; max-inline-size: 320px; }

/* ==========================================================================
   Store Settings
   ========================================================================== */
.settings-media { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-block-end: var(--s-5); }
.media-card { display: flex; flex-direction: column; gap: var(--s-2); }
.media-label { font-size: .75rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.media-preview {
  inline-size: 96px; block-size: 96px; border: 1px solid var(--border-strong);
  border-radius: var(--r-md); background: var(--surface-sunk);
  display: grid; place-items: center; overflow: hidden;
}
.media-preview--wide { inline-size: 200px; }
.media-preview img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.media-empty { font-size: .75rem; color: var(--text-3); }
.media-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-block-size: 32px; padding: 0 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: .8125rem; font-weight: 500; cursor: pointer;
}
.media-btn:hover { background: var(--surface-sunk); }
.settings-form { max-inline-size: 560px; }
.settings-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-3); }
.settings-2col > label { display: flex; flex-direction: column; gap: 5px; font-size: .8125rem; color: var(--text-2); }

/* --- Phase B.1: storefront theme controls --- */
.theme-block {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4) var(--s-4); margin-block: var(--s-2);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.theme-block legend { font-size: .8125rem; font-weight: 600; color: var(--text-2); padding-inline: 4px; }
.theme-tag { font-weight: 400; color: var(--text-3); }
.settings-2col .cin { display: flex; align-items: center; gap: 6px; }
.settings-2col .cin input[type="color"] {
  inline-size: 34px; block-size: 34px; padding: 2px; min-block-size: 0;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); cursor: pointer; background: var(--surface);
}
.settings-2col .cin input[type="text"] { min-block-size: 34px; text-transform: lowercase; }
.theme-preview {
  --pv-p: #1f7a4d; --pv-on-p: #fff; --pv-s: #17603c;
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-3);
  padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-sunk);
}
.theme-preview .tp-primary {
  background: var(--pv-p); color: var(--pv-on-p); border: 0; border-radius: var(--r-md);
  font-weight: 600; font-size: .8125rem; min-block-size: 34px; padding: 0 14px; cursor: default;
}
.theme-preview .tp-nav {
  font-size: .8125rem; font-weight: 700;
  color: color-mix(in srgb, var(--pv-p) 55%, #000);
  border-block-end: 3px solid var(--pv-s); padding-block-end: 2px;
}
.theme-preview .tp-accent {
  font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--pv-p) 12%, #fff);
  color: color-mix(in srgb, var(--pv-p) 55%, #000);
}
.theme-block .btn-ghost.sm { align-self: flex-start; }
.theme-mode { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.theme-auto { display: flex; flex-direction: column; gap: var(--s-2); }
.theme-auto .notice.is-ok { color: var(--ok); background: var(--ok-tint); }
.settings-2col .cin input:disabled { opacity: .6; cursor: not-allowed; }

/* operating hours (Store Settings) */
.hours-block .hours-status { border: 0; padding: 0; margin-block: var(--s-2) var(--s-3); }
.hours-block .hours-status legend { font-size: .8125rem; font-weight: 600; color: var(--text-2); padding: 0; margin-block-end: 4px; }
.hours-row {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto auto auto auto;
  align-items: center; gap: var(--s-2);
  padding-block: 6px; border-block-start: 1px solid var(--border);
}
.hours-row:first-child { border-block-start: 0; }
.hours-row .hours-day { font-size: .8125rem; font-weight: 600; }
.hours-row .hours-open { font-size: .75rem; }
.hours-row input[type="time"] { min-block-size: 32px; }
.hours-row.is-closed input[type="time"] { opacity: .4; }
.hours-row .hours-dash { color: var(--text-3); }
@media (max-width: 520px) {
  .hours-row { grid-template-columns: 1fr auto; grid-auto-rows: min-content; }
  .hours-row .hours-day { grid-column: 1; }
  .hours-row .hours-open { grid-column: 2; justify-self: end; }
  .hours-row .h-from { grid-column: 1; }
  .hours-row .hours-dash { grid-column: 1 / -1; display: none; }
  .hours-row .h-to { grid-column: 2; }
}

/* delivery areas (Store Settings) */
.zones-block #zones-list { margin-block: 0; }
.zones-block .item:first-child { border-block-start: 0; }
.zones-empty {
  padding: var(--s-3) var(--s-4); background: var(--surface-sunk);
  border-radius: var(--r-md); display: flex; flex-direction: column; gap: var(--s-1);
}
.zones-empty p { margin: 0; font-size: .8125rem; }
#zone-form .chk { flex-direction: row; align-items: center; gap: var(--s-2); }

/* ==========================================================================
   Phase D — merchant order operations
   ========================================================================== */

/* D-2: order tools (sound / desktop-alert toggles) */
.order-tools { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-2);
  font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer;
}
.tool-btn:hover { background: var(--surface-sunk); }
.tool-btn.on { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-tint); }
.tool-btn:disabled { opacity: .5; cursor: not-allowed; }
.tool-btn .icon { inline-size: 16px; block-size: 16px; }

/* D-1: newly detected order rows */
.order-item--new { border-inline-start: 3px solid var(--brand); background: var(--brand-tint-soft, #f1f6f3); }
.new-tag {
  font-size: .625rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 6px; border-radius: var(--r-pill); background: var(--brand); color: #fff;
}

/* D-2: toast */
.toast-host {
  position: fixed; inset-block-start: var(--s-4); inset-inline-end: var(--s-4);
  z-index: 60; display: flex; flex-direction: column; gap: var(--s-2);
  max-inline-size: min(92vw, 340px);
}
.toast {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 10px 12px; border-radius: var(--r-md);
  background: var(--text); color: #fff; box-shadow: var(--shadow-md);
  font-size: .875rem; font-weight: 500;
  opacity: 0; transform: translateY(-6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast-msg { flex: 1 1 auto; }
.toast-open {
  flex: 0 0 auto; padding: 4px 10px; border-radius: var(--r-sm);
  background: #fff; color: var(--text); font: inherit; font-weight: 700; font-size: .8125rem; cursor: pointer;
}
.toast-x { flex: 0 0 auto; color: #fff; opacity: .8; padding: 2px; cursor: pointer; }
.toast-x:hover { opacity: 1; }
.toast-x .icon { inline-size: 14px; block-size: 14px; }

/* D-3: order detail grouping */
.od-meta { font-size: .8125rem; color: var(--text-3); margin-block: 2px var(--s-3); }
.od-block { margin-block: var(--s-2) var(--s-3); }
.od-line { display: flex; gap: var(--s-3); font-size: .875rem; padding-block: 3px; }
.od-k { flex: 0 0 96px; color: var(--text-3); }

/* D-3: printable packing slip */
#print-area { display: none; }
@media print {
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  .slip { font: 13px/1.5 system-ui, sans-serif; color: #000; max-width: 640px; margin: 0 auto; }
  .slip-head { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
  .slip-head strong { font-size: 15px; }
  .slip h2 { margin: 6px 0 2px; font-size: 20px; }
  .slip-sub { margin: 0 0 12px; color: #333; }
  .slip table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
  .slip-kv th { text-align: start; width: 120px; padding: 3px 8px 3px 0; vertical-align: top; color: #333; font-weight: 600; }
  .slip-kv td { padding: 3px 0; }
  .slip-items th, .slip-items td { border-bottom: 1px solid #ccc; padding: 5px 6px; text-align: start; }
  .slip-items .c { text-align: center; } .slip-items .r { text-align: right; }
  .slip-tot th { text-align: start; padding: 3px 8px 3px 0; }
  .slip-tot td.r { text-align: right; }
  .slip-tot .grand th, .slip-tot .grand td { border-top: 2px solid #000; font-size: 15px; font-weight: 700; padding-top: 6px; }
  .slip-notes { border: 1px solid #000; padding: 8px; }
}

/* ==========================================================================
   Phase E — order lifecycle (timeline, cancellation)
   ========================================================================== */

.cxl-tag {
  font-size: .625rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 6px; border-radius: var(--r-pill); background: var(--bad); color: #fff;
}
.cancel-alert {
  margin: var(--s-2) 0 0; padding: 8px 12px; border-radius: var(--r-md);
  background: var(--bad-tint, #fdecec); color: var(--bad); border: 1px solid var(--bad);
  font-size: .8125rem; font-weight: 600;
}
.od-cxl {
  display: flex; gap: 8px; align-items: flex-start;
  margin: var(--s-3) 0; padding: 8px 12px; border-radius: var(--r-md);
  background: var(--bad-tint, #fdecec); border: 1px solid var(--bad); color: var(--bad);
  font-size: .8125rem; font-weight: 500;
}
.od-cxl .icon { inline-size: 16px; block-size: 16px; flex: 0 0 auto; margin-top: 1px; }

.od-timeline { margin: var(--s-4) 0 var(--s-3); }
.od-timeline h4 { margin: 0 0 var(--s-2); font-size: .8125rem; color: var(--text-3); font-weight: 600; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl-row { position: relative; display: flex; gap: 10px; padding: 0 0 12px 2px; }
.tl-row:not(:last-child)::before {
  content: ""; position: absolute; inset-inline-start: 5px; top: 14px; bottom: 0;
  width: 2px; background: var(--border-strong);
}
.tl-dot {
  flex: 0 0 auto; inline-size: 12px; block-size: 12px; margin-top: 2px;
  border-radius: 50%; background: var(--brand); border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.tl-row--cxl .tl-dot { background: var(--bad); }
.tl-main { display: flex; flex-direction: column; gap: 1px; font-size: .8125rem; }
.tl-note { color: var(--text-2); font-style: italic; }
.tl-meta { color: var(--text-3); font-size: .75rem; }

.cxl-form {
  margin: var(--s-2) 0; padding: var(--s-3); border: 1px solid var(--bad);
  border-radius: var(--r-md); background: var(--surface-sunk);
}
.cxl-label {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--s-2);
  font-size: .75rem; font-weight: 600; color: var(--text-2);
}
.cxl-label select, .cxl-label input {
  font: inherit; font-size: .875rem; padding: 7px 9px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface);
}
.cxl-actions { display: flex; justify-content: flex-end; gap: var(--s-2); }

/* ==========================================================================
   Phase F — Platform Admin assist mode
   ========================================================================== */

.assist-banner {
  position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 80;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 16px;
  background: #7c2d12; color: #fff;
  font-size: .8125rem;
}
.assist-banner-text { flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.3; }
.assist-banner-text strong { letter-spacing: .06em; font-size: .75rem; }
.assist-exit {
  flex: 0 0 auto; padding: 5px 12px; border-radius: var(--r-sm);
  background: #fff; color: #7c2d12; font: inherit; font-weight: 700; font-size: .8125rem;
  border: 0; cursor: pointer;
}
body.has-assist .shell { padding-block-start: 52px; }

.pd-img-up { display: inline-block; cursor: pointer; text-align: center; }

/* ---------- pre-sale finalization: getting started + store link/QR ---------- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8125rem; overflow-wrap: anywhere; }

.gs-card {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--brand-tint-soft); padding: 14px 16px; margin-block-end: var(--s-6);
}
.gs-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.gs-head h2 { font-size: 1rem; margin: 0; }
.gs-status { font-size: .8125rem; font-weight: 600; border-radius: var(--r-pill); padding: 2px 10px; background: #fdf6ea; color: #92600c; }
.gs-status.gs-not_live { background: var(--bad-tint); color: var(--bad); }
.gs-list { list-style: none; margin: 10px 0 0; padding: 0; }
.gs-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-block-start: 1px solid var(--border); font-size: .9375rem; }
.gs-list li:first-child { border-block-start: 0; }
.gs-list li.todo { cursor: pointer; }
.gs-list li.todo:hover { color: var(--brand-strong); }
.gs-list .gs-mark { inline-size: 20px; text-align: center; font-weight: 700; }
.gs-list li.done .gs-mark { color: var(--ok); }
.gs-list li.todo .gs-mark { color: #cc8a1f; }
.gs-list li.todo.other { cursor: default; color: inherit; }
.gs-list .gs-owner { margin-inline-start: auto; font-size: .75rem; color: var(--text-2, #666); }
.gs-live { margin-block-start: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gs-live p { flex-basis: 100%; margin: 0; }
.gs-live a { overflow-wrap: anywhere; }
.gs-list .gs-txt { flex: 1 1 auto; }
.gs-list li.done .gs-txt { color: var(--text-2); }
.gs-list .gs-go { display: inline-flex; align-items: center; gap: 3px; font-size: .8125rem; color: var(--text-3); }
.gs-list .gs-go .icon { inline-size: 14px; block-size: 14px; }
/* first-run setup steps: whole row is one button (keyboard + screen readers) */
.gs-list .gs-step { display: flex; align-items: center; gap: 8px; inline-size: 100%; padding: 0; border: 0;
  background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; min-block-size: 32px; }
.gs-list .gs-step:hover .gs-txt { color: var(--brand-strong); }
.gs-prepared { margin-block-start: 10px; }
.gs-prepared p { margin: 0 0 4px; }
.gs-prepared .gs-prepared-title { font-weight: 700; color: var(--brand-strong); }

.store-link-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; margin-block-end: var(--s-6); }
.slc-row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.slc-label { font-size: .75rem; color: var(--text-3); inline-size: 100%; }
.slc-row a.mono { flex: 1 1 220px; color: var(--text-2); text-decoration: none; }
.slc-act { display: flex; gap: 6px; }
/* QR: a printable counter card (store identity + framed code + call to action)
   beside its actions. Stacks on narrow screens; the card keeps a fixed width
   so the printed code is always a scannable size. */
.slc-qr {
  display: flex; gap: var(--s-6); align-items: center; flex-wrap: wrap;
  margin-block-start: var(--s-4); padding: var(--s-4);
  background: var(--surface-sunk); border-radius: var(--r-lg);
}
.qr-poster {
  flex: 0 0 auto; inline-size: 248px; margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 18px 14px; text-align: center;
  background: #fff; color: #1c1a17;
  border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px -12px rgba(0,0,0,.18);
  border-block-start: 4px solid var(--brand);
}
.qr-poster-head { display: flex; align-items: center; justify-content: center; gap: 8px; max-inline-size: 100%; }
.qr-poster-logo { display: grid; place-items: center; inline-size: 36px; block-size: 36px; flex: 0 0 auto; }
.qr-poster-logo img { max-inline-size: 100%; max-block-size: 100%; object-fit: contain; }
.qr-poster-name {
  font-size: 1rem; font-weight: 700; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qr-poster-code {
  inline-size: 196px; block-size: 196px; padding: 6px;
  border: 2px solid color-mix(in srgb, var(--brand) 35%, #fff); border-radius: 14px;
}
.qr-poster-code svg { display: block; inline-size: 100%; block-size: 100%; }
.qr-poster figcaption { display: flex; flex-direction: column; gap: 2px; }
.qr-poster-cta { font-size: .9375rem; font-weight: 700; color: var(--brand); }
.qr-poster-url { font-size: .75rem; color: #5b564d; font-variant-numeric: tabular-nums; word-break: break-all; }
.qr-poster-foot {
  font-size: .6875rem; color: #948d81; padding-block-start: 8px;
  border-block-start: 1px dashed #e4dfd6; inline-size: 100%;
}
.slc-qr-side { display: flex; flex-direction: column; gap: var(--s-3); align-items: flex-start; flex: 1 1 200px; }
.slc-qr-title { font-size: 1rem; font-weight: 700; }
.slc-qr-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.slc-qr-actions .btn-primary { display: inline-flex; align-items: center; gap: 6px; }
.slc-qr-actions .icon { inline-size: 16px; block-size: 16px; }
@media (max-width: 520px) {
  .slc-qr { justify-content: center; }
  .slc-qr-side { align-items: stretch; }
  .slc-qr-actions > * { flex: 1 1 auto; justify-content: center; }
}
/* Print: the card is copied into #print-area (the only element @media print
   keeps, see the slip rules above), centred at a comfortable A6-ish size. */
@media print {
  .qr-poster--print {
    inline-size: 9.5cm; margin: 2cm auto 0; box-shadow: none;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .qr-poster--print .qr-poster-code { inline-size: 7cm; block-size: 7cm; }
}

/* ==========================================================================
   Market Admin product-ops batch: store identity in the sidebar, Missing
   Images cleanup queue, scan / export tools
   ========================================================================== */
.side-brand { min-inline-size: 0; }
.side-store { display: flex; flex-direction: column; min-inline-size: 0; line-height: 1.2; }
.side-store strong {
  font-size: .9375rem; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.side-platform { font-size: .6875rem; font-weight: 500; color: var(--text-3); }
/* the real store logo: contained, never cropped or stretched.
   `position: relative` + the image at `position: absolute; inset: 0` is
   deliberate: a percentage-sized <img> as a `place-items: center` grid
   child does not reliably resize to its box in every engine (the parent's
   non-stretch alignment can leave the image at its own intrinsic size —
   e.g. a 1600x912 store logo — instead of the 44px/36px box). Absolute
   positioning inside a sized, positioned parent is unaffected by grid/flex
   alignment and always clamps the image to the box, whatever its original
   dimensions (regression fix — the store logo previously covered the
   screen once a store with a real logo loaded here). */
.side-mark.has-logo {
  position: relative;
  inline-size: 44px; block-size: 44px; flex: 0 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px; overflow: hidden;
}
.side-mark.has-logo img {
  /* Anchor only the start corner and size with an explicit calc() — NOT
     `inset: 0/3px` on all four sides with width/height left at their
     default `auto`. For an absolutely positioned replaced element (img),
     `auto` sizing falls back to the image's OWN intrinsic size regardless
     of the inset constraints (this is what reproduced the regression: a
     1600x912-class logo rendered at its full natural size, covering the
     screen). An explicit width/height removes that ambiguity entirely.
     3px matches the parent's own padding, so the visible size is unchanged
     from before this fix. */
  position: absolute; inset-block-start: 3px; inset-inline-start: 3px;
  inline-size: calc(100% - 6px); block-size: calc(100% - 6px);
  object-fit: contain; display: block;
}
@media (max-width: 899px) { .side-mark.has-logo { inline-size: 36px; block-size: 36px; } }

.btn-ghost.on { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-tint); }
.head-tools .btn-ghost .icon { inline-size: 16px; block-size: 16px; }
.add-image-btn { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.add-image-btn .icon { inline-size: 14px; block-size: 14px; }
.add-image-btn.busy { opacity: .5; pointer-events: none; }
.catalog-table td.cell-actions .add-image-btn { padding: 4px 9px; font-size: .75rem; min-block-size: 0; }
.catalog-table tr.no-image .cell-name::after {
  content: ""; display: inline-block; inline-size: 7px; block-size: 7px; border-radius: 50%;
  background: var(--prep); margin-inline-start: 6px; vertical-align: middle;
}

/* ==========================================================================
   Visual polish — typography
   Arabic is a joined script: any letter-spacing (positive tracking or negative
   tightening) breaks the letter joins in Cairo. Reset it in RTL only; Latin
   text in LTR keeps its tracking. Headings balance their line breaks where the
   browser supports it (no effect elsewhere).
   ========================================================================== */
[dir="rtl"], [dir="rtl"] *, [dir="rtl"] *::before, [dir="rtl"] *::after { letter-spacing: 0 !important; }
:is(h1, h2, h3) { text-wrap: balance; }
