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) minmax(0, 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: minmax(0, 1fr); }
  .ms-chat-list { min-width: 0; }
  .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-b-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-win-input { display: block; flex: 1 1 auto; min-width: 0; height: 2.1rem; min-height: 2.1rem; max-height: 140px; padding: .48rem .7rem; line-height: 1.25; resize: none; overflow-y: auto; scrollbar-width: thin; 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; }
}
/* Tablets: the name, badges and contact chips keep most of the width (the chips sat one per line). */
@media (min-width: 768px) and (max-width: 1023px) {
  .ms-hero-actions { max-width: 40%; }
}
/* 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; }
/* ---- Status cards: hero, counters, groups of rows (views/desk-panel.php) ---- */
.ms-hl { --hl-ok: var(--success); --hl-warn: var(--warning); --hl-fail: var(--destructive); }
.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-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-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-list { 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; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
.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-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; }
@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); }
}
/* ---- 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; } }
/* Media viewer (theme/media-viewer.js): photos and videos of a chat, on the page. */
.ms-mv { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgb(8 10 14 / .94); color: #fff; overflow: hidden; }
.ms-mv[open] { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) 4.5rem; grid-template-rows: auto minmax(0, 1fr); }
.ms-mv::backdrop { background: rgb(8 10 14 / .94); }
html.ms-mv-open { overflow: hidden; }
.ms-mv-top { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: .4rem; padding: .6rem .8rem; padding-top: calc(.6rem + env(safe-area-inset-top, 0px)); }
.ms-mv-count { margin-inline-end: auto; font-size: .9rem; font-variant-numeric: tabular-nums; opacity: .85; direction: ltr; unicode-bidi: isolate; }
.ms-mv-fail { color: rgb(255 255 255 / .75); font-size: .95rem; text-align: center; }
.ms-mv-btn { display: inline-grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 999px; color: #fff; background: rgb(255 255 255 / .1); }
.ms-mv-btn:hover, .ms-mv-btn:focus-visible { background: rgb(255 255 255 / .22); outline: none; }
.ms-mv-stage { grid-row: 2; grid-column: 2; display: grid; place-items: center; min-width: 0; min-height: 0; padding: .5rem 0 1.25rem; overflow: hidden; }
/* The whole picture always fits the screen: no scrolling to see the rest of it. */
.ms-mv-stage img, .ms-mv-stage video { display: block; width: auto; height: auto; max-width: min(100%, calc(100vw - 10rem)); max-height: calc(100dvh - 6.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); object-fit: contain; border-radius: .5rem; box-shadow: 0 10px 40px -10px #000; background: #000; }
.ms-mv-nav { grid-row: 2; align-self: center; justify-self: center; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 999px; color: #fff; background: rgb(255 255 255 / .12); }
.ms-mv-nav:hover:not(:disabled), .ms-mv-nav:focus-visible { background: rgb(255 255 255 / .25); outline: none; }
.ms-mv-nav:disabled { opacity: .25; cursor: default; }
.ms-mv-nav[hidden] { display: none; }
.ms-mv-nav.is-prev { grid-column: 1; }
.ms-mv-nav.is-next { grid-column: 3; }
html[dir="rtl"] .ms-mv-nav svg { transform: scaleX(-1); }
@media (max-width: 640px) {
  .ms-mv[open] { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .ms-mv-nav { position: absolute; top: 50%; translate: 0 -50%; width: 2.5rem; height: 2.5rem; background: rgb(0 0 0 / .45); }
  .ms-mv-nav.is-prev { inset-inline-start: .4rem; }
  .ms-mv-nav.is-next { inset-inline-end: .4rem; }
  .ms-mv-stage img, .ms-mv-stage video { max-width: calc(100vw - 1rem); }
}
/* Video bubbles: a still frame with a play mark (opens the viewer). */
.ms-bubble-video, .wa-b-video { position: relative; display: block; }
.ms-bubble-video video, .wa-b-video video { display: block; width: 100%; max-height: 16rem; object-fit: cover; border-radius: inherit; background: #000; pointer-events: none; }
.ms-play { position: absolute; inset: 0; margin: auto; width: 3rem; height: 3rem; border-radius: 999px; background: rgb(0 0 0 / .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center / 1.6rem no-repeat; }
/* WhatsApp actions mirrored in the chats: deleted, edited, reactions. */
.ms-bubble.is-deleted, .wa-b.is-deleted { opacity: .78; }
.ms-deleted-text, .wa-deleted { display: inline-flex; align-items: center; gap: .35rem; font-style: italic; color: var(--muted-foreground); }
.ms-edited, .wa-edited { font-style: normal; font-size: .68rem; opacity: .75; margin-inline-end: .35rem; }
.ms-bubble-row.has-react, .wa-brow.has-react { margin-bottom: .9rem; }
.ms-bubble, .wa-b { position: relative; }
.ms-react, .wa-react { position: absolute; bottom: -.85rem; inset-inline-end: .5rem; padding: .05rem .35rem; border-radius: 999px; background: var(--card); border: 1px solid var(--border); box-shadow: 0 1px 2px #0000001f; font-size: .78rem; line-height: 1.35; white-space: nowrap; }

/* Mobiserv Desk status in the header: a dot (green connected, red not found, amber attention, blue busy) and its panel. */
.ms-desk { position: relative; display: flex; align-items: center; }
.ms-desk-pill { display: inline-flex; align-items: center; gap: .45rem; height: 2rem; padding: 0 .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--foreground); font-size: .78rem; font-weight: 600; letter-spacing: .02em; transition: background .15s, border-color .15s; }
.ms-desk-pill:hover, .ms-desk-pill[aria-expanded="true"] { background: var(--accent); }
.ms-desk-dot { position: relative; width: .6rem; height: .6rem; border-radius: 999px; background: #9ca3af; flex: none; }
.ms-desk-dot::after { content: ""; position: absolute; inset: -4px; border-radius: inherit; background: inherit; opacity: 0; }
.ms-desk-pill[data-state="ok"] { border-color: color-mix(in srgb, #16a34a 35%, var(--border)); }
.ms-desk-pill[data-state="ok"] .ms-desk-dot { background: #16a34a; }
.ms-desk-pill[data-state="ok"] .ms-desk-dot::after { animation: ms-desk-pulse 2.4s ease-out infinite; }
.ms-desk-pill[data-state="off"] { border-color: color-mix(in srgb, #dc2626 40%, var(--border)); }
.ms-desk-pill[data-state="off"] .ms-desk-dot { background: #dc2626; }
.ms-desk-pill[data-state="warn"] .ms-desk-dot { background: #d97706; }
.ms-desk-pill[data-state="updating"] .ms-desk-dot, .ms-desk-pill[data-state="checking"] .ms-desk-dot { background: #2563eb; animation: ms-desk-blink 1s ease-in-out infinite; }
@keyframes ms-desk-pulse { 0% { transform: scale(.6); opacity: .55; } 100% { transform: scale(1.9); opacity: 0; } }
@keyframes ms-desk-blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .ms-desk-dot, .ms-desk-dot::after { animation: none !important; } }
@media (max-width: 640px) { .ms-desk-label { display: none; } .ms-desk-pill { width: 2rem; padding: 0; justify-content: center; } }
.ms-desk-pop { position: absolute; top: calc(100% + .5rem); inset-inline-end: 0; z-index: 60; width: min(20rem, calc(100vw - 1.5rem)); padding: .9rem; border: 1px solid var(--border); border-radius: .9rem; background: var(--popover, var(--card)); color: var(--popover-foreground, var(--foreground)); box-shadow: 0 18px 40px -12px #0000003d; }
.ms-desk-head { display: flex; align-items: center; gap: .65rem; }
.ms-desk-head b { display: block; font-size: .9rem; }
.ms-desk-head small { display: block; font-size: .72rem; color: var(--muted-foreground); }
.ms-desk-big { width: .8rem; height: .8rem; border-radius: 999px; flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent); }
.ms-desk-big.is-ok { background: #16a34a; color: #16a34a; }
.ms-desk-big.is-off { background: #dc2626; color: #dc2626; }
.ms-desk-big.is-warn { background: #d97706; color: #d97706; }
.ms-desk-big.is-busy { background: #2563eb; color: #2563eb; }
.ms-desk-lead { margin: .7rem 0 0; font-size: .8rem; line-height: 1.6; color: var(--muted-foreground); }
.ms-desk-list { margin: .75rem 0 0; padding: .35rem 0 0; list-style: none; border-top: 1px solid var(--border); }
.ms-desk-row { display: flex; align-items: center; gap: .5rem; padding: .32rem 0; font-size: .8rem; }
.ms-desk-mark { width: .45rem; height: .45rem; border-radius: 999px; flex: none; }
.ms-desk-mark.is-ok { background: #16a34a; } .ms-desk-mark.is-bad { background: #dc2626; } .ms-desk-mark.is-mute { background: #9ca3af; }
.ms-desk-name { flex: 1 1 auto; }
.ms-desk-val { color: var(--muted-foreground); font-size: .75rem; }
.ms-desk-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.ms-desk-actions .apex-btn { height: 2rem; font-size: .78rem; flex: 1 1 auto; justify-content: center; }
.ms-desk-actions .apex-btn i, .ms-desk-actions .apex-btn svg { width: .9rem; height: .9rem; }
/* Message boxes (chat page and widget): they grow with the text; no scrollbar arrows next to the lines. */
.ms-composer-field textarea, .wa-win-input { scrollbar-width: none; -ms-overflow-style: none; resize: none; }
.ms-composer-field textarea::-webkit-scrollbar, .wa-win-input::-webkit-scrollbar { display: none; width: 0; height: 0; }
/* Quotes and the reply bar in the chats (the message menu itself is styled further down, .ms-ma-*). */
.ms-bubble-row, .wa-brow { position: relative; }
.ms-quote { display: flex; flex-direction: column; gap: .05rem; margin-bottom: .3rem; padding: .3rem .5rem; border-radius: .4rem; border-inline-start: 3px solid var(--primary); background: color-mix(in srgb, var(--foreground) 6%, transparent); font-size: .74rem; max-width: 100%; }
.ms-quote.is-in { border-inline-start-color: #0ea5e9; }
.ms-quote b { font-size: .72rem; color: var(--primary); }
.ms-quote.is-in b { color: #0284c7; }
.ms-quote span { color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-wrap; }
/* The header Desk button is the dot alone (no word): a round button the size of the header icons. */
.ms-desk-pill { width: 2rem; height: 2rem; padding: 0; justify-content: center; gap: 0; }
.ms-desk-dot { width: .7rem; height: .7rem; }
/* On a phone a chat opened from the widget is the whole screen, with only its close button. */
@media (max-width: 640px) {
  .wa-dock-windows .wa-win.is-full { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-height: none; border-radius: 0; border: 0; box-shadow: none; z-index: 5; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); transform: none !important; }
  .wa-win.is-full .wa-win-head { border-radius: 0; cursor: default; }
  .wa-win.is-full .wa-win-head .wa-win-ico[data-close] { width: 2.4rem; height: 2.4rem; }
  html.ms-chat-full, html.ms-chat-full body { overflow: hidden; }
  html.ms-chat-full .wa-dock { z-index: 90; }
  html.ms-chat-full .wa-dock-launch, html.ms-chat-full .wa-dock-list { display: none; }
}
.ms-bubble:focus, .wa-b:focus { outline: none; }
/* WhatsApp-style message gestures (msg-actions.js): reactions bar + menu, corner arrow, swipe-to-reply. */
.ms-bubble-actions { display: none !important; }
[data-msg-id] { position: relative; -webkit-touch-callout: none; touch-action: pan-y; }
.ms-ma-layer { position: fixed; inset: 0; z-index: 1000; }
.ms-ma-layer.is-touch { background: rgb(0 0 0 / .32); animation: ms-ma-fade .12s ease-out; }
@keyframes ms-ma-fade { from { opacity: 0; } }
.ms-ma-react, .ms-ma-menu { position: fixed; background: var(--popover, var(--card)); color: var(--popover-foreground, var(--foreground)); box-shadow: 0 10px 30px -8px #00000059, 0 0 0 1px color-mix(in srgb, var(--border) 70%, transparent); animation: ms-ma-pop .14s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes ms-ma-pop { from { transform: scale(.85); opacity: 0; } }
.ms-ma-react { display: flex; gap: .15rem; padding: .3rem .45rem; border-radius: 999px; }
.ms-ma-react button { width: 2.35rem; height: 2.35rem; border-radius: 999px; font-size: 1.45rem; line-height: 1; transition: transform .12s, background .12s; }
.ms-ma-react button:hover { transform: scale(1.22) translateY(-2px); }
.ms-ma-react button.is-on { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.ms-ma-menu { min-width: 12rem; padding: .3rem; border-radius: .8rem; }
.ms-ma-menu button { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .62rem .75rem; border-radius: .55rem; font-size: .92rem; text-align: start; }
.ms-ma-menu button:hover { background: var(--accent); }
.ms-ma-menu button svg { color: var(--muted-foreground); flex: none; }
.ms-ma-menu button.is-danger, .ms-ma-menu button.is-danger svg { color: #dc2626; }
.is-picked { z-index: 1001; filter: brightness(1.04); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 45%, transparent), 0 8px 24px -10px #0000005c !important; }
/* Computer: the arrow in the message's top corner and the reaction button beside it, on hover. */
.ms-ma-hover { position: absolute; top: .15rem; inset-inline-end: .15rem; display: none; }
.ms-ma-chev { display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 999px; color: var(--muted-foreground); background: radial-gradient(circle, var(--wa-in, var(--card)) 55%, transparent 72%); }
.is-out .ms-ma-chev, .ms-bubble-row.is-out .ms-ma-chev { background: radial-gradient(circle, var(--wa-out, var(--card)) 55%, transparent 72%); }
.ms-ma-smile { position: absolute; top: 50%; translate: 0 -50%; display: none; width: 1.9rem; height: 1.9rem; border-radius: 999px; place-items: center; color: var(--muted-foreground); background: var(--card); box-shadow: 0 1px 3px #00000026; }
.is-in .ms-ma-smile, .ms-bubble-row.is-in .ms-ma-smile { inset-inline-end: -2.3rem; }
.is-out .ms-ma-smile, .ms-bubble-row.is-out .ms-ma-smile { inset-inline-start: -2.3rem; }
@media (hover: hover) and (pointer: fine) {
  [data-msg-id]:hover > .ms-ma-hover { display: block; }
  [data-msg-id]:hover > .ms-ma-smile { display: inline-grid; }
}
/* The Desk dot: no frame around it, and the "Check again" button spins while it checks. */
.ms-desk-pill, .ms-desk-pill[data-state] { border: 0 !important; background: transparent; }
.ms-desk-pill:hover, .ms-desk-pill[aria-expanded="true"] { background: var(--accent); }
[data-desk-again].is-busy svg { animation: ms-desk-spin .8s linear infinite; }
[data-desk-again].is-busy { opacity: .75; cursor: progress; }
@keyframes ms-desk-spin { to { transform: rotate(360deg); } }

/* Phones: a long press on a message opens the message menu, never the browser's text selection or its menu. */
@media (hover: none), (pointer: coarse) {
  [data-msg-id], [data-msg-id] * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  [data-msg-id] img, [data-msg-id] video { -webkit-user-drag: none; }
}
/* A quoted message: who + text (or "📷 Image") at the start, a small picture at the end, as in WhatsApp. */
.ms-quote { flex-direction: row; align-items: stretch; gap: .5rem; overflow: hidden; }
.ms-quote-main { display: flex; flex-direction: column; gap: .05rem; min-width: 0; flex: 1 1 auto; justify-content: center; }
.ms-quote-main span svg { vertical-align: -2px; }
.ms-quote-thumb { flex: none; width: 2.6rem; height: 2.6rem; margin: -.3rem; margin-inline-start: 0; object-fit: cover; border-radius: 0; border-start-end-radius: .4rem; border-end-end-radius: .4rem; }
.ms-quote-main span svg { display: inline-block; vertical-align: -2px; margin-inline-end: .2rem; }

/* Purchase return form (pages/purchase-return.js). */
.ms-pret-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: .6rem; }
.ms-pret-row:has(input:disabled) { opacity: .55; }
.ms-pret-total { display: flex; align-items: center; justify-content: space-between; padding: .65rem .8rem; border-radius: .6rem; background: var(--muted); font-size: .95rem; }
/* Returns page: the chosen type chip, and the purchase-invoice picker. */
.ms-chip.is-on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--card)); color: var(--foreground); font-weight: 600; }
.ms-pick-row { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: .6rem; text-align: start; }
.ms-pick-row:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--card)); }
/* ── Responsive review 2026-11-05 ─────────────────────────────────────────────────────────── */
/* KPI rows never leave one card alone on the last line: phones (2 columns) stretch an odd last
   card across the row; tablets put 4 cards in 2×2 and 5–6 in rows of 3. */
@media (max-width: 639px) {
  .ms-kpis > .ms-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (min-width: 640px) and (max-width: 1279px) {
  .ms-kpis:has(> .ms-kpi:nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ms-kpis:has(> .ms-kpi:nth-child(5):last-child),
  .ms-kpis:has(> .ms-kpi:nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* A KPI's change ("-4.9%") stays in one piece and reads left to right; its words wrap after it. */
.ms-kpi-hint > .flex { flex-wrap: wrap; row-gap: .1rem; }
.ms-kpi-hint > .flex > svg { flex-shrink: 0; }
.ms-kpi-hint > .flex > .font-semibold { white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
/* WAClient stopped calling the webhook: delivered / read never arrive (conversations page + dock). */
.ms-wa-stall { display: flex; flex-direction: column; gap: .2rem; margin: .5rem .75rem; padding: .6rem .75rem; border-radius: .65rem;
  background: color-mix(in srgb, var(--warning) 11%, var(--card)); border: 1px solid color-mix(in srgb, var(--warning) 38%, transparent);
  font-size: .75rem; line-height: 1.5; color: var(--foreground); }
.ms-wa-stall b { font-size: .8rem; font-weight: 600; color: color-mix(in srgb, var(--warning) 70%, var(--foreground)); }
.ms-wa-stall span { color: var(--muted-foreground); overflow-wrap: anywhere; }
.wa-win-stall { margin: 0; padding: .3rem .75rem; font-size: .7rem; line-height: 1.4; cursor: help;
  background: color-mix(in srgb, var(--warning) 11%, var(--card)); color: color-mix(in srgb, var(--warning) 70%, var(--foreground));
  border-top: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); }
/* ── Returns page: each return is one card on phones (pages/returns.js adds the card column) ── */
.ms-ret-cardcell { display: none; }
@media (max-width: 1023px) {
  html[data-page="returns"] #table .ms-table thead { display: none; }
  html[data-page="returns"] #table .ms-table,
  html[data-page="returns"] #table .ms-table tbody,
  html[data-page="returns"] #table .ms-table tr { display: block; width: 100%; }
  html[data-page="returns"] #table .ms-table tr { border: 0 !important; background: none !important; }
  html[data-page="returns"] #table .ms-table tr + tr { margin-top: .65rem; }
  html[data-page="returns"] #table .ms-table td { display: none; }
  html[data-page="returns"] #table .ms-table td.ms-ret-cardcell { display: block; padding: 0 !important; border: 0 !important; background: none !important; }
  html[data-page="returns"] #table .ms-table, html[data-page="returns"] #table .overflow-x-auto:has(> .ms-table) { background: none !important; }
  /* the cards stand on their own: no outer frame around the list */
  html[data-page="returns"] #table .overflow-hidden.rounded-xl:has(> .overflow-x-auto > .ms-table) { border: 0; border-radius: 0; background: none; overflow: visible; }
  html[data-page="returns"] #table .overflow-x-auto { overflow: visible; }
  /* the empty-list message keeps its own cell */
  html[data-page="returns"] #table .ms-table td[colspan] { display: block; padding: 2rem 1rem !important; text-align: center; border: 1px dashed var(--border) !important; border-radius: .85rem; }
}
/* Tablets: two cards side by side, same height per row. */
@media (min-width: 640px) and (max-width: 1023px) {
  html[data-page="returns"] #table .ms-table tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  html[data-page="returns"] #table .ms-table tr + tr { margin-top: 0; }
  html[data-page="returns"] #table .ms-table tr:has(> td[colspan]) { grid-column: 1 / -1; }
  html[data-page="returns"] #table td.ms-ret-cardcell, html[data-page="returns"] #table .ms-ret-card { height: 100%; }
  html[data-page="returns"] #table .ms-ret-actions { margin-top: auto; }
}
.ms-ret-card { display: flex; flex-direction: column; gap: .7rem; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: .9rem; background: var(--card); color: var(--card-foreground); }
.ms-ret-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.ms-ret-id { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; min-width: 0; }
.ms-ret-id b { font-size: .95rem; font-weight: 700; letter-spacing: .01em; }
.ms-ret-sum { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; text-align: end; }
.ms-ret-sum b { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-ret-sum small { font-size: .7rem; color: var(--muted-foreground); }
.ms-ret-party .ms-who { min-width: 0; }
.ms-ret-lines { display: flex; flex-direction: column; gap: .3rem; margin: 0; padding: .55rem .7rem; list-style: none; border-radius: .65rem; background: var(--muted); font-size: .82rem; }
.ms-ret-lines li { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.ms-ret-lines li span { min-width: 0; overflow-wrap: anywhere; }
.ms-ret-lines li b { flex-shrink: 0; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted-foreground); }
.ms-ret-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem .9rem; margin: 0; }
.ms-ret-meta div { min-width: 0; }
.ms-ret-meta dt { font-size: .7rem; color: var(--muted-foreground); }
.ms-ret-meta dd { margin: .1rem 0 0; font-size: .82rem; font-weight: 500; overflow-wrap: anywhere; }
.ms-ret-meta dd a { color: var(--primary); text-decoration: none; }
.ms-ret-note { display: flex; align-items: flex-start; gap: .45rem; margin: 0; font-size: .8rem; color: var(--muted-foreground); overflow-wrap: anywhere; }
.ms-ret-note svg, .ms-ret-note i { width: .95rem; height: .95rem; flex-shrink: 0; margin-top: .15rem; }
.ms-ret-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: .5rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.ms-ret-actions .apex-btn { justify-content: center; gap: .4rem; height: 2.4rem; }
.ms-ret-actions svg, .ms-ret-actions i { width: 1rem; height: 1rem; }
/* ── Tables as cards on phones and tablets (theme/table-cards.js marks them .ms-cards) ───────── */
@media (max-width: 1023px) {
  #main-content table.ms-cards { display: block; width: 100%; min-width: 0 !important; }
  #main-content table.ms-cards > thead { display: none; }
  #main-content table.ms-cards > tbody { display: grid; grid-template-columns: minmax(0, 1fr); gap: .65rem; }
  #main-content table.ms-cards > tbody > tr {
    position: relative; display: flex; flex-direction: column; min-width: 0;
    padding: .8rem .95rem .65rem; border: 1px solid var(--border) !important; border-radius: .9rem;
    background: var(--card) !important; color: var(--card-foreground);
  }
  #main-content table.ms-cards > tbody > tr > td {
    position: static !important; display: flex; align-items: center; justify-content: space-between; gap: .9rem;
    min-width: 0 !important; width: auto !important; max-width: none !important; padding: .34rem 0 !important;
    border: 0 !important; background: none !important; box-shadow: none !important;
    text-align: end; font-size: .84rem; white-space: normal;
  }
  #main-content table.ms-cards > tbody > tr > td + td:not(.ms-card-head):not(.ms-card-act) { border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent) !important; }
  #main-content table.ms-cards > tbody > tr > td[data-label]:not(.ms-card-head)::before {
    content: attr(data-label); flex-shrink: 0; max-width: 45%; font-size: .72rem; font-weight: 500; color: var(--muted-foreground); text-align: start;
  }
  #main-content table.ms-cards > tbody > tr > td > * { min-width: 0; max-width: 100%; }
  #main-content table.ms-cards > tbody > tr > td:not(.ms-card-head) :is(.ms-who, .ms-item, .flex) { justify-content: flex-end; }
  #main-content table.ms-cards > tbody > tr > td :is(.truncate) { white-space: normal; overflow-wrap: anywhere; }
  /* title of the card: the first column, without its label */
  #main-content table.ms-cards > tbody > tr > td.ms-card-head {
    order: -2; justify-content: flex-start; text-align: start; font-size: .92rem;
    padding: 0 0 .6rem !important; margin-bottom: .15rem; padding-inline-end: 2.6rem !important;
    border-bottom: 1px solid var(--border) !important;
  }
  #main-content table.ms-cards > tbody > tr > td.ms-card-head :is(.ms-who, .ms-item, .flex) { justify-content: flex-start; }
  /* the row's actions in the card's corner */
  #main-content table.ms-cards > tbody > tr > td.ms-card-act { position: absolute !important; top: .5rem; inset-inline-end: .5rem; padding: 0 !important; border: 0 !important; }
  #main-content table.ms-cards > tbody > tr > td.ms-card-act::before { display: none; }
  #main-content table.ms-cards > tbody > tr > td.ms-card-check { order: -3; position: absolute !important; top: .75rem; inset-inline-end: 2.9rem; padding: 0 !important; }
  #main-content table.ms-cards > tbody > tr > td.ms-card-check::before { display: none; }
  #main-content table.ms-cards > tbody > tr > td:is(.ms-card-blank, :empty) { display: none; }
  #main-content table.ms-cards > tbody > tr > td:is(.ms-card-blank, :empty) + td { border-top: 0 !important; }
  /* "no results" */
  #main-content table.ms-cards > tbody > tr.ms-card-empty { padding: 1.5rem 1rem; border-style: dashed !important; }
  #main-content table.ms-cards > tbody > tr.ms-card-empty > td { justify-content: center; text-align: center; }
  #main-content table.ms-cards > tbody > tr.ms-card-empty > td::before { display: none; }
  /* the cards stand on their own: no table frame around them, nothing scrolls sideways */
  #main-content :is(.overflow-x-auto, div):has(> table.ms-cards) { overflow: visible !important; border: 0 !important; border-radius: 0 !important; background: none !important; box-shadow: none !important; margin-inline: 0 !important; }
  #main-content .overflow-hidden.rounded-xl:has(> .overflow-x-auto > table.ms-cards) { overflow: visible; border: 0; border-radius: 0; background: none; }
}
@media (min-width: 640px) and (max-width: 1023px) {
  #main-content table.ms-cards > tbody { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  #main-content table.ms-cards > tbody > tr.ms-card-empty { grid-column: 1 / -1; }
}

/* Tables that stay tables: the frozen first column has no divider line of its own any more
   (it showed even when nothing scrolls); a soft shadow appears only while the table is scrolled. */
@media (max-width: 1023px) {
  apex-data-table [data-table] :is(th, td):first-child,
  #main-content table.ms-table:not(apex-data-table table):not(.receipt-card table) :is(th, td):first-child { border-inline-end: 0 !important; }
  #main-content :is(.overflow-x-auto, div:has(> table.ms-table)) { scroll-timeline: --ms-tx inline; }
  @supports (animation-timeline: scroll()) {
    apex-data-table [data-table] :is(th, td):first-child,
    #main-content table.ms-table:not(.ms-cards) :is(th, td):first-child { animation: ms-freeze-edge linear both; animation-timeline: --ms-tx; animation-range: 0 32px; }
  }
}
@keyframes ms-freeze-edge { from { box-shadow: none; } to { box-shadow: var(--ms-freeze-shadow, -10px 0 12px -10px #0000002e); } }
html[dir="ltr"] { --ms-freeze-shadow: 10px 0 12px -10px #0000002e; }
/* Cards in the Returns page's layout: title and headline amount on top, the details two by two
   (label above value), the row's actions as buttons along the bottom. */
@media (max-width: 1023px) {
  #main-content table.ms-cards > tbody > tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem .9rem; align-items: start;
    padding: .9rem 1rem;
  }
  #main-content table.ms-cards > tbody > tr > td {
    flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: .12rem;
    padding: 0 !important; text-align: start; font-size: .83rem; font-weight: 500;
  }
  #main-content table.ms-cards > tbody > tr > td + td:not(.ms-card-head):not(.ms-card-act) { border-top: 0 !important; }
  #main-content table.ms-cards > tbody > tr > td[data-label]:not(.ms-card-head)::before { max-width: 100%; font-size: .7rem; font-weight: 400; }
  #main-content table.ms-cards > tbody > tr > td:not(.ms-card-head) :is(.ms-who, .ms-item, .flex) { justify-content: flex-start; }
  #main-content table.ms-cards > tbody > tr > td > * { text-align: start; }
  /* top: the title … the amount */
  #main-content table.ms-cards > tbody > tr > td.ms-card-head {
    grid-column: 1 / -1; grid-row: 1; padding: 0 !important; margin: 0; border: 0 !important; font-size: .95rem; font-weight: 600;
  }
  #main-content table.ms-cards > tbody > tr.ms-card-hasmoney > td.ms-card-head { grid-column: 1; }
  #main-content table.ms-cards > tbody > tr > td.ms-card-money {
    grid-column: 2; grid-row: 1; flex-direction: column-reverse; align-items: flex-end; justify-self: end; text-align: end;
    font-size: 1.02rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  #main-content table.ms-cards > tbody > tr > td.ms-card-money > * { text-align: end; font-weight: 700; }
  #main-content table.ms-cards > tbody > tr > td.ms-card-money::before { font-size: .68rem !important; font-weight: 400; }
  /* bottom: the actions as buttons (the ⋯ menu's own items, always shown) */
  #main-content table.ms-cards > tbody > tr > td.ms-card-act {
    position: static !important; grid-column: 1 / -1; order: 99; display: block; width: 100% !important;
    padding-top: .75rem !important; border-top: 1px solid var(--border) !important;
  }
  #main-content table.ms-cards td.ms-card-act > div { display: block; width: 100%; }
  #main-content table.ms-cards td.ms-card-act [data-action-trigger] { display: none !important; }
  #main-content table.ms-cards td.ms-card-act [data-action-menu] {
    display: grid !important; grid-template-columns: repeat(auto-fit, minmax(6.2rem, 1fr)); gap: .5rem;
    position: static !important; width: 100% !important; min-width: 0 !important; margin: 0 !important; padding: 0 !important;
    border: 0 !important; background: none !important; box-shadow: none !important;
  }
  #main-content table.ms-cards td.ms-card-act [data-action-menu] > :is(a, button) {
    justify-content: center; gap: .4rem; height: 2.4rem; padding: 0 .6rem !important; white-space: nowrap;
    border: 1px solid var(--border); border-radius: .6rem; background: var(--card); font-size: .8rem; font-weight: 500;
  }
  #main-content table.ms-cards td.ms-card-act [data-action-menu] > :is(a, button):hover { background: var(--accent); }
  #main-content table.ms-cards td.ms-card-act [data-action-menu] > .text-destructive { border-color: color-mix(in srgb, var(--destructive) 35%, var(--border)); }
  #main-content table.ms-cards td.ms-card-act [data-action-menu] svg { width: 1rem; height: 1rem; flex-shrink: 0; }
  /* a plain button / link in the last cell (no menu) */
  #main-content table.ms-cards td.ms-card-act > :is(a, button) { width: 100%; justify-content: center; }
  #main-content table.ms-cards > tbody > tr > td.ms-card-check { position: absolute !important; top: .9rem; inset-inline-end: 1rem; }
  #main-content table.ms-cards > tbody > tr:has(> td.ms-card-check) > td.ms-card-head { padding-inline-end: 2rem !important; }
}.ms-card-btns { display: none; }
@media (max-width: 1023px) {
  #main-content table.ms-cards td.ms-card-act:has(> .ms-card-btns) > div:not(.ms-card-btns) { display: none; }
  #main-content table.ms-cards td.ms-card-act > .ms-card-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.2rem, 1fr)); gap: .5rem; width: 100%; }
  .ms-card-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-width: 0; height: 2.4rem; padding: 0 .6rem;
    border: 1px solid var(--border); border-radius: .6rem; background: var(--card); color: var(--foreground);
    font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; transition: background .15s;
  }
  .ms-card-btn:hover { background: var(--accent); }
  .ms-card-btn.is-danger { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 35%, var(--border)); }
  .ms-card-btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }
}
/* ── The one preview window (print-doc.js previewDialog): paper on a desk, buttons always in view ── */
.apex-dialog.ms-print-dlg {
  width: min(40rem, calc(100% - 2rem)); max-width: none; height: min(92dvh, 62rem); max-height: none;
  margin: auto; padding: 0; border: 1px solid var(--border); border-radius: 1.1rem; overflow: hidden;
  background: var(--card); box-shadow: 0 24px 64px -20px #00000066;
}
.apex-dialog.ms-print-dlg::backdrop { background: #0f172a8c; backdrop-filter: blur(2px); }
.apex-dialog.ms-print-dlg.ms-contract-dlg, .apex-dialog.ms-print-dlg.is-wide { width: min(64rem, calc(100% - 2rem)); }
.ms-print-dlg .ms-print-head { flex-shrink: 0; align-items: center; padding: .85rem 1.1rem; background: var(--card); }
.ms-print-dlg .ms-print-head h2 { font-size: 1.02rem; font-weight: 700; }
.ms-print-dlg .ms-print-head > div { min-width: 0; }
.ms-print-dlg .ms-print-head p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-print-dlg .ms-print-x { display: grid; place-items: center; flex-shrink: 0; font-size: 1rem; }
.ms-print-dlg .ms-print-tabs { flex-shrink: 0; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-columns: none; margin: .7rem 1.1rem .1rem; }
.ms-print-dlg .ms-print-paper {
  flex: 1 1 auto; min-height: 0; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0;
  overflow: auto; overscroll-behavior: contain; background: #e9ebef; border-block: 1px solid var(--border);
}
.ms-print-dlg .ms-print-paper iframe { display: block; width: 100%; min-height: 0; height: 26rem; border: 0; background: transparent; }
html.dark .ms-print-dlg .ms-print-paper, [data-theme="dark"] .ms-print-dlg .ms-print-paper { background: #1d2127; }
.ms-print-dlg .ms-print-wait { background: transparent; }
.ms-print-dlg .ms-print-msg { flex-shrink: 0; margin: 0; padding: .55rem 1.1rem 0; font-size: .78rem; text-align: center; }
.ms-print-dlg .ms-print-foot {
  flex-shrink: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .55rem;
  padding: .75rem 1.1rem calc(.8rem + env(safe-area-inset-bottom, 0px)); background: var(--card);
}
.ms-print-dlg .ms-print-foot > .apex-btn { height: 2.65rem; justify-content: center; gap: .45rem; padding-inline: 1.1rem; font-weight: 600; }
.ms-print-dlg .ms-print-foot > .apex-btn:first-child { flex: none; }
.ms-print-dlg .ms-print-foot svg { flex-shrink: 0; }
/* phones: the whole screen, three equal buttons */
@media (max-width: 639px) {
  .apex-dialog.ms-print-dlg, .apex-dialog.ms-print-dlg.ms-contract-dlg, .apex-dialog.ms-print-dlg.is-wide {
    width: 100%; height: 100dvh; margin: 0; border: 0; border-radius: 0;
  }
  .ms-print-dlg .ms-print-head { padding: .7rem .9rem; }
  .ms-print-dlg .ms-print-foot { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); padding-inline: .9rem; }
  .ms-print-dlg .ms-print-foot > .apex-btn { padding-inline: .5rem; }
}
/* tablets: a little more room for the paper */
@media (min-width: 640px) and (max-width: 1023px) {
  .apex-dialog.ms-print-dlg { width: min(42rem, calc(100% - 3rem)); height: min(90dvh, 64rem); }
  .apex-dialog.ms-print-dlg.ms-contract-dlg, .apex-dialog.ms-print-dlg.is-wide { width: calc(100% - 3rem); }
}
/* Rows per page (the data tables' pager): a tidy compact select, as tall as the page buttons. */
select[data-rows].apex-input {
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
  height: 2.125rem; width: auto; min-width: 4.6rem; padding-block: 0; padding-inline: .8rem 2rem;
  line-height: calc(2.125rem - 2px); font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: start;
  border: 1px solid var(--border); border-radius: .6rem; background-color: var(--card); color: var(--foreground); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: .95rem; background-position: right .6rem center;
  transition: border-color .15s, box-shadow .15s;
}
html[dir="rtl"] select[data-rows].apex-input { background-position: left .6rem center; }
select[data-rows].apex-input:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
select[data-rows].apex-input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
/* Settings → WhatsApp → Link Mobiserv Desk (theme/wa-link.js) */
.ms-wl-body { display: flex; flex-direction: column; gap: .75rem; padding: 1rem 1.25rem 1.25rem; }
.ms-wl-state { margin: 0; font-size: .9rem; }
.ms-wl-state b { font-weight: 700; }
.ms-wl-state.is-ok b { color: var(--success); }
.ms-wl-state.is-wait b { color: var(--warning); }
.ms-wl-state.is-bad b { color: var(--destructive); }
.ms-wl-sources { margin: 0; font-size: .78rem; color: var(--muted-foreground); }
.ms-wl-qr { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; padding: 1rem; border: 1px dashed var(--border); border-radius: .9rem; background: color-mix(in srgb, var(--muted) 50%, var(--card)); }
.ms-wl-qr img { width: 240px; height: 240px; border-radius: .6rem; background: #fff; padding: 6px; }
.ms-wl-qr ol { margin: 0; padding-inline-start: 1.2rem; display: flex; flex-direction: column; gap: .45rem; font-size: .88rem; }
.ms-wl-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.ms-wl-note { margin: 0; font-size: .82rem; color: var(--muted-foreground); }
@media (max-width: 639px) { .ms-wl-qr { justify-content: center; } .ms-wl-qr img { width: 220px; height: 220px; } .ms-wl-actions .apex-btn { width: 100%; justify-content: center; } }
/* Settings → Integrations → WhatsApp (theme/wa-page.js): overview, then WAClient (the API), then WA Server (its helper) */
.ms-wa-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.ms-wa-tile { display: flex; align-items: flex-start; gap: .75rem; min-width: 0; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: .9rem; background: var(--card); }
.ms-wa-tile > div { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.ms-wa-tile small { font-size: .72rem; color: var(--muted-foreground); }
.ms-wa-tile b { font-size: 1rem; font-weight: 700; }
.ms-wa-tile span:not(.ms-wa-tile-ico) { font-size: .72rem; color: var(--muted-foreground); overflow-wrap: anywhere; }
.ms-wa-tile-ico { display: grid; place-items: center; flex-shrink: 0; width: 2.2rem; height: 2.2rem; border-radius: .7rem; background: color-mix(in srgb, var(--ms-t, var(--muted-foreground)) 13%, transparent); color: var(--ms-t, var(--muted-foreground)); }
.ms-wa-tile-ico svg, .ms-wa-tile-ico i { width: 1.1rem; height: 1.1rem; }
.ms-wa-tile.is-ok { --ms-t: var(--success); }
.ms-wa-tile.is-warn { --ms-t: var(--warning); }
.ms-wa-tile.is-bad { --ms-t: var(--destructive); }
.ms-wa-tile.is-ok b { color: var(--success); }
.ms-wa-tile.is-warn b { color: color-mix(in srgb, var(--warning) 80%, var(--foreground)); }
.ms-wa-tile.is-bad b { color: var(--destructive); }
.ms-wa-group { padding-top: .75rem; }
.ms-wa-group-head { display: flex; align-items: flex-start; gap: .75rem; }
.ms-wa-group-head h2 { font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.ms-wa-group-head p { margin-top: .2rem; font-size: .82rem; line-height: 1.6; color: var(--muted-foreground); max-width: 52rem; }
.ms-wa-badge { flex-shrink: 0; margin-top: .1rem; padding: .2rem .55rem; border-radius: .5rem; font-size: .72rem; font-weight: 700; letter-spacing: .01em; background: color-mix(in srgb, var(--primary) 13%, transparent); color: var(--primary); direction: ltr; }
.ms-wa-badge.is-helper { background: color-mix(in srgb, var(--chart-3) 15%, transparent); color: var(--chart-3); }
#ms-wa-g-team .ms-wa-badge { background: var(--muted); color: var(--muted-foreground); direction: inherit; }
@media (max-width: 1023px) { .ms-wa-overview { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 640px) and (max-width: 1023px) { .ms-wa-overview { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ms-wa-tile { flex-direction: column; } }
/* ══ Settings, new layout (theme/settings-shell.js) ═══════════════════════════════════════════ */
/* the page's own menu and the sub-tabs this frame replaces are kept (hidden) to open panels */
.ms-st .settings-nav,
.ms-st .settings-subnav:has([data-subtab]),
.ms-st .settings-subnav:has([data-int-tab]),
.ms-st .ms-sc-cards { display: none !important; }
.ms-st .settings-layout { display: grid !important; grid-template-columns: 15.5rem minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.ms-st .settings-main { min-width: 0; }
.ms-st.is-st-home .settings-main > :not(.ms-st-home) { display: none !important; }
.ms-st:not(.is-st-home) .ms-st-home { display: none; }

/* side rail */
.ms-st-rail { position: sticky; top: 5rem; display: flex; flex-direction: column; gap: .9rem; padding: .85rem .6rem; max-height: calc(100vh - 6rem); overflow-y: auto; }
.ms-st-rtitle { margin: 0 .55rem .3rem; font-size: .68rem; font-weight: 700; letter-spacing: .04em; color: var(--muted-foreground); text-transform: uppercase; }
.ms-st-ritem { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: .6rem; font-size: .86rem; font-weight: 500; color: var(--foreground); text-decoration: none; transition: background .15s, color .15s; }
.ms-st-ritem svg, .ms-st-ritem i { width: 1rem; height: 1rem; flex-shrink: 0; color: var(--muted-foreground); }
.ms-st-ritem:hover { background: var(--muted); }
.ms-st-ritem.is-on { background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); font-weight: 600; }
.ms-st-ritem.is-on svg, .ms-st-ritem.is-on i { color: var(--primary); }
.ms-st-ritem .ms-st-out { margin-inline-start: auto; width: .85rem; height: .85rem; }
html[dir="rtl"] .ms-st-ritem .ms-st-out { transform: scaleX(-1); }

/* phones: one button that opens the list */
.ms-st-picker { display: none; }
.ms-st-picker > summary { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; list-style: none; cursor: pointer; }
.ms-st-picker > summary::-webkit-details-marker { display: none; }
.ms-st-picker > summary span { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ms-st-picker > summary small { font-size: .7rem; color: var(--muted-foreground); }
.ms-st-picker > summary b { font-size: .95rem; }
.ms-st-picker > summary svg, .ms-st-picker > summary i { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.ms-st-picker[open] .ms-st-pchev { transform: rotate(180deg); }
.ms-st-sheet { display: flex; flex-direction: column; gap: .8rem; margin-top: .5rem; padding: .8rem .5rem; max-height: 70vh; overflow-y: auto; }

/* section heading */
.ms-st-head:empty { display: none; }
.ms-st-head { margin-bottom: 1rem; }
.ms-st-back { display: none; align-items: center; gap: .35rem; margin-bottom: .6rem; font-size: .8rem; color: var(--muted-foreground); text-decoration: none; }
.ms-st-back svg, .ms-st-back i { width: .9rem; height: .9rem; }
html[dir="ltr"] .ms-st-back svg { transform: scaleX(-1); }
.ms-st-htitle { display: flex; align-items: flex-start; gap: .85rem; }
.ms-st-htitle .ms-kpi-well { width: 2.75rem; height: 2.75rem; }
.ms-st-htitle h2 { font-size: 1.3rem; font-weight: 700; line-height: 1.25; }
.ms-st-htitle p { margin: .2rem 0 0; font-size: .85rem; color: var(--muted-foreground); line-height: 1.6; max-width: 52rem; }
.ms-st-htitle .ms-st-crumb { margin: 0 0 .1rem; font-size: .72rem; font-weight: 600; color: var(--primary); }

/* home: status tiles and the groups */
.ms-st-home { display: flex; flex-direction: column; gap: 1.25rem; }
.ms-st-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.ms-st-tile { display: flex; align-items: flex-start; gap: .75rem; min-width: 0; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--card); color: var(--card-foreground); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.ms-st-tile: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-st-tile > span:last-child { display: flex; flex-direction: column; gap: .1rem; }
.ms-st-tile small { font-size: .72rem; color: var(--muted-foreground); }
.ms-st-tile b { font-size: 1.05rem; font-weight: 700; color: var(--ms-tone, var(--foreground)); }
.ms-st-tile em { font-style: normal; font-size: .72rem; color: var(--muted-foreground); overflow-wrap: anywhere; }
.ms-st-tile.ms-tone-muted { --ms-tone: var(--muted-foreground); }
.ms-st-tile.ms-tone-muted b { color: var(--foreground); }
.ms-st-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.ms-st-gcard { padding: 0; overflow: hidden; }
.ms-st-gcard > header { display: flex; align-items: flex-start; gap: .75rem; padding: 1rem 1.1rem .85rem; border-bottom: 1px solid var(--border); }
.ms-st-gcard h3 { font-size: 1rem; font-weight: 700; }
.ms-st-gcard header p { margin: .15rem 0 0; font-size: .78rem; color: var(--muted-foreground); }
.ms-st-glist { display: flex; flex-direction: column; padding: .35rem; }
.ms-st-glist a { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: .6rem; color: var(--foreground); text-decoration: none; transition: background .15s; }
.ms-st-glist a:hover { background: var(--muted); }
.ms-st-glist a > span { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1; }
.ms-st-glist b { font-size: .88rem; font-weight: 600; }
.ms-st-glist small { font-size: .74rem; line-height: 1.45; color: var(--muted-foreground); }
.ms-st-chev { width: .95rem; height: .95rem; flex-shrink: 0; color: var(--muted-foreground); }
html[dir="ltr"] .ms-st-chev { transform: scaleX(-1); }

/* WhatsApp section: WAClient, then WA Server, then the team */
.ms-st-sub { display: flex; align-items: flex-start; gap: .7rem; padding: .6rem .1rem .1rem; }
.ms-st-sub h3 { font-size: 1rem; font-weight: 700; }
.ms-st-sub p { margin: .15rem 0 0; font-size: .8rem; line-height: 1.6; color: var(--muted-foreground); max-width: 52rem; }
.ms-st-sbadge { flex-shrink: 0; margin-top: .1rem; padding: .2rem .55rem; border-radius: .5rem; font-size: .72rem; font-weight: 700; background: color-mix(in srgb, var(--primary) 13%, transparent); color: var(--primary); direction: ltr; }
.ms-st-sbadge.is-helper { background: color-mix(in srgb, var(--chart-3) 15%, transparent); color: var(--chart-3); }
#ms-st-wa-team .ms-st-sbadge { background: var(--muted); color: var(--muted-foreground); direction: inherit; }

/* tablets: the rail stays, two groups a row */
@media (max-width: 1279px) {
  .ms-st-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ms-st-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .ms-st .settings-layout { grid-template-columns: 13.5rem minmax(0, 1fr); gap: 1rem; }
  .ms-st-groups { grid-template-columns: minmax(0, 1fr); }
}
/* phones: the picker instead of the rail */
@media (max-width: 767px) {
  .ms-st .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .ms-st-rail { display: none; }
  .ms-st-picker { display: block; position: sticky; top: 4.25rem; z-index: 20; margin-bottom: .9rem; }
  .ms-st-back { display: inline-flex; }
  .ms-st-htitle h2 { font-size: 1.15rem; }
  .ms-st-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .ms-st-tile { flex-direction: column; gap: .5rem; padding: .8rem; }
  .ms-st-tile .ms-kpi-well { display: flex; width: 2rem; height: 2rem; }
}
/* ══ Settings (new) — assets/pages/settings-home.js ══════════════════════════════════════════ */
.ms-set-home { display: flex; flex-direction: column; gap: 1.75rem; }
.ms-set-group > header { display: flex; align-items: center; gap: .75rem; margin-bottom: .85rem; }
.ms-set-gicon { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .75rem; background: color-mix(in srgb, var(--ms-tone) 13%, transparent); color: var(--ms-tone); flex-shrink: 0; }
.ms-set-gicon svg, .ms-set-gicon i { width: 1.15rem; height: 1.15rem; }
.ms-set-group h2 { font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.ms-set-group header p { margin-top: .1rem; font-size: .8rem; color: var(--muted-foreground); }
.ms-set-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: .75rem; }
.ms-set-tile { position: relative; display: flex; align-items: flex-start; gap: .8rem; min-width: 0; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--card); color: var(--card-foreground); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.ms-set-tile:hover { border-color: color-mix(in srgb, var(--ms-tone, var(--primary)) 45%, var(--border)); box-shadow: 0 6px 18px -10px #00000040; transform: translateY(-1px); }
.ms-set-tile .ms-kpi-well { color: var(--ms-tone); background: color-mix(in srgb, var(--ms-tone) 13%, transparent); }
.ms-set-tile-text { display: flex; flex-direction: column; gap: .2rem; min-width: 0; flex: 1; }
.ms-set-tile-text b { font-size: .95rem; font-weight: 650; }
.ms-set-tile-text small { font-size: .78rem; line-height: 1.5; color: var(--muted-foreground); }
.ms-set-tile-text em { align-self: flex-start; margin-top: .3rem; padding: .15rem .55rem; border-radius: 999px; font-style: normal; font-size: .72rem; font-weight: 600; background: var(--muted); color: var(--foreground); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-set-go { width: 1rem; height: 1rem; flex-shrink: 0; margin-top: .2rem; color: var(--muted-foreground); }
html[dir="ltr"] .ms-set-go { transform: scaleX(-1); }
html[dir="ltr"] .ms-set-back { transform: scaleX(-1); }

/* section pages */
.ms-set-cols { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.ms-set-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ms-set-card { padding: 0; overflow: hidden; }
.ms-set-card > header { padding: 1rem 1.25rem .85rem; border-bottom: 1px solid var(--border); }
.ms-set-card > header h3 { display: flex; align-items: center; gap: .5rem; font-size: .98rem; font-weight: 700; }
.ms-set-card > header h3 svg, .ms-set-card > header h3 i { width: 1.05rem; height: 1.05rem; color: var(--primary); }
.ms-set-card > header p { margin-top: .2rem; font-size: .8rem; color: var(--muted-foreground); }
.ms-set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.1rem; padding: 1.15rem 1.25rem 1.25rem; }
.ms-set-field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.ms-set-field:has(textarea), .ms-set-grid > .ms-set-field:first-child:has(#p-name) { grid-column: 1 / -1; }
.ms-set-hint { margin: 0; font-size: .74rem; line-height: 1.5; color: var(--muted-foreground); }
.ms-set-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }

.ms-set-logos { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; padding: 1.15rem 1.25rem .5rem; }
.ms-set-logo { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.ms-set-logo-box { display: grid; place-items: center; flex-shrink: 0; width: 8.5rem; height: 4.5rem; padding: .5rem; border-radius: .8rem; border: 1px dashed var(--border); overflow: hidden; }
.ms-set-logo.is-light .ms-set-logo-box { background: #fff; }
.ms-set-logo.is-dark .ms-set-logo-box { background: #111827; border-color: #111827; }
.ms-set-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ms-set-logo-meta { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.ms-set-logo-meta b, .ms-set-fav b { font-size: .86rem; }
.ms-set-logo-meta small { font-size: .74rem; color: var(--muted-foreground); }
.ms-set-logo-meta .ms-set-actions { margin-top: .35rem; }
.ms-set-fav { display: flex; align-items: center; gap: .9rem; margin: .5rem 1.25rem 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.ms-set-fav-prev { display: grid; place-items: center; flex-shrink: 0; width: 3.5rem; height: 3.5rem; border-radius: .8rem; background: var(--muted); overflow: hidden; }
.ms-set-fav .ms-set-actions { margin-top: .4rem; }

.ms-set-receipt { display: flex; flex-direction: column; align-items: center; gap: .25rem; margin: 1.1rem auto 1.25rem; width: min(17rem, calc(100% - 2.5rem)); padding: 1rem .9rem .8rem; background: #fff; color: #111; border-radius: 4px; box-shadow: 0 1px 3px #0000001f, 0 10px 24px -12px #00000040; text-align: center; font-size: .78rem; }
.ms-set-receipt b { font-size: 1rem; }
.ms-set-receipt hr { width: 100%; margin: .5rem 0 .3rem; border: 0; border-top: 1px dashed #bbb; }
.ms-set-receipt small { color: #777; font-size: .68rem; }
.ms-set-r-logo { max-height: 2.6rem; max-width: 70%; object-fit: contain; margin-bottom: .2rem; }

.ms-set-savebar { position: sticky; bottom: 1rem; z-index: 25; grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; 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) 9%, var(--card)); box-shadow: 0 14px 34px -16px #00000059; }
.ms-set-savebar > span { display: flex; align-items: center; gap: .45rem; font-size: .86rem; font-weight: 600; }
.ms-set-savebar > span svg, .ms-set-savebar > span i { width: .9rem; height: .9rem; color: var(--warning); }
.ms-set-savebar[hidden] { display: none; }

/* appearance */
.ms-set-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .65rem; padding: 1.15rem 1.25rem 1.25rem; }
.ms-set-choice { display: flex; flex-direction: column; align-items: center; gap: .55rem; padding: .85rem .6rem; border: 1.5px solid var(--border); border-radius: calc(var(--radius) + 2px); background: var(--card); cursor: pointer; transition: border-color .15s, background .15s; }
.ms-set-choice:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.ms-set-choice.is-on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--card)); }
.ms-set-choice b { font-size: .82rem; font-weight: 600; }
.ms-set-mode { display: flex; width: 4.5rem; height: 3rem; border-radius: .55rem; overflow: hidden; border: 1px solid var(--border); }
.ms-set-mode i { flex: 1; }
.ms-set-mode.is-light i { background: #f8fafc; }
.ms-set-mode.is-light i + i { background: #e2e8f0; }
.ms-set-mode.is-dark i { background: #1e2530; }
.ms-set-mode.is-dark i + i { background: #0f141b; }
.ms-set-mode.is-system i:first-child { background: #f8fafc; }
.ms-set-mode.is-system i + i { background: #1e2530; }
.ms-set-corner { width: 3rem; height: 2.25rem; border: 2px solid var(--primary); border-inline-start-color: transparent; border-bottom-color: transparent; border-start-end-radius: var(--rr, .5rem); }
.ms-set-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: .65rem; padding: 1.15rem 1.25rem 1.25rem; }
.ms-set-swatch { display: flex; flex-direction: column; align-items: center; gap: .45rem; padding: .7rem .4rem; border: 1.5px solid var(--border); border-radius: calc(var(--radius) + 2px); background: var(--card); cursor: pointer; }
.ms-set-swatch span { width: 2rem; height: 2rem; border-radius: 999px; background: var(--sw); box-shadow: inset 0 0 0 2px #ffffff55; }
.ms-set-swatch small { font-size: .76rem; font-weight: 500; }
.ms-set-swatch.is-on { border-color: var(--sw); background: color-mix(in srgb, var(--sw) 8%, var(--card)); }
.ms-set-swatch.is-on span { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--sw); }
.ms-set-sample { display: flex; flex-direction: column; gap: .85rem; padding: 1.15rem 1.25rem; }
.ms-set-sample .ms-kpis { grid-template-columns: minmax(0, 1fr); }
.ms-set-sample-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.ms-set-note { display: flex; align-items: flex-start; gap: .4rem; padding: 0 1.25rem 1.2rem; }
.ms-set-note svg, .ms-set-note i { width: .9rem; height: .9rem; flex-shrink: 0; margin-top: .1rem; }

/* tablets: one column of cards; phones: one column of fields */
@media (max-width: 1023px) {
  .ms-set-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 639px) {
  .ms-set-grid { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
  .ms-set-card > header { padding: .9rem 1rem .75rem; }
  .ms-set-logos { padding: 1rem 1rem .4rem; }
  .ms-set-logo-box { width: 7rem; height: 4rem; }
  .ms-set-fav { margin: .4rem 1rem 1rem; }
  .ms-set-choices, .ms-set-swatches, .ms-set-sample { padding: 1rem; }
  .ms-set-swatches { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ms-set-savebar { bottom: .75rem; }
  .ms-set-savebar .ms-set-actions { width: 100%; }
  .ms-set-savebar .ms-set-actions .apex-btn { flex: 1; justify-content: center; }
}/* phones: two compact tiles a row (title + state; the description is in the section itself) */
@media (max-width: 639px) {
  .ms-set-home { gap: 1.35rem; }
  .ms-set-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .ms-set-tile { flex-direction: column; gap: .55rem; padding: .85rem .8rem; }
  .ms-set-tile .ms-kpi-well { display: flex; width: 2.1rem; height: 2.1rem; }
  .ms-set-tile-text small { display: none; }
  .ms-set-tile-text b { font-size: .88rem; line-height: 1.35; }
  .ms-set-go { position: absolute; top: .9rem; inset-inline-end: .8rem; }
}
html[dir="rtl"] .ms-set-tile .ms-set-go[data-lucide="arrow-up-right"], html[dir="rtl"] .ms-set-tile svg.ms-set-go.lucide-arrow-up-right { transform: scaleX(-1); }
@media (max-width: 639px) { .ms-set-choices:has(> [data-theme-pick]) { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ms-set-choices:has(> [data-radius-pick]) { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ms-set-mode { width: 3.6rem; height: 2.5rem; } }
/* the section's state sits beside its title */
.ms-set-tile-top { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; min-width: 0; }
.ms-set-tile-top em { margin-top: 0; align-self: center; }/* logo / icon boxes when nothing is uploaded yet */
.ms-set-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; width: 100%; height: 100%; color: var(--muted-foreground); }
.ms-set-empty svg, .ms-set-empty i { width: 1.35rem; height: 1.35rem; opacity: .7; }
.ms-set-empty small { font-size: .72rem; line-height: 1; white-space: nowrap; }
.ms-set-logo.is-dark .ms-set-empty { color: #94a3b8; }
.ms-set-empty.is-small svg, .ms-set-empty.is-small i { width: 1.25rem; height: 1.25rem; }
.ms-set-fav-prev img { width: 100%; height: 100%; object-fit: contain; }
/* settings sections: editable rows (sources, payment methods), switches, choices, previews */
.ms-set-rows { display: flex; flex-direction: column; }
.ms-set-row { display: flex; align-items: center; gap: .85rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); }
.ms-set-row:last-child { border-bottom: 0; }
.ms-set-row-ico { display: grid; place-items: center; flex-shrink: 0; width: 2.4rem; height: 2.4rem; border-radius: .75rem; background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); }
.ms-set-row-ico svg, .ms-set-row-ico i { width: 1.1rem; height: 1.1rem; }
.ms-set-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.ms-set-row-main small { font-size: .72rem; color: var(--muted-foreground); }
.ms-set-row-two { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
.ms-set-row-two > div { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.ms-set-mini { font-size: .7rem; font-weight: 600; color: var(--muted-foreground); }
.ms-set-row-opts { display: flex; flex-direction: column; gap: .4rem; flex-shrink: 0; }
.ms-set-switch { display: inline-flex; align-items: center; gap: .45rem; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.ms-set-field-switch { justify-content: flex-end; }
.ms-set-del { flex-shrink: 0; color: var(--destructive); }
.ms-set-foot { display: flex; flex-wrap: wrap; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--muted) 35%, var(--card)); }
.ms-set-clock { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 1.5rem 1.25rem; text-align: center; }
.ms-set-clock b { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ms-set-clock small { font-size: .78rem; color: var(--muted-foreground); direction: ltr; }
.ms-set-money { display: flex; flex-wrap: wrap; gap: .5rem; padding: 1.15rem 1.25rem 1.25rem; }
.ms-set-money span { padding: .45rem .75rem; border-radius: .6rem; background: var(--muted); font-family: var(--font-mono, ui-monospace, monospace); font-size: .9rem; font-weight: 600; }
.ms-set-modes { display: flex; flex-wrap: wrap; gap: .45rem; padding: 1.1rem 1.25rem 0; }
.ms-set-mode-opt { cursor: pointer; }
.ms-set-mode-opt input { position: absolute; opacity: 0; pointer-events: none; }
.ms-set-mode-opt span { display: inline-block; padding: .45rem .8rem; border: 1.5px solid var(--border); border-radius: 999px; font-size: .8rem; font-weight: 500; transition: border-color .15s, background .15s, color .15s; }
.ms-set-mode-opt input:checked + span { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--primary); font-weight: 600; }
.ms-set-mode-opt input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.ms-set-grid > .ms-set-field[hidden] { display: none; }
.ms-set-example { margin: 0; padding: 0 1.25rem 1.15rem; font-size: .82rem; font-weight: 600; color: var(--primary); }
@media (max-width: 1023px) { .ms-set-row-two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .ms-set-row-two > div:first-child { grid-column: 1 / -1; } }
@media (max-width: 639px) {
  .ms-set-row { flex-wrap: wrap; padding: .85rem 1rem; gap: .65rem; }
  .ms-set-row-main { flex-basis: calc(100% - 3.1rem - 2.6rem); }
  .ms-set-row-opts { flex-direction: row; flex-wrap: wrap; gap: .4rem 1rem; width: 100%; order: 3; padding-inline-start: 3.05rem; }
  .ms-set-row-two { grid-template-columns: minmax(0, 1fr); }
  .ms-set-foot { padding: .8rem 1rem; }
  .ms-set-foot .apex-btn { flex: 1; justify-content: center; }
  .ms-set-modes { padding: 1rem 1rem 0; }
  .ms-set-example { padding: 0 1rem 1rem; }
  .ms-set-money { padding: 1rem; }
}
/* settings → languages */
.ms-set-langs { display: flex; flex-direction: column; gap: .55rem; padding: 1.15rem 1.25rem 1rem; }
.ms-set-lang { display: flex; align-items: center; gap: .8rem; padding: .75rem .9rem; border: 1.5px solid var(--border); border-radius: calc(var(--radius) + 2px); cursor: pointer; transition: border-color .15s, background .15s; }
.ms-set-lang:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.ms-set-lang.is-on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--card)); }
.ms-set-lang input { accent-color: var(--primary); width: 1rem; height: 1rem; flex-shrink: 0; }
.ms-set-lang-code { display: grid; place-items: center; flex-shrink: 0; width: 2.4rem; height: 2.4rem; border-radius: .7rem; background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); font-size: .75rem; font-weight: 800; letter-spacing: .04em; font-family: var(--font-mono, ui-monospace, monospace); }
.ms-set-lang-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.ms-set-lang-text b { font-size: .9rem; }
.ms-set-lang-text small { font-size: .74rem; color: var(--muted-foreground); }
.ms-set-lang em { flex-shrink: 0; font-style: normal; font-size: .68rem; font-weight: 600; padding: .15rem .5rem; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); }
.ms-set-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ms-set-stat { display: flex; align-items: baseline; gap: .6rem; padding: 1.15rem 1.25rem; }
.ms-set-stat b { font-size: 1.9rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; line-height: 1; }
.ms-set-stat span { font-size: .82rem; color: var(--muted-foreground); }
.ms-set-phrases > summary { cursor: pointer; padding: .85rem 1.25rem; font-size: .84rem; font-weight: 600; color: var(--primary); }
.ms-set-phrases[open] > summary { border-bottom: 1px solid var(--border); }

/* settings → links */
.ms-set-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; align-items: start; }
.ms-set-links [data-l-group][hidden], .ms-set-link[hidden] { display: none !important; }
.ms-set-link { display: grid; grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr); gap: .5rem .9rem; align-items: start; padding: .8rem 1.25rem; border-bottom: 1px solid var(--border); }
.ms-set-link:last-child { border-bottom: 0; }
.ms-set-link-name { display: flex; flex-direction: column; gap: .25rem; padding-top: .45rem; min-width: 0; }
.ms-set-link-name b { font-size: .84rem; font-weight: 600; }
.ms-set-link-name small { display: flex; flex-wrap: wrap; gap: .2rem; justify-content: flex-start; }
.ms-set-link-name code { font-size: .66rem; padding: .05rem .3rem; border-radius: .35rem; background: var(--muted); color: var(--muted-foreground); }
.ms-set-link-main { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.ms-set-link-input { display: flex; align-items: stretch; min-width: 0; }
.ms-set-link-input > span { display: grid; place-items: center; padding: 0 .55rem; border: 1px solid var(--input, var(--border)); border-inline-end: 0; border-radius: var(--radius) 0 0 var(--radius); background: var(--muted); color: var(--muted-foreground); font-family: var(--font-mono, ui-monospace, monospace); font-size: .85rem; }
.ms-set-link-input > input { flex: 1; min-width: 0; border-radius: 0 var(--radius) var(--radius) 0; font-family: var(--font-mono, ui-monospace, monospace); font-size: .84rem; }
.ms-set-link-ex { display: flex; align-items: center; gap: .3rem; font-size: .72rem; color: var(--muted-foreground); font-family: var(--font-mono, ui-monospace, monospace); overflow-wrap: anywhere; }
.ms-set-link-ex svg, .ms-set-link-ex i { width: .8rem; height: .8rem; flex-shrink: 0; }
.ms-set-link .apex-field-error:empty { display: none; }
#set-links .ms-set-row #l-find { flex: 1; }
@media (max-width: 1279px) { .ms-set-links { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 639px) {
  .ms-set-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .ms-set-link { grid-template-columns: minmax(0, 1fr); padding: .8rem 1rem; }
  .ms-set-link-name { padding-top: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .4rem; }
}
/* settings → work, talk, devices, system sections */
.ms-set-stack { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ms-set-row-main b { font-size: .88rem; font-weight: 600; }
.ms-set-head-act { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.ms-set-head-act > div { min-width: 0; flex: 1; }
.ms-set-card > header.ms-set-head-act p { margin-top: .2rem; font-size: .8rem; color: var(--muted-foreground); }
.ms-set-table { padding: .25rem 0 0; min-width: 0; }
.ms-set-table .apex-card { border: 0; box-shadow: none; border-radius: 0; }
.ms-set-stages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .6rem; padding: 1.15rem 1.25rem 1.25rem; counter-reset: st; }
.ms-set-stage { position: relative; display: flex; flex-direction: column; gap: .45rem; padding: .8rem .85rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); background: color-mix(in srgb, var(--muted) 30%, var(--card)); min-width: 0; }
.ms-set-stage > b { font-size: .82rem; }
.ms-set-stage-n { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 999px; background: var(--primary); color: var(--primary-foreground, #fff); font-size: .72rem; font-weight: 700; }
.ms-set-stage-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.ms-set-stage-list small { font-size: .72rem; color: var(--muted-foreground); }
#sf-parts.is-off { opacity: .55; }
.ms-set-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; padding: 1rem 1.25rem; margin: 0; }
.ms-set-facts > div { padding: .7rem .85rem; border: 1px solid var(--border); border-radius: var(--radius); }
.ms-set-facts dt { font-size: .72rem; color: var(--muted-foreground); }
.ms-set-facts dd { margin: .2rem 0 0; font-weight: 700; font-size: .92rem; }
.ms-set-err { color: var(--destructive); padding-top: .9rem; font-size: .8rem; }
.ms-set-qr { display: flex; justify-content: center; padding: 1rem 1.25rem; }
.ms-set-qr img { width: 100%; max-width: 15rem; height: auto; border-radius: .75rem; border: 1px solid var(--border); background: #fff; padding: .5rem; }
.ms-set-grid-1 { grid-template-columns: minmax(0, 1fr); }
.ms-set-tabs { display: inline-flex; gap: .3rem; padding: .3rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--card); }
.ms-set-tabbtn { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem 1rem; border-radius: var(--radius); font-size: .85rem; font-weight: 600; color: var(--muted-foreground); }
.ms-set-tabbtn svg, .ms-set-tabbtn i { width: 1rem; height: 1rem; }
.ms-set-tabbtn.is-on { background: var(--primary); color: var(--primary-foreground, #fff); }
[data-tp-pane][hidden] { display: none !important; }
.ms-set-tpls { display: flex; flex-direction: column; }
.ms-set-tpl { border-bottom: 1px solid var(--border); }
.ms-set-tpl:last-child { border-bottom: 0; }
.ms-set-tpl > summary { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .8rem 1.25rem; cursor: pointer; list-style: none; }
.ms-set-tpl > summary::-webkit-details-marker { display: none; }
.ms-set-tpl > summary small { font-size: .72rem; color: var(--muted-foreground); }
.ms-set-tpl[open] > summary { background: color-mix(in srgb, var(--muted) 35%, var(--card)); }
.ms-set-tpl-body { display: flex; flex-direction: column; gap: .75rem; padding: .9rem 1.25rem 1.1rem; }
.ms-set-sticky { position: sticky; top: 5rem; }
.ms-set-tokens { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; padding: 1rem 1.25rem 1.2rem; }
.ms-set-token { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; padding: .45rem .6rem; border: 1px dashed var(--border); border-radius: var(--radius); font-family: var(--font-mono, ui-monospace, monospace); font-size: .76rem; font-weight: 600; color: var(--primary); text-align: start; }
.ms-set-token small { font-family: var(--font-sans, inherit); font-weight: 400; font-size: .68rem; color: var(--muted-foreground); }
.ms-set-token:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.ms-set-list { list-style: none; margin: 0; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .6rem; font-size: .82rem; line-height: 1.6; }
.ms-set-list li { display: flex; gap: .5rem; }
.ms-set-list svg, .ms-set-list i { width: .95rem; height: .95rem; flex-shrink: 0; margin-top: .25rem; color: var(--primary); }
.ms-set-host { min-width: 0; }
.ms-set-host .max-w-3xl, .ms-set-host .max-w-2xl { max-width: none; }
#wa-side { gap: 1rem; }
@media (max-width: 1023px) { .ms-set-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ms-set-sticky { position: static; } }
@media (max-width: 639px) { .ms-set-stages, .ms-set-facts { grid-template-columns: minmax(0, 1fr); } .ms-set-tabs { display: flex; } .ms-set-tabbtn { flex: 1; justify-content: center; } }
/* settings → printing → the other slips */
.ms-set-docs { margin-top: 1rem; }
.ms-set-tabs-in { margin: 1rem 1.25rem 0; flex-wrap: wrap; }
.ms-set-docpane { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 22rem); gap: 1rem; padding: 0 0 1rem; }
.ms-set-docpane[hidden] { display: none !important; }
.ms-set-doc-form { min-width: 0; }
.ms-set-doc-form > .ms-set-hint { padding: 1rem 1.25rem 0; }
.ms-set-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem 1rem; padding: 0 1.25rem; }
.ms-set-doc-prev { display: flex; justify-content: center; align-items: flex-start; margin: 1rem 1.25rem 0 1.25rem; padding: 1rem; border-radius: calc(var(--radius) + 2px); background: color-mix(in srgb, var(--muted) 60%, var(--card)); }
.ms-set-doc-prev iframe { width: 100%; max-width: 20rem; height: 32rem; border: 0; background: #fff; border-radius: .4rem; box-shadow: 0 6px 22px rgba(0,0,0,.12); }
@media (max-width: 1023px) { .ms-set-docpane { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 639px) { .ms-set-checks { grid-template-columns: minmax(0, 1fr); } }
/* settings → printing (one layout for labels, receipts and slips) */
.ms-set-pnav { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; padding: .9rem 1rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--card); }
.ms-set-pnav-group { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.ms-set-pnav-label { font-size: .68rem; font-weight: 700; letter-spacing: .02em; color: var(--muted-foreground); padding-inline-start: .2rem; }
.ms-set-pnav-items { display: flex; flex-wrap: wrap; gap: .3rem; }
.ms-set-ptab { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .82rem; font-weight: 600; color: var(--foreground); background: var(--card); transition: border-color .15s, background .15s; }
.ms-set-ptab svg, .ms-set-ptab i { width: .95rem; height: .95rem; color: var(--muted-foreground); }
.ms-set-ptab:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.ms-set-ptab.is-on { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground, #fff); }
.ms-set-ptab.is-on svg, .ms-set-ptab.is-on i { color: inherit; }
.ms-set-print #print-form { display: block; }
.ms-set-print #print-form > * + * { margin-top: 0; }
.ms-set-pp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 26rem); gap: 1rem; align-items: start; }
.ms-set-pp.hidden, .ms-set-pp[hidden] { display: none !important; }
.ms-set-pp.is-one { grid-template-columns: minmax(0, 1fr); }
.ms-set-pp-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ms-set-pp-body { padding: 1.1rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ms-set-pp-body > * { margin: 0 !important; }
.ms-set-pp-body .grid.gap-4 { gap: 1rem; }
.ms-set-pp-body .text-xs.text-muted-foreground { font-size: .74rem; line-height: 1.55; }
.ms-set-pp-body .space-y-2 > * + *, .ms-set-pp-body .space-y-3 > * + * { margin-top: .4rem; }
.ms-set-pp-prev { position: sticky; top: 5rem; }
.ms-set-pp-paper { display: flex; justify-content: center; align-items: flex-start; padding: 1.25rem; min-height: 12rem; overflow: auto; background: color-mix(in srgb, var(--muted) 65%, var(--card)); background-image: radial-gradient(color-mix(in srgb, var(--foreground) 9%, transparent) 1px, transparent 1px); background-size: 14px 14px; }
.ms-set-pp-paper iframe { display: block; max-width: 100%; border: 0; background: #fff; border-radius: .35rem; box-shadow: 0 8px 26px rgba(0,0,0,.14); }
.ms-set-pp-paper [data-doc-frame] { width: 20rem; height: 32rem; }
.ms-set-pp-paper > div { max-width: 100%; }
.ms-set-checks .ms-set-switch { white-space: normal; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.ms-set-checks .ms-set-switch:has(input:checked) { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: color-mix(in srgb, var(--primary) 5%, var(--card)); }
.ms-set-print .ms-set-checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; padding: 0; }
#set-docs .ms-set-checks { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; }
#set-docs .ms-set-pp-body .ms-set-grid { padding: 0; }
#set-docs:has(.ms-set-pp:not([hidden])) { margin-top: 0; }
#printers-list { border-radius: var(--radius); }
@media (max-width: 1199px) { .ms-set-print .ms-set-checks, #set-docs .ms-set-checks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1023px) { .ms-set-pp { grid-template-columns: minmax(0, 1fr); } .ms-set-pp-prev { position: static; order: -1; } }
@media (max-width: 639px) {
  .ms-set-pnav { padding: .75rem; }
  .ms-set-pnav-group { width: 100%; }
  .ms-set-print .ms-set-checks, #set-docs .ms-set-checks { grid-template-columns: minmax(0, 1fr); }
  .ms-set-pp-paper { padding: .75rem; }
}
@media (max-width: 639px) {
  .ms-set-pnav { flex-wrap: nowrap; overflow-x: auto; gap: 1rem; scrollbar-width: none; }
  .ms-set-pnav::-webkit-scrollbar { display: none; }
  .ms-set-pnav-group { width: auto; flex-shrink: 0; }
  .ms-set-pnav-items { flex-wrap: nowrap; }
  .ms-set-ptab { white-space: nowrap; }
  .ms-set-print .ms-set-checks, #set-docs .ms-set-checks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ms-set-checks .ms-set-switch { font-size: .76rem; padding: .5rem .55rem; }
}
/* "Turn on notifications on this device" */
.ms-push-card { position: fixed; z-index: 70; inset-inline: 1rem; bottom: 1rem; margin-inline: auto; max-width: 30rem; display: flex; align-items: center; gap: .8rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 6px); background: var(--card); color: var(--foreground); box-shadow: 0 14px 40px rgba(0,0,0,.18); opacity: 0; transform: translateY(1rem); transition: opacity .25s, transform .25s; }
.ms-push-card.is-in { opacity: 1; transform: none; }
.ms-push-ico { display: grid; place-items: center; flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: .8rem; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.ms-push-ico svg, .ms-push-ico i { width: 1.2rem; height: 1.2rem; }
.ms-push-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.ms-push-text b { font-size: .88rem; }
.ms-push-text small { font-size: .74rem; line-height: 1.5; color: var(--muted-foreground); }
.ms-push-acts { display: flex; gap: .35rem; flex-shrink: 0; }
@media (max-width: 639px) { .ms-push-card { flex-wrap: wrap; bottom: calc(5.5rem + env(safe-area-inset-bottom)); } .ms-push-acts { width: 100%; justify-content: flex-end; } }
/* settings → WhatsApp: the webhook, Desk link and team cards */
.ms-wh-card, .ms-wl-card, .ms-wa-team { margin: 0; }
.ms-wh-url { display: flex; align-items: stretch; gap: .5rem; min-width: 0; }
.ms-wh-url code { flex: 1; min-width: 0; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: color-mix(in srgb, var(--muted) 55%, var(--card)); font: 600 .76rem/1.5 var(--font-mono, ui-monospace, monospace); text-align: left; overflow-wrap: anywhere; }
.ms-wh-url .apex-btn { flex-shrink: 0; align-self: center; gap: .35rem; }
.ms-wh-url .apex-btn svg { width: .9rem; height: .9rem; }
.ms-wh-chips { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-start; }
.ms-wh-chips code { padding: .2rem .5rem; border-radius: .45rem; background: color-mix(in srgb, var(--primary) 9%, transparent); color: var(--primary); font: 600 .72rem/1.4 var(--font-mono, ui-monospace, monospace); }
.ms-wh-health { display: flex; flex-direction: column; gap: .4rem; }
.ms-wh-hrow { display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .8rem; }
.ms-wh-hrow svg, .ms-wh-hrow i { width: .95rem; height: .95rem; flex-shrink: 0; color: var(--primary); }
.ms-wh-hrow span { flex: 1; min-width: 0; color: var(--muted-foreground); }
.ms-wh-hrow b { font-weight: 700; }
.ms-wh-hrow.is-warn svg, .ms-wh-hrow.is-warn i { color: var(--warning, #d97706); }
.ms-wh-hrow.is-bad { border-color: color-mix(in srgb, var(--destructive) 40%, var(--border)); }
.ms-wh-hrow.is-bad svg, .ms-wh-hrow.is-bad i, .ms-wh-hrow.is-bad b { color: var(--destructive); }
.ms-wh-card .ms-wh-peek { margin: 0 1.25rem 1.25rem; max-height: 18rem; overflow: auto; padding: .75rem; border-radius: var(--radius); background: var(--muted); font: .7rem/1.5 var(--font-mono, ui-monospace, monospace); text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.ms-wl-card .ms-wl-body > * { margin: 0; }
.ms-wl-card .ms-wl-state { padding: .6rem .75rem; border-radius: var(--radius); background: color-mix(in srgb, var(--muted) 55%, var(--card)); font-size: .82rem; }
.ms-wl-card .ms-wl-state.is-ok { background: color-mix(in srgb, var(--success, #16a34a) 10%, var(--card)); }
.ms-wl-card .ms-wl-sources, .ms-wl-card .ms-wl-note { font-size: .76rem; color: var(--muted-foreground); line-height: 1.6; }
.ms-wa-team .ms-wa-team-body { display: grid; gap: .6rem; padding: 1rem 1.25rem 1.15rem; }
.ms-wa-team .ms-wa-team-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); background: var(--card); }
.ms-wa-team .ms-wa-team-row:has(input:checked) { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); background: color-mix(in srgb, var(--primary) 4%, var(--card)); }

.ms-wa-team .ms-wa-team-row span { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.ms-wa-team .ms-wa-team-row b { font-size: .86rem; }
.ms-wa-team .ms-wa-team-row small { font-size: .74rem; color: var(--muted-foreground); line-height: 1.5; }
.ms-wa-team .ms-payroll-msg { padding: 0; margin: 0; font-size: .74rem; }
.ms-wa-team .ms-payroll-msg:empty { display: none; }
#wa-session .ms-set-facts dd[dir="ltr"] { unicode-bidi: isolate; }

/* writing direction: each message, preview and box follows its own text (Arabic right, English left) */
.ms-bubble-text, .wa-b-text, .ms-conv-preview, .wa-dock-conv-prev, .ms-chat-note, .wa-note, .wa-transfer-note,
.ms-chat-pane textarea, .wa-win-input, .ms-conv-name, .ms-chat-head-name, .wa-win-title {
  unicode-bidi: plaintext; text-align: start;
}
.ms-bubble-text, .wa-b-text { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Arabic pages: numbers, codes, tokens and addresses keep their own (left-to-right) order but sit
   on the right like the rest of the text */
html[dir="rtl"] input[dir="ltr"], html[dir="rtl"] textarea[dir="ltr"], html[dir="rtl"] select[dir="ltr"],
html[dir="rtl"] .ms-set-facts dd, html[dir="rtl"] .ms-wh-url code, html[dir="rtl"] .ms-wh-card .ms-wh-peek { text-align: right; }
html[dir="rtl"] input[dir="ltr"]::placeholder { text-align: right; }
.ms-wh-chips code { unicode-bidi: isolate; }
/* pinned conversations */
.ms-conv-pin, .wa-dock-pin { display: inline-flex; flex-shrink: 0; color: var(--primary); }
.ms-conv-pin svg, .wa-dock-pin svg { transform: rotate(45deg); }
.ms-conv.is-pinned, .wa-dock-conv.is-pinned { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.ms-chat-pin { display: inline-grid; place-items: center; flex-shrink: 0; width: 2.25rem; height: 2.25rem; border-radius: .65rem; border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground); transition: color .15s, border-color .15s, background .15s; }
.ms-chat-pin:hover { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.ms-chat-pin.is-on { color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--card)); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
/* ── Right-click menu (theme/context-menu.js) ──────────────────────────── */
.ms-cm {
  position: fixed; z-index: 2147483000; min-width: 13.5rem; max-width: min(22rem, calc(100vw - 12px));
  max-height: calc(100vh - 12px); overflow-y: auto; padding: .3rem;
  background: var(--popover); color: var(--popover-foreground);
  border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 18px 40px -12px #00000059, 0 4px 12px -4px #00000026;
  opacity: 0; transform: scale(.97); transform-origin: top; transition: opacity .09s ease, transform .09s ease;
  font-size: .875rem; user-select: none; outline: none;
}
.ms-cm.is-in { opacity: 1; transform: none; }
.ms-cm-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 2rem; padding: .35rem .6rem;
  border: 0; border-radius: calc(var(--radius) - 2px); background: transparent; color: inherit;
  text-align: start; cursor: default; line-height: 1.25;
}
.ms-cm-item:hover:not(:disabled), .ms-cm-item:focus-visible { background: var(--accent); color: var(--accent-foreground); outline: none; }
.ms-cm-item:focus { outline: none; }
.ms-cm-item:disabled { opacity: .45; }
.ms-cm-item.is-strong .ms-cm-label { font-weight: 600; }
.ms-cm-item.is-danger { color: var(--destructive); }
.ms-cm-item.is-danger:hover, .ms-cm-item.is-danger:focus-visible { background: color-mix(in srgb, var(--destructive) 12%, transparent); color: var(--destructive); }
.ms-cm-ico { display: inline-flex; width: 1rem; flex-shrink: 0; justify-content: center; color: var(--muted-foreground); }
.ms-cm-item.is-danger .ms-cm-ico { color: inherit; }
.ms-cm-ico svg, .ms-cm-ico i { width: 1rem; height: 1rem; }
.ms-cm-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-cm-key { margin-inline-start: 1rem; font: inherit; font-size: .72rem; color: var(--muted-foreground); direction: ltr; white-space: nowrap; }
.ms-cm-sep { height: 1px; margin: .3rem .25rem; background: var(--border); }
.ms-cm-hint { padding: .35rem .6rem .2rem; font-size: .7rem; color: var(--muted-foreground); border-top: 1px solid var(--border); margin-top: .3rem; }
@media (pointer: coarse) {
  .ms-cm-item { min-height: 2.75rem; font-size: .95rem; }
  .ms-cm-key, .ms-cm-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ms-cm { transition: none; } }
/* Rows reachable with the keyboard (Enter opens, Menu key shows the menu) */
apex-data-table tr[data-row-id]:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; background: color-mix(in srgb, var(--primary) 6%, transparent); }
/* ── Device polish: phone, tablet, laptop (2026-11-07) ─────────────────── */
/* Taps act at once (no double-tap zoom wait), no blue flash, buttons are not text. */
a, button, [role="button"], summary, label, .apex-btn, apex-data-table tr[data-row-id] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.apex-btn, .ms-kpi, apex-sidebar a, summary { -webkit-user-select: none; user-select: none; }
:focus-visible { outline-offset: 2px; }

@media (max-width: 767px) {
  /* iPhone zooms the whole page into any field written smaller than 16px: keep fields at 16px. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea, .apex-input { font-size: 16px !important; }
  /* Room under the last card for the floating chat button. */
  #main-content { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
  /* Search and export on one line (export was a whole line of its own). */
  apex-data-table > .space-y-4 > div:first-child { flex-direction: row; align-items: center; gap: .5rem; }
  apex-data-table > .space-y-4 > div:first-child > div:first-child { min-width: 0; }
  apex-data-table > .space-y-4 > div:first-child > [data-csv-export] { flex-shrink: 0; height: 2.5rem; }
}

@media (max-width: 639px) {
  /* The figures: one swipeable strip instead of half a screen, so the list starts at once. */
  .ms-kpis {
    display: flex; gap: .5rem; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scrollbar-width: none;
    margin-inline: -1rem; padding-inline: 1rem; padding-block: .1rem;
  }
  .ms-kpis::-webkit-scrollbar { display: none; }
  .ms-kpis > .ms-kpi { flex: 0 0 auto; width: 42vw; max-width: 12rem; scroll-snap-align: start; padding: .65rem .75rem; }
  .ms-kpis > .ms-kpi.ms-kpi-spark { width: 72vw; max-width: 18rem; }
  .ms-kpis .ms-kpi-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ms-kpis .ms-kpi-value { margin-top: .2rem; }
  /* The page title row: less height above the work. */
  .ms-ph { gap: .65rem; }
  .ms-ph h1 { font-size: 1.3rem; }
}

/* Installed as an app (home screen / desktop window): clear the notch and the home bar, and no
   pull-to-refresh bounce pulling the whole app around. */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .apex-content > header, header.sticky { padding-top: env(safe-area-inset-top, 0px); }
  #wa-dock { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* Large screens: lists use the width they have. */
@media (min-width: 1600px) {
  #main-content { padding-inline: 2rem; }
}
/* ── Keyboard shortcuts panel (theme/ux-boost.js) ───────────────────────── */
.ms-keys { position: fixed; inset: 0; z-index: 2147482000; display: grid; place-items: center; padding: 1rem; background: #0006; backdrop-filter: blur(2px); }
.ms-keys-card { width: min(28rem, 100%); max-height: calc(100vh - 2rem); overflow: auto; background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); box-shadow: 0 24px 60px -20px #0008; padding: 1rem 1.1rem; }
.ms-keys-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; font-size: 1rem; }
.ms-keys dl { display: grid; gap: .15rem; margin: 0; }
.ms-keys dl > div { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .45rem .1rem; border-top: 1px solid var(--border); font-size: .875rem; }
.ms-keys dd { margin: 0; color: var(--muted-foreground); text-align: end; }
.ms-keys kbd, .ms-cm-key { font-family: inherit; }
.ms-keys kbd { display: inline-block; padding: .15rem .45rem; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: .4rem; background: var(--muted, var(--accent)); font-size: .78rem; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
/* ── Chat widget: pin on each conversation (wa-dock.js) ────────────────── */
.wa-dock-row { position: relative; }
.wa-dock-row > .wa-dock-conv { width: 100%; }
.wa-dock-pinbtn {
  position: absolute; inset-inline-end: 10px; bottom: 8px; display: grid; place-items: center;
  width: 26px; height: 26px; border: 0; border-radius: 8px; background: var(--card, #fff); color: var(--muted-foreground);
  box-shadow: 0 1px 3px #0000001f; opacity: 0; transition: opacity .12s, color .12s; cursor: pointer;
}
.wa-dock-row:hover .wa-dock-pinbtn, .wa-dock-pinbtn:focus-visible { opacity: 1; }
.wa-dock-row.is-pinned .wa-dock-pinbtn:hover, .wa-dock-pinbtn:hover { color: var(--primary); }
/* Touch: pinning is in the long-press menu and the chat header (no button on every row). */
@media (pointer: coarse) { .wa-dock-pinbtn { display: none; } }
.wa-win-ico.is-on { color: var(--primary); }
.wa-dock-toast { position: fixed; z-index: 2147483000; inset-inline-start: 50%; bottom: 96px; transform: translateX(-50%); padding: .55rem .9rem; border-radius: 10px; background: var(--foreground); color: var(--background); font-size: .85rem; box-shadow: 0 10px 30px -10px #0006; }
[dir="rtl"] .wa-dock-toast { transform: translateX(50%); }

/* ── @mentions in team notes (theme/mention.js) ────────────────────────── */
.ms-mention-list {
  position: fixed; z-index: 2147483001; max-height: 260px; overflow-y: auto; padding: .3rem;
  background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px); box-shadow: 0 18px 40px -12px #00000059;
}
.ms-mention-head { padding: .3rem .55rem .35rem; font-size: .72rem; font-weight: 600; color: var(--muted-foreground); }
.ms-mention-opt { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .4rem .55rem; border: 0; border-radius: calc(var(--radius) - 2px); background: transparent; color: inherit; text-align: start; font-size: .875rem; cursor: pointer; }
.ms-mention-opt.is-on, .ms-mention-opt:hover { background: var(--accent); color: var(--accent-foreground); }
.ms-mention-ava { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-size: .75rem; font-weight: 700; flex-shrink: 0; }
.ms-mention { padding: 0 .25rem; border-radius: .3rem; background: color-mix(in srgb, var(--primary) 13%, transparent); color: var(--primary); font-weight: 600; }
.ms-mention.is-me { background: color-mix(in srgb, #f59e0b 22%, transparent); color: #b45309; }
.dark .ms-mention.is-me { color: #fbbf24; }
/* ── Conversations: WhatsApp-like flow in the system's own look (theme/wa-chat.js) ── */
/* Messages in a row from the same side are one group: the name once, closer together,
   the corner "tail" only on the first one. */
.ms-bubble-row:not(.is-cont) { margin-top: .35rem; }
.ms-bubble-row.is-cont { margin-top: -.1rem; }
.is-in.is-cont .ms-bubble { border-start-start-radius: .6rem; }
.is-out.is-cont .ms-bubble { border-start-end-radius: .6rem; }

/* The thread and its "new messages" button */
.ms-thread-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ms-thread-wrap > .ms-thread { flex: 1 1 auto; }
.ms-to-bottom {
  position: absolute; inset-inline-end: 1.1rem; bottom: .9rem; z-index: 3; display: grid; place-items: center;
  width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); color: var(--muted-foreground); box-shadow: 0 6px 18px -8px #0000004d; cursor: pointer;
  animation: ms-pop .16s ease;
}
.ms-to-bottom:hover { color: var(--primary); }
.ms-to-bottom-n { position: absolute; top: -.45rem; inset-inline-start: -.3rem; min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
@keyframes ms-pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* Where the unread messages start */
.ms-unread-line { align-self: stretch; display: flex; justify-content: center; margin: .6rem -6%; padding: .3rem 0; background: color-mix(in srgb, var(--primary) 9%, transparent); }
.ms-unread-line span { font-size: .72rem; font-weight: 700; color: var(--primary); }

/* Conversation list: search and quick filters */
.ms-chat-tools { padding: .6rem .75rem .5rem; border-bottom: 1px solid var(--border); display: grid; gap: .5rem; }
.ms-chat-search { display: flex; align-items: center; gap: .45rem; height: 2.3rem; padding: 0 .7rem; border-radius: 999px; background: var(--muted, color-mix(in srgb, var(--foreground) 5%, transparent)); color: var(--muted-foreground); }
.ms-chat-search:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.ms-chat-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--foreground); font-size: .85rem; }
.ms-chat-search input::-webkit-search-cancel-button { cursor: pointer; }
.ms-chat-filters { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; }
.ms-chat-filters::-webkit-scrollbar { display: none; }
.ms-chat-filters button { flex-shrink: 0; display: inline-flex; align-items: center; gap: .3rem; height: 1.75rem; padding: 0 .7rem; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted-foreground); font-size: .78rem; font-weight: 600; cursor: pointer; }
.ms-chat-filters button:hover { color: var(--foreground); }
.ms-chat-filters button.is-on { background: color-mix(in srgb, var(--primary) 13%, transparent); border-color: transparent; color: var(--primary); }
.ms-chat-filters button span { min-width: 1.1rem; padding: 0 .3rem; border-radius: 999px; background: color-mix(in srgb, currentColor 16%, transparent); font-size: .68rem; text-align: center; }
/* Unread conversations stand out, as in WhatsApp */
.ms-conv.is-unread .ms-conv-name { font-weight: 800; }
.ms-conv.is-unread .ms-conv-time { color: var(--primary); font-weight: 700; }
.ms-conv.is-unread .ms-conv-preview { color: var(--foreground); }
/* ── Chat widget: search, quick filters, days and grouped messages (wa-dock.js) ── */
.wa-dock-tools { display: grid; gap: .45rem; padding: .55rem .7rem .5rem; border-bottom: 1px solid var(--border); }
.wa-dock-search { display: flex; align-items: center; gap: .4rem; height: 2.1rem; padding: 0 .65rem; border-radius: 999px; background: var(--muted, color-mix(in srgb, var(--foreground) 5%, transparent)); color: var(--muted-foreground); }
.wa-dock-search:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.wa-dock-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--foreground); font-size: .82rem; }
.wa-dock-filters { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; }
.wa-dock-filters::-webkit-scrollbar { display: none; }
.wa-dock-filters button { flex-shrink: 0; display: inline-flex; align-items: center; gap: .25rem; height: 1.6rem; padding: 0 .6rem; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted-foreground); font-size: .74rem; font-weight: 600; cursor: pointer; }
.wa-dock-filters button.is-on { background: color-mix(in srgb, var(--primary) 13%, transparent); border-color: transparent; color: var(--primary); }
.wa-dock-filters button span { min-width: 1rem; padding: 0 .28rem; border-radius: 999px; background: color-mix(in srgb, currentColor 16%, transparent); font-size: .65rem; text-align: center; }
.wa-dock-row.is-unread .wa-dock-conv-top b { font-weight: 800; }
.wa-dock-row.is-unread .wa-dock-conv-top small { color: var(--primary); font-weight: 700; }
.wa-dock-row.is-unread .wa-dock-conv-prev { color: var(--foreground); }
.wa-day { align-self: center; margin: .45rem 0 .25rem; }
.wa-day span { padding: .15rem .6rem; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: .68rem; color: var(--muted-foreground); }
.wa-brow:not(.is-cont) { margin-top: .3rem; }
.wa-brow.is-cont { margin-top: -.08rem; }
.wa-brow.is-in.is-cont .wa-b { border-start-start-radius: .5rem; }
.wa-brow.is-out.is-cont .wa-b { border-start-end-radius: .5rem; }
/* ── Chat widget sizes: phone · tablet · computer ───────────────────────── */
.wa-dock-scrim { display: none; }
/* Phones: the list is a bottom sheet over a dimmed page; a chat is the whole screen. */
@media (max-width: 640px) {
  .wa-dock-scrim { display: block; position: fixed; inset: 0; z-index: 1001; background: #0000004d; animation: wa-fade .18s ease; }
  .wa-dock-list {
    position: fixed; inset-inline: 0; bottom: 0; top: auto; width: 100%; height: min(85dvh, 44rem); max-height: none;
    border-radius: 1.1rem 1.1rem 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 1002;
    animation: wa-sheet .22s cubic-bezier(.2, .8, .2, 1);
  }
  .wa-dock-list::before { content: ""; align-self: center; width: 2.4rem; height: .3rem; margin-top: .5rem; border-radius: 999px; background: var(--border); flex-shrink: 0; }
  .wa-dock.is-list .wa-dock-launch { visibility: hidden; }
  .wa-dock-list-head { padding: .55rem 1rem .6rem; }
  .wa-dock-conv { padding: .75rem 1rem; }
  .wa-dock-search { height: 2.5rem; }
  .wa-dock-filters button { height: 1.9rem; padding: 0 .8rem; font-size: .8rem; }
}
/* Tablets: floating panels beside the chat button, a sensible size — never the full width. */
@media (min-width: 641px) and (pointer: coarse) {
  .wa-dock-windows { inset-inline: auto; inset-inline-end: 1rem; bottom: calc(5.2rem + env(safe-area-inset-bottom, 0px)); flex-direction: row-reverse; align-items: flex-end; max-width: calc(100vw - 2rem); }
  .wa-dock-windows .wa-win:not(.is-min) { width: min(24rem, calc(100vw - 2rem)); height: min(36rem, calc(100dvh - 8rem)); max-height: none; }
  .wa-dock-windows .wa-win.is-min { width: 13rem; }
  .wa-dock-list { width: min(23rem, calc(100vw - 2rem)); max-height: min(36rem, calc(100dvh - 7rem)); }
  .wa-dock-conv { padding: .7rem .9rem; }
}
/* Short screens (landscape phones, small laptops): nothing taller than the screen. */
@media (max-height: 560px) and (min-width: 641px) {
  .wa-dock-windows .wa-win:not(.is-min), .wa-win { height: calc(100dvh - 5.5rem); }
  .wa-dock-list { max-height: calc(100dvh - 5.5rem); }
}
@keyframes wa-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes wa-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .wa-dock-list, .wa-dock-scrim { animation: none; } }
/* Delivery ticks beside the last message in the conversation lists (as WhatsApp) */
.ms-conv-preview > .ms-tick, .wa-dock-conv-prev > .wa-tick { display: inline-flex; vertical-align: -0.15em; margin-inline-end: .25rem; color: var(--wa-tick, var(--muted-foreground)); }
.ms-conv-preview > .ms-tick.is-read, .wa-dock-conv-prev > .wa-tick.is-read { color: var(--wa-read, #53bdeb); }
.ms-conv-preview > .ms-tick.is-failed, .wa-dock-conv-prev > .wa-tick.is-failed { color: var(--destructive); }
.ms-conv-preview > .ms-tick svg, .wa-dock-conv-prev > .wa-tick svg { width: 1rem; height: 1rem; }
/* The ticks stay at the start of the line in the interface's direction (the right in Arabic);
   only the preview text follows its own writing direction (an English text no longer pulls the
   ticks to the other side). */
.ms-conv-preview, .wa-dock-conv-prev { display: flex; align-items: center; min-width: 0; unicode-bidi: normal; }
.ms-prev-text { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.ms-conv-preview > .ms-tick, .wa-dock-conv-prev > .wa-tick { flex-shrink: 0; }
/* Computers: a taller conversation list in the widget (more conversations at a glance). */
@media (min-width: 768px) and (pointer: fine) {
  .wa-dock-list { width: 22rem; height: min(40rem, calc(100dvh - 6.5rem)); max-height: none; }
}
/* A smaller chat button (54 → 46 px on computers and tablets, 50 px on phones), with the list
   and the windows placed against its new size. */
.wa-dock-launch { width: 2.9rem; height: 2.9rem; box-shadow: 0 5px 14px -4px #0000004d; }
.wa-dock-launch svg { width: 20px; height: 20px; }
.wa-dock-badge { transform: scale(.9); transform-origin: top; }
/* Tablets: the list floats just above the (smaller) chat button. Phones keep the bottom sheet. */
@media (min-width: 641px) {
  .wa-dock-list { bottom: 3.55rem; }
}
/* Computers: the list stands on the bottom edge beside the chat button, like the chat windows
   (it starts at the page's footer, not in the middle of the screen); open windows move aside. */
@media (min-width: 768px) and (pointer: fine) {
  .wa-dock-windows { inset-inline-end: calc(1rem + 2.9rem + .8rem); }
  .wa-dock-list {
    position: fixed; bottom: 0; inset-inline-end: calc(1rem + 2.9rem + .8rem);
    height: min(40rem, calc(100dvh - 4.5rem));
    border-radius: 1rem 1rem 0 0; border-bottom: 0;
    box-shadow: 0 -10px 34px -14px #00000066, 0 0 0 1px color-mix(in srgb, var(--border) 80%, transparent);
    animation: wa-rise .18s cubic-bezier(.2, .8, .2, 1);
  }
  .wa-dock.is-list .wa-dock-windows { inset-inline-end: calc(1rem + 2.9rem + .8rem + 22rem + .6rem); max-width: calc(100vw - 1rem - 2.9rem - .8rem - 22rem - .6rem - 1rem); }
}
@keyframes wa-rise { from { transform: translateY(1.5rem); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .wa-dock-list { animation: none; } }
@media (max-width: 640px) {
  .wa-dock-launch { width: 3.1rem; height: 3.1rem; }
  .wa-dock-launch svg { width: 22px; height: 22px; }
}
/* Delivery ticks in the lists: a little smaller, in line with the preview text. */
.ms-conv-preview > .ms-tick svg, .wa-dock-conv-prev > .wa-tick svg { width: .82rem; height: .82rem; }
.ms-conv-preview > .ms-tick, .wa-dock-conv-prev > .wa-tick { margin-inline-end: .2rem; }
/* Settings → WhatsApp: where WAClient really sends the events (wa-settings.js) */
.ms-wh-gw { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .85rem; border-radius: calc(var(--radius) + 2px); font-size: .84rem; line-height: 1.55; }
.ms-wh-gw > svg, .ms-wh-gw > i { flex-shrink: 0; width: 1.1rem; height: 1.1rem; margin-top: .15rem; }
.ms-wh-gw.is-ok { background: color-mix(in srgb, var(--success, #16a34a) 10%, transparent); color: var(--success, #16a34a); font-weight: 600; }
.ms-wh-gw.is-bad { background: color-mix(in srgb, var(--destructive) 9%, transparent); border: 1px solid color-mix(in srgb, var(--destructive) 30%, transparent); color: var(--foreground); }
.ms-wh-gw.is-bad > svg, .ms-wh-gw.is-bad > i { color: var(--destructive); }
.ms-wh-gw.is-bad b { display: block; color: var(--destructive); }
.ms-wh-gw ul { margin: .3rem 0; padding-inline-start: 1.1rem; list-style: disc; }
.ms-wh-gw small { color: var(--muted-foreground); }/* ── Widget on phones and touch tablets ─────────────────────────────────────────────────────────
   The conversation list has a grip on its top edge: drag it up for a taller list, down for a
   shorter one (all the way down closes it); the size is remembered (wa-dock.js). */
.wa-dock-grab { display: none; }
@media not all and (min-width: 768px) and (pointer: fine) {
  .wa-dock-list::before { content: none; display: none; }
  .wa-dock-grab { display: block; position: relative; flex-shrink: 0; height: 1.15rem; cursor: ns-resize; touch-action: none; }
  .wa-dock-grab::after { content: ""; position: absolute; top: .42rem; inset-inline-start: 50%; width: 2.6rem; height: .3rem; border-radius: 999px; background: color-mix(in srgb, var(--muted-foreground) 45%, transparent); transform: translateX(-50%); }
  [dir="rtl"] .wa-dock-grab::after { transform: translateX(50%); }
  .wa-dock-list-head { touch-action: none; }
  .wa-dock-list.is-sizing { animation: none; transition: none; user-select: none; }
  .wa-dock-list.is-sizing .wa-dock-grab::after { background: var(--primary); }
  .wa-dock-list { max-height: calc(100dvh - var(--ms-head-h, 0px) - 4.5rem); }
}
@media (max-width: 640px) {
  .wa-dock-list { max-height: calc(100dvh - var(--ms-head-h, 0px)); }
}
/* A chat opened from the widget starts under the page header (the header, the menu and the bell
   stay usable): the full width on phones, a panel at the side on tablets. */
@media (max-width: 640px), (pointer: coarse) and (max-width: 1366px) {
  .wa-dock-windows .wa-win.is-full { position: fixed; inset: var(--ms-head-h, 0px) 0 0 0; width: 100vw; height: auto; max-height: none; border-radius: 0; border: 0; border-top: 1px solid var(--border); box-shadow: none; z-index: 5; padding-top: 0; padding-bottom: env(safe-area-inset-bottom, 0px); transform: none !important; }
  .wa-win.is-full .wa-win-head { border-radius: 0; cursor: default; }
  .wa-win.is-full .wa-win-head .wa-win-ico[data-close] { width: 2.4rem; height: 2.4rem; }
  html.ms-chat-full, html.ms-chat-full body { overflow: hidden; }
  html.ms-chat-full .wa-dock-launch, html.ms-chat-full .wa-dock-list, html.ms-chat-full .wa-dock-scrim { display: none; }
}
@media (min-width: 641px) and (pointer: coarse) and (max-width: 1366px) {
  .wa-dock-windows .wa-win.is-full { inset-inline-start: auto; width: min(28rem, 100vw); border-inline-start: 1px solid var(--border); box-shadow: 0 0 40px -14px #00000066; }
}
@media (min-width: 641px) and (pointer: coarse) {
  .wa-dock-list { height: min(36rem, calc(100dvh - var(--ms-head-h, 0px) - 6rem)); }
}
/* The phone app's bars are in every page (header.php, layout.php); only app-shell.css shows them. */
.ms-appbar-back, .ms-appbar-title, .ms-tabbar { display: none; }
/* Installed on a computer (Chrome / Edge app window): no browser Back, so the header has one. */
html.ms-installed .ms-appbar-back:not([hidden]) { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex-shrink: 0; border: 0; border-radius: .6rem; background: none; color: var(--muted-foreground); cursor: pointer; transition: background-color .15s, color .15s; }
html.ms-installed .ms-appbar-back:hover { background: var(--accent); color: var(--foreground); }
[dir="rtl"] html.ms-installed .ms-appbar-back svg, html[dir="rtl"].ms-installed .ms-appbar-back svg { transform: scaleX(-1); }


/* Settings → WhatsApp: the provider card (WAClient, an outside provider) and its three steps. */
.ms-wa-provider { border-inline-start: 4px solid oklch(62% .17 150); }
.ms-wa-pv-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.ms-wa-pv-steps li { display: flex; align-items: flex-start; gap: .7rem; padding: .85rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); background: color-mix(in srgb, var(--muted) 35%, transparent); }
.ms-wa-pv-steps b { display: block; font-size: .85rem; font-weight: 600; }
.ms-wa-pv-steps small { display: block; margin-top: .2rem; font-size: .76rem; line-height: 1.5; color: var(--muted-foreground); }
.ms-wa-pv-n { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 999px; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: color-mix(in srgb, oklch(62% .17 150) 15%, transparent); color: oklch(45% .14 150); }
html.dark .ms-wa-pv-n { color: oklch(78% .14 150); }
.ms-wa-pv-foot { justify-content: flex-start; flex-wrap: wrap; gap: .5rem; }
