html[lang="ar"] {
  --font-geist-sans: "Noto Sans Arabic", sans-serif;
  --default-font-family: "Noto Sans Arabic", sans-serif;
  font-family: "Noto Sans Arabic", sans-serif;
}

html[lang="ar"] body,
html[lang="ar"] button,
html[lang="ar"] input,
html[lang="ar"] select,
html[lang="ar"] textarea,
html[lang="ar"] table {
  font-family: "Noto Sans Arabic", sans-serif;
}

html[dir="rtl"] table:not(.ms-slip) {
  direction: rtl;
}

html[dir="ltr"] table:not(.ms-slip),
html:not([dir="rtl"]) table:not(.ms-slip) {
  direction: ltr;
}

html[dir="rtl"] table:not(.ms-slip) :is(th, td) {
  text-align: right !important;
}

html[dir="ltr"] table:not(.ms-slip) :is(th, td),
html:not([dir="rtl"]) table:not(.ms-slip) :is(th, td) {
  text-align: left !important;
}

/* Everything inside a table cell starts on the reading side: text, amounts, badges, images. */
table:not(.ms-slip) :is(th, td) :where(.text-end, .text-right, .text-left, .text-center) {
  text-align: start !important;
}

table:not(.ms-slip) :is(th, td) :where(.flex, .inline-flex):where(.justify-end, .justify-center, .justify-between) {
  justify-content: flex-start !important;
}

table:not(.ms-slip) :is(th, td) :where(.flex-col):where(.items-end, .items-center) {
  align-items: flex-start !important;
}

table:not(.ms-slip) :is(th, td) :where(img, .mx-auto) {
  margin-inline: 0 !important;
}

table:not(.ms-slip) :is(th, td) :where(.ms-auto) {
  margin-inline-start: 0 !important;
}

/* display:contents on these elements drops their children after the page mutates them. */
/* Home stat sparklines sit on the card's bottom border. */
.overview-stats > a {
  display: flex;
  flex-direction: column;
}

.overview-stats [id^="dash-spark"] {
  margin-top: auto;
  line-height: 0;
}

.overview-stats [id^="dash-spark"] .apexcharts-canvas,
.overview-stats [id^="dash-spark"] svg {
  display: block;
}

.overview-stats [id^="dash-spark"] .apexcharts-canvas {
  transform: translateY(1px);
}

apex-sidebar .sidebar-brand-text {
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  text-align: center;
}

apex-sidebar [data-shop-brand-name],
apex-sidebar [data-shop-brand-desc] {
  width: 100%;
  text-align: center;
}

html.dark [data-theme-icon="light"],
html:not(.dark) [data-theme-icon="dark"] {
  display: none !important;
}

html.dark [data-theme-icon="dark"] {
  display: block !important;
}

apex-sidebar {
  display: block !important;
  width: 0;
  min-width: 0;
  flex: 0 0 0;
  overflow: visible;
}

apex-header {
  display: block !important;
}

@media (min-width: 1024px) {
  .apex-sidebar-aside {
    transform: none !important;
  }
}

/* Keep every section reachable. The menu used to jump to the open page and hide its scrollbar. */
apex-sidebar nav.scrollbar-fade {
  scrollbar-color: oklch(45% 0 0 / 0.45) transparent;
}

apex-sidebar nav.scrollbar-fade::-webkit-scrollbar {
  width: 8px;
}

apex-sidebar nav.scrollbar-fade::-webkit-scrollbar-thumb {
  background: oklch(45% 0 0 / 0.45);
  border-radius: 999px;
}

/* The page body stays unseen until its heading and the rest are both ready. */
html[data-boot="app"]:not([data-ready]) #main-content {
  visibility: hidden;
}

/* ── People pages: clients, suppliers, staff ───────────────────────────── */
.ms-people { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }

.ms-ph { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.ms-ph-title { display: flex; align-items: center; gap: .875rem; min-width: 0; }
.ms-ph-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 3rem; height: 3rem; border-radius: 1rem;
  background: color-mix(in srgb, var(--ms-tone, var(--primary)) 14%, transparent);
  color: var(--ms-tone, var(--primary));
}
.ms-ph-icon svg, .ms-ph-icon i { width: 1.5rem; height: 1.5rem; }
.ms-ph h1 { font-size: 1.5rem; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.ms-ph p { margin-top: .25rem; font-size: .875rem; color: var(--muted-foreground); }
.ms-ph-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.ms-kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.ms-kpi {
  position: relative; overflow: hidden; display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
  padding: 1rem 1.125rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px);
  background: var(--card); color: var(--card-foreground);
  box-shadow: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.ms-kpi:hover, button.ms-kpi:hover { border-color: color-mix(in srgb, var(--ms-tone, var(--primary)) 45%, var(--border)); box-shadow: 0 4px 14px -6px #00000026; transform: translateY(-1px); }
button.ms-kpi { text-align: start; cursor: pointer; width: 100%; }
.ms-kpi::before { opacity: 1; }
.ms-kpi.is-active { border-color: var(--ms-tone, var(--primary)); }
.ms-kpi-label { font-size: .75rem; font-weight: 500; color: var(--muted-foreground); }
.ms-kpi-value { margin-top: .35rem; font-size: 1.45rem; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.ms-kpi-hint { margin-top: .3rem; font-size: .72rem; color: var(--muted-foreground); }
@media (max-width: 639px) {
  .ms-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .ms-kpi { padding: .8rem .85rem; }
  .ms-kpi-value { font-size: 1.1rem; }
  .ms-kpis .ms-kpi-well { display: none; }
}
.ms-kpi-well {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 2.5rem; height: 2.5rem; border-radius: .8rem;
  background: color-mix(in srgb, var(--ms-tone, var(--primary)) 13%, transparent);
  color: var(--ms-tone, var(--primary));
}
.ms-kpi-well svg, .ms-kpi-well i { width: 1.2rem; height: 1.2rem; }

.ms-tone-primary { --ms-tone: var(--primary); }
.ms-tone-due { --ms-tone: var(--destructive); }
.ms-tone-credit { --ms-tone: var(--warning); }
.ms-tone-ok { --ms-tone: var(--success); }
.ms-tone-info { --ms-tone: var(--chart-3); }
.ms-tone-teal { --ms-tone: var(--chart-2); }
.ms-tone-violet { --ms-tone: var(--chart-5); }
.ms-tone-muted { --ms-tone: var(--muted-foreground); }

/* Avatars: hue comes from the name. */
.ms-av {
  --h: 160; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 2.5rem; height: 2.5rem; border-radius: 999px; font-weight: 600; font-size: .85rem; letter-spacing: .02em;
  background: oklch(92% .05 var(--h)); color: oklch(38% .12 var(--h));
}
html.dark .ms-av { background: oklch(32% .07 var(--h)); color: oklch(88% .08 var(--h)); }
.ms-av-lg { width: 4.5rem; height: 4.5rem; font-size: 1.5rem; border-radius: 1.25rem; }

/* List cells */
.ms-who { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.ms-who-name { font-weight: 600; font-size: .875rem; line-height: 1.25; }
.ms-who-sub { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; margin-top: .15rem; font-size: .75rem; color: var(--muted-foreground); }
.ms-who-sub span { display: inline-flex; align-items: center; gap: .25rem; direction: ltr; unicode-bidi: isolate; }
.ms-who-sub svg, .ms-who-sub i { width: .8rem; height: .8rem; }
/* Addresses and other words follow the page direction (only numbers stay left-to-right); a wrapped line keeps its icon on the first line. */
.ms-who-sub span:has(.lucide-map-pin, [data-lucide="map-pin"]) { direction: inherit; align-items: flex-start; text-align: start; overflow-wrap: anywhere; }
.ms-who-sub span:has(.lucide-map-pin, [data-lucide="map-pin"]) svg { margin-top: .15rem; }
.ms-who-sub svg, .ms-who-sub i { flex-shrink: 0; }
.ms-amt { display: inline-flex; flex-direction: column; align-items: flex-start; gap: .1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-amt b { font-weight: 700; font-size: .875rem; }
.ms-amt small { font-size: .7rem; color: var(--muted-foreground); }
.ms-amt.is-due b { color: var(--destructive); }
.ms-amt.is-credit b { color: color-mix(in srgb, var(--warning) 60%, var(--foreground)); }
.ms-amt.is-zero b { color: var(--muted-foreground); font-weight: 500; }
.ms-pill {
  display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--ms-tone, var(--muted-foreground)) 13%, transparent);
  color: color-mix(in srgb, var(--ms-tone, var(--muted-foreground)) 75%, var(--foreground));
}
.ms-pill::before { content: ""; width: .4rem; height: .4rem; border-radius: 999px; background: currentColor; }
.ms-meter { display: block; width: 100%; min-width: 5rem; height: .35rem; margin-top: .35rem; border-radius: 999px; background: var(--muted); overflow: hidden; }
.ms-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--ms-tone, var(--primary)); }
.ms-muted { color: var(--muted-foreground); font-size: .8rem; }

/* Detail hero */
.ms-hero {
  position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: calc(var(--radius) + 8px);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--ms-tone, var(--primary)) 12%, transparent) 0%, transparent 55%),
    var(--card);
  box-shadow: 0 1px 3px 0 #0000000f;
}
html[dir="rtl"] .ms-hero {
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--ms-tone, var(--primary)) 12%, transparent) 0%, transparent 55%),
    var(--card);
}
.ms-hero-body { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1.25rem; padding: 1.5rem; }
.ms-hero-id { display: flex; align-items: flex-start; gap: 1.1rem; min-width: 0; flex: 1 1 22rem; }
.ms-hero-id h1 { font-size: 1.6rem; line-height: 1.2; font-weight: 700; letter-spacing: -.015em; overflow-wrap: anywhere; }
.ms-hero-tags { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .45rem; }
.ms-hero-lead { margin-top: .5rem; font-size: .85rem; color: var(--muted-foreground); }
.ms-hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.ms-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.ms-chip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: 999px;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--card) 80%, transparent);
  font-size: .78rem; font-weight: 500; color: var(--foreground); transition: background .15s, border-color .15s;
}
.ms-chip span { direction: ltr; unicode-bidi: isolate; }
a.ms-chip:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--card)); }
.ms-chip svg, .ms-chip i { width: .9rem; height: .9rem; color: var(--muted-foreground); }
.ms-chip.is-wa svg, .ms-chip.is-wa i { color: oklch(62% .17 150); }
/* ── Repair order page re-layout (order-detail-tweaks.js) ─────────────── */
.ms-od-hidden { display: none !important; }
/* Cable check: desktop only, and only when a diagnostic report is actually attached. */
.ms-cable-card.ms-od-noresult { display: none !important; }
@media (max-width: 1023px) { :root[data-page="order-detail"] .ms-cable-card { display: none !important; } }
/* The device name stands alone in the header — drop the client name printed beside it. */
:root[data-page="order-detail"] .ms-hero-lead > span:not(:first-child) { display: none !important; }
/* Warranty gets its own boxed section, lifted visually out of the order-details list. */
#warranty-form.ms-warranty-box { margin-top: 1rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: .75rem; background: color-mix(in srgb, var(--muted) 30%, var(--card)); }
.ms-warranty-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem; }
.ms-warranty-head svg { color: var(--primary); flex-shrink: 0; }
.ms-warranty-head h3 { font-size: .95rem; font-weight: 600; margin: 0; }

/* Payment-reminder chip (clients who owe the shop): a clear, clickable action. */
button.ms-chip.ms-chip-remind { cursor: pointer; border-color: color-mix(in srgb, var(--destructive) 40%, var(--border)); background: color-mix(in srgb, var(--destructive) 8%, var(--card)); color: var(--destructive); font-weight: 600; }
button.ms-chip.ms-chip-remind svg { color: var(--destructive); }
button.ms-chip.ms-chip-remind:hover { border-color: var(--destructive); background: color-mix(in srgb, var(--destructive) 14%, var(--card)); }

/* ── Item 3: Device inspection is a desktop workflow — hide it on phones/tablets ──
   The scan/diagnose flow needs a wired computer, so on narrow screens we drop the
   sidebar link and the live panel and show a short "open on desktop" note instead. */
/* Phones/tablets: narrow screens, and touch-only devices of any size (large tablets). */
@media (max-width: 1023px), (hover: none) and (pointer: coarse) {
  a[href*="/diagnostics"],
  a[href*="diag.html"],
  .ms-hide-touch { display: none !important; }
  :root[data-page="diag"] #diag-root,
  :root[data-page="diag"] #btn-scan,
  :root[data-page="diag"] .ms-ph-actions { display: none !important; }
}
.ms-desktop-only-note {
  display: flex; flex-direction: column; align-items: center; gap: .55rem; text-align: center;
  margin-top: 1rem; padding: 2.25rem 1.25rem; border: 1px dashed var(--border); border-radius: 1rem;
  background: color-mix(in srgb, var(--muted) 35%, var(--card)); color: var(--muted-foreground); font-size: .85rem;
}
.ms-desktop-only-note svg { width: 2.25rem; height: 2.25rem; opacity: .6; }
.ms-desktop-only-note strong { color: var(--foreground); font-size: 1.02rem; }

/* ── Item 18: frozen first column in responsive tables ──────────────────────
   On phones/tablets the data-table freezes the first column (apex-data-table
   [data-table] th/td:first-child). It shipped at z-index 1 with a physical-right
   box-shadow divider — so the divider fell on the wrong side in RTL and the column
   could sit level with scrolling cells. Lift it above the scrolling cells so rows
   pass cleanly underneath, keep it opaque, and draw the divider on the inner
   (inline-end) edge so it's correct in both LTR and RTL. */
@media (max-width: 1023px) {
  apex-data-table [data-table] :is(th, td):first-child {
    z-index: 3 !important;
    box-shadow: none !important;
    border-inline-end: 1px solid var(--border);
    background: var(--card);
  }
}
/* ms-style tables: keep the sticky header above the scrolling body too. */
.ms-sticky th { z-index: 3; }

/* ── Every table in the style of "Active orders" (the reference table) ──────
   The data-table component already frames its tables; plain .ms-table tables (inside client /
   supplier / staff accounts, vouchers, accounting, reports …) get the same treatment: a rounded
   bordered frame that scrolls sideways, an opaque tinted header, row dividers, and on phones and
   tablets a frozen first column that rows slide under. Tables that bring their own frame keep it. */
#main-content div:has(> table.ms-table):not(apex-data-table div):not(.receipt-card *):not(.border):not([class*="rounded"]):not(.apex-card) {
  border: 1px solid var(--border); border-radius: .9rem; background: var(--card);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
/* Inside a card without padding (account tabs), keep the framed table off the card's edges. */
.apex-card:not([class*="p-"]) div:has(> table.ms-table):not(apex-data-table div):not(.receipt-card *):not(.border):not([class*="rounded"]):not(.apex-card) { margin: .75rem 1rem 1rem; }
#main-content div:has(> table.ms-table):not(apex-data-table div)[class*="-mx-"] { margin-inline: 0 !important; padding-inline: 0 !important; }
.ms-table thead th { background: color-mix(in srgb, var(--muted) 55%, var(--card)); }
.ms-table tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 1023px) {
  #main-content table.ms-table:not(apex-data-table table):not(.receipt-card table) :is(th, td):first-child {
    position: sticky; inset-inline-start: 0; z-index: 3; border-inline-end: 1px solid var(--border); min-width: 8rem;
  }
  #main-content table.ms-table:not(apex-data-table table):not(.receipt-card table) tbody td:first-child { background: var(--card); }
  #main-content table.ms-table:not(apex-data-table table):not(.receipt-card table) tbody tr:hover td:first-child { background: color-mix(in srgb, var(--muted) 40%, var(--card)); }
}

/* ── Item 4: Accounting (data-page "books") on phones, in the style of the other pages ──
   Period presets → one compact segmented row; section views → one scrolling underline-tab
   row; statements and ledgers use tighter cells so account names don't stack. */
@media (max-width: 767px) {
  :root[data-page="books"] .ms-ph-actions #presets {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .2rem; width: 100%;
    padding: .2rem; border: 1px solid var(--border); border-radius: .7rem; background: var(--muted);
  }
  :root[data-page="books"] #presets > button {
    height: 2.1rem; padding-inline: .25rem; border: 0 !important; border-radius: .5rem; font-size: .8rem;
    white-space: nowrap; background: transparent; color: var(--muted-foreground); box-shadow: none;
  }
  :root[data-page="books"] #presets > button.bg-primary { background: var(--card) !important; color: var(--foreground) !important; font-weight: 600; box-shadow: 0 1px 2px #0000001f; }
  :root[data-page="books"] #views.ms-tabs {
    flex-wrap: nowrap; gap: 0; overflow-x: auto; scrollbar-width: none; margin-bottom: .85rem;
    border-bottom: 1px solid var(--border);
  }
  :root[data-page="books"] #views.ms-tabs::-webkit-scrollbar { display: none; }
  :root[data-page="books"] #views.ms-tabs > button {
    flex: 0 0 auto; height: auto; padding: .6rem .8rem; margin-bottom: -1px; border: 0 !important; border-radius: 0;
    border-bottom: 2px solid transparent !important; background: transparent !important; color: var(--muted-foreground) !important;
    white-space: nowrap; font-size: .85rem; box-shadow: none;
  }
  :root[data-page="books"] #views.ms-tabs > button.bg-primary { color: var(--primary) !important; border-bottom-color: var(--primary) !important; font-weight: 600; }
  :root[data-page="books"] #books-tools { gap: .5rem; margin-bottom: .75rem; }
  :root[data-page="books"] #books-body section.p-4 { padding: .85rem; }
  :root[data-page="books"] #books-body [class*="grid-cols-[minmax(0,1fr)_9.5rem]"] { grid-template-columns: minmax(0, 1fr) 6.5rem; gap: .75rem; }
  :root[data-page="books"] #books-body table { font-size: .8rem; }
  :root[data-page="books"] #books-body table :is(th, td) { padding: .55rem .6rem !important; }
}
/* ── Order page layout (order-detail-tweaks.js) ──────────────────────────
   Main: details → quick check → pricing → photos → cable. Side: status → warranty → technician →
   bench → barcode. Phones: one column, actions first. The header (hero) is untouched. */
.ms-od-details { display: flex; flex-direction: column; gap: 1rem; }
.ms-od-details > * + * { margin-top: 0 !important; }
.ms-od-problem { padding: .8rem 1rem; border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border)); border-radius: .75rem; background: color-mix(in srgb, var(--primary) 6%, var(--card)); }
.ms-od-problem > p:first-child { margin: 0 0 .2rem !important; font-size: .74rem; font-weight: 600; color: var(--primary) !important; }
.ms-od-problem > p:last-child { font-size: .95rem; font-weight: 500; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.ms-od-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .6rem; margin: 0; }
/* Order fact tiles (own class — .ms-fact belongs to the account profile lists). */
.ms-odf { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; min-width: 0; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: .65rem; background: color-mix(in srgb, var(--muted) 30%, var(--card)); }
.ms-odf dt { margin: 0; font-size: .72rem; line-height: 1.3; color: var(--muted-foreground); text-align: start; }
.ms-odf dd { margin: 0; font-size: .87rem; font-weight: 600; line-height: 1.4; text-align: start; overflow-wrap: anywhere; }
.ms-od-details .ms-od-problem { padding: .85rem 1rem !important; margin: 0 !important; }
/* Warranty box: one column in the side column, title with its icon, full-width save. */
.ms-od-warranty .ms-warranty-head { display: flex; align-items: center; justify-content: flex-start; gap: .5rem; }
.ms-od-warranty form { margin: 0; }
.ms-od-warranty form .grid { grid-template-columns: minmax(0, 1fr) !important; }
.ms-od-warranty form > div:last-child { flex-direction: column !important; align-items: stretch !important; }
.ms-od-warranty form button[type="submit"] { width: 100%; justify-content: center; }
.ms-od-side .ms-pipe { gap: .55rem; }
.ms-od-side .ms-pipe-group { display: grid; grid-template-columns: minmax(5.5rem, 7rem) 1fr; align-items: center; gap: .5rem; }
.ms-od-side .ms-pipe-label { margin: 0; }
.ms-od-side .ms-pipe-row { gap: .35rem; }
.ms-od-side button.ms-pipe-chip { padding: .4rem .7rem; font-size: .78rem; }
@media (max-width: 1023px) {
  .ms-od-grid { display: flex !important; flex-direction: column; gap: 1rem; }
  .ms-od-main, .ms-od-side { display: contents; }
  .ms-od-grid .apex-card { margin-top: 0 !important; }
  [data-od-kind="status"] { order: 1; } [data-od-kind="details"] { order: 2; } [data-od-kind="quick"] { order: 3; }
  [data-od-kind="pricing"] { order: 4; } [data-od-kind="photos"] { order: 5; } [data-od-kind="warranty"] { order: 6; }
  [data-od-kind="assign"] { order: 7; } [data-od-kind="bench"] { order: 8; } [data-od-kind="cable"] { order: 9; }
  [data-od-kind="barcode"] { order: 10; }
  .ms-od-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Print / share popup (order-print.js) ── */
.apex-dialog.ms-print-dlg { max-width: 34rem; width: calc(100% - 1.5rem); max-height: min(94vh, 52rem); display: flex; flex-direction: column; overflow: hidden; }
.ms-print-dlg[open] { display: flex; }
.ms-print-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; padding: 1rem 1.15rem .75rem; border-bottom: 1px solid var(--border); }
.ms-print-head h2 { font-size: 1rem; font-weight: 650; }
.ms-print-head p { margin-top: .1rem; font-size: .8rem; color: var(--muted-foreground); }
.ms-print-x { width: 2rem; height: 2rem; border-radius: .5rem; color: var(--muted-foreground); }
.ms-print-x:hover { background: var(--muted); color: var(--foreground); }
.ms-print-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; margin: .75rem 1.15rem 0; padding: .2rem; border-radius: .7rem; background: var(--muted); }
.ms-print-tabs button { height: 2.1rem; border-radius: .5rem; font-size: .82rem; font-weight: 500; color: var(--muted-foreground); }
.ms-print-tabs button[aria-selected="true"] { background: var(--card); color: var(--foreground); font-weight: 600; box-shadow: 0 1px 2px #0000001f; }
.ms-print-tabs button:disabled { opacity: .45; cursor: not-allowed; }
.ms-print-paper { position: relative; flex: 1 1 auto; min-height: 18rem; margin: .75rem 1.15rem 0; border: 1px solid var(--border); border-radius: .75rem; background: #f3f4f6; overflow: hidden; }
.ms-print-paper iframe { display: block; width: 100%; height: 100%; min-height: 26rem; border: 0; background: #fff; }
.ms-print-wait { position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; color: var(--muted-foreground); background: #fff; }
.ms-print-wait[hidden] { display: none; }
.ms-print-foot { display: flex; flex-wrap: wrap; gap: .5rem; padding: .85rem 1.15rem 1rem; }
.ms-print-foot > .apex-btn:first-child { flex: 1 1 auto; justify-content: center; }
.ms-print-share { position: relative; }
.ms-print-menu { position: absolute; bottom: calc(100% + .35rem); inset-inline-start: 0; z-index: 5; min-width: 12rem; padding: .3rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--popover); box-shadow: 0 10px 30px -10px #0000004d; }
.ms-print-menu button { display: block; width: 100%; padding: .5rem .65rem; border-radius: .45rem; text-align: start; font-size: .85rem; }
.ms-print-menu button:hover { background: var(--muted); }
.ms-print-msg { min-height: 0; padding: 0 1.15rem .75rem; font-size: .8rem; color: var(--muted-foreground); }
.ms-print-msg:empty { display: none; }
@media (max-width: 639px) {
  .apex-dialog.ms-print-dlg { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .ms-print-foot > .apex-btn, .ms-print-share, .ms-print-share > .apex-btn { flex: 1 1 0; justify-content: center; }
}

/* ── Item 7: add a device + manufacturer from the new-order device search (device-add.js) ── */
.ms-adddev-row {
  display: flex; align-items: center; gap: .5rem; width: 100%; margin-top: .25rem; padding: .55rem .6rem;
  border-top: 1px dashed var(--border); border-radius: .45rem; text-align: start; font-size: .85rem; font-weight: 600; color: var(--primary);
}
.ms-adddev-row:hover, .ms-adddev-row:focus-visible { background: color-mix(in srgb, var(--primary) 9%, transparent); outline: none; }
.ms-adddev-row svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.ms-adddev-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apex-dialog.ms-adddev { max-width: 30rem; }
.ms-adddev-head { display: flex; align-items: flex-start; gap: .75rem; padding: 1.1rem 1.25rem .85rem; border-bottom: 1px solid var(--border); }
.ms-adddev-head h2 { font-size: 1rem; font-weight: 650; }
.ms-adddev-head p { margin-top: .15rem; font-size: .8rem; color: var(--muted-foreground); }
.ms-adddev-icon { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: .7rem; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.ms-adddev-icon svg { width: 1.15rem; height: 1.15rem; }
.ms-adddev-body { display: grid; gap: .8rem; padding: 1rem 1.25rem; }
.ms-adddev-field { display: grid; gap: .35rem; font-size: .82rem; font-weight: 600; }
.ms-adddev-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: -.25rem; }
.ms-adddev-chips .ms-chip { cursor: pointer; font-size: .75rem; padding: .2rem .6rem; }
.ms-adddev-chips .ms-chip.is-on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--card)); color: var(--primary); font-weight: 600; }
.ms-adddev-preview { min-height: 1.1rem; font-size: .8rem; color: var(--muted-foreground); }
.ms-adddev-preview b { color: var(--foreground); }
.ms-adddev-new { color: var(--primary); font-weight: 600; }
.ms-adddev-err { padding: .5rem .65rem; border-radius: .5rem; background: color-mix(in srgb, var(--destructive) 10%, transparent); color: var(--destructive); font-size: .8rem; }
.ms-adddev-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem 1.1rem; border-top: 1px solid var(--border); }
@media (max-width: 639px) { .ms-adddev-foot .apex-btn { flex: 1 1 0; justify-content: center; } }

/* ── Item 8: continue an order on a phone (order-continue.js) ── */
@media (max-width: 1023px) { .ms-od-continue { display: none !important; } }
.apex-dialog.ms-qrdlg { max-width: 24rem; text-align: center; }
.ms-qrdlg-head { padding: 1.15rem 1.25rem .5rem; }
.ms-qrdlg-head h2 { font-size: 1.05rem; font-weight: 650; }
.ms-qrdlg-head p { margin-top: .3rem; font-size: .82rem; color: var(--muted-foreground); line-height: 1.55; }
.ms-qrdlg-code { display: grid; place-items: center; margin: .5rem auto 0; padding: .6rem; width: max-content; border: 1px solid var(--border); border-radius: 1rem; background: #fff; }
.ms-qrdlg-code svg { display: block; width: 13.5rem; height: 13.5rem; }
.ms-qrdlg-order { margin-top: .45rem; font-family: var(--font-geist-mono, monospace); font-weight: 650; letter-spacing: .04em; }
.ms-qrdlg-steps { display: grid; gap: .35rem; margin: .85rem 1.25rem 0; padding-inline-start: 1.1rem; text-align: start; font-size: .8rem; color: var(--muted-foreground); list-style: decimal; }
.ms-qrdlg-warn { margin: .75rem 1.25rem 0; padding: .55rem .7rem; border-radius: .55rem; background: color-mix(in srgb, var(--warning, #d97706) 12%, transparent); color: var(--warning, #b45309); font-size: .78rem; text-align: start; }
.ms-qrdlg-link { display: flex; align-items: center; gap: .4rem; margin: .85rem 1.25rem 0; }
.ms-qrdlg-link code { flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--muted); font-size: .7rem; text-align: start; }
.ms-qrdlg-link .apex-btn { flex-shrink: 0; height: 2.1rem; }
.ms-qrdlg-foot { padding: 1rem 1.25rem 1.15rem; }
.ms-qrdlg-foot .apex-btn { width: 100%; justify-content: center; }
.ms-photo-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-top: .35rem; }
.ms-photo-btn { cursor: pointer; gap: .4rem; }
.ms-photo-tools.is-busy .ms-photo-btn { pointer-events: none; opacity: .55; }
.ms-photo-status { font-size: .8rem; color: var(--muted-foreground); }
.ms-photo-status.is-error { color: var(--destructive); }
.apex-card.ms-photo-focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); transition: box-shadow .3s; }
@media (max-width: 639px) { .ms-photo-btn { flex: 1 1 calc(50% - .5rem); justify-content: center; } .ms-photo-status { flex-basis: 100%; } }

/* ── Item 15: salary due dates + settle by voucher (staff-payroll.js) ── */
.ms-payroll { padding: 0 !important; overflow: hidden; margin-top: 1rem; }
.ms-payroll > .ms-section-head { padding: 1rem 1.25rem !important; border-bottom: 1px solid var(--border); }
.ms-payroll-body { display: grid; gap: 1rem; padding: 1rem 1.25rem 1.25rem; }
.ms-payroll-top { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .6rem; align-items: end; }
.ms-payroll-day { display: grid; gap: .35rem; grid-column: span 2; }
.ms-payroll-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.ms-payroll-row .apex-input { width: 7rem; }
.ms-payroll-row .apex-select { width: auto; min-width: 7.5rem; height: 2rem; }
.ms-payroll-note { padding: .6rem .8rem; border-radius: .6rem; background: color-mix(in srgb, var(--warning, #d97706) 10%, transparent); color: var(--foreground); font-size: .82rem; }
.ms-pay-badge { display: inline-flex; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.ms-pay-badge.is-paid { background: color-mix(in srgb, var(--success, #16a34a) 14%, transparent); color: var(--success, #15803d); }
.ms-pay-badge.is-due { background: color-mix(in srgb, var(--destructive) 12%, transparent); color: var(--destructive); }
.ms-pay-badge.is-upcoming { background: var(--muted); color: var(--muted-foreground); }
.ms-payroll-msg { font-size: .82rem; color: var(--success, #15803d); }
.ms-payroll-msg.is-error { color: var(--destructive); }
.ms-payroll-msg:empty { display: none; }

/* ── Item 15: contract signatory (Settings) + contract document (staff-contract.js) ── */
.ms-signatory { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.ms-signatory-mode { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .875rem; }
.ms-signatory-mode label { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.ms-signatory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .75rem; }
.ms-signatory-grid label { display: grid; gap: .35rem; }
.ms-signatory-grid [hidden] { display: none; }
.ms-sig-box { display: grid; gap: .5rem; }
.ms-sig-current { display: flex; align-items: center; gap: .75rem; font-size: .78rem; color: var(--muted-foreground); }
.ms-sig-current img { height: 3.5rem; max-width: 12rem; padding: .25rem; border: 1px solid var(--border); border-radius: .5rem; background: #fff; object-fit: contain; }
.ms-sig-pad { display: block; width: 100%; max-width: 28rem; height: 9rem; border: 1px solid var(--border); border-radius: .65rem; background: #fff; touch-action: none; cursor: crosshair; }
.ms-sig-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ms-sig-actions [hidden] { display: none; }
.ms-sig-msg { font-size: .82rem; color: var(--success, #15803d); }
.ms-sig-msg.is-error { color: var(--destructive); }
.ms-sig-msg:empty { display: none; }
.ms-contract-tools { display: flex; flex-wrap: wrap; gap: .4rem; margin-inline-start: auto; }
.apex-dialog.ms-contract-dlg { max-width: 56rem; }
.ms-contract-dlg .ms-print-paper iframe { min-height: 34rem; }

/* ── Item 17: staff advance requests (staff-advances.js) ── */
.ms-adv-card { padding: 0 !important; overflow: hidden; margin-top: 1rem; }
.ms-adv-slot > .ms-adv-card { margin: 0 0 1rem; }
.ms-adv-card > .ms-section-head { padding: 1rem 1.25rem !important; border-bottom: 1px solid var(--border); }
.ms-adv-body { display: grid; gap: .85rem; padding: 1rem 1.25rem 1.15rem; }
.ms-adv-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.ms-adv-form label { display: grid; gap: .3rem; }
.ms-adv-form [data-amount] { width: 9rem; }
.ms-adv-form .ms-adv-reason { flex: 1 1 14rem; }
.ms-adv-count { display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.35rem; margin-inline-start: .35rem; padding: 0 .35rem; border-radius: 999px; background: var(--destructive); color: #fff; font-size: .72rem; font-weight: 700; vertical-align: middle; }

/* ── Item 16: each staff account's receipt printer (staff-printer.js) ── */
.ms-printer-card { padding: 0 !important; overflow: hidden; margin-top: 1rem; }
.ms-printer-card > .ms-section-head { padding: 1rem 1.25rem !important; border-bottom: 1px solid var(--border); }
.ms-printer-body { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: 1rem 1.25rem 1.15rem; }
.ms-printer-body .apex-select { flex: 1 1 16rem; width: auto; }
.ms-printer-msg { flex-basis: 100%; font-size: .8rem; color: var(--success, #15803d); }
.ms-printer-msg.is-error { color: var(--destructive); }
.ms-printer-msg:empty { display: none; }

/* ── Item 19: bilingual names (names-i18n.js) ── */
.ms-name-en-hint { margin-inline-start: .4rem; font-size: .7rem; font-weight: 500; color: var(--muted-foreground); }
.ms-name-en-field input { font-family: inherit; }
.ms-name-alt { display: block; margin-top: .1rem; font-size: .85rem; font-weight: 500; color: var(--muted-foreground); letter-spacing: .01em; }

/* The floating chat button must never hide the last rows of a page on phones/tablets. */
@media (max-width: 1023px) {
  :root:has(#wa-dock) #main-content { padding-bottom: 5.5rem !important; }
}

.ms-hero-foot {
  display: flex; flex-wrap: wrap; gap: 1.5rem; padding: .85rem 1.5rem; border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 45%, transparent); font-size: .78rem; color: var(--muted-foreground);
}
.ms-hero-foot b { display: block; margin-top: .1rem; font-size: .85rem; font-weight: 600; color: var(--foreground); }
.ms-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted-foreground); margin-bottom: .75rem; }
.ms-crumbs a:hover { color: var(--foreground); }
.ms-crumbs svg, .ms-crumbs i { width: .8rem; height: .8rem; }
html[dir="rtl"] .ms-crumbs svg { transform: scaleX(-1); }

/* Underline tabs */
.ms-tabs {
  display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1rem;
  scrollbar-width: none;
}
.ms-tabs::-webkit-scrollbar { display: none; }
.ms-tab {
  position: relative; display: inline-flex; align-items: center; gap: .45rem; padding: .7rem .9rem; white-space: nowrap;
  font-size: .875rem; font-weight: 500; color: var(--muted-foreground); transition: color .15s;
}
.ms-tab:hover { color: var(--foreground); }
.ms-tab svg, .ms-tab i { width: 1rem; height: 1rem; }
.ms-tab[aria-selected="true"] { color: var(--foreground); }
.ms-tab[aria-selected="true"]::after {
  content: ""; position: absolute; inset-inline: .5rem; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary);
}
.ms-tab-count {
  min-width: 1.35rem; padding: 0 .4rem; border-radius: 999px; font-size: .7rem; line-height: 1.35rem; text-align: center;
  background: var(--muted); color: var(--muted-foreground);
}
.ms-tab[aria-selected="true"] .ms-tab-count { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }

/* Panels */
.ms-panel-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .ms-panel-grid.is-split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }
.ms-facts { display: grid; gap: .1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .ms-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.5rem; } }
.ms-fact { display: flex; align-items: flex-start; gap: .75rem; padding: 1rem 0; border-bottom: 1px dashed var(--border); min-width: 0; }
.ms-fact-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2rem; height: 2rem; border-radius: .6rem; background: var(--muted); color: var(--muted-foreground); }
.ms-fact-icon svg, .ms-fact-icon i { width: 1rem; height: 1rem; }
.ms-fact dt { font-size: .72rem; font-weight: 500; color: var(--muted-foreground); }
.ms-fact dd { margin-top: .1rem; font-size: .875rem; font-weight: 500; overflow-wrap: anywhere; }
.ms-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.ms-section-head h2, .ms-section-head h3 { display: flex; align-items: center; gap: .5rem; font-size: .95rem; font-weight: 600; }
.ms-section-head h2 svg, .ms-section-head h2 i, .ms-section-head h3 svg, .ms-section-head h3 i { width: 1.05rem; height: 1.05rem; color: var(--muted-foreground); }
.ms-section-head p { margin-top: .15rem; font-size: .8rem; color: var(--muted-foreground); }
.ms-table { width: 100%; font-size: .875rem; }
.ms-table thead th { padding: .65rem 1.25rem; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); background: color-mix(in srgb, var(--muted) 55%, transparent); border-bottom: 1px solid var(--border); white-space: nowrap; }
html[lang="ar"] .ms-table thead th { text-transform: none; letter-spacing: 0; font-size: .78rem; }
.ms-table tbody td { padding: .8rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ms-table tbody tr:last-child td { border-bottom: 0; }
.ms-table tbody tr:hover td { background: color-mix(in srgb, var(--muted) 40%, transparent); }
.ms-table .num { text-align: start !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-empty { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 2.5rem 1rem; text-align: center; color: var(--muted-foreground); font-size: .85rem; }
.ms-empty svg, .ms-empty i { width: 2rem; height: 2rem; opacity: .55; }
.ms-run { font-variant-numeric: tabular-nums; color: var(--muted-foreground); font-size: .8rem; }
.ms-side { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; border-radius: .55rem; }
.ms-side svg, .ms-side i { width: .95rem; height: .95rem; }
.ms-side.is-up { background: color-mix(in srgb, var(--destructive) 12%, transparent); color: var(--destructive); }
.ms-side.is-down { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.ms-seg { display: inline-flex; flex-wrap: wrap; gap: .25rem; padding: .2rem; border-radius: .6rem; background: var(--muted); }
.ms-seg button { padding: .3rem .7rem; border-radius: .45rem; font-size: .78rem; font-weight: 500; color: var(--muted-foreground); }
.ms-seg button[aria-pressed="true"] { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px #0000001a; }

html[dir] table.ms-table :is(th, td).num,
html:not([dir]) table.ms-table :is(th, td).num { text-align: start !important; }
.ms-hero-foot > div > span { font-size: .72rem; }
.ms-table a { font-weight: 500; }
.ms-table .ms-mono { font-family: var(--font-geist-mono); font-size: .78rem; }

/* ── Orders, sales and the counter ─────────────────────────────────────── */
.ms-hero-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 4.5rem; height: 4.5rem; border-radius: 1.25rem;
  background: color-mix(in srgb, var(--ms-tone, var(--primary)) 15%, transparent);
  color: var(--ms-tone, var(--primary));
}
.ms-hero-icon svg, .ms-hero-icon i { width: 2rem; height: 2rem; }
.ms-hero-kicker { font-size: .75rem; font-weight: 500; color: var(--muted-foreground); }
.ms-hero-code { font-family: var(--font-geist-mono); letter-spacing: 0 !important; }

.ms-steps { display: flex; gap: 0; margin: 0; padding: .25rem 1.5rem 1.25rem; list-style: none; overflow-x: auto; scrollbar-width: none; }
.ms-steps::-webkit-scrollbar { display: none; }
.ms-steps li { position: relative; flex: 1 1 0; min-width: 5.5rem; display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center; }
.ms-steps li::before {
  content: ""; position: absolute; top: .875rem; inset-inline-start: calc(-50% + 1rem); inset-inline-end: calc(50% + 1rem);
  height: 2px; border-radius: 2px; background: var(--border);
}
.ms-steps li:first-child::before { display: none; }
.ms-steps li.is-done::before, .ms-steps li.is-now::before, .ms-steps li.is-stop::before { background: var(--primary); }
.ms-step-dot {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; border-radius: 999px; border: 2px solid var(--border); background: var(--card);
  font-size: .72rem; color: var(--muted-foreground);
}
.ms-step-dot svg, .ms-step-dot i { width: .9rem; height: .9rem; }
.ms-step-label { font-size: .72rem; font-weight: 500; color: var(--muted-foreground); line-height: 1.25; }
.ms-steps li.is-done .ms-step-dot { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }
.ms-steps li.is-now .ms-step-dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.ms-steps li.is-now .ms-step-label { color: var(--foreground); font-weight: 600; }
.ms-steps li.is-stop .ms-step-dot { border-color: var(--destructive); background: var(--destructive); color: var(--primary-foreground); }
.ms-steps li.is-stop .ms-step-label { color: var(--destructive); font-weight: 600; }

.ms-filters { overflow: hidden; }
.ms-filters > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; padding: .85rem 1.25rem; cursor: pointer; list-style: none;
}
.ms-filters > summary::-webkit-details-marker { display: none; }
.ms-filters-title { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 600; }
.ms-filters-title svg, .ms-filters-title i { width: 1rem; height: 1rem; color: var(--muted-foreground); }
.ms-filters-lead { flex: 1 1 12rem; font-size: .78rem; color: var(--muted-foreground); }
.ms-filters-caret { width: 1rem; height: 1rem; margin-inline-start: auto; color: var(--muted-foreground); transition: transform .15s; }
.ms-filters[open] .ms-filters-caret { transform: rotate(180deg); }
.ms-filters-body { padding: 0 1.25rem 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }

.ms-cell-stack { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.ms-cell-stack > small { font-size: .72rem; color: var(--muted-foreground); white-space: nowrap; }
.ms-nowrap, .ms-table .ms-muted { white-space: nowrap; }
.ms-code { font-family: var(--font-geist-mono); font-size: .8rem; font-weight: 600; color: var(--primary); }
.ms-tech { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; font-size: .82rem; }
.ms-tech .ms-av { width: 1.75rem; height: 1.75rem; font-size: .65rem; }

/* Counter */
.ms-pos { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1180px) { .ms-pos { grid-template-columns: minmax(0, 1.7fr) minmax(20rem, 1fr); } .ms-pos-side { position: sticky; top: 1rem; } }
.ms-item p.font-medium { white-space: nowrap; }
.ms-cart { min-width: 28rem; }
.ms-cart :is(thead th, tbody td) { padding-inline: .6rem; }
.ms-cart .ms-price { width: 5.5rem; }
.ms-cart .ms-qty button { width: 1.75rem; }
.ms-cart .ms-qty input { width: 2.5rem; }
.ms-cart .ms-item { gap: .6rem; }
.ms-cart :is(thead th, tbody td):first-child { padding-inline-start: 1.25rem; }
.ms-scan { position: relative; flex: 1 1 auto; min-width: 0; }
.ms-scan > svg, .ms-scan > i { position: absolute; inset-inline-start: .85rem; top: 50%; width: 1.1rem; height: 1.1rem; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.ms-scan .apex-input { height: 2.75rem; padding-inline-start: 2.6rem; font-size: .95rem; }
.ms-item { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.ms-item-mark { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2.25rem; height: 2.25rem; border-radius: .7rem; background: var(--muted); color: var(--muted-foreground); }
.ms-item-mark svg, .ms-item-mark i { width: 1rem; height: 1rem; }
.ms-stock { font-size: .72rem; color: var(--muted-foreground); }
.ms-stock.is-low { color: color-mix(in srgb, var(--warning) 70%, var(--foreground)); font-weight: 600; }
.ms-qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: .6rem; overflow: hidden; background: var(--card); }
.ms-qty button { display: flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; color: var(--muted-foreground); }
.ms-qty button:hover { background: var(--muted); color: var(--foreground); }
.ms-qty button svg, .ms-qty button i { width: .85rem; height: .85rem; }
.ms-qty input { width: 3rem; height: 2rem; border: 0; border-inline: 1px solid var(--border); background: transparent; text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.ms-qty input::-webkit-inner-spin-button, .ms-qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ms-price { width: 7rem; height: 2rem; text-align: start; font-variant-numeric: tabular-nums; }
.ms-total {
  border-radius: calc(var(--radius) + 6px); padding: 1rem 1.15rem;
  background: color-mix(in srgb, var(--primary) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
}
.ms-total-label { font-size: .75rem; font-weight: 500; color: var(--muted-foreground); }
.ms-total-value { margin-top: .2rem; font-size: 2rem; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--foreground); }
.ms-total-rows { display: grid; gap: .3rem; margin-top: .75rem; padding-top: .65rem; border-top: 1px dashed color-mix(in srgb, var(--primary) 30%, var(--border)); font-size: .8rem; }
.ms-total-rows div { display: flex; justify-content: space-between; gap: .75rem; color: var(--muted-foreground); }
.ms-total-rows b { font-weight: 600; color: var(--foreground); font-variant-numeric: tabular-nums; }
.ms-step-title { display: flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 600; color: var(--foreground); }
.ms-step-title > span:first-child { display: inline-flex; align-items: center; justify-content: center; width: 1.35rem; height: 1.35rem; border-radius: 999px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-size: .7rem; }
.ms-ready { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--success); }
.ms-ready svg, .ms-ready i { width: .95rem; height: .95rem; }
.ms-checkout { height: 3rem; font-size: 1rem; font-weight: 600; }
.ms-sum-line { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--border); font-size: .875rem; }
.ms-sum-line:last-child { border-bottom: 0; }
.ms-sum-line span { color: var(--muted-foreground); }
.ms-sum-line b { font-weight: 600; font-variant-numeric: tabular-nums; }
.ms-sum-line.is-total b { font-size: 1.1rem; font-weight: 800; }
.ms-sum-line.is-due b { color: var(--destructive); }
/* ── Dashboard, catalog and reports ───────────────────────────────────── */
.ms-stock-num { display: inline-flex; align-items: baseline; gap: .35rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-stock-num small { font-size: .68rem; font-weight: 600; }
.ms-stock-num.is-low { color: color-mix(in srgb, var(--warning) 75%, var(--foreground)); }
.ms-cell-stack.ms-end { align-items: flex-end; }
/* Inside tables every column follows the language: right in Arabic, left in English. */
table:not(.ms-slip) :is(th, td) .ms-cell-stack.ms-end { align-items: flex-start; }
.ms-note { display: grid; gap: .6rem; padding: 1rem 1.25rem; }
.ms-split { display: flex; height: .5rem; overflow: hidden; border-radius: 999px; background: var(--muted); }
.ms-split > span:first-child { background: color-mix(in srgb, var(--muted-foreground) 40%, transparent); }
.ms-split > span.is-gain { background: var(--success); }
.ms-split > span.is-loss { background: var(--destructive); }
.ms-split-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; font-size: .78rem; color: var(--muted-foreground); }
.ms-split-legend > span { display: inline-flex; align-items: center; gap: .4rem; font-variant-numeric: tabular-nums; }
.ms-split-legend i { display: inline-block; width: .6rem; height: .6rem; border-radius: 999px; }
.ms-split-legend i.is-cost { background: color-mix(in srgb, var(--muted-foreground) 40%, transparent); }
.ms-split-legend i.is-gain { background: var(--success); }
.ms-note-text { display: flex; align-items: flex-start; gap: .5rem; font-size: .78rem; color: var(--muted-foreground); }
.ms-note-text > svg, .ms-note-text > i { flex-shrink: 0; width: .95rem; height: .95rem; margin-top: .1rem; }

.ms-kpi-spark { flex-direction: column; align-items: stretch; gap: .25rem; padding-bottom: 0; overflow: hidden; }
.ms-kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
/* The row fills the box so the icon sits at the far edge (left in Arabic), not beside the text. */
.ms-kpi > .ms-kpi-top { flex: 1 1 auto; min-width: 0; }
/* Button-style tabs on an underlined row need room above the line. */
.ms-tabs:has(> button:not(.ms-tab)) { padding-bottom: .75rem; }
.ms-kpi-chart { position: relative; width: calc(100% + 2.25rem); height: 64px; min-height: 64px; margin: .35rem -1.125rem 0; line-height: 0; color: var(--ms-tone, var(--primary)); }
.ms-spark { display: block; width: 100%; height: 64px; }
.ms-kpi-chart .apexcharts-canvas, .ms-kpi-chart .apexcharts-svg { overflow: visible; }
.ms-kpi-chart .apexcharts-tooltip { font-size: .72rem; box-shadow: 0 6px 18px -8px #0000004d; }
.ms-kpi-chart svg, .ms-kpi-chart .apexcharts-canvas { display: block; }
.ms-kpi-hint p { font-size: inherit; }
.ms-kpi-sub { display: block; margin-top: .15rem; font-size: .78rem; font-weight: 500; color: var(--muted-foreground); }
.ms-dash-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .45rem; font-size: .78rem; color: var(--muted-foreground); }
.ms-dash-shop { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; color: var(--foreground); }
.ms-dash-shop svg, .ms-dash-shop i { width: .9rem; height: .9rem; color: var(--muted-foreground); }
.ms-section-head > a { font-size: .78rem; font-weight: 500; color: var(--primary); }
.ms-stock-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.ms-stock-stats > div { min-width: 0; padding: .85rem 1rem; background: var(--card); }
.ms-stock-stats > div + div { border-inline-start: 1px solid var(--border); }
#diag-root .apex-card.p-4 > .ms-section-head,
#diag-root .apex-card.space-y-3 > .ms-section-head { margin: -1rem -1rem .25rem !important; padding: 1rem 1.25rem !important; }
#diag-root .apex-card.overflow-hidden > .ms-section-head { padding: 1rem 1.25rem !important; }
#diag-root #facts-panel { padding: 1rem 1.15rem; }
.ms-dash-list > li { padding: .75rem 1.25rem; border-bottom: 1px solid var(--border); }
#promo-root .promo-layout { display: grid; gap: 1rem; align-items: stretch; }
@media (min-width: 1280px) { #promo-root .promo-layout { grid-template-columns: minmax(0, 1.15fr) minmax(20rem, .85fr); } }
#promo-root .promo-clients { display: flex; flex-direction: column; min-height: 36rem; height: 100%; }
#promo-root .promo-scroll { flex: 1 1 auto; min-height: 32rem; height: calc(100vh - 16rem); overflow: auto; }
.ms-dash-list > li:last-child { border-bottom: 0; }
.dashboard-overview .apex-card { overflow: hidden; }

.ms-sticky th { position: sticky; top: 0; z-index: 1; background: color-mix(in srgb, var(--muted) 55%, var(--card)) !important; }
.ms-report-dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding: 1rem 1.25rem 1.25rem; font-size: .875rem; }
@media (min-width: 640px) { .ms-report-dl { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media print { .ms-filters, .ms-tabs, .ms-ph-actions { display: none !important; } }

/* ── Converted legacy pages ───────────────────────────────────────────── */
.ms-kpi-legacy { position: relative; overflow: hidden; border: 1px solid var(--border) !important; border-radius: calc(var(--radius) + 4px) !important; box-shadow: none !important; background: var(--card); transition: border-color .15s, transform .15s; }
.ms-kpi-legacy::before, .ms-kpi::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--ms-tone, var(--primary)); border-start-start-radius: inherit; border-end-start-radius: inherit; }
:is(a, button).ms-kpi-legacy:hover { border-color: color-mix(in srgb, var(--ms-tone, var(--primary)) 45%, var(--border)); box-shadow: 0 4px 14px -6px #00000026; transform: translateY(-1px); }
.ms-kpi-legacy p.text-2xl { font-size: 1.45rem; line-height: 1.15; }
.ms-kpi-legacy-well { border-radius: .85rem !important; }
.apex-card > .ms-section-head { padding: 1rem 1.25rem !important; margin: 0 !important; border-bottom: 1px solid var(--border); }
/* Only for a body with no padding of its own; a bordered box with p-3 keeps its own space. */
.apex-card > .ms-section-head + :where(:not([class^="p-"]):not([class*=" p-"]):not([class*=":p-"]):not([class^="pt-"]):not([class*=" pt-"]):not([class*=":pt-"]):not([class^="py-"]):not([class*=" py-"]):not([class*=":py-"])) { padding-top: 1rem; }
.ms-sh-title { font-size: .95rem !important; font-weight: 600; }
main .ms-ph + .settings-subnav, main .ms-ph ~ .settings-subnav { margin-top: .25rem; }

/* ── Notifications ────────────────────────────────────────────────────── */
.ms-note-badge { position: absolute; top: -.2rem; inset-inline-end: -.25rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .3rem; border-radius: 999px; background: var(--destructive); color: #fff; font-size: .62rem; font-weight: 700; line-height: 1.1rem; text-align: center; box-shadow: 0 0 0 2px var(--background); pointer-events: none; }
.ms-note-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.ms-note-count { min-width: 1.3rem; padding: .05rem .45rem; border-radius: 999px; background: color-mix(in srgb, var(--destructive) 14%, transparent); color: var(--destructive); font-size: .7rem; font-weight: 700; text-align: center; }
.ms-note-read { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; color: var(--primary); }
.ms-search-close { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 1.75rem; height: 1.75rem; border-radius: .45rem; color: var(--muted-foreground); }
.ms-search-close:hover { background: var(--muted); color: var(--foreground); }
.ms-search-close svg, .ms-search-close i { width: 1rem; height: 1rem; }
.ms-note-read:disabled { color: var(--muted-foreground); opacity: .6; cursor: default; }
.ms-note-tabs { display: flex; gap: .25rem; padding: .5rem 1rem; border-bottom: 1px solid var(--border); }
.ms-note-tabs button { padding: .25rem .7rem; border-radius: 999px; font-size: .75rem; font-weight: 500; color: var(--muted-foreground); }
.ms-note-tabs button[aria-pressed="true"] { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.ms-note-day { position: sticky; top: 0; z-index: 1; padding: .4rem 1rem; font-size: .68rem; font-weight: 600; letter-spacing: .03em; color: var(--muted-foreground); background: color-mix(in srgb, var(--muted) 60%, var(--popover)); }
.ms-note { position: relative; display: flex; align-items: flex-start; gap: .75rem; width: 100%; padding: .7rem 1rem; text-align: start; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); transition: background .15s; }
a.ms-note:hover { background: color-mix(in srgb, var(--accent) 60%, transparent); }
.ms-note.is-new { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.ms-note-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2rem; height: 2rem; border-radius: .7rem; background: color-mix(in srgb, var(--ms-tone, var(--muted-foreground)) 13%, transparent); color: var(--ms-tone, var(--muted-foreground)); }
.ms-note-icon svg, .ms-note-icon i { width: 1rem; height: 1rem; }
.ms-note-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .82rem; font-weight: 500; line-height: 1.35; }
.ms-note-meta { display: block; margin-top: .25rem; font-size: .68rem; color: var(--muted-foreground); }
.ms-note-new { flex-shrink: 0; width: .5rem; height: .5rem; margin-top: .4rem; border-radius: 999px; background: var(--primary); }
.ms-note-empty { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 2.25rem 1rem; color: var(--muted-foreground); font-size: .82rem; }
.ms-note-empty svg, .ms-note-empty i { width: 1.75rem; height: 1.75rem; opacity: .5; }
.ms-note-badge { animation: ms-note-pulse 1.8s ease-in-out infinite; }
@keyframes ms-note-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.ms-note-panel {
  width: 22.5rem; max-width: calc(100vw - 1.5rem); overflow: hidden;
}
.ms-note-panel [data-note-list] { max-height: 16rem; overflow: auto; }
.ms-note-panel .ms-note, .ms-note-panel .ms-note-text, .ms-note-panel .ms-note-meta {
  min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere;
}
.dashboard-overview .ms-kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); }
.dashboard-overview .ms-kpi { height: 100%; }
.dashboard-overview .ms-kpi > .min-w-0 { flex: 1 1 auto; min-width: 0; }
.dashboard-overview .ms-kpi-value, .dashboard-overview .ms-kpi-hint { overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .dashboard-overview .ms-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
#intake-form { display: flex; flex-direction: column; gap: 1rem; }
#intake-form.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 0; }
#intake-form .apex-card { display: flex; flex-direction: column; gap: 1rem; }
#intake-form .apex-card > .ms-section-head { padding: 0 0 .85rem !important; margin: 0 !important; }
#intake-form label.ring-1 { box-shadow: none !important; }
#intake-form .intake-line {
  display: flex; flex-direction: column; gap: .75rem; padding: 1rem;
  border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px);
  background: color-mix(in srgb, var(--muted) 22%, var(--card));
}
#intake-form .intake-grid { display: grid; gap: .75rem 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { #intake-form .intake-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#intake-form .intake-grid > * { min-width: 0; }
#intake-form .apex-input, #intake-form .apex-select { width: 100%; min-height: 2.5rem; }
#intake-form .intake-total > .flex { min-height: 1.6rem; align-items: center; gap: .75rem; }
#intake-form .intake-total > .flex > :last-child { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
#intake-form .intake-layout { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 1100px) { #intake-form .intake-layout { grid-template-columns: minmax(0, 1.45fr) minmax(18rem, .8fr); } }
.ms-note-tools { display: grid; gap: .45rem; padding: .55rem .75rem .65rem; border-bottom: 1px solid var(--border); }
.ms-note-areas { display: flex; flex-wrap: wrap; gap: .3rem; }
.ms-note-areas button, .ms-note-mute { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 600; color: var(--muted-foreground); }
.ms-note-areas button[aria-pressed="true"] { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.ms-note-mute[aria-pressed="true"] { background: color-mix(in srgb, var(--warning) 16%, transparent); color: color-mix(in srgb, var(--warning) 70%, var(--foreground)); }
.ms-note-tools-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.ms-note-mute svg, .ms-note-mute i { width: .85rem; height: .85rem; }

.ms-toasts {
  position: fixed; inset-inline-end: 1rem; bottom: 1rem; z-index: 80;
  display: flex; flex-direction: column; gap: .55rem; width: min(22rem, calc(100vw - 2rem)); pointer-events: none;
}
.ms-toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: .7rem;
  padding: .8rem .85rem; border-radius: .9rem; border: 1px solid var(--border);
  background: var(--popover); color: var(--popover-foreground);
  box-shadow: 0 12px 32px -14px #0000004d; animation: ms-toast-in .22s ease;
}
.ms-toast.is-out { animation: ms-toast-out .2s ease forwards; }
.ms-toast[data-tone="success"] { --ms-tone: var(--success); }
.ms-toast[data-tone="danger"] { --ms-tone: var(--destructive); }
.ms-toast[data-tone="warning"] { --ms-tone: var(--warning); }
.ms-toast[data-tone="info"] { --ms-tone: var(--primary); }
.ms-toast-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 1.85rem; height: 1.85rem; border-radius: .6rem;
  background: color-mix(in srgb, var(--ms-tone, var(--primary)) 14%, transparent);
  color: var(--ms-tone, var(--primary));
}
.ms-toast-icon svg, .ms-toast-icon i { width: 1rem; height: 1rem; }
.ms-toast-text { flex: 1 1 auto; min-width: 0; font-size: .85rem; font-weight: 500; line-height: 1.4; }
.ms-toast-close {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 1.4rem; height: 1.4rem; border-radius: .4rem; color: var(--muted-foreground);
}
.ms-toast-close:hover { background: var(--muted); color: var(--foreground); }
.ms-toast-close svg, .ms-toast-close i { width: .85rem; height: .85rem; }
@keyframes ms-toast-in { from { opacity: 0; transform: translateY(.6rem); } to { opacity: 1; transform: none; } }
@keyframes ms-toast-out { to { opacity: 0; transform: translateY(.4rem); } }

.ms-form-card { overflow: hidden; }
.ms-form-card > .ms-section-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.ms-form-steps { display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 1100px) { .ms-form-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 1fr); gap: 1rem; align-items: start; } }

button.ms-pick, .ms-pick { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .7rem 1.15rem; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; text-align: start; }
button.ms-pick { font: inherit; cursor: pointer; }
button.ms-pick:hover { background: color-mix(in srgb, var(--muted) 50%, transparent); }
.ms-pick.is-on { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.ms-pick-card { border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--border)); border-radius: calc(var(--radius) + 4px); background: color-mix(in srgb, var(--primary) 6%, var(--card)); }
.ms-pick .ms-av { width: 2.25rem; height: 2.25rem; font-size: .78rem; }
.ms-pick-mark { margin-inline-start: auto; width: 1rem; height: 1rem; flex-shrink: 0; color: var(--muted-foreground); }
.ms-pick.is-on .ms-pick-mark { color: var(--primary); }
.ms-pick-amt { margin-top: .35rem; }

.ms-people .apex-card:not([class*="border-"]) {
  border: 1px solid var(--border);
  box-shadow: none;
  border-radius: calc(var(--radius) + 4px);
}
.apex-card.p-3 > .ms-section-head,
.apex-card.p-3.space-y-2 > .ms-section-head,
.apex-card.p-3.space-y-3 > .ms-section-head,
.apex-card.p-3.space-y-4 > .ms-section-head,
.apex-card.p-3.space-y-5 > .ms-section-head {
  margin: -.75rem -.75rem .5rem !important;
  padding: .9rem 1rem !important;
}
.apex-card.p-4 > .ms-section-head,
.apex-card.p-4.space-y-2 > .ms-section-head,
.apex-card.p-4.space-y-3 > .ms-section-head,
.apex-card.p-4.space-y-4 > .ms-section-head,
.apex-card.p-4.space-y-5 > .ms-section-head {
  margin: -1rem -1rem .5rem !important;
  padding: 1rem 1.25rem !important;
}
.apex-card.p-5 > .ms-section-head,
.apex-card.p-5.space-y-2 > .ms-section-head,
.apex-card.p-5.space-y-3 > .ms-section-head,
.apex-card.p-5.space-y-4 > .ms-section-head,
.apex-card.p-5.space-y-5 > .ms-section-head {
  margin: -1.25rem -1.25rem .5rem !important;
  padding: 1rem 1.25rem !important;
}
.apex-card.p-6 > .ms-section-head,
.apex-card.p-6.space-y-2 > .ms-section-head,
.apex-card.p-6.space-y-3 > .ms-section-head,
.apex-card.p-6.space-y-4 > .ms-section-head,
.apex-card.p-6.space-y-5 > .ms-section-head {
  margin: -1.5rem -1.5rem .5rem !important;
  padding: 1.1rem 1.5rem !important;
}
main .divide-y > li { padding-block: .9rem; }
main .border-t.pt-2 { padding-top: .9rem !important; }
:is(.apex-card.space-y-2, .apex-card.space-y-3, .apex-card.space-y-4, .apex-card.space-y-5) > .ms-section-head + :where(:not([class^="p-"]):not([class*=" p-"]):not([class*=":p-"]):not([class^="pt-"]):not([class*=" pt-"]):not([class*=":pt-"]):not([class^="py-"]):not([class*=" py-"]):not([class*=":py-"])) { padding-top: 0; }

.ms-scan-group + .ms-scan-group { margin-top: 1rem; }
.ms-scan-label { margin: 0 0 .4rem; font-size: .72rem; font-weight: 600; letter-spacing: .02em; color: var(--muted-foreground); }
/* The checklist list only — the sale page's barcode field is also .ms-scan (a label) and must keep a single border. */
ul.ms-scan { border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); overflow: hidden; background: var(--card); }
.ms-scan-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .85rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.ms-scan-row:last-child { border-bottom: 0; }
.ms-scan-row .ms-pill { flex-shrink: 0; margin-top: .1rem; }

.ms-cable { border: 1px solid var(--border); border-radius: calc(var(--radius) + 6px); background: color-mix(in srgb, var(--muted) 22%, var(--card)); overflow: hidden; }
.ms-cable-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .95rem 1.15rem; border-bottom: 1px solid var(--border); }
.ms-cable-body { display: flex; flex-direction: column; gap: 1rem; max-height: 28rem; overflow: auto; padding: 1.05rem 1.15rem 1.2rem; }
.ms-cable-note { padding-top: 1rem; border-top: 1px solid var(--border); }
.ms-pipe-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem 1rem; margin: -1.5rem -1.5rem 1rem; padding: 1.15rem 1.5rem 1.05rem; border-bottom: 1px solid var(--border); }
.ms-pipe-head p { margin: .35rem 0 0; }
.ms-pipe { display: flex; flex-direction: column; gap: .95rem; }
.ms-pipe-label { margin: 0 0 .45rem; font-size: .72rem; font-weight: 600; color: var(--muted-foreground); }
.ms-pipe-row { display: flex; flex-wrap: wrap; gap: .5rem; }
button.ms-pipe-chip { padding: .55rem .95rem; border: 1px solid var(--border); border-radius: .65rem; background: color-mix(in srgb, var(--muted) 42%, var(--card)); color: var(--foreground); font: inherit; font-size: .8rem; font-weight: 500; line-height: 1.35; cursor: pointer; }
button.ms-pipe-chip:hover { background: color-mix(in srgb, var(--accent) 65%, var(--card)); }
button.ms-pipe-chip.is-now { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }
button.ms-pipe-chip.is-done { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: color-mix(in srgb, var(--primary) 10%, var(--card)); }
.ms-pipe-done { margin: 0; padding: .9rem 1rem; border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border)); border-radius: .75rem; background: color-mix(in srgb, var(--success) 10%, var(--card)); font-size: .875rem; }
.ms-pipe-foot { display: flex; flex-direction: column; gap: .75rem; padding-top: 1.05rem; border-top: 1px solid var(--border); }
.ms-tech-act { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .65rem; }
#active-orders .space-y-4 > div:has(table) { overflow-x: auto; }

.ms-party { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; min-width: 0; color: inherit; }
.ms-party .ms-who { flex: 1 1 auto; }
.ms-party .ms-who-name { overflow: hidden; text-overflow: ellipsis; }
.ms-party .ms-amt { align-items: flex-end; flex: 0 0 auto; }
.ms-party:hover .ms-who-name { color: var(--primary); }
.ms-dash-list > li.is-empty { color: var(--muted-foreground); font-size: .875rem; }

@media (max-width: 767px) {
  #main-content { padding: .85rem !important; overflow-x: hidden; }
  .ms-ph { align-items: stretch; gap: .75rem; }
  .ms-ph h1 { font-size: 1.2rem; }
  .ms-ph-icon { width: 2.4rem; height: 2.4rem; border-radius: .75rem; }
  .ms-ph-icon svg, .ms-ph-icon i { width: 1.15rem; height: 1.15rem; }
  .ms-ph-actions { width: 100%; }
  .ms-ph-actions .apex-btn { flex: 1 1 calc(50% - .5rem); justify-content: center; min-width: 0; }
  .apex-card > .ms-section-head,
  .apex-card.p-3 > .ms-section-head,
  .apex-card.p-4 > .ms-section-head,
  .apex-card.p-5 > .ms-section-head,
  .apex-card.p-6 > .ms-section-head,
  .apex-card.p-6.space-y-4 > .ms-section-head { padding: .85rem 1rem !important; align-items: flex-start; }
  .apex-card.p-3 > .ms-section-head { margin-inline: -.75rem !important; }
  .apex-card.p-4 > .ms-section-head { margin-inline: -1rem !important; }
  .apex-card.p-5 > .ms-section-head { margin-inline: -1.25rem !important; }
  .apex-card.p-6 > .ms-section-head,
  .apex-card.p-6.space-y-4 > .ms-section-head { margin-inline: -1.5rem !important; }
  .ms-section-head h2, .ms-section-head h3 { font-size: .9rem; min-width: 0; }
  .ms-section-head p { overflow-wrap: anywhere; }
  .ms-kpi { padding: .85rem .9rem; }
  .ms-kpi-value { font-size: 1.15rem; }
  .ms-table thead th, .ms-table tbody td { padding: .7rem .8rem; }
  #main-content div:has(> table),
  #main-content apex-data-table .space-y-4 > div:has(table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  #main-content div:has(> table)::-webkit-scrollbar,
  #main-content apex-data-table .space-y-4 > div:has(table)::-webkit-scrollbar { height: .55rem; }
  #main-content div:has(> table)::-webkit-scrollbar-thumb,
  #main-content apex-data-table .space-y-4 > div:has(table)::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
  #main-content .receipt-card div:has(> table) { overflow: visible; }
  .dashboard-overview .border-t.px-6 { padding-inline: 1rem !important; padding-block: .85rem !important; }
  .ms-filters > summary { padding: .8rem 1rem; }
  .ms-steps { padding-inline: .75rem; }
  .ms-pipe-chip { font-size: .78rem; }
  .ms-dash-meta { gap: .35rem .5rem; }
  apex-header .apex-btn, #main-content .apex-input, #main-content .apex-select { max-width: 100%; }
}
.ms-pad { padding: .9rem 1rem !important; }
.ms-log { padding: .95rem 1.05rem !important; }

/* ── Settings ─────────────────────────────────────────────────────────── */
/* Section list as a sticky card; sub-sections as underline tabs; one content width. */
.settings-layout { gap: 1.5rem; }
.settings-nav {
  gap: .15rem; padding: .5rem; border: 1px solid var(--border); border-radius: 1rem;
  background: var(--card); box-shadow: 0 1px 2px #0000000d;
}
.settings-tab { position: relative; min-height: 2.5rem; padding: .55rem .75rem; border: 0; border-radius: .65rem; font-weight: 500; transition: background .15s, color .15s; }
.settings-tab svg, .settings-tab i { width: 1.05rem; height: 1.05rem; flex-shrink: 0; opacity: .75; }
.settings-tab.is-active { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); font-weight: 600; }
.settings-tab.is-active svg, .settings-tab.is-active i { opacity: 1; }
.settings-tab.is-active::before {
  content: ""; position: absolute; inset-block: .55rem; inset-inline-start: -.5rem; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--primary);
}
[dir="rtl"] .settings-tab.is-active::before { border-radius: 3px 0 0 3px; }
.settings-main { max-width: 60rem; }
.settings-main > .mb-4:not(.hidden) { margin-bottom: 1.25rem; }
.settings-subnav {
  width: 100% !important; gap: .25rem; padding: 0; border-radius: 0; background: transparent;
  border-bottom: 1px solid var(--border); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.settings-subnav::-webkit-scrollbar { display: none; }
.settings-subnav > button {
  flex: 0 0 auto; padding: .6rem .85rem !important; border-radius: 0 !important; margin-bottom: -1px;
  background: transparent !important; box-shadow: none !important; color: var(--muted-foreground) !important;
  border-bottom: 2px solid transparent; white-space: nowrap; font-size: .875rem;
}
.settings-subnav > button:hover { color: var(--foreground) !important; }
.settings-subnav > button.bg-background { color: var(--foreground) !important; font-weight: 600; border-bottom-color: var(--primary); }
.settings-main .apex-card { border-radius: 1rem; }
.settings-main .apex-card + .apex-card { margin-top: 1rem; }
@media (max-width: 767px) {
  .settings-layout { padding-inline: 0; }
  .settings-nav {
    display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: .35rem;
    padding: .35rem; border-radius: .85rem;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-tab { width: auto; flex: 0 0 auto; white-space: nowrap; min-height: 2.25rem; padding: .45rem .75rem; }
  .settings-tab.is-active::before { display: none; }
}

/* Settings → Messages: order assignment message card. */
.ms-assign-card { display: grid; gap: 1rem; margin-bottom: 1rem; padding: 1.25rem 1.5rem; border-color: color-mix(in srgb, var(--primary) 35%, var(--border)) !important; }
.ms-assign-head { display: flex; align-items: flex-start; gap: .85rem; }
.ms-assign-head h3 { font-size: 1rem; font-weight: 650; }
.ms-assign-head p { margin-top: .2rem; font-size: .82rem; line-height: 1.55; color: var(--muted-foreground); }
.ms-assign-icon { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; flex-shrink: 0; border-radius: .75rem; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.ms-assign-icon svg { width: 1.2rem; height: 1.2rem; }
.ms-assign-card .ms-assign-switch { margin-bottom: 0; }
.ms-assign-switch--sub { border-style: dashed; background: transparent; }
.ms-assign-vars { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted-foreground); }
.ms-assign-vars [data-var] { padding: .2rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: var(--muted); color: var(--foreground); font-family: var(--font-geist-mono, ui-monospace, monospace); font-size: .74rem; direction: ltr; }
.ms-assign-vars [data-var]:hover { border-color: var(--primary); color: var(--primary); }
.ms-assign-reset { margin-inline-start: auto; color: var(--primary); font-weight: 500; }
.ms-assign-preview { padding: .85rem 1rem; border-radius: .75rem; background: color-mix(in srgb, var(--success, #16a34a) 9%, var(--card)); border: 1px dashed color-mix(in srgb, var(--success, #16a34a) 35%, var(--border)); }
.ms-assign-preview-label { display: block; margin-bottom: .3rem; font-size: .72rem; font-weight: 600; color: var(--muted-foreground); }
.ms-assign-preview p { white-space: pre-wrap; font-size: .9rem; line-height: 1.6; }
@media (max-width: 639px) { .ms-assign-card { padding: 1rem; } .ms-assign-reset { margin-inline-start: 0; } }

/* Settings → Messages: switch for the technician WhatsApp on assignment. */
.ms-assign-switch {
  display: flex; align-items: flex-start; gap: .65rem; margin-bottom: .75rem; padding: .8rem .9rem;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); border-radius: .75rem;
  background: color-mix(in srgb, var(--primary) 6%, var(--card)); cursor: pointer;
}
.ms-assign-switch input { margin-top: .15rem; flex-shrink: 0; }
.ms-assign-switch b { display: block; font-size: .875rem; font-weight: 600; }
.ms-assign-switch small { display: block; margin-top: .2rem; font-size: .78rem; line-height: 1.5; color: var(--muted-foreground); }

/* ── Text editor ──────────────────────────────────────────────────────── */
.te-dialog { width: min(72rem, 96vw); max-width: 72rem; max-height: 92vh; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.te-dialog:not([open]) { display: none; }
.te-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.te-head h3 { font-size: 1rem; font-weight: 600; }
.te-head p { margin-top: .2rem; font-size: .8rem; color: var(--muted-foreground); }
.te-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .75rem 1.25rem; }
.te-bar > .apex-input, .te-bar > .apex-select { height: 2.25rem; }
.te-lang { width: auto; min-width: 9rem; }
.te-search { flex: 1 1 16rem; }
.te-seg { display: inline-flex; height: 2.25rem; padding: .2rem; border-radius: .6rem; background: var(--muted); }
.te-seg button { padding: 0 .75rem; border-radius: .45rem; font-size: .8rem; font-weight: 500; color: var(--muted-foreground); }
.te-seg button.is-on { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px #0000001a; }
.te-replace { border-block: 1px solid var(--border); }
.te-replace > summary { cursor: pointer; padding: .6rem 1.25rem; font-size: .82rem; font-weight: 500; color: var(--primary); }
.te-replace .te-bar { padding-top: 0; }
.te-replace .apex-input { flex: 1 1 12rem; }
.te-hint { font-size: .78rem; color: var(--muted-foreground); }
.te-table-wrap { flex: 1 1 auto; min-height: 12rem; overflow: auto; border-top: 1px solid var(--border); }
.te-table { width: 100%; border-collapse: collapse; font-size: .84rem; table-layout: fixed; }
.te-table thead th { position: sticky; top: 0; z-index: 1; padding: .55rem .75rem; text-align: start; font-size: .75rem; font-weight: 600; color: var(--muted-foreground); background: color-mix(in srgb, var(--muted) 70%, var(--card)); border-bottom: 1px solid var(--border); }
.te-table thead th:nth-child(1), .te-table thead th:nth-child(2) { width: 32%; }
.te-table thead th:nth-child(4) { width: 3rem; }
.te-table td { padding: .5rem .75rem; vertical-align: top; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.te-source { color: var(--muted-foreground); font-size: .78rem; }
.te-base { color: var(--foreground); }
.te-input { width: 100%; height: auto; min-height: 2.25rem; padding-block: .45rem; resize: vertical; font-size: .84rem; line-height: 1.4; }
.te-edited td { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.te-edited .te-input { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.te-empty { padding: 2rem !important; text-align: center; color: var(--muted-foreground); }
.te-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1.25rem; border-top: 1px solid var(--border); }
.te-pager { display: flex; align-items: center; gap: .5rem; }
.te-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-inline-start: auto; }
.te-import { cursor: pointer; }
.te-danger { color: var(--destructive); }
.te-status { width: 100%; order: -1; font-size: .8rem; color: var(--primary); }
html.te-picking .te-hover { outline: 2px dashed var(--primary) !important; outline-offset: 2px; cursor: text !important; }
#te-pick-bar { position: fixed; z-index: 60; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem .6rem 1rem; border: 1px solid var(--border); border-radius: .85rem; background: var(--popover, var(--card)); box-shadow: 0 10px 30px -10px #00000059; font-size: .84rem; }
@media (max-width: 639px) {
  .te-table thead th:nth-child(2), .te-table td:nth-child(2) { display: none; }
  .te-table thead th:nth-child(1) { width: 40%; }
  #te-pick-bar { left: 1rem; right: 1rem; transform: none; }
}

/* ── Consistency layer ────────────────────────────────────────────────── */
/* One control height: 2.25rem on desktop, 2.5rem on phones. A field and the
   buttons in the same row always match. In-table controls (h-8) stay compact. */
.ms-scan .apex-input { height: 2.25rem; padding-inline-start: 2.5rem; font-size: .875rem; }
.ms-scan > svg, .ms-scan > i { width: 1rem; height: 1rem; }
#intake-form :is(.apex-input, .apex-select):not(textarea) { min-height: 0; }
:is(.apex-input, .apex-select).h-8 { height: 2rem; }
:is(.flex, .grid):has(> :is(.apex-input, .apex-select):not(.h-8), > * > :is(.apex-input, .apex-select):not(.h-8), > * > * > :is(.apex-input, .apex-select):not(.h-8)) > .apex-btn-sm { height: 2.25rem; }
/* Filter chips grouped beside a search field (vouchers, promotion). */
:is(.flex, .grid):has(> :is(.apex-input, .apex-select):not(.h-8), > * > :is(.apex-input, .apex-select):not(.h-8), > * > * > :is(.apex-input, .apex-select):not(.h-8)) > .flex > :is(.apex-btn-sm, .flex > .apex-btn-sm) { height: 2.25rem; }
#dir-filters > .apex-btn-sm { height: 2.25rem; }
/* Segmented tabs (bg-muted p-1 group) total 2.25rem, like a field. */
.rounded-lg.bg-muted.p-1 > .apex-tab { height: 1.75rem; padding-block: 0; display: inline-flex; align-items: center; }
/* "Client (optional …)" hint beside a step title. */
.ms-step-title .font-normal.text-muted-foreground { margin-inline-start: .3rem; }

/* A card body under a section head: tables sit flush under the divider,
   data tables get the same inner gutter as the head (1.25rem). */
.apex-card > .ms-section-head + [class*="overflow-"]:has(> table) { padding-top: 0; }
/* A body that starts with a table, through any number of plain wrappers, sits flush under the divider. */
.apex-card > .ms-section-head + :is(:has(> table:first-child), :has(> :first-child > table:first-child), :has(> :first-child > :first-child > table:first-child)) { padding-top: 0; }
.apex-card > .ms-section-head + :has(apex-data-table) { padding: 1rem 1.25rem 1.25rem; }
.ms-cart :is(thead th, tbody td):last-child { padding-inline-end: 1.25rem; }
.te-empty { text-align: start !important; }

/* Accounting: tighter toolbar, six cash-book cards as a 3 × 2 grid, readable hints. */
#books-tools { margin-bottom: 1rem; }
#cash-book > .ms-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#cash-book .ms-kpi { height: 100%; }
#cash-book .ms-kpi-hint, #books-body .ms-kpi-hint { line-height: 1.55; overflow-wrap: normal; }
#books-body section.rounded-xl > h2 { font-size: .95rem; font-weight: 600; }
#books-body section.rounded-xl > h2 + p { margin-bottom: .75rem; }
#books-body .tabular-nums, #books-body .font-mono { unicode-bidi: isolate; }
@media (max-width: 1023px) { #cash-book > .ms-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) {
  #books-body .grid:has(> .ms-kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  #books-body .ms-kpi { padding: .8rem .85rem; }
  #books-body .ms-kpi .ms-kpi-well { display: none; }
  #books-body [class*="grid-cols-[minmax(0,1fr)_9.5rem]"] { grid-template-columns: minmax(0, 1fr) 6.5rem; gap: .75rem; }
}

/* Device check: readable checks grouped by section, state on the edge. */
.ms-checks { display: grid; gap: 1rem; }
.ms-check-group h4 { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; font-size: .78rem; font-weight: 600; color: var(--muted-foreground); }
.ms-check-group h4 span { min-width: 1.3rem; padding: 0 .4rem; border-radius: 999px; background: var(--muted); font-size: .68rem; line-height: 1.3rem; text-align: center; }
.ms-check-grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
.ms-check { --ms-c: var(--muted-foreground); position: relative; overflow: hidden; padding: .6rem .75rem; padding-inline-start: .95rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--card); }
.ms-check::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--ms-c); }
.ms-check.is-ok { --ms-c: #16a34a; }
.ms-check.is-warn { --ms-c: #d97706; }
.ms-check.is-fail { --ms-c: var(--destructive); }
.ms-check.is-fail { background: color-mix(in srgb, var(--destructive) 5%, var(--card)); }
.ms-check-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.ms-check-head p { min-width: 0; font-size: .8rem; font-weight: 600; }
.ms-check-state { flex-shrink: 0; padding: .1rem .5rem; border-radius: 999px; font-size: .68rem; font-weight: 600; color: var(--ms-c); background: color-mix(in srgb, var(--ms-c) 12%, transparent); white-space: nowrap; }
.ms-check-detail { margin-top: .3rem; font-family: var(--font-geist-mono); font-size: .7rem; line-height: 1.5; color: var(--muted-foreground); overflow-wrap: anywhere; text-align: left; }
html[dir="rtl"] .ms-check-detail { text-align: right; }
.ms-check-steps { margin-top: .4rem; padding-inline-start: 1.1rem; list-style: decimal; display: grid; gap: .2rem; font-size: .74rem; line-height: 1.55; color: var(--foreground); }
/* Device check → boot modes card. */
#ms-modes .ms-section-head h2 svg, #ms-modes .ms-section-head h2 i { color: var(--primary); }
.ms-mode-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.ms-mode-chip { padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--border); font-size: .7rem; color: var(--muted-foreground); background: var(--background); }
.ms-mode-chip.is-dfu { border-color: #7c3aed66; color: #7c3aed; background: #7c3aed14; font-weight: 600; }
.ms-mode-chip.is-rec { border-color: #d9770666; color: #b45309; background: #d9770614; font-weight: 600; }
.ms-mode-chip.is-fb { border-color: #0284c766; color: #0369a1; background: #0284c714; font-weight: 600; }
.ms-mode-body { padding: 1rem 1.25rem 1.25rem; display: grid; gap: .85rem; }
.ms-mode-lead, .ms-mode-hint { font-size: .78rem; line-height: 1.6; color: var(--muted-foreground); }
.ms-mode-grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); }
.ms-mode-btn { display: flex; align-items: center; gap: .55rem; min-height: 2.6rem; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--background); font-size: .8rem; font-weight: 500; text-align: start; transition: border-color .15s, background .15s; }
.ms-mode-btn svg, .ms-mode-btn i { width: 1rem; height: 1rem; flex-shrink: 0; color: var(--muted-foreground); }
.ms-mode-btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); background: color-mix(in srgb, var(--primary) 5%, var(--background)); }
.ms-mode-btn:disabled { opacity: .45; cursor: not-allowed; }
.ms-mode-btn.is-accent { border-color: #7c3aed55; }
.ms-mode-btn.is-accent svg, .ms-mode-btn.is-accent i { color: #7c3aed; }
.ms-mode-fb { padding: .75rem; border: 1px solid #0284c744; border-radius: .65rem; background: #0284c70d; display: grid; gap: .5rem; }
.ms-mode-fb > p { font-size: .75rem; font-weight: 600; color: #0369a1; }
.ms-mode-fb-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.ms-mode-fb-row code { font-size: .75rem; }
.ms-dfu { display: grid; gap: .6rem; padding: .9rem; border: 1px solid var(--border); border-radius: .75rem; background: color-mix(in srgb, var(--muted) 35%, var(--card)); font-size: .8rem; }
.ms-dfu p { color: var(--muted-foreground); line-height: 1.6; }
.ms-dfu.is-ok { border-color: #16a34a55; background: #16a34a0f; }
.ms-dfu.is-warn { border-color: #d9770655; background: #d977060f; }
.ms-dfu-models { display: flex; flex-wrap: wrap; gap: .4rem; }
.ms-dfu-model { padding: .35rem .7rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--background); font-size: .75rem; }
.ms-dfu-model.is-on { border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--background)); font-weight: 600; }
.ms-dfu-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ms-dfu.is-run { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.ms-dfu.is-run ol { display: grid; gap: .35rem; padding-inline-start: 1.1rem; list-style: decimal; }
.ms-dfu.is-run li { color: var(--muted-foreground); }
.ms-dfu.is-run li.is-done { text-decoration: line-through; opacity: .6; }
.ms-dfu.is-run li.is-now { color: var(--foreground); font-weight: 700; }
.ms-dfu-count { display: grid; place-items: center; width: 5.5rem; height: 5.5rem; border-radius: 50%; border: 3px solid #7c3aed; color: #7c3aed; }
.ms-dfu-count span { font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ms-dfu-count small { font-size: .65rem; }
.ms-dfu.is-run > button { grid-column: 1 / -1; justify-self: start; }

/* ── WhatsApp inbox (Conversations page) ─────────────────────────────── */
#main-content:has(.ms-chat-root) { padding: 0 !important; }
.ms-chat-root { --wa-bg: color-mix(in srgb, var(--muted) 45%, var(--background)); --wa-out: color-mix(in srgb, var(--primary) 16%, var(--card)); --wa-in: var(--card); --wa-head: var(--card); --wa-tick: var(--muted-foreground); --wa-read: #53bdeb; height: calc(100dvh - 4rem); }
.ms-chat-loading, .ms-chat-fallback { padding: 2rem; text-align: center; color: var(--muted-foreground); }
.ms-chat { display: grid; grid-template-columns: minmax(300px, 360px) 1fr; height: 100%; background: var(--card); border-top: 1px solid var(--border); overflow: hidden; }

/* conversation list */
.ms-chat-list { display: flex; flex-direction: column; min-height: 0; border-inline-end: 1px solid var(--border); background: var(--card); }
.ms-chat-list-head { display: flex; align-items: center; gap: .5rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.ms-chat-list-head h2 { font-size: 1rem; font-weight: 700; }
.ms-chat-count { min-width: 1.4rem; padding: 0 .45rem; border-radius: 999px; background: var(--muted); font-size: .72rem; line-height: 1.4rem; text-align: center; color: var(--muted-foreground); }
.ms-chat-list-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.ms-wa-connect { position: relative; margin-inline-start: auto; }
.ms-wa-connect-btn { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--card); color: var(--muted-foreground); cursor: pointer; }
.ms-wa-connect-btn:hover { color: var(--foreground); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.ms-wa-connect-panel { position: absolute; inset-inline-end: 0; top: calc(100% + .4rem); z-index: 30; width: min(22rem, 80vw); padding: .85rem; border: 1px solid var(--border); border-radius: .7rem; background: var(--popover, var(--card)); box-shadow: 0 12px 30px -10px #00000040; }
.ms-wa-connect-panel h3 { font-size: .9rem; font-weight: 700; margin-bottom: .35rem; }
.ms-wa-connect-panel p { font-size: .76rem; line-height: 1.6; color: var(--muted-foreground); }
.ms-wa-url { display: flex; align-items: stretch; gap: .4rem; margin: .6rem 0 .4rem; }
.ms-wa-url code { flex: 1 1 auto; min-width: 0; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--muted); font-size: .68rem; overflow-x: auto; white-space: nowrap; }
.ms-wa-url button { flex-shrink: 0; padding: 0 .7rem; border: 0; border-radius: .45rem; background: var(--primary); color: var(--primary-foreground); font-size: .74rem; font-weight: 600; cursor: pointer; }
.ms-wa-events { font-size: .7rem; color: var(--muted-foreground); }
.ms-chat-list-empty { padding: 2rem 1.25rem; text-align: center; font-size: .85rem; line-height: 1.7; color: var(--muted-foreground); }
.ms-conv { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .7rem 1rem; text-align: start; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); background: transparent; cursor: pointer; transition: background .12s; }
.ms-conv:hover { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.ms-conv.is-active { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.ms-conv-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.ms-conv-top, .ms-conv-bottom { display: flex; align-items: center; gap: .5rem; }
.ms-conv-name { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-conv-time { flex-shrink: 0; font-size: .7rem; color: var(--muted-foreground); }
.ms-conv-preview { flex: 1 1 auto; min-width: 0; font-size: .8rem; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-conv-unread { flex-shrink: 0; min-width: 1.15rem; height: 1.15rem; padding: 0 .35rem; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); font-size: .68rem; font-weight: 700; line-height: 1.15rem; text-align: center; }

.ms-chat-avatar { flex-shrink: 0; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: color-mix(in srgb, var(--primary) 18%, var(--muted)); color: var(--primary); font-weight: 700; font-size: .85rem; }
.ms-chat-avatar.is-supplier { background: #f59e0b22; color: #b45309; }
.ms-chat-avatar.is-staff { background: #8b5cf622; color: #7c3aed; }
.ms-chat-avatar.is-none { background: var(--muted); color: var(--muted-foreground); }

/* open conversation */
.ms-chat-pane { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background-color: var(--wa-bg); }
.ms-chat-head, .ms-thread, .ms-composer { position: relative; z-index: 1; }
.ms-chat-pane.is-empty { align-items: center; justify-content: center; }
.ms-chat-empty { text-align: center; color: var(--muted-foreground); }
.ms-chat-empty span { font-size: 3rem; }
.ms-chat-empty p { margin-top: .5rem; font-size: .9rem; }
.ms-chat-head { display: flex; align-items: center; gap: .7rem; padding: .6rem 1rem; background: var(--wa-head); border-bottom: 1px solid var(--border); }
.ms-chat-head-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ms-chat-head-name { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-chat-head-sub { font-size: .74rem; color: var(--muted-foreground); }
.ms-party-badge { flex-shrink: 0; padding: .15rem .6rem; border-radius: 999px; font-size: .7rem; font-weight: 600; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.ms-party-badge.is-supplier { background: #f59e0b22; color: #b45309; }
.ms-party-badge.is-staff { background: #8b5cf622; color: #7c3aed; }
.ms-party-badge.is-none { background: var(--muted); color: var(--muted-foreground); }

.ms-thread { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem 6% 1.25rem; display: flex; flex-direction: column; gap: .25rem; }
.ms-thread-empty { margin: auto; color: var(--muted-foreground); font-size: .85rem; }
.ms-day { align-self: center; margin: .6rem 0; }
.ms-day span { padding: .2rem .7rem; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: .72rem; color: var(--muted-foreground); }
.ms-bubble-row { display: flex; }
.ms-bubble-row.is-out { justify-content: flex-end; }
.ms-bubble-row.is-in { justify-content: flex-start; }
.ms-bubble { position: relative; max-width: 76%; padding: .4rem .6rem .5rem; border-radius: .6rem; font-size: .88rem; line-height: 1.5; box-shadow: 0 1px 1px #00000014; word-wrap: break-word; }
.is-in .ms-bubble { background: var(--wa-in); border: 1px solid var(--border); border-start-start-radius: .25rem; color: var(--foreground); }
.is-out .ms-bubble { background: var(--wa-out); border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent); border-start-end-radius: .25rem; color: var(--foreground); }
.ms-bubble-text { white-space: pre-wrap; }
.ms-bubble-author { display: block; font-size: .72rem; font-weight: 700; color: var(--primary); margin-bottom: .1rem; }
.ms-bubble-kind { display: block; font-size: .78rem; font-weight: 600; opacity: .85; margin-bottom: .1rem; }
.ms-bubble-meta { float: inline-end; display: inline-flex; align-items: center; gap: .2rem; margin-inline-start: .5rem; margin-top: .25rem; font-size: .66rem; color: var(--wa-tick); white-space: nowrap; }
.ms-tick.is-read { color: var(--wa-read); }
.ms-tick.is-failed { color: var(--destructive); font-weight: 700; }
.ms-tick.is-pending { font-size: .58rem; opacity: .8; }

/* internal team note */
.ms-chat-note { align-self: center; max-width: 82%; margin: .5rem 0; padding: .5rem .8rem; border-radius: .6rem; background: color-mix(in srgb, #d97706 12%, var(--card)); border: 1px solid color-mix(in srgb, #d97706 34%, var(--border)); color: var(--foreground); font-size: .84rem; }
.ms-chat-note-tag { display: block; font-size: .72rem; font-weight: 700; margin-bottom: .15rem; }
.ms-chat-note p { white-space: pre-wrap; }
.ms-chat-note-time { display: block; margin-top: .2rem; font-size: .66rem; opacity: .7; text-align: end; }

/* composer */
.ms-composer { padding: .5rem .75rem .65rem; background: var(--wa-head); border-top: 1px solid var(--border); }
.ms-composer-modes { display: flex; gap: .4rem; margin-bottom: .45rem; }
.ms-composer-modes button { padding: .25rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--card); font-size: .74rem; font-weight: 500; color: var(--muted-foreground); cursor: pointer; }
.ms-composer-modes button.is-on { border-color: transparent; background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); font-weight: 600; }
.ms-composer.is-note .ms-composer-modes button.is-on { background: color-mix(in srgb, #d97706 16%, transparent); color: #b45309; }
.ms-composer-row { display: flex; align-items: flex-end; gap: .5rem; }
.ms-composer-row textarea { flex: 1 1 auto; min-height: 2.6rem; max-height: 140px; padding: .6rem .9rem; border: 1px solid var(--border); border-radius: 1.3rem; background: var(--card); color: var(--foreground); font: inherit; font-size: .88rem; line-height: 1.4; resize: none; }
.ms-composer.is-note .ms-composer-row textarea { background: color-mix(in srgb, #d97706 8%, var(--card)); border-color: color-mix(in srgb, #d97706 30%, var(--border)); }
.ms-send { flex-shrink: 0; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border: 0; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); cursor: pointer; transition: opacity .12s, transform .12s; }
.ms-send:hover:not(:disabled) { transform: scale(1.05); }
.ms-send:disabled { opacity: .5; cursor: default; }
html[dir="rtl"] .ms-send svg { transform: scaleX(-1); }

@media (max-width: 820px) {
  .ms-chat { grid-template-columns: 1fr; }
  .ms-chat:has(.ms-chat-pane:not(.is-empty)) .ms-chat-list { display: none; }
  /* Phones: the list and the open conversation take turns; no empty placeholder under the list. */
  .ms-chat-pane.is-empty { display: none !important; }
}

/* Parties in the system's colours: clients = primary, suppliers = info, staff = violet
   (the same tones and icons as the Clients / Suppliers / Staff pages). */
.ms-party-badge.is-client, .ms-conv-party.is-client { --ms-party: var(--primary); }
.ms-party-badge.is-supplier, .ms-conv-party.is-supplier { --ms-party: var(--chart-3); }
.ms-party-badge.is-staff, .ms-conv-party.is-staff { --ms-party: var(--chart-5); }
.ms-party-badge:is(.is-client, .is-supplier, .is-staff) { background: color-mix(in srgb, var(--ms-party) 16%, transparent); color: var(--ms-party); }
/* Avatars: the same per-person colour as the Clients / Suppliers / Staff lists (.ms-av, --h from the name). */
.ms-chat-avatar.ms-av, .wa-ava.ms-av { background: oklch(92% .05 var(--h)); color: oklch(38% .12 var(--h)); }
html.dark .ms-chat-avatar.ms-av, html.dark .wa-ava.ms-av { background: oklch(32% .07 var(--h)); color: oklch(88% .08 var(--h)); }
.ms-conv-party { display: inline-flex; align-items: center; gap: .2rem; flex-shrink: 0; padding: .05rem .4rem; border-radius: 999px; font-size: .64rem; font-weight: 600; background: color-mix(in srgb, var(--ms-party) 13%, transparent); color: var(--ms-party); }
.ms-conv-top { gap: .35rem; }

/* Back to the list (phones / small tablets, where the list and the chat take turns). */
.ms-chat-back { display: none; flex-shrink: 0; width: 2.2rem; height: 2.2rem; place-items: center; border-radius: 50%; color: var(--foreground); }
.ms-chat-back:hover { background: var(--muted); }
html[dir="rtl"] .ms-chat-back svg { transform: scaleX(-1); }
@media (max-width: 820px) { .ms-chat-back { display: grid; } }

/* Attachments */
.ms-attach { flex-shrink: 0; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; color: var(--muted-foreground); }
.ms-attach:hover:not(:disabled) { background: var(--muted); color: var(--foreground); }
.ms-attach:disabled { opacity: .5; }
.ms-composer-err { margin: 0 0 .4rem; font-size: .78rem; color: var(--destructive); }
.ms-bubble-img { display: block; margin: -.1rem -.25rem .3rem; }
.ms-bubble-img img { display: block; max-width: min(18rem, 100%); max-height: 18rem; border-radius: .45rem; object-fit: cover; }
.ms-bubble-file { display: inline-flex; align-items: center; gap: .4rem; margin-bottom: .2rem; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--card); font-size: .82rem; font-weight: 600; color: var(--foreground); }

/* ── WhatsApp chat dock (footer, every page) ─────────────────────────── */
.wa-dock { position: fixed; bottom: 1rem; inset-inline-start: auto; inset-inline-end: 1rem; z-index: 1000; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: .75rem; }
.wa-dock button, .wa-dock a, .wa-dock-launch, .wa-dock-conv { touch-action: manipulation; }
.wa-author { display: block; font-size: .68rem; font-weight: 700; color: var(--primary); }
.wa-dock-launch { position: relative; display: grid; place-items: center; width: 3.4rem; height: 3.4rem; border: 0; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); box-shadow: 0 6px 18px -4px #0000005a; cursor: pointer; transition: transform .15s; }
.wa-dock-launch:hover { transform: scale(1.06); }
.wa-dock-badge { position: absolute; top: -.2rem; inset-inline-end: -.2rem; min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem; border-radius: 999px; background: var(--destructive); color: #fff; font-size: .68rem; font-weight: 700; line-height: 1.25rem; text-align: center; box-shadow: 0 0 0 2px var(--background); }

.wa-dock-list { position: absolute; bottom: 4.1rem; inset-inline-end: 0; width: 20rem; max-height: min(26rem, 70vh); display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: .85rem; background: var(--card); box-shadow: 0 14px 40px -12px #00000055; overflow: hidden; }
.wa-dock-list-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .9rem; }
.wa-dock-all { margin-inline-start: auto; font-size: .74rem; font-weight: 600; color: var(--primary); }
.wa-dock-list-head button { border: 0; background: none; color: var(--muted-foreground); font-size: .9rem; cursor: pointer; }
.wa-dock-list-body { flex: 1 1 auto; overflow-y: auto; }
.wa-dock-empty { padding: 1.5rem; text-align: center; font-size: .82rem; color: var(--muted-foreground); }
.wa-dock-conv { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .6rem .8rem; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); background: none; text-align: start; cursor: pointer; }
.wa-dock-conv:hover { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.wa-dock-conv-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.wa-dock-conv-top { display: flex; align-items: center; gap: .4rem; }
.wa-dock-conv-top b { flex: 1 1 auto; min-width: 0; font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-dock-conv-top small { flex-shrink: 0; font-size: .66rem; color: var(--muted-foreground); }
.wa-dock-conv-prev { font-size: .76rem; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-dock-conv-unread { flex-shrink: 0; min-width: 1.1rem; height: 1.1rem; padding: 0 .3rem; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); font-size: .64rem; font-weight: 700; line-height: 1.1rem; text-align: center; }

.wa-ava { flex-shrink: 0; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: color-mix(in srgb, var(--primary) 18%, var(--muted)); color: var(--primary); font-weight: 700; font-size: .72rem; }
.wa-ava.is-supplier { background: #f59e0b22; color: #b45309; }
.wa-ava.is-staff { background: #8b5cf622; color: #7c3aed; }
.wa-ava.is-none { background: var(--muted); color: var(--muted-foreground); }

.wa-win { --wa-bg: color-mix(in srgb, var(--muted) 45%, var(--background)); --wa-out: color-mix(in srgb, var(--primary) 16%, var(--card)); --wa-in: var(--card); width: 20.5rem; height: 27rem; max-height: 72vh; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: .85rem .85rem 0 0; background: var(--card); box-shadow: 0 14px 40px -12px #00000055; overflow: hidden; }
.wa-win.is-min { width: 14rem; height: auto; flex-direction: row; align-items: center; border-radius: .7rem; }
.wa-win-bar { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; border: 0; background: none; cursor: pointer; }
.wa-win-bar b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.wa-win-x { padding: 0 .7rem; border: 0; background: none; color: var(--muted-foreground); cursor: pointer; }
.wa-win-head { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; background: var(--card); color: var(--foreground); border-bottom: 1px solid var(--border); }
.wa-win-head .wa-ava:not(.ms-av) { background: color-mix(in srgb, var(--primary) 18%, var(--muted)); color: var(--primary); }
.wa-win-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.wa-win-title b { font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-win-title small { font-size: .66rem; opacity: .8; }
.wa-win-ico { padding: 0 .3rem; border: 0; background: none; color: inherit; font-size: .95rem; line-height: 1; cursor: pointer; text-decoration: none; opacity: .85; }
.wa-win-ico:hover { opacity: 1; }
.wa-win-msgs { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: .6rem .7rem; background-color: var(--wa-bg); display: flex; flex-direction: column; gap: .2rem; }
.wa-win-empty { margin: auto; color: var(--muted-foreground); font-size: .8rem; }
.wa-brow { display: flex; }
.wa-brow.is-out { justify-content: flex-end; }
.wa-brow.is-in { justify-content: flex-start; }
.wa-b { max-width: 82%; padding: .35rem .5rem; border-radius: .5rem; font-size: .82rem; line-height: 1.45; box-shadow: 0 1px 1px #00000014; word-wrap: break-word; color: var(--foreground); }
.is-in .wa-b { background: var(--wa-in); border: 1px solid var(--border); border-start-start-radius: .25rem; }
.is-out .wa-b { background: var(--wa-out); border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent); border-start-end-radius: .25rem; }
.wa-bm { float: inline-end; display: inline-flex; gap: .15rem; margin-inline-start: .4rem; margin-top: .2rem; font-size: .6rem; color: var(--muted-foreground); }
.wa-tick.is-read { color: var(--primary); }
.wa-tick.is-failed { color: var(--destructive); font-weight: 700; }
.wa-tick.is-pending { font-size: .55rem; opacity: .8; }
.wa-note { align-self: center; max-width: 88%; margin: .25rem 0; padding: .35rem .6rem; border-radius: .5rem; background: color-mix(in srgb, #d97706 12%, var(--card)); border: 1px solid color-mix(in srgb, #d97706 34%, var(--border)); color: var(--foreground); font-size: .76rem; }
.wa-note span { display: block; margin-top: .1rem; font-size: .6rem; opacity: .7; text-align: end; }
.wa-win-foot { display: flex; align-items: center; gap: .35rem; padding: .45rem .5rem; background: var(--wa-head, #f0f2f5); border-top: 1px solid var(--border); }
.wa-win-modes { display: flex; }
.wa-win-modes button { padding: .2rem .35rem; border: 0; background: none; font-size: .95rem; opacity: .5; cursor: pointer; border-radius: .4rem; }
.wa-win-modes button.is-on { opacity: 1; background: color-mix(in srgb, var(--primary) 14%, transparent); }
.wa-win-input { flex: 1 1 auto; min-width: 0; height: 2.1rem; padding: 0 .7rem; border: 1px solid var(--border); border-radius: 1.05rem; background: var(--card); color: var(--foreground); font: inherit; font-size: .82rem; }
.wa-win-foot.is-note .wa-win-input { background: color-mix(in srgb, #d97706 8%, var(--card)); border-color: color-mix(in srgb, #d97706 30%, var(--border)); }
.wa-win-send { flex-shrink: 0; display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border: 0; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); cursor: pointer; }
html[dir="rtl"] .wa-win-send { transform: scaleX(-1); }

@media (max-width: 640px) {
  .wa-dock { inset-inline-start: auto; inset-inline-end: .75rem; bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)); }
  .wa-win { position: fixed; inset-inline: .5rem; bottom: .5rem; width: auto; height: 72vh; max-height: 72vh; z-index: 1; }
  .wa-win.is-min { position: static; width: 12rem; height: auto; }
  /* The list opens on top of any pop-up window, as a near-full-height sheet, so a tap on the
     launcher always shows it — even when a chat window is already open. */
  .wa-dock-list { position: fixed; inset-inline: .5rem; bottom: 4.9rem; width: auto; max-height: min(32rem, 78vh); z-index: 3; }
}

/* Settings → WhatsApp → inbox webhook card. */
.ms-wh-body { padding: 1rem 1.25rem 1.25rem; display: grid; gap: .6rem; }
.ms-wh-url { display: flex; align-items: stretch; gap: .5rem; }
.ms-wh-url code { flex: 1 1 auto; min-width: 0; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--muted); font-size: .72rem; overflow-x: auto; white-space: nowrap; }
.ms-wh-events { font-size: .8rem; color: var(--muted-foreground); line-height: 1.6; }
.ms-wh-events b { color: var(--foreground); }
.ms-wh-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ms-wh-rotate { color: var(--destructive); }
.ms-wh-note { font-size: .74rem; color: var(--muted-foreground); }
.ms-wh-peek { max-height: 16rem; overflow: auto; margin-top: .3rem; padding: .7rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--muted); font-size: .68rem; line-height: 1.5; white-space: pre-wrap; word-break: break-all; direction: ltr; }

/* Desk update modal: pushed when the Desk app on this PC is outdated. */
.ms-du-overlay { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 1rem; background: color-mix(in srgb, #0b1220 62%, transparent); backdrop-filter: blur(3px); animation: ms-du-in .18s ease-out; }
@keyframes ms-du-in { from { opacity: 0; } to { opacity: 1; } }
.ms-du-card { width: min(27rem, 100%); padding: 1.6rem 1.5rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); box-shadow: 0 24px 60px -20px #00000066; text-align: center; animation: ms-du-pop .2s ease-out; }
@keyframes ms-du-pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.ms-du-icon { width: 3.25rem; height: 3.25rem; margin: 0 auto .9rem; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.ms-du-icon svg, .ms-du-icon i { width: 1.6rem; height: 1.6rem; }
.ms-du-icon.is-ok { background: #16a34a1f; color: #15803d; }
.ms-du-icon.is-spin svg, .ms-du-icon.is-spin i { animation: ms-du-spin 1s linear infinite; }
@keyframes ms-du-spin { to { transform: rotate(360deg); } }
.ms-du-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; }
.ms-du-card p { font-size: .85rem; line-height: 1.65; color: var(--muted-foreground); }
.ms-du-ver { display: flex; flex-wrap: wrap; gap: .25rem 1rem; justify-content: center; margin-top: .85rem; font-size: .72rem; }
.ms-du-ver code { font-size: .72rem; color: var(--foreground); }
.ms-du-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1.25rem; }
.ms-du-actions .apex-btn { min-width: 9rem; }
.ms-du-manual { display: inline-block; margin-top: .9rem; font-size: .78rem; font-weight: 500; color: var(--primary); text-decoration: underline; text-underline-offset: 2px; background: none; border: 0; cursor: pointer; }
.ms-du-manual:hover { color: color-mix(in srgb, var(--primary) 80%, var(--foreground)); }

/* Device check → fastboot format & repair. */
.ms-flash { display: grid; gap: .65rem; padding: .85rem; border: 1px solid #0284c744; border-radius: .75rem; background: #0284c70a; }
.ms-flash-head { display: flex; align-items: center; gap: .6rem; }
.ms-flash-head > svg, .ms-flash-head > i { width: 1.1rem; height: 1.1rem; color: #0369a1; flex-shrink: 0; }
.ms-flash-head > div { flex: 1 1 auto; min-width: 0; display: grid; }
.ms-flash-head b { font-size: .85rem; }
.ms-flash-head small { font-size: .7rem; color: var(--muted-foreground); font-family: var(--font-geist-mono); }
.ms-flash-lock { flex-shrink: 0; padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--border); font-size: .68rem; font-weight: 600; color: var(--muted-foreground); }
.ms-flash-lock.is-open { border-color: #16a34a55; color: #15803d; background: #16a34a12; }
.ms-flash-lock.is-locked { border-color: #d9770655; color: #b45309; background: #d9770612; }
.ms-flash-note { display: flex; align-items: flex-start; gap: .4rem; font-size: .74rem; line-height: 1.55; color: var(--muted-foreground); }
.ms-flash-note svg, .ms-flash-note i { width: .95rem; height: .95rem; margin-top: .1rem; color: #15803d; flex-shrink: 0; }
.ms-flash-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ms-flash-adv { border-top: 1px solid var(--border); padding-top: .6rem; }
.ms-flash-adv > summary { font-size: .78rem; font-weight: 600; cursor: pointer; color: var(--foreground); }
.ms-flash-form { display: grid; gap: .5rem; margin-top: .6rem; }
.ms-flash-form .apex-label { font-size: .72rem; }
.ms-flash-form input[type="file"] { font-size: .76rem; padding: .35rem; }

/* A head pulled to the edges of a padded card must not be capped at the content width,
   or its divider stops short on one side (the left one in Arabic). */
.apex-card:is(.p-3, .p-4, .p-5, .p-6) > .ms-section-head { max-width: none; }
/* Empty "no scan yet" box: no tall blank area. */
.apex-card .rounded-xl.min-h-\[8rem\]:not(:has(*)) , .apex-card .rounded-xl.min-h-\[8rem\]:has(> p:only-child) { min-height: 0; }

/* The device list keeps its own height (and stays in view) instead of stretching beside a long report. */
@media (min-width: 1024px) {
  .grid.lg\:grid-cols-\[minmax\(0\,1fr\)_minmax\(0\,1\.2fr\)\] { align-items: start; }
  .grid.lg\:grid-cols-\[minmax\(0\,1fr\)_minmax\(0\,1\.2fr\)\] > :first-child { position: sticky; top: 5rem; }
}

/* Supplier invoices: dues summary under the table. */
.ms-due-foot td { padding: .6rem 1.25rem; font-size: .85rem; color: var(--muted-foreground); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--muted) 30%, transparent); }
.ms-due-foot .is-total td { color: var(--foreground); font-weight: 700; font-size: .9rem; }

/* Supplier payment: which purchase invoices the payment settles. */
.ms-alloc { padding: .85rem 1rem; border: 1px solid var(--border); border-radius: .75rem; background: color-mix(in srgb, var(--muted) 35%, transparent); }
.ms-alloc-row { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: .6rem; background: var(--background); cursor: pointer; }
.ms-alloc-row:has(:checked) { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.ms-alloc-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; font-size: .85rem; }
.ms-alloc-name b { font-family: var(--font-geist-mono); font-weight: 600; }
.ms-alloc-name small { color: var(--muted-foreground); font-size: .72rem; }
.ms-alloc-row .apex-input { flex: 0 0 7rem; text-align: start; font-variant-numeric: tabular-nums; }
#alloc-sum b { color: var(--foreground); font-variant-numeric: tabular-nums; }
#alloc-sum.text-destructive b { color: var(--destructive); }

@media (max-width: 639px) {
  .apex-btn:not(.apex-btn-sm):not([class*=" h-"]) { height: 2.5rem; }
  :is(.flex, .grid):has(> :is(.apex-input, .apex-select):not(.h-8), > * > :is(.apex-input, .apex-select):not(.h-8), > * > * > :is(.apex-input, .apex-select):not(.h-8)) > .apex-btn-sm { height: 2.5rem; }
  :is(.apex-input, .apex-select).h-8 { height: 2rem; }
  .ms-scan .apex-input { height: 2.5rem; }
  .apex-card > .ms-section-head + :has(apex-data-table) { padding: .85rem 1rem 1rem; }
  /* Header notifications: a full-width sheet under the header instead of a popover tied to the bell. */
  .ms-note-panel {
    position: fixed !important; inset-inline: .75rem !important; top: calc(3.75rem + env(safe-area-inset-top, 0px)) !important;
    width: auto; max-width: none; margin-top: 0; display: flex; flex-direction: column;
    max-height: calc(100dvh - 5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  .ms-note-panel > * { flex-shrink: 0; }
  .ms-note-panel > .max-h-96, .ms-note-panel [data-note-list] { flex: 1 1 auto; max-height: none; min-height: 0; }
  .ms-note-panel .ms-note-tools, .ms-note-panel .ms-note-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ms-note-panel .ms-note-tools > *, .ms-note-panel .ms-note-tabs > * { flex-wrap: nowrap; white-space: nowrap; }
  /* Detail tabs: compact, and fade the far edge so more tabs read as scrollable. */
  .ms-tab { padding: .65rem .6rem; gap: .35rem; }
  .ms-tab > svg, .ms-tab > i { display: none; }
  .ms-tabs { scroll-snap-type: x proximity; mask-image: linear-gradient(to right, #000 calc(100% - 1.75rem), transparent); }
  [dir="rtl"] .ms-tabs { mask-image: linear-gradient(to left, #000 calc(100% - 1.75rem), transparent); }
  .ms-tab { scroll-snap-align: start; }
}

/* Chat dock: attachments, media bubbles, send errors, WhatsApp-blue read ticks. */
.wa-tick.is-read { color: #53bdeb; }
.wa-win-attach { flex-shrink: 0; display: grid; place-items: center; width: 2rem; height: 2rem; border: 0; border-radius: 50%; background: none; color: var(--muted-foreground); cursor: pointer; }
.wa-win-attach:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.wa-win-attach:disabled { cursor: progress; opacity: .7; }
.wa-spin { width: 1rem; height: 1rem; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: wa-spin .8s linear infinite; }
@keyframes wa-spin { to { transform: rotate(360deg); } }
.wa-win-err { margin: 0; padding: .3rem .7rem; font-size: .72rem; color: var(--destructive); background: color-mix(in srgb, var(--destructive) 8%, var(--card)); border-top: 1px solid color-mix(in srgb, var(--destructive) 25%, var(--border)); }
.wa-b-img { display: block; margin-bottom: .25rem; }
.wa-b-img img { display: block; max-width: 100%; max-height: 11rem; border-radius: .4rem; object-fit: cover; }
.wa-b-file { display: inline-flex; align-items: center; gap: .3rem; margin-bottom: .2rem; padding: .3rem .5rem; border-radius: .4rem; background: color-mix(in srgb, var(--foreground) 6%, transparent); color: inherit; font-weight: 600; text-decoration: none; }
.wa-b-kind { font-style: normal; opacity: .8; }
/* Chat line icons (chat-icons.js): aligned with their labels, sized by the SVG, colour from the text. */
.ms-ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; vertical-align: middle; }
.ms-i { flex-shrink: 0; display: block; }
.ms-composer-modes button { display: inline-flex; align-items: center; gap: .35rem; }
.ms-chat-note-tag { display: flex; align-items: center; gap: .3rem; color: #b45309; }
html.dark .ms-chat-note-tag { color: #fbbf24; }
.ms-chat-empty span { display: grid; place-items: center; width: 4.5rem; height: 4.5rem; margin-inline: auto; border-radius: 1.25rem; font-size: 0; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.ms-bubble-file .ms-ico, .wa-b-file .ms-i { color: var(--primary); }
.ms-bubble-kind { display: inline-flex; align-items: center; gap: .3rem; }
.ms-tick .ms-ico { display: inline-flex; }
.wa-win-ico { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; padding: 0; border-radius: .45rem; }
.wa-win-ico:hover { background: color-mix(in srgb, var(--foreground) 8%, transparent); }
.wa-win-x, .wa-dock-list-head [data-close-list] { display: inline-grid; place-items: center; }
.wa-win-modes { gap: .1rem; }
.wa-win-modes button { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; padding: 0; color: var(--muted-foreground); opacity: 1; }
.wa-win-modes button:hover { background: color-mix(in srgb, var(--foreground) 7%, transparent); }
.wa-win-modes button.is-on { color: var(--primary); }
.wa-win-foot.is-note .wa-win-modes button.is-on { color: #b45309; background: color-mix(in srgb, #d97706 16%, transparent); }
.wa-win-send .ms-i { width: 17px; height: 17px; }
.wa-note b { display: inline-flex; align-items: center; gap: .25rem; color: #b45309; }
html.dark .wa-note b { color: #fbbf24; }
.wa-b-kind { display: inline-flex; align-items: center; gap: .25rem; }
.wa-tick .ms-i { display: inline-block; vertical-align: -2px; }
/* Add-device: background save notice. */
.ms-adddev-toast { position: fixed; inset-inline: 1rem; bottom: 1.25rem; z-index: 90; max-width: 26rem; margin-inline: auto; padding: .7rem 1rem; border-radius: .7rem; background: var(--foreground); color: var(--background); font-size: .85rem; box-shadow: 0 10px 30px -10px #00000066; }
/* Floating chat dock: windows float above the launcher (rounded, lifted); draggable on desktop. */
.wa-dock-windows { position: fixed; bottom: calc(5.4rem + env(safe-area-inset-bottom, 0px)); inset-inline-end: 1rem; z-index: 1000; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: .75rem; pointer-events: none; }
.wa-dock-windows > * { pointer-events: auto; }
.wa-win { border-radius: 1rem; box-shadow: 0 28px 60px -18px #00000070, 0 6px 16px -8px #00000033; }
.wa-win.is-min { border-radius: 999px; box-shadow: 0 10px 28px -10px #00000060; }
.wa-win-head { border-radius: 1rem 1rem 0 0; }
.wa-dock-list { border-radius: 1rem; box-shadow: 0 28px 60px -18px #00000070, 0 6px 16px -8px #00000033; }
@media (min-width: 768px) and (pointer: fine) {
  .wa-win-head { cursor: grab; user-select: none; }
  .wa-dock.is-dragging .wa-win-head { cursor: grabbing; }
}
@media (max-width: 767px), (pointer: coarse) {
  .wa-dock-windows { inset-inline: .6rem; bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); flex-direction: column-reverse; align-items: stretch; }
  .wa-dock-windows .wa-win:not(.is-min) { position: static; inset: auto; width: auto; height: min(70vh, 34rem); max-height: calc(100vh - 7rem); }
  .wa-dock-windows .wa-win.is-min { position: static; align-self: flex-end; width: 12rem; }
}
/* While a chat window is dragged, page text is not selected. */
html.ms-no-select, html.ms-no-select * { user-select: none !important; -webkit-user-select: none !important; }

/* Notification bell (chat list + dock list). */
.ms-chat-bell, .wa-dock-bell { display: inline-grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: .55rem; background: none; color: var(--muted-foreground); cursor: pointer; }
.ms-chat-bell { margin-inline-start: auto; }
.ms-chat-bell:hover, .wa-dock-bell:hover { background: color-mix(in srgb, var(--foreground) 7%, transparent); }
.ms-chat-bell.is-on, .wa-dock-bell.is-on { color: var(--primary); }
.ms-chat-bell.is-ask, .wa-dock-bell.is-ask { color: #d97706; animation: ms-bell 1.6s ease-in-out 2; }
.ms-chat-bell.is-blocked, .wa-dock-bell.is-blocked { color: var(--destructive); }
@keyframes ms-bell { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } }
/* Sale cart quantity: a pill stepper with round, touch-sized buttons (+ stands out, both stop at their limit). */
.ms-cart .ms-qty { gap: .2rem; padding: .2rem; border: 1px solid var(--border); border-radius: 999px; background: var(--muted); overflow: visible; }
.ms-cart .ms-qty button { width: 2rem; height: 2rem; border-radius: 50%; background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px #0000001a; transition: transform .1s, background .15s; }
.ms-cart .ms-qty button:hover { background: var(--card); color: var(--primary); }
.ms-cart .ms-qty button:active { transform: scale(.92); }
.ms-cart .ms-qty button[data-inc] { background: var(--primary); color: var(--primary-foreground); }
.ms-cart .ms-qty button[data-inc]:hover { background: color-mix(in srgb, var(--primary) 88%, #000); color: var(--primary-foreground); }
.ms-cart .ms-qty button:disabled { opacity: .35; box-shadow: none; cursor: not-allowed; transform: none; }
.ms-cart .ms-qty button svg, .ms-cart .ms-qty button i { width: .9rem; height: .9rem; }
.ms-cart .ms-qty input { width: 2.6rem; height: 2rem; border: 0; background: transparent; font-size: .95rem; font-weight: 700; color: var(--foreground); }
.ms-cart .ms-qty input:focus { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; border-radius: .5rem; }

/* Phone: each cart line is a card — name on top, then quantity · price · total — nothing cut off. */
@media (max-width: 639px) {
  .overflow-x-auto:has(> .ms-cart) { overflow: visible; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: none !important; }
  table.ms-table.ms-cart, .ms-cart tbody { display: block; width: 100%; min-width: 0; border: 0; box-shadow: none; background: none; }
  .ms-cart thead { display: none; }
  .ms-cart tbody tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "item item rm" "qty price line"; align-items: center; gap: .6rem .75rem; margin-bottom: .6rem; padding: .75rem; border: 1px solid var(--border); border-radius: .9rem; background: var(--card); }
  .ms-cart tbody td { display: block; position: static !important; min-width: 0 !important; width: auto !important; padding: 0 !important; border: 0 !important; background: none !important; box-shadow: none !important; }
  .ms-cart tbody td:nth-child(1) { grid-area: item; }
  .ms-cart tbody td:nth-child(2) { grid-area: qty; }
  .ms-cart tbody td:nth-child(3) { grid-area: price; }
  .ms-cart tbody td:nth-child(4) { grid-area: line; font-weight: 700; text-align: end; white-space: nowrap; }
  .ms-cart tbody td:nth-child(5) { grid-area: rm; }
  .ms-cart tbody td:only-child { grid-column: 1 / -1; grid-row: auto; }
  .ms-cart .ms-price { width: 100%; max-width: 6.5rem; }
}
/* Section heads built as a column (title over a subtitle) keep the title at the start, not centred. */
.ms-section-head.flex-col { align-items: stretch; justify-content: flex-start; text-align: start; }
/* Space under the head's border when the body below is a form / fields (the body sets pt-0);
   a table right under the head stays flush with it. */
.apex-card > .ms-section-head + .pt-0:not(:has(table, apex-data-table)) { padding-top: 1.25rem !important; }
/* The English-name field lines up with the rest of an Arabic form (still typed left-to-right). */
html[dir="rtl"] #ms-name-en { text-align: right; }
html[dir="rtl"] #ms-name-en::placeholder { text-align: right; }
/* A button waiting for the server after a click (click-guard.js). */
.ms-busy { cursor: progress !important; opacity: .65; }

/* The other-language name sits right under the main name on every profile (it is written in the
   other direction, so its own "start" would push it to the far side). */
html[dir="rtl"] .ms-name-alt { text-align: right; }
html[dir="ltr"] .ms-name-alt { text-align: left; }
/* Header actions stay beside the name on every profile and on the order page (wide screens):
   when they don't fit on one line the buttons wrap inside their own column, instead of the whole
   group dropping below the name on pages that have more buttons (supplier, order). */
@media (min-width: 768px) {
  .ms-hero-body { flex-wrap: nowrap; }
  .ms-hero-id { flex: 1 1 16rem; }
  .ms-hero-actions { flex: 0 1 auto; max-width: 52%; justify-content: flex-end; align-content: flex-start; }
}
/* Messages page: WhatsApp / Email tabs */
.ms-msg-tabs { display: inline-flex; gap: .25rem; padding: .25rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--card); max-width: 100%; }
.ms-msg-tab { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem 1rem; border-radius: .55rem; font-size: .875rem; font-weight: 500; color: var(--muted-foreground); transition: background .15s, color .15s; }
.ms-msg-tab:hover { color: var(--foreground); background: color-mix(in srgb, var(--muted) 70%, transparent); }
.ms-msg-tab.is-active { background: var(--primary); color: var(--primary-foreground); }
.ms-msg-tab-n { min-width: 1.5rem; padding: 0 .4rem; border-radius: 999px; font-size: .72rem; line-height: 1.25rem; text-align: center; background: color-mix(in srgb, currentColor 14%, transparent); }
@media (max-width: 480px) { .ms-msg-tabs { display: flex; } .ms-msg-tab { flex: 1; justify-content: center; } }

/* Promotion page: previous campaigns */
.ms-camp-stats { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .85rem; font-weight: 600; }
.ms-camp-stats small { font-size: .72rem; font-weight: 400; color: var(--muted-foreground); }
.ms-camp-stats .is-sent { color: var(--chart-3); }
.ms-camp-stats .is-ok { color: var(--success); }
.ms-camp-stats .is-read { color: var(--chart-2); }
.ms-camp-stats .is-bad { color: var(--destructive); }
.ms-camp-bar { display: flex; height: .35rem; overflow: hidden; border-radius: 999px; background: var(--muted); }
.ms-camp-bar i { display: block; height: 100%; }
.ms-camp-bar .is-read { background: var(--chart-2); }
.ms-camp-bar .is-ok { background: var(--success); }
.ms-camp-bar .is-sent { background: var(--chart-3); }
.ms-camp-bar .is-bad { background: var(--destructive); }@media (min-width: 768px) { #messages-root .ms-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }

/* Shared print template: the paper on a grey desk (receipt page), preview window, share menu */
.ms-doc-desk { display: flex; justify-content: center; padding: 1.5rem .75rem 2rem; border: 1px solid var(--border); border-radius: 1rem; background: #e9ebef; overflow-x: auto; }
.ms-doc-desk .ms-doc { flex-shrink: 0; box-shadow: 0 1px 3px #0000001f, 0 10px 28px -10px #00000040; border-radius: 2px; }
html.dark .ms-doc-desk, [data-theme="dark"] .ms-doc-desk { background: #1d2127; }
.ms-print-paper { overflow: auto; max-height: calc(94vh - 13rem); background: #e9ebef; }
.ms-print-paper iframe { min-height: 0; height: 26rem; background: #e9ebef; }
.ms-label-dlg .ms-print-paper iframe { height: 18rem; }
.ms-prev-frame { display: block; height: 22rem; border: 0; border-radius: .75rem; background: #e9ebef; }
.ms-share-pop { position: fixed; z-index: 1000; min-width: 13rem; padding: .3rem; border: 1px solid var(--border); border-radius: .7rem; background: var(--popover, var(--card)); color: var(--popover-foreground, var(--foreground)); box-shadow: 0 12px 32px -10px #00000059; }
.ms-share-pop button { display: block; width: 100%; padding: .55rem .7rem; border-radius: .45rem; text-align: start; font-size: .875rem; }
.ms-share-pop button:hover, .ms-share-pop button:focus-visible { background: var(--muted); outline: none; }
.wa-staged { display: flex; align-items: center; gap: .6rem; margin: 0 .6rem .4rem; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: .6rem; background: var(--muted); }
.wa-staged img { width: 2.6rem; height: 2.6rem; object-fit: cover; object-position: top; border-radius: .35rem; background: #fff; }
.wa-staged span { display: flex; flex: 1; min-width: 0; flex-direction: column; font-size: .78rem; }
.wa-staged b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.wa-staged small { color: var(--muted-foreground); }
/* Accounting: segmented tabs, toolbar card, statements */
.ms-seg { display: inline-flex; flex-wrap: wrap; gap: .2rem; padding: .25rem; border: 0 !important; border-radius: .7rem; background: var(--muted); max-width: 100%; }
.ms-seg .apex-tab { display: inline-flex; align-items: center; gap: .4rem; height: 2.15rem; padding: 0 .85rem; border-radius: .5rem; font-size: .85rem; white-space: nowrap; }
.ms-seg .apex-tab svg { width: 1rem; height: 1rem; }
#views.ms-seg { display: flex; width: fit-content; margin-bottom: 1rem; }
#books-tools:not(.hidden) { padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-xl, .9rem); background: var(--card); }
.ms-acc-sec h2 { font-size: .95rem; font-weight: 650; }
.ms-acc-row { display: grid; grid-template-columns: minmax(0, 1fr) 9.5rem; align-items: baseline; gap: 1rem; padding: .4rem .5rem; border-radius: .45rem; font-size: .9rem; }
button:hover > .ms-acc-row { background: color-mix(in srgb, var(--muted) 60%, transparent); }
.ms-acc-amt { text-align: end; font-variant-numeric: tabular-nums; font-weight: 500; }
.ms-acc-row.is-neg .ms-acc-amt { color: var(--destructive); }
.ms-acc-row.is-total { margin-top: .35rem; background: var(--muted); font-weight: 650; }
.ms-acc-row.is-total .ms-acc-amt { font-weight: 700; }
#books-body table .font-mono.tabular-nums, #books-body td.text-end.font-mono { font-family: inherit; font-weight: 500; }
@media (max-width: 640px) { .ms-acc-row { grid-template-columns: minmax(0, 1fr) 7rem; } .ms-seg .apex-tab { padding: 0 .6rem; } }
/* Failed message → resend */
.wa-resend { display: inline-flex; align-items: center; gap: .3rem; margin-top: .35rem; padding: .2rem .55rem; border: 1px solid color-mix(in srgb, var(--destructive) 45%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--destructive) 8%, var(--card)); color: var(--destructive); font-size: .75rem; font-weight: 600; cursor: pointer; }
.wa-resend:hover { background: color-mix(in srgb, var(--destructive) 15%, var(--card)); }
.wa-resend .ms-ico, .wa-resend svg { display: inline-flex; }
/* Backup center (Settings → Backup) */
.ms-bk { display: flex; flex-direction: column; gap: 1rem; max-width: 72rem; }
.ms-bk-head { display: flex; align-items: center; gap: .875rem; }
.ms-bk-head h2 { font-size: 1.15rem; font-weight: 700; }
.ms-bk-head p { margin-top: .15rem; font-size: .85rem; color: var(--muted-foreground); }
.ms-bk-tiles .ms-bk-val { font-size: 1.15rem; }
.ms-bk-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) { .ms-bk-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.ms-bk-card { overflow: hidden; }
.ms-bk-body { padding: 1rem 1.25rem 1.25rem; }
.ms-bk-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ms-bk-actions > * { flex: 1 1 13rem; justify-content: center; }
.ms-bk-schedule { display: flex; align-items: flex-start; gap: .75rem; padding: .85rem; border: 1px solid var(--border); border-radius: .75rem; background: color-mix(in srgb, var(--muted) 45%, transparent); font-size: .875rem; }
.ms-bk-providers { display: flex; flex-wrap: wrap; gap: .4rem; }
.ms-bk-prov { padding: .45rem .8rem; border: 1px solid var(--border); border-radius: .6rem; font-size: .82rem; font-weight: 500; background: var(--card); }
.ms-bk-prov:hover { border-color: var(--primary); }
.ms-bk-prov.is-on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--primary); font-weight: 650; }
.ms-bk-hint { display: flex; gap: .5rem; align-items: flex-start; padding: .65rem .8rem; border-radius: .6rem; background: color-mix(in srgb, var(--chart-3) 9%, transparent); font-size: .8rem; color: var(--muted-foreground); }
.ms-bk-hint svg { flex: none; width: 1rem; height: 1rem; margin-top: .1rem; }
.ms-bk-oauth { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem; border: 1px dashed var(--border); border-radius: .6rem; }
.ms-bk-oauth code { display: block; margin-top: .25rem; font-size: .75rem; word-break: break-all; }
.ms-bk-opts { display: grid; gap: .45rem; align-content: start; padding-top: 1.4rem; }
.ms-bk-check { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.ms-bk-status { display: flex; align-items: center; gap: .45rem; font-size: .82rem; }
.ms-bk-status svg { width: 1rem; height: 1rem; }
.ms-bk-status.is-ok { color: var(--success); }
.ms-bk-status.is-bad { color: var(--destructive); }
.ms-bk-tl-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.ms-bk-list { list-style: none; margin: 0; padding: .25rem 0; }
.ms-bk-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .75rem; padding: .7rem 1.25rem; border-bottom: 1px solid var(--border); }
.ms-bk-list li:last-child { border-bottom: 0; }
.ms-bk-ico { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .7rem; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.ms-bk-ico.is-db { background: color-mix(in srgb, var(--chart-5) 14%, transparent); color: var(--chart-5); }
.ms-bk-ico svg { width: 1.1rem; height: 1.1rem; }
/* The timeline the settings page draws: cleaner rows */
.ms-bk #backup-list h4 { padding: .85rem 1.25rem .25rem !important; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.ms-bk #backup-list ol { padding: 0 1.25rem !important; }
.ms-bk #backup-list li > div:last-child { padding: .35rem 0 .9rem !important; }
.ms-bk #backup-list .apex-btn { height: 2rem; padding: 0 .75rem; font-size: .8rem; }
/* ---- System health (views/system-health.php) ---- */
.ms-hl { --hl-ok: var(--success); --hl-warn: var(--warning); --hl-fail: var(--destructive); }
.ms-hl.is-busy .ms-hl-groups { opacity: .65; pointer-events: none; }
.ms-hl-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.ms-hl-hero h2 { margin-top: .15rem; font-size: 1.2rem; font-weight: 700; }
.ms-hl-sub { margin-top: .2rem; font-size: .82rem; color: var(--muted-foreground); }
.ms-hl-lock { display: flex; align-items: center; gap: .4rem; margin-top: .55rem; font-size: .75rem; color: var(--muted-foreground); }
.ms-hl-lock svg { width: .85rem; height: .85rem; flex: none; }
.ms-hl-ring { --tone: var(--primary); flex: none; display: grid; place-items: center; width: 5.5rem; height: 5.5rem; border-radius: 50%;
  background: radial-gradient(closest-side, var(--card) 78%, transparent 80% 100%), conic-gradient(var(--tone) calc(var(--p) * 1%), color-mix(in srgb, var(--muted) 80%, transparent) 0); }
.ms-hl-ring[data-tone="ok"] { --tone: var(--hl-ok); }
.ms-hl-ring[data-tone="warn"] { --tone: var(--hl-warn); }
.ms-hl-ring[data-tone="fail"] { --tone: var(--hl-fail); }
.ms-hl-ring span { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ms-hl-counts { display: flex; gap: .6rem; }
.ms-hl-count { min-width: 5.5rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: .8rem; text-align: center; }
.ms-hl-count b { display: block; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ms-hl-count span { font-size: .72rem; color: var(--muted-foreground); }
.ms-hl-count.is-ok b { color: var(--hl-ok); }
.ms-hl-count.is-warn b { color: var(--hl-warn); }
.ms-hl-count.is-fail b { color: var(--hl-fail); }
.ms-hl-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1200px) { .ms-hl-grid { grid-template-columns: minmax(0, 1fr) 22rem; } }
.ms-hl-groups, .ms-hl-side { display: grid; gap: 1rem; }
.ms-hl-group { overflow: hidden; }
.ms-hl-group > header { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); }
.ms-hl-group > header h3 { font-size: .95rem; font-weight: 700; }
.ms-hl-gcount { margin-inline-start: auto; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: color-mix(in srgb, var(--hl-ok) 12%, transparent); color: var(--hl-ok); }
.ms-hl-gcount[data-tone="warn"] { background: color-mix(in srgb, var(--hl-warn) 14%, transparent); color: color-mix(in srgb, var(--hl-warn) 75%, var(--foreground)); }
.ms-hl-gcount[data-tone="fail"] { background: color-mix(in srgb, var(--hl-fail) 12%, transparent); color: var(--hl-fail); }
.ms-hl-list, .ms-hl-history { list-style: none; margin: 0; padding: 0; }
.ms-hl-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: .8rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); }
.ms-hl-row:last-child { border-bottom: 0; }
.ms-hl-row.is-fail { background: color-mix(in srgb, var(--hl-fail) 4%, transparent); }
.ms-hl-row.is-warn { background: color-mix(in srgb, var(--hl-warn) 5%, transparent); }
.ms-hl-dot { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .65rem; }
.ms-hl-dot svg { width: 1.05rem; height: 1.05rem; }
.is-ok > .ms-hl-dot { background: color-mix(in srgb, var(--hl-ok) 13%, transparent); color: var(--hl-ok); }
.is-warn > .ms-hl-dot { background: color-mix(in srgb, var(--hl-warn) 15%, transparent); color: var(--hl-warn); }
.is-fail > .ms-hl-dot { background: color-mix(in srgb, var(--hl-fail) 13%, transparent); color: var(--hl-fail); }
.ms-hl-title { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; font-size: .88rem; font-weight: 650; }
.ms-hl-badge { padding: .05rem .45rem; border-radius: 999px; font-size: .68rem; font-weight: 600; }
.ms-hl-badge.is-ok { background: color-mix(in srgb, var(--hl-ok) 12%, transparent); color: var(--hl-ok); }
.ms-hl-badge.is-warn { background: color-mix(in srgb, var(--hl-warn) 15%, transparent); color: color-mix(in srgb, var(--hl-warn) 75%, var(--foreground)); }
.ms-hl-badge.is-fail { background: color-mix(in srgb, var(--hl-fail) 12%, transparent); color: var(--hl-fail); }
.ms-hl-detail { margin-top: .15rem; font-size: .8rem; color: var(--muted-foreground); overflow-wrap: anywhere; }
.ms-hl-items { margin-top: .4rem; font-size: .76rem; }
.ms-hl-items summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.ms-hl-items ul { margin: .35rem 0 0; padding: .5rem .7rem; list-style: none; border-radius: .5rem; background: color-mix(in srgb, var(--muted) 55%, transparent); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; max-height: 14rem; overflow: auto; }
.ms-hl-items li { padding: .1rem 0; overflow-wrap: anywhere; text-align: start; }
.ms-hl-fix { white-space: nowrap; }
.ms-hl-manual { align-self: center; font-size: .72rem; color: var(--muted-foreground); white-space: nowrap; }
.ms-hl-wait { display: flex; align-items: center; gap: .5rem; padding: 1rem 1.25rem; font-size: .82rem; color: var(--muted-foreground); }
.ms-hl-wait svg { width: 1rem; height: 1rem; animation: spin 1s linear infinite; }
.ms-hl-tools { display: grid; gap: .5rem; padding: 1rem 1.25rem 1.25rem; }
.ms-hl-tools .apex-btn { justify-content: flex-start; }
.ms-hl-history { max-height: 30rem; overflow: auto; }
.ms-hl-history > li { padding: .75rem 1.25rem; border-bottom: 1px solid var(--border); }
.ms-hl-history > li:last-child { border-bottom: 0; }
.ms-hl-when { font-size: .72rem; color: var(--muted-foreground); margin-bottom: .25rem; }
.ms-hl-res { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .8rem; }
.ms-hl-res svg { width: .85rem; height: .85rem; }
.ms-hl-res.is-ok svg { color: var(--hl-ok); }
.ms-hl-res.is-fail svg { color: var(--hl-fail); }
.ms-hl-res small { flex-basis: 100%; color: var(--hl-fail); font-size: .72rem; }
.ms-hl-dlg { position: fixed; inset: 0; margin: auto; width: min(28rem, calc(100vw - 2rem)); height: fit-content; max-height: calc(100dvh - 2rem); overflow: auto; padding: 0; border: 1px solid var(--border); }
.ms-hl-dlg::backdrop { background: #0006; }
.ms-hl-dlg form { display: grid; gap: .6rem; padding: 1.25rem; }
.ms-hl-dlg-head { display: flex; gap: .75rem; align-items: flex-start; }
.ms-hl-dlg-head h3 { font-size: 1rem; font-weight: 700; }
.ms-hl-dlg-fixes { list-style: none; margin: .25rem 0; padding: .5rem .75rem; border-radius: .6rem; background: color-mix(in srgb, var(--muted) 55%, transparent); font-size: .82rem; }
.ms-hl-dlg-fixes li { display: flex; align-items: center; gap: .45rem; padding: .15rem 0; }
.ms-hl-dlg-fixes svg { width: .85rem; height: .85rem; color: var(--primary); }
.ms-hl-err { font-size: .8rem; color: var(--hl-fail); }
.ms-hl-dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }
@media (max-width: 639px) {
  .ms-hl-hero { padding: 1rem; }
  .ms-hl-counts { width: 100%; }
  .ms-hl-count { flex: 1; min-width: 0; }
  .ms-hl-row { grid-template-columns: auto minmax(0, 1fr); }
  .ms-hl-row > .ms-hl-fix, .ms-hl-row > .ms-hl-manual { grid-column: 2; justify-self: start; }
}
/* ---- Settings center (theme/settings-center.js) ---- */
.ms-sc-head { display: grid; gap: .75rem; margin-bottom: 1.25rem; }
.ms-sc-search { position: relative; display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem .35rem .9rem; border-radius: calc(var(--radius) + 6px); }
[dir="rtl"] .ms-sc-search { padding: .35rem .9rem .35rem .5rem; }
.ms-sc-search > svg { width: 1.1rem; height: 1.1rem; flex: none; color: var(--muted-foreground); }
.ms-sc-input { flex: 1; min-width: 0; height: 2.6rem; border: 0; outline: 0; background: transparent; font-size: .95rem; color: var(--foreground); }
.ms-sc-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.ms-sc-search kbd { padding: .1rem .45rem; border: 1px solid var(--border); border-radius: .35rem; font-size: .72rem; color: var(--muted-foreground); background: var(--muted); }
.ms-sc-results { position: absolute; inset-inline: 0; top: calc(100% + .35rem); z-index: 40; max-height: 26rem; overflow: auto; padding: .35rem; box-shadow: 0 18px 40px -18px #0000004d; }
.ms-sc-hit { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .7rem; border-radius: .55rem; text-align: start; }
.ms-sc-hit:hover, .ms-sc-hit.is-active { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.ms-sc-hit > svg { width: 1rem; height: 1rem; flex: none; color: var(--primary); }
.ms-sc-hit b { display: block; font-size: .87rem; font-weight: 600; }
.ms-sc-hit mark { background: color-mix(in srgb, var(--warning) 30%, transparent); color: inherit; border-radius: .2rem; }
.ms-sc-hit small { display: block; font-size: .73rem; color: var(--muted-foreground); }
.ms-sc-none { padding: .8rem; font-size: .85rem; color: var(--muted-foreground); }
.ms-sc-cards { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.ms-sc-card { display: flex; align-items: center; gap: .8rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--card); transition: border-color .15s, transform .15s, box-shadow .15s; }
.ms-sc-card:hover { border-color: color-mix(in srgb, var(--ms-tone, var(--primary)) 45%, var(--border)); box-shadow: 0 4px 14px -6px #00000026; transform: translateY(-1px); }
.ms-sc-card b { display: block; font-size: .9rem; font-weight: 650; }
.ms-sc-card small { display: block; margin-top: .1rem; font-size: .75rem; color: var(--muted-foreground); }
.ms-sc-card .ms-sc-go { width: 1rem; height: 1rem; margin-inline-start: auto; flex: none; color: var(--muted-foreground); }
[dir="rtl"] .ms-sc-card .ms-sc-go { transform: scaleX(-1); }
.ms-sc .settings-tab { align-items: flex-start; }
.ms-sc .settings-tab > svg { margin-top: .15rem; }
.ms-sc-tab { display: flex; flex-direction: column; min-width: 0; text-align: start; }
.ms-sc-desc { margin-top: .1rem; font-size: .7rem; font-weight: 400; line-height: 1.35; color: var(--muted-foreground); white-space: normal; }
@media (max-width: 1023px) { .ms-sc-desc { display: none; } }
.ms-sc-flash { animation: ms-sc-flash 2.2s ease; border-radius: .6rem; }
@keyframes ms-sc-flash { 0%, 35% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent); background-color: color-mix(in srgb, var(--primary) 7%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.ms-sc-bar { position: sticky; bottom: 1rem; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: 1rem; padding: .75rem 1rem; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border)); border-radius: calc(var(--radius) + 6px); background: color-mix(in srgb, var(--warning) 8%, var(--card)); box-shadow: 0 14px 34px -16px #00000059; }
.ms-sc-bar[hidden] { display: none; }
.ms-sc-bar > div { flex: 1; }
.ms-sc-bar b { font-size: .9rem; }
.ms-sc-bar p { font-size: .78rem; color: var(--muted-foreground); }
.ms-sc-bar-ico { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: .65rem; background: color-mix(in srgb, var(--warning) 18%, transparent); color: color-mix(in srgb, var(--warning) 80%, var(--foreground)); }
.ms-sc-bar-ico svg { width: 1.1rem; height: 1.1rem; }
/* ---- Vouchers (views/vouchers.php) ---- */
.ms-vch { --vch-in: var(--success); --vch-out: var(--destructive); }
.ms-vch-form .ms-section-head { gap: 1rem; }
.ms-vch-dir { display: inline-flex; gap: .25rem; padding: .25rem; border-radius: .8rem; background: var(--muted); }
.ms-vch-dir-btn { display: inline-flex; align-items: center; gap: .45rem; height: 2.4rem; padding: 0 1.1rem; border-radius: .6rem; font-size: .88rem; font-weight: 600; color: var(--muted-foreground); transition: background .15s, color .15s; }
.ms-vch-dir-btn svg { width: 1rem; height: 1rem; }
.ms-vch-dir-btn:hover { color: var(--foreground); }
.ms-vch-dir-btn.is-on { background: var(--card); color: var(--foreground); box-shadow: 0 1px 3px #0000001f; }
.ms-vch-dir-btn.is-on[data-tone="in"] svg { color: var(--vch-in); }
.ms-vch-dir-btn.is-on[data-tone="out"] svg { color: var(--vch-out); }
.ms-vch-body { display: grid; gap: 1.25rem; padding: 1.25rem; }
.ms-vch-label { margin: 0 0 .75rem; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-foreground); }
.ms-vch-hint { padding: .65rem .85rem; border-radius: .6rem; background: color-mix(in srgb, var(--chart-3) 9%, transparent); font-size: .8rem; color: var(--muted-foreground); }
.ms-vch-box { padding: 1rem; border: 1px dashed var(--border); border-radius: .8rem; background: color-mix(in srgb, var(--muted) 35%, transparent); }
.ms-vch-money { display: grid; gap: .75rem; padding: 1rem; border: 1px solid var(--border); border-radius: .8rem; background: color-mix(in srgb, var(--muted) 30%, transparent); }
.ms-vch-money [data-tender] { padding: .5rem; border-radius: .6rem; background: var(--card); border: 1px solid var(--border); }
.ms-vch-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--muted) 40%, transparent); }
.ms-vch-total { display: flex; align-items: baseline; gap: .6rem; }
.ms-vch-total span { font-size: .85rem; color: var(--muted-foreground); }
.ms-vch-total b { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ms-vch-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.ms-vch-bar .ms-seg .apex-tab-active { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px #0000001a; }
.ms-vch-bar .ms-tab-count { margin-inline-start: .15rem; }
.ms-vch-search { position: relative; margin-inline-start: auto; width: min(100%, 20rem); }
.ms-vch-search svg { position: absolute; inset-inline-start: .75rem; top: 50%; width: 1rem; height: 1rem; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.ms-vch-search input { width: 100%; padding-inline-start: 2.3rem; }
.ms-vch-select { width: auto; min-width: 11rem; height: 2.65rem; }
.ms-vch-scroll { overflow-x: auto; }
.ms-vch-table { min-width: 760px; }
.ms-vch-table td { padding: .8rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ms-vch-table .num { text-align: end; }
.ms-vch-table tbody tr:not(.ms-vch-group):hover { background: color-mix(in srgb, var(--muted) 35%, transparent); }
.ms-vch-table tr.is-voided td { color: var(--muted-foreground); }
.ms-vch-table tr.is-voided .ms-vch-amount, .ms-vch-table tr.is-voided .ms-vch-code { text-decoration: line-through; opacity: .7; }
.ms-vch-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 700; font-size: .82rem; }
.ms-vch-void { display: inline-block; width: fit-content; padding: .05rem .45rem; border-radius: 999px; font-size: .68rem; font-weight: 600; background: color-mix(in srgb, var(--destructive) 12%, transparent); color: var(--destructive); }
.ms-vch-methods { display: flex; flex-wrap: wrap; gap: .3rem; }
.ms-vch-method { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; background: var(--muted); color: var(--muted-foreground); white-space: nowrap; }
.ms-vch-method b { color: var(--foreground); font-weight: 600; font-variant-numeric: tabular-nums; }
.ms-vch-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-vch-amount.is-in { color: var(--vch-in); }
.ms-vch-amount.is-out { color: color-mix(in srgb, var(--vch-out) 85%, var(--foreground)); }
.ms-vch-actions { display: inline-flex; justify-content: flex-end; gap: .35rem; }
.ms-vch-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--card); color: var(--muted-foreground); transition: color .15s, border-color .15s, background .15s; }
.ms-vch-icon svg { width: .95rem; height: .95rem; }
.ms-vch-icon:hover { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.ms-vch-icon.is-danger:hover { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 45%, var(--border)); background: color-mix(in srgb, var(--destructive) 6%, var(--card)); }
.ms-vch-empty { display: grid; place-items: center; gap: .5rem; padding: 3rem 1rem; color: var(--muted-foreground); font-size: .88rem; }
.ms-vch-empty svg { width: 2rem; height: 2rem; opacity: .5; }
.ms-vch-exp-grid { display: grid; gap: 1rem; margin-top: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1280px) { .ms-vch-exp-grid { grid-template-columns: 21rem minmax(0, 1fr); } }
.ms-vch-share { list-style: none; margin: 0; padding: .5rem 1.25rem 1.25rem; display: grid; gap: .9rem; }
.ms-vch-share-top { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.ms-vch-share-top b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-vch-share-top small { color: var(--muted-foreground); font-size: .72rem; white-space: nowrap; }
.ms-vch-share-val { margin-inline-start: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-vch-share-val em { margin-inline-start: .4rem; font-style: normal; font-weight: 500; font-size: .72rem; color: var(--muted-foreground); }
.ms-vch-share-bar { height: .45rem; margin-top: .4rem; border-radius: 999px; background: var(--muted); overflow: hidden; }
.ms-vch-share-bar i { display: block; height: 100%; border-radius: inherit; }
.ms-vch-dot { width: .6rem; height: .6rem; border-radius: 50%; flex: none; }
:is(.ms-vch-dot, .ms-vch-share-bar i)[style*="--i:0"] { background: var(--chart-1); }
:is(.ms-vch-dot, .ms-vch-share-bar i)[style*="--i:1"] { background: var(--chart-2); }
:is(.ms-vch-dot, .ms-vch-share-bar i)[style*="--i:2"] { background: var(--chart-3); }
:is(.ms-vch-dot, .ms-vch-share-bar i)[style*="--i:3"] { background: var(--chart-4); }
:is(.ms-vch-dot, .ms-vch-share-bar i)[style*="--i:4"] { background: var(--chart-5); }
:is(.ms-vch-dot, .ms-vch-share-bar i)[style*="--i:5"] { background: var(--primary); }
.ms-vch-group td { padding: .6rem 1.25rem; background: color-mix(in srgb, var(--primary) 5%, var(--card)); border-bottom: 1px solid var(--border); }
.ms-vch-group div { display: flex; align-items: baseline; gap: .5rem; }
.ms-vch-group b { font-size: .88rem; }
.ms-vch-group small { font-size: .72rem; color: var(--muted-foreground); }
@media (max-width: 639px) {
  .ms-vch-dir { width: 100%; }
  .ms-vch-dir-btn { flex: 1; justify-content: center; padding: 0 .5rem; }
  .ms-vch-search { width: 100%; margin-inline-start: 0; }
  .ms-vch-foot .apex-btn { width: 100%; justify-content: center; }
}.ms-vch-bar .hidden, .ms-vch-bar [hidden] { display: none !important; }
.ms-vch-table.is-compact { min-width: 640px; }
.ms-vch-table.is-compact td { padding: .7rem 1rem; }@media (max-width: 639px) {
  .ms-vch .ms-kpi-value { font-size: 1.05rem; white-space: nowrap; }
  .ms-vch .ms-kpi-label, .ms-vch .ms-kpi-hint { white-space: normal; overflow-wrap: break-word; }
  .ms-vch-select { width: 100%; }
}
/* Staff advances + payroll: hidden card takes no space; tables scroll on tablets and become cards on phones. */
.ms-adv-card[hidden], .ms-adv-slot:empty { display: none !important; }
.ms-adv-body > div, .ms-payroll-body > div { overflow-x: auto; }
.ms-adv-body .ms-table, .ms-payroll-body .ms-table { width: 100%; }
@media (max-width: 640px) {
  .ms-adv-card > .ms-section-head, .ms-payroll > .ms-section-head { padding: .85rem 1rem !important; }
  .ms-adv-body, .ms-payroll-body { padding: .85rem 1rem 1rem; }
  .ms-payroll-top { grid-template-columns: 1fr 1fr; }
  .ms-payroll-day { grid-column: 1 / -1; }
  .ms-payroll-row .apex-input { flex: 1 1 6rem; width: auto; }
  .ms-adv-form { display: grid; grid-template-columns: 1fr; }
  .ms-adv-form [data-amount] { width: 100%; }
  .ms-adv-form .ms-adv-reason { flex: none; }
  .ms-adv-form [data-send] { width: 100%; justify-content: center; }
  .ms-table.ms-stack, .ms-table.ms-stack tbody, .ms-table.ms-stack tr, .ms-table.ms-stack td { display: block; width: 100%; }
  .ms-table.ms-stack thead { display: none; }
  .ms-table.ms-stack tr { margin-bottom: .6rem; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--card); }
  .ms-table.ms-stack td { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .3rem 0 !important; border: 0 !important; text-align: start; }
  .ms-table.ms-stack td[data-label]::before { content: attr(data-label); color: var(--muted-foreground); font-size: .75rem; flex-shrink: 0; }
  .ms-table.ms-stack td:empty { display: none; }
  .ms-table.ms-stack td.ms-stack-actions { display: block; padding-top: .5rem !important; }
  .ms-table.ms-stack .ms-stack-actions .ms-payroll-row { display: grid; grid-template-columns: 1fr 1fr; }
  .ms-table.ms-stack .ms-stack-actions .apex-select { grid-column: 1 / -1; width: 100%; height: 2.4rem; }
  .ms-table.ms-stack .ms-stack-actions .apex-btn { width: 100%; justify-content: center; }
  .ms-table.ms-stack .ms-stack-actions .ms-payroll-row > :only-child, .ms-table.ms-stack .ms-stack-actions .apex-btn:last-child:nth-child(2) { grid-column: 1 / -1; }
}
/* Vouchers on phones: each voucher / expense is a card (number + amount on top, labelled lines, actions at the end). */
@media (max-width: 639px) {
  .ms-vch-scroll { overflow: visible; }
  .ms-vch-table, .ms-vch-table.is-compact { min-width: 0; width: 100%; }
  .ms-vch-table thead { display: none; }
  .ms-vch-table, .ms-vch-table tbody { display: block; }
  .ms-vch-table tbody tr:not(.ms-vch-group) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .75rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
  .ms-vch-table tbody tr td { display: block; padding: 0 !important; border: 0 !important; min-width: 0; height: auto; text-align: start; position: static !important; background: transparent !important; box-shadow: none !important; }
  .ms-vch-table tbody tr:not(.ms-vch-group) td:first-child { grid-column: 1; grid-row: 1; }
  .ms-vch-table tbody tr:not(.ms-vch-group) td.num:has(.ms-vch-amount) { grid-column: 2; grid-row: 1; align-self: start; text-align: end; }
  .ms-vch-table tbody tr:not(.ms-vch-group) td[data-label] { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: .75rem; font-size: .82rem; }
  .ms-vch-table tbody tr:not(.ms-vch-group) td[data-label]::before { content: attr(data-label); flex-shrink: 0; font-size: .72rem; color: var(--muted-foreground); }
  .ms-vch-table tbody tr:not(.ms-vch-group) td[data-label] > * { min-width: 0; text-align: end; }
  .ms-vch-table td[data-label] .ms-who, .ms-vch-table td[data-label] .ms-item { justify-content: flex-end; }
  .ms-vch-table td[data-label] .ms-who-sub, .ms-vch-table td[data-label] .ms-stock { justify-content: flex-end; overflow-wrap: anywhere; }
  .ms-vch-table td[data-label] .ms-vch-methods { justify-content: flex-end; }
  .ms-vch-table tbody tr:not(.ms-vch-group) td.num:has(.ms-vch-actions) { grid-column: 1 / -1; padding-top: .35rem; }
  .ms-vch-table .ms-vch-actions { display: flex; justify-content: flex-end; }
  .ms-vch-table .ms-vch-amount { font-size: .95rem; }
  .ms-vch-group { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; background: color-mix(in srgb, var(--primary) 5%, var(--card)); border-bottom: 1px solid var(--border); }
  .ms-vch-group td:empty { display: none; }
  .ms-vch-share { padding: .5rem 1rem 1rem; }
  .ms-vch-share-top { flex-wrap: wrap; }
  .ms-vch-bar .ms-seg { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .ms-vch-bar .ms-seg .apex-tab { flex: 1 0 auto; justify-content: center; white-space: nowrap; }
}
/* Conversations: who is responsible (assign) — dock windows, the full page and the notice. */
.wa-win-assign { display: flex; align-items: center; gap: .4rem; padding: .35rem .75rem; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--muted) 45%, var(--card)); font-size: .75rem; color: var(--muted-foreground); }
.wa-win-assign svg { width: .8rem; height: .8rem; flex: none; }
.wa-win-assign select { flex: 1; min-width: 0; height: 1.75rem; padding: 0 .4rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--card); color: var(--foreground); font-size: .78rem; }
.wa-assign-line, .ms-chat-assign { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .4rem; margin: .4rem auto; padding: .25rem .7rem; width: fit-content; max-width: 92%; border-radius: 999px; background: color-mix(in srgb, var(--primary) 9%, var(--card)); color: var(--foreground); font-size: .74rem; text-align: center; }
.wa-assign-line span, .ms-chat-assign small { font-size: .68rem; color: var(--muted-foreground); }
.wa-dock-mine, .ms-conv-assignee { flex: none; padding: .05rem .45rem; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); font-size: .66rem; font-weight: 600; white-space: nowrap; max-width: 7rem; overflow: hidden; text-overflow: ellipsis; }
.wa-dock-mine, .ms-conv-assignee.is-me { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.ms-chat-assign-pick { display: flex; align-items: center; gap: .35rem; margin-inline-start: .5rem; font-size: .75rem; color: var(--muted-foreground); }
.ms-chat-assign-pick select { height: 2rem; max-width: 11rem; padding: 0 .5rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--card); color: var(--foreground); font-size: .8rem; }
.ms-chat-mine { display: inline-grid; place-items: center; margin-inline-start: auto; width: 2rem; height: 2rem; border-radius: 999px; color: var(--muted-foreground); background: transparent; }
.ms-chat-mine:hover { background: var(--muted); color: var(--foreground); }
.ms-chat-mine.is-on { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.wa-assign-toast { display: flex; align-items: center; gap: .6rem; }
.wa-assign-toast svg { width: 1rem; height: 1rem; flex: none; }
.wa-assign-toast button { flex: none; padding: .25rem .7rem; border-radius: .45rem; background: var(--primary); color: var(--primary-foreground, #fff); font-size: .78rem; font-weight: 600; }
@media (max-width: 640px) {
  .ms-chat-assign-pick span { display: none; }
  .ms-chat-assign-pick select { max-width: 8.5rem; }
}
/* Order steps on phones: all steps fit the card (they were 88px each and the last one was cut at the edge). */
@media (max-width: 640px) {
  .ms-steps { padding-inline: .5rem; }
  .ms-steps li { min-width: 0; padding-inline: .15rem; }
  .ms-step-label { font-size: .68rem; overflow-wrap: anywhere; }
}
/* One-line (truncated) Arabic text: room for the letters that go below the line (ي، ج، ع…), same layout. */
:lang(ar) .truncate, :lang(ar) .ms-conv-name, :lang(ar) .ms-conv-preview { padding-block: .12em; margin-block: -.12em; }
/* Message status marks (Font Awesome, WhatsApp colours): grey clock / tick / ticks, blue ticks when read, red when not sent. */
.ms-st { display: inline-flex; align-items: center; vertical-align: middle; color: #8696a0; line-height: 1; }
.ms-st svg { display: block; }
.ms-st.is-read { color: #53bdeb; }
.ms-st.is-failed { color: #ea0038; }
.ms-st.is-pending svg { opacity: .85; }
.ms-st-pill { display: inline-flex; align-items: center; gap: .35rem; }
/* Transfer the conversation to people (dock window + chat header). */
.wa-win-assign label { display: flex; flex: 1; min-width: 0; align-items: center; gap: .4rem; }
.wa-transfer-btn, .ms-chat-transfer-btn { display: inline-flex; align-items: center; gap: .3rem; flex: none; height: 1.75rem; padding: 0 .55rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--card); color: var(--foreground); font-size: .74rem; font-weight: 600; }
.ms-chat-transfer-btn { height: 2rem; font-size: .8rem; }
.wa-transfer-btn.is-on, .ms-chat-transfer-btn.is-on { border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--card)); }
[dir="rtl"] .ms-i-forward { transform: scaleX(-1); }
.wa-transfer, .ms-chat-transfer-pop { display: grid; gap: .5rem; padding: .65rem .75rem; border-bottom: 1px solid var(--border); background: var(--card); font-size: .8rem; }
.wa-transfer p, .ms-chat-transfer-pop p { font-weight: 600; font-size: .78rem; }
.wa-transfer-people { display: flex; flex-wrap: wrap; gap: .35rem; max-height: 7.5rem; overflow: auto; }
.wa-transfer-people label { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: .78rem; }
.wa-transfer-people label:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
.wa-transfer-note { height: 2rem; padding: 0 .6rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--background); color: var(--foreground); font-size: .8rem; }
.wa-transfer-foot { display: flex; gap: .4rem; }
.wa-transfer-foot button { height: 1.9rem; padding: 0 .8rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--card); font-size: .78rem; font-weight: 600; }
.wa-transfer-foot button.is-primary { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground, #fff); }
.ms-chat-transfer { position: relative; }
.ms-chat-transfer-pop { position: absolute; z-index: 30; top: calc(100% + .4rem); inset-inline-end: 0; width: min(20rem, 85vw); border: 1px solid var(--border); border-radius: .75rem; box-shadow: 0 10px 30px #0000002e; }
.wa-assign-line svg, .ms-chat-assign svg { width: .75rem; height: .75rem; flex: none; }
.wa-assign-line em, .ms-chat-assign em { flex-basis: 100%; font-style: normal; color: var(--muted-foreground); }
/* Chat header: the Client / Supplier tag sits right after the name; the assignee and Transfer keep to the far side. */
.ms-chat-head-title { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.ms-chat-head-title .ms-chat-head-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-chat-head-title .ms-party-badge { flex: none; }
.ms-chat-head-main { flex: 1 1 auto; min-width: 0; }
.ms-chat-head .ms-chat-assign-pick { margin-inline-start: auto; }
.ms-chat-head .ms-chat-transfer { margin-inline-start: .4rem; }
/* The Transfer box opens above the messages, on a solid background. */
.ms-chat-head { position: relative; z-index: 6; }
.ms-chat-transfer-pop { background: var(--popover, var(--card)); }
/* Settings → WhatsApp: conversation team options. */
.ms-wa-team { padding: 0 !important; overflow: hidden; margin-top: 1rem; }
.ms-wa-team > .ms-section-head { padding: 1rem 1.25rem !important; border-bottom: 1px solid var(--border); }
.ms-wa-team-body { display: grid; gap: .6rem; padding: 1rem 1.25rem 1.15rem; }
.ms-wa-team-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: .7rem; cursor: pointer; }
.ms-wa-team-row b { display: block; font-size: .88rem; font-weight: 600; }
.ms-wa-team-row small { display: block; margin-top: .15rem; font-size: .76rem; color: var(--muted-foreground); }
.ms-wa-team-row input { flex: none; }
/* Chat header on phones: name on the first row, assignee + Transfer on a second row. */
@media (max-width: 640px) {
  .ms-chat-head { flex-wrap: wrap; row-gap: .45rem; }
  .ms-chat-head-main { flex: 1 1 8rem; min-width: 8rem; }
  .ms-chat-head .ms-chat-assign-pick { order: 5; margin-inline-start: 0; flex: 1 1 calc(100% - 7rem); }
  .ms-chat-head .ms-chat-assign-pick select { max-width: none; width: 100%; }
  .ms-chat-head .ms-chat-transfer { order: 6; }
}
/* Settings → webhook card on phones: the long URL and the event list wrap inside the card. */
#wa-webhook-card .ms-wh-url { flex-wrap: wrap; min-width: 0; }
#wa-webhook-card .ms-wh-url code { flex: 1 1 100%; min-width: 0; max-width: 100%; white-space: normal; word-break: break-all; }
#wa-webhook-card .ms-wh-events { overflow-wrap: anywhere; white-space: normal; }
.ms-vch-group b { line-height: 1.5; }

/* ── Chat on computers: Facebook-style footer. A "Conversations" bar on the bottom edge opens the
   list upwards; chat windows stand on the bottom edge beside it; a folded window is a bar there. ── */
.wa-dock-launch-label { display: none; }
@media (min-width: 768px) and (pointer: fine) {
  /* The round chat button stays as it was; the windows stand on the bottom edge beside it. */
  .wa-dock-windows { position: fixed; bottom: 0; inset-inline-end: calc(1rem + 3.4rem + .9rem); transform: none !important; gap: .6rem; align-items: flex-end; }
  .wa-win { height: min(28rem, calc(100vh - 4rem)); border-radius: .85rem .85rem 0 0; border-bottom: 0; box-shadow: 0 -8px 30px -12px #00000059, 0 0 0 1px color-mix(in srgb, var(--border) 80%, transparent); }
  .wa-win-head { border-radius: .85rem .85rem 0 0; cursor: pointer; }
  .wa-win-head:hover { background: color-mix(in srgb, var(--muted) 55%, var(--card)); }
  .wa-win.is-min { width: 15rem; height: 2.85rem; border-radius: .85rem .85rem 0 0; box-shadow: 0 -6px 22px -10px #0000004d; }
  .wa-win.is-min .wa-win-bar { height: 100%; }
  .wa-win.is-min .wa-win-bar b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wa-win.is-min .wa-dock-conv-unread { margin-inline-start: auto; }
}
/* The conversation list opens above any open chat window, never behind it. */
.wa-dock-list { z-index: 1002; }

/* Message field as in WhatsApp: the attach clip sits inside the field, at its end. */
.wa-win-field, .ms-composer-field { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; }
.wa-win-field .wa-win-input { width: 100%; padding-inline-end: 2.4rem; }
.wa-win-field .wa-win-attach { position: absolute; inset-inline-end: .2rem; top: 50%; transform: translateY(-50%); width: 1.8rem; height: 1.8rem; }
.ms-composer-field textarea { width: 100%; padding-inline-end: 2.8rem; }
.ms-composer-field .ms-attach { position: absolute; inset-inline-end: .3rem; bottom: .3rem; margin: 0; }
.wa-win-modes [data-transfer].is-on { color: var(--primary); }.ms-composer-field .ms-attach { width: 2rem; height: 2rem; }
/* Transfer sits with "Reply / Team note" in the composer; its box opens upwards. */
.ms-composer-modes .ms-chat-transfer { position: relative; }
.ms-composer-modes .ms-chat-transfer-pop { top: auto; bottom: calc(100% + .45rem); inset-inline-start: 0; inset-inline-end: auto; }
.ms-composer-modes .ms-chat-transfer > button.is-on { border-color: transparent; background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); font-weight: 600; }
.wa-transfer-select { height: 2.1rem; padding: 0 .6rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--background); color: var(--foreground); font-size: .82rem; }

/* Settings: room between the page lead and the search box. */
.ms-sc-head { margin-top: 1.25rem; }
.ms-note-times { margin-inline-start: .3rem; padding: 0 .4rem; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); font-size: .68rem; font-weight: 600; }

/* Advance requests / payroll: room above the card on the staff list, inner padding everywhere,
   and on phones the request cards use the full width (no second frame around them). */
.ms-adv-slot > .ms-adv-card { margin: 1.25rem 0 1.25rem !important; }
.ms-adv-body, .ms-payroll-body { padding: 1rem 1.25rem 1.25rem !important; }
@media (max-width: 640px) {
  .ms-adv-body, .ms-payroll-body { padding: .85rem .85rem 1rem !important; }
  .ms-adv-body > div:has(> table.ms-stack), .ms-payroll-body > div:has(> table.ms-stack) { margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: none !important; width: 100% !important; overflow: visible; }
  .ms-table.ms-stack tr { padding: .7rem .85rem; }
  .ms-table.ms-stack td { font-size: .85rem; }
}
/* Staff profile → Contract: the contract page itself, on a soft background like a sheet of paper. */
.ms-contract-sheet { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: .75rem; background: #fff; box-shadow: 0 6px 20px -12px #0000003d; }
.ms-contract-sheet iframe { display: block; border: 0; background: #fff; transform-origin: top right; }
[dir="ltr"] .ms-contract-sheet iframe { transform-origin: top left; }
.ms-contract-sheet { margin-inline: auto; max-width: 760px; }
/* Signature pads have the shape of the signature space on the contract (70 × 24 mm), so a
   signature fills that space instead of shrinking into it. */
canvas[data-sign-pad], .ms-sig-pad { display: block; width: min(100%, 27rem) !important; height: auto !important; aspect-ratio: 70 / 24; margin-inline: auto; }
/* Phones: cards drop to 16px padding, so their header strip must pull back by the same 16px
   (it was pulled 24px and stuck out of the card on both sides). */
@media (max-width: 767px) {
  .apex-card:is(.p-5, .p-6)[class][class] > .ms-section-head { margin: -1rem -1rem .5rem !important; padding: .9rem 1rem !important; }
}
/* Number fields everywhere: no up/down arrows (typed amounts only). */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.ms-contract-signed { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; background: color-mix(in srgb, var(--success, #16a34a) 14%, transparent); color: var(--success, #15803d); font-size: .78rem; font-weight: 600; }

/* Phones: tables whose rows become cards (sale cart, advance requests, payroll) keep the last
   card's bottom border — the general "#main-content … tbody tr:last-child { border-bottom: 0 }"
   (meant for plain tables) was cutting it off. */
@media (max-width: 640px) {
  #main-content :is(table.ms-cart, table.ms-stack) tbody tr:last-child { border-bottom: 1px solid var(--border) !important; }
}
/* A table inside a part of a card that already has its own inner padding (a "…-body" or a
   p- or px- padding box) takes that part's full width — the same width as the notes and forms above it —
   instead of adding the card-edge margin a second time. */
#main-content :is([class*="-body"], .p-3, .p-4, .p-5, .p-6, [class*="px-"]) > div:has(> table.ms-table) { margin-inline: 0 !important; }
/* A table set straight in a card lines up with the card header's text (1.25rem from the edge). */
@media (min-width: 641px) {
  .apex-card:not([class*="p-"]) > div:has(> table.ms-table):not(.border):not([class*="rounded"]) { margin-inline: 1.25rem !important; }
}
/* Phones: the "Transfer the conversation to" box opens across the screen above the message box
   (it was pinned to the button and ran off the left edge). */
@media (max-width: 640px) {
  .ms-composer-modes .ms-chat-transfer-pop { position: fixed; inset-inline: .75rem; bottom: calc(7.5rem + env(safe-area-inset-bottom, 0px)); top: auto; width: auto; z-index: 60; }
}
/* Chat header: "back" sits at the far end — left in Arabic, right in English — pointing outwards. */
.ms-chat-head .ms-chat-back { order: 4; margin-inline-start: auto; }
.ms-chat-head .ms-chat-head-main + .ms-chat-back, .ms-chat-head .ms-chat-assign-pick ~ .ms-chat-back { margin-inline-start: .25rem; }
html[dir="rtl"] .ms-chat-back svg { transform: none; }
html[dir="ltr"] .ms-chat-back svg { transform: scaleX(-1); }
/* Conversations page: exactly the visible screen (100dvh — on phones 100vh also counts the space
   behind the browser bar, so the page kept sliding up and down). Only the messages scroll. */
/* --ms-app-h is the height really visible (wa-chat.js, from visualViewport: also shrinks while the
   keyboard is open); 100vh / 100dvh are the fallbacks for browsers without it. */
html[data-page="chat"], html[data-page="chat"] body { height: 100vh; height: 100dvh; height: var(--ms-app-h, 100dvh); overflow: hidden; overscroll-behavior: none; }
html[data-page="chat"] body .min-h-screen { min-height: 0; height: 100vh; height: 100dvh; height: var(--ms-app-h, 100dvh); }
html[data-page="chat"] .ms-composer { padding-bottom: calc(.65rem + env(safe-area-inset-bottom, 0px)); }
html[data-page="chat"] #main-content { overflow: hidden; }
html[data-page="chat"] .ms-chat-root, html[data-page="chat"] .ms-chat { height: 100%; }
html[data-page="chat"] .ms-thread, html[data-page="chat"] .ms-chat-list-body { overscroll-behavior: contain; }
/* Order page → Rejection & refund. */
.ms-or { padding: 0 !important; overflow: hidden; margin-top: 1rem; }
.ms-or > .ms-section-head { padding: 1rem 1.25rem !important; border-bottom: 1px solid var(--border); }
.ms-or-body { display: grid; gap: .8rem; padding: 1rem 1.25rem 1.25rem; }
.ms-or-lead { font-size: .84rem; color: var(--muted-foreground); }
.ms-or-form { display: grid; gap: .6rem; }
.ms-or-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ms-or-row .apex-input { flex: 1 1 8rem; width: auto; }
.ms-or-row .apex-select { flex: 1 1 9rem; width: auto; }
.ms-or-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ms-or-choices { display: grid; gap: .4rem; border: 0; padding: 0; margin: 0; }
.ms-or-choices label { display: flex; align-items: center; gap: .5rem; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: .6rem; font-size: .85rem; cursor: pointer; }
.ms-or-choices label:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.ms-or-choices label:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.ms-or-note { display: grid; gap: .2rem; padding: .7rem .85rem; border-radius: .6rem; font-size: .85rem; }
.ms-or-note small { color: var(--muted-foreground); font-size: .74rem; }
.ms-or-note.is-wait { background: color-mix(in srgb, #d97706 10%, transparent); }
.ms-or-note.is-done { background: color-mix(in srgb, var(--destructive) 8%, transparent); }
.ms-or-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .5rem; margin: 0; }
.ms-or-facts div { padding: .55rem .75rem; border: 1px solid var(--border); border-radius: .6rem; }
.ms-or-facts dt { font-size: .72rem; color: var(--muted-foreground); }
.ms-or-facts dd { margin: 0; font-weight: 600; font-size: .9rem; }
.ms-or-facts dd.is-due { color: var(--destructive); }
.ms-or-refunds { margin: 0; padding-inline-start: 1.1rem; font-size: .8rem; color: var(--muted-foreground); }
/* Hand-back / refund confirmation dialogs. */
.ms-or-confirm { width: min(30rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto; padding: 0; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); color: var(--foreground); }
.ms-or-confirm::backdrop { background: #0006; }
.ms-or-confirm > form { display: grid; gap: .7rem; padding: 1.25rem 1.35rem 1.35rem; }
.ms-or-confirm h3 { font-size: 1rem; font-weight: 700; }
.ms-or-confirm .ms-or-actions { justify-content: flex-start; margin-top: .25rem; }
/* A rejected order's steps: Reception → Workshop → Rejected → Back at reception → Delivered,
   the "Rejected" step in red once passed. */
.ms-steps[data-rejected] li:nth-child(3).is-done .ms-step-dot { border-color: var(--destructive); background: var(--destructive); color: #fff; }
.ms-steps[data-rejected] li:nth-child(3) .ms-step-label { color: var(--destructive); font-weight: 600; }
.ms-or-check { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }

/* Rejection details shown inside the order's Status path card. */
.ms-or.ms-or-in { margin: 0 0 1rem !important; border: 0; box-shadow: none; background: none; }
.ms-or-in .ms-or-body { padding: 0; }
.ms-or-in:has(.ms-or-body > .ms-payroll-msg:only-child) { display: none; }

/* The rejection decision, under the "Declined" chip in the status path. */
.ms-pipe-decision { display: grid; gap: .15rem; padding: .55rem .75rem; border-radius: .6rem; background: color-mix(in srgb, var(--destructive) 8%, transparent); font-size: .8rem; }
.ms-pipe-decision b { color: var(--destructive); }
.ms-pipe-decision small { color: var(--muted-foreground); font-size: .72rem; }
.ms-pipe-decision.is-wait { background: color-mix(in srgb, #d97706 10%, transparent); }
.ms-pipe-decision.is-wait b { color: #b45309; }


.ms-pipe-chip.is-closed { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* Account statement: period picker (theme/account-statement.js). */
.ms-st-dlg { width: min(28rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto; padding: 0; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); color: var(--foreground); }
.ms-st-form { display: grid; gap: .85rem; padding: 1.25rem; }
.ms-st-form h3 { font-size: 1.05rem; font-weight: 700; }
.ms-st-lead { font-size: .85rem; color: var(--muted-foreground); }
.ms-st-periods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.ms-st-periods label { display: flex; align-items: center; gap: .5rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: .6rem; font-size: .85rem; cursor: pointer; }
.ms-st-periods label:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.ms-st-custom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.ms-st-custom[hidden] { display: none; }
.ms-st-custom label { display: grid; gap: .3rem; }
.ms-st-err { color: var(--destructive); font-size: .82rem; }
.ms-st-err:empty { display: none; }
.ms-st-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 420px) { .ms-st-periods, .ms-st-custom { grid-template-columns: 1fr; } }