/* Saidala ERP/CRM. Only skin-engine tokens: no raw colours (the logo's colours come from tokens too). */
.hidden, [hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.bad { color: var(--danger); font-weight: 700; }
.warn-t { color: var(--warning, var(--danger)); font-weight: 700; }

/* ---- loading: the logo with typing dots */
.loader { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); transition: opacity .35s var(--ease); }
.loader.done { opacity: 0; pointer-events: none; }
.loader .mark { width: 96px; height: 96px; }
.typing .dot { animation: dot-bounce 1.2s infinite ease-in-out; transform-box: fill-box; transform-origin: center; }
.typing .dot:nth-of-type(2) { animation-delay: .15s; } .typing .dot:nth-of-type(3) { animation-delay: .3s; }
@keyframes dot-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-7px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing .dot, .chat .typing i { animation: none; } }

/* ---- shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100dvh; }
.side { background: var(--header); color: var(--on-header); padding: 18px 12px; display: flex; flex-direction: column; gap: 6px;
        border-inline-end: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font: 900 20px/1 var(--font); padding: 4px 8px 16px; }
.brand small { display: block; font: 700 11px/1.4 var(--font); color: var(--on-header-muted); letter-spacing: .06em; }
.mark { width: 38px; height: 38px; }
.nav { border: 0; background: transparent; color: var(--on-header-muted); text-align: start; padding: 11px 12px;
       border-radius: var(--r-md); font: 700 14px var(--font); cursor: pointer; min-height: var(--tap); }
.nav.on, .nav:hover { background: var(--surface-2); color: var(--text); }
/* Q 11-21: top tabs inside a grouped page (Staff: Chat · Board; Manage: Money · Activity · Team) */
.group-tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--q-border); margin-bottom: 4px; overflow-x: auto;
  overflow-y: hidden; scrollbar-width: none; }   /* Q 11-21: the tab underline's -1px made a phantom up/down scrollbar; still swipes sideways on phones */
.group-tabs::-webkit-scrollbar { display: none; }
.group-tabs[hidden] { display: none; }
.group-tab { border: 0; background: none; color: var(--text-muted); font: 700 15px var(--font); padding: 10px 14px 11px; cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.group-tab:hover { color: var(--text); }
.group-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.group-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.side-foot { margin-top: auto; padding: 8px; }
main { padding: 20px 24px 120px; display: grid; gap: 16px; align-content: start; min-width: 0; }
main > section { display: grid; gap: 10px; align-content: start; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: var(--fs-xl); }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ui-btn.icon { min-width: 40px; padding: 0 10px; font-weight: 900; }

/* Job161: system notice must stay visible on every view, including Android web tabs. */
#system-notice-banner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px; padding: 12px 16px; min-width: 0; position: sticky; top: 0; z-index: 35;
  border: 1px solid var(--q-border-strong); border-inline-start: 4px solid var(--warning);
  background: var(--q-warning-bg); color: var(--text); box-shadow: var(--shadow-1, none); }
#system-notice-banner[hidden] { display: none; }
#system-notice-text { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; line-height: 1.6; font-weight: 700; }
#system-notice-ack { flex: 0 0 auto; min-height: var(--tap); }
@media (max-width: 420px) { #system-notice-banner { padding: 10px; } #system-notice-ack { width: 100%; } }

/* ---- popovers: [ ? ] help and the Dr. menu */
.pop-wrap { position: relative; }
.pop { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 60; width: 290px; padding: 8px; display: grid; gap: 2px; }
.pop-item { text-align: start; border: 0; background: transparent; color: var(--text); padding: 10px 12px; border-radius: var(--r-md);
            font: 600 14px var(--font); cursor: pointer; }
.pop-item:hover { background: var(--surface-2); }
.pop-item.static { cursor: default; display: grid; gap: 8px; } .pop-item.static:hover { background: transparent; }
.pop-item.danger { color: var(--danger); }
.pop-item.layla-t { color: var(--layla); }
.me-head { display: grid; padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.layla-says { display: flex; gap: 10px; align-items: center; background: var(--layla-soft); color: var(--text); border-radius: var(--r-md);
              padding: 10px 12px; margin-bottom: 6px; font-size: var(--fs-sm); font-weight: 600; }

/* ---- full-width rows that open in place */
.list-head { display: flex; gap: 8px; max-width: 640px; }
.list-head .ui-btn { white-space: nowrap; flex: none; }
.xrows { display: grid; gap: 6px; }
/* Excel-style: click a column title to sort; again to flip. ▼ = high to low / Z–A, ▲ = low to high / A–Z. */
.th { border: 0; background: transparent; color: inherit; font: inherit; text-align: start; padding: 4px 0; cursor: pointer; }
.th:hover { color: var(--text); }
.th.on { color: var(--accent); }
.th.on::after { content: ' ▲'; } .th.on.desc::after { content: ' ▼'; }
.cust-cols { --cols: minmax(180px, 2fr) minmax(120px, 1fr) minmax(90px, .8fr) 28px; }
.item-cols, #item-rows { --cols: minmax(190px, 2.2fr) minmax(64px, .6fr) minmax(70px, .7fr) minmax(100px, .9fr) minmax(110px, 1fr) minmax(90px, .8fr) 28px; }
#rows { --cols: minmax(180px, 2fr) minmax(120px, 1fr) minmax(90px, .8fr) 28px; }
.xhead-row { display: grid; grid-template-columns: var(--cols); gap: 12px; padding: 0 14px; font-size: var(--fs-sm); font-weight: 700; }
.xrow { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.xrow.open { border-color: var(--accent); box-shadow: var(--shadow-1, none); }
.xhead { width: 100%; display: grid; grid-template-columns: var(--cols); gap: 12px; align-items: center; padding: 10px 14px;
         border: 0; background: transparent; color: var(--text); font: inherit; text-align: start; cursor: pointer; min-height: var(--tap); }
.xhead:hover { background: var(--brand-soft); }
.c-main { display: grid; gap: 2px; min-width: 0; } .c-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { justify-self: end; width: 10px; height: 10px; border-right: 2.5px solid var(--text-muted); border-bottom: 2.5px solid var(--text-muted);
        transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s var(--ease); }
.xrow.open .chev { transform: rotate(225deg) translate(-2px, -2px); border-color: var(--accent); }
.xbody { display: none; border-top: 1px solid var(--line); padding: 14px; }
.xrow.open .xbody { display: block; }
.xgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.xgrid h3 { margin: 10px 0 8px; font-size: var(--fs-md, 16px); }

.field { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field .k { color: var(--text-muted); font-weight: 700; font-size: var(--fs-sm); }
.field .v { overflow-wrap: anywhere; }
.field .ui-input { min-height: 38px; }
.edit-row { display: flex; gap: 6px; }
.orders, .batches { display: grid; gap: 6px; }
.order-line, .batch-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.price-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.price-row .ui-input { max-width: 160px; }
.big-price { font: 900 var(--fs-2xl)/1 var(--font-num); margin-bottom: 10px; }
.ok-msg { color: var(--success); min-height: 1.2em; margin: 0; }
.empty { padding: 30px 6px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }

/* ---- dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 4px; padding: 16px; }
.stat strong { font: 900 var(--fs-2xl)/1.1 var(--font-num); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.dash-grid .ui-card { padding: 16px; } .dash-grid h3 { margin: 0 0 10px; }

/* ---- dialogs */
dialog.ui-card { width: min(440px, 92vw); color: var(--text); padding: 22px; }
dialog.permissions-dialog { max-height: 88dvh; overflow: auto; }
/* Non-modal (top-layer modals would hide Layla's pointer), so it draws its own backdrop. */
dialog[open] { position: fixed; inset: 0; margin: auto; height: fit-content; z-index: 40; box-shadow: 0 0 0 100vmax var(--overlay) !important; }
dialog form { display: grid; gap: 12px; }
dialog h2 { margin: 0; }
dialog .row { display: flex; gap: 8px; }
/* Job167: shared modal forms, including native date controls with intrinsic widths. */
dialog.erp-ask-dialog { max-width: 92vw; max-height: 88dvh; overflow: auto; box-sizing: border-box; }
dialog.erp-ask-dialog form { grid-template-columns: minmax(0, 1fr); overflow-wrap: anywhere; }
dialog.erp-ask-dialog .ui-label, dialog.erp-ask-dialog .ui-input, dialog.erp-ask-dialog .ui-check span { min-width: 0; max-width: 100%; }
dialog.erp-ask-dialog .ui-check { align-items: flex-start; }
dialog.erp-ask-dialog .ui-check input { flex: none; margin-block-start: 4px; }
dialog.erp-ask-dialog .row { flex-wrap: wrap; }
dialog.erp-ask-dialog textarea { resize: vertical; }
dialog.erp-ask-dialog::backdrop { background: transparent; }

/* ---- Layla: closed she is the logo's chat bubble; open, the bubble grows into the chat window */
.layla-fab { position: fixed; inset-inline-start: 236px; bottom: 51px; display: grid; justify-items: start; gap: 10px; z-index: 50;
             transition: transform .25s var(--ease), opacity .25s; }
.layla-fab.touring { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
 .lb-badge { position: absolute; top: 2px; inset-inline-end: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--layla);
            border: 2px solid var(--surface); }
.layla-panel { position: relative; width: min(360px, calc(100vw - 36px)); padding: 14px; display: grid; gap: 10px;
               background: var(--surface); color: var(--text); border: 4px solid var(--accent); border-radius: 24px;
               box-shadow: 0 10px 30px var(--overlay); transform-origin: 0% 100%; animation: bubble-open .28s var(--ease); }
/* No triangle: the window's bottom-left corner is square, like a speech bubble's tail, wherever it is dragged. */
.layla-panel { border-end-start-radius: 6px; }
.layla-fab.moved { inset: auto; }
.layla-fab.dragging .layla-panel { box-shadow: 0 18px 44px var(--overlay); transition: none; }
.layla-head { cursor: grab; user-select: none; touch-action: none; } .layla-fab.dragging .layla-head { cursor: grabbing; }
.side-layla { position: relative; }
.side-layla.away img, .side-layla.away .qclip { visibility: hidden; }
.side-layla.away::after { content: ''; position: absolute; inset: 12.5% 13.8% 18.5% 12.5%; border: 2px dashed var(--layla); border-radius: 26%; opacity: .45; }   /* her rounded-square spot, not a circle (Q 11-20) */
.side-name { position: absolute; left: 50%; top: -17px; transform: translateX(-50%); font: 900 13px/1 var(--font); color: var(--layla);
             letter-spacing: .04em; pointer-events: none; }
.foot-row { align-items: flex-end; padding-top: 18px; }
.server-line { display: flex; gap: 6px; align-items: center; color: var(--text-muted); margin-top: 6px; }
.check-row { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.search-wrap { position: relative; flex: 1; display: flex; }
.search-wrap .ui-input { flex: 1; padding-inline-end: 38px; }
.search-x { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border: 0;
            border-radius: 50%; background: var(--surface-2); color: var(--text-muted); font: 700 13px/26px var(--font); cursor: pointer; padding: 0; }
.search-x:hover { color: var(--text); background: var(--brand-soft); }
.side-layla.on img { filter: drop-shadow(0 0 2px var(--layla)) drop-shadow(0 0 5px var(--layla)); }
.lb-typing { position: absolute; top: -10px; inset-inline-end: -12px; display: none; gap: 3px; padding: 5px 7px; border-radius: 10px;
             background: var(--surface); box-shadow: 0 2px 6px var(--overlay); }
.side-layla.typing .lb-typing { display: flex; }
.lb-typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--layla); animation: dot-bounce 1.2s infinite ease-in-out; }
.lb-typing i:nth-child(2) { animation-delay: .15s; } .lb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bubble-open { from { transform: scale(.25); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.layla-head { display: flex; align-items: center; gap: 8px; }
.chat-face { width: 44px; height: 44px; flex: none; filter: drop-shadow(0 2px 3px var(--overlay)); }
/* Layla's living face: same frame as the stills (geometry explained in layla-guide.js QCLIP_CSS). */
.qclip { position: relative; display: block; }
.qclip[hidden], .chat-face[hidden], .side-layla img[hidden] { display: none; }
.qclip > span { position: absolute; inset: 0; -webkit-mask: url(/ui/layla/moods/q-hole-192.png) center/contain no-repeat; mask: url(/ui/layla/moods/q-hole-192.png) center/contain no-repeat; }
.qclip video { position: absolute; left: 12.5%; top: 8.79%; width: 73.63%; height: 73.63%; object-fit: fill; }
.qclip video.exact { width: var(--clip-px); height: var(--clip-px); left: var(--clip-left); top: var(--clip-top); }   /* 1:1 pixels at whole-pixel offsets */
.qclip::after { content: ""; position: absolute; inset: 0; background: url(/ui/layla/moods/q-frame-192.png) center/contain no-repeat; pointer-events: none; }
.side-clip { width: 100%; height: 100%; }
/* No CSS filter on the video itself (it pushes Chrome to a blurrier path): the shadow rides on the frame only. */
:root .layla-head .qclip.chat-face { filter: none; }   /* beats the dark-skin .chat-face filter */
.qclip::before { content: ""; position: absolute; inset: 0; background: url(/ui/layla/moods/normal-192.png) center/contain no-repeat;
  filter: drop-shadow(0 2px 4px var(--overlay)); }   /* the still under the video: carries the SAME outline filter as her still */
:root[data-avatar="v2"] .qclip::before { background-image: url(/ui/layla/moods_v2/normal-192.png); }   /* Layla v2 (Q 11-21) */
:root[data-skin="dark"] .qclip::before { filter: drop-shadow(0 0 1.5px #ffffffb0) drop-shadow(0 2px 4px var(--overlay)); }
.layla-head .chat-face { width: 72px; height: 72px; }   /* still and clip the same size: no jump between moods */
.chat-face.face-pop, .side-layla img.face-pop { animation: face-pop .32s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes face-pop { from { transform: scale(.6) rotate(-8deg); } to { transform: none; } }
.foot-row { display: flex; align-items: center; gap: 10px; }
/* [ ? ] sits beside Layla at the bottom-left, so its menu opens upward and to the right. */
.help-pop.up { top: auto; bottom: calc(100% + 10px); inset-inline-end: auto; inset-inline-start: 0; }
.help-btn { border: 0; background: none; padding: 0; cursor: pointer; width: 64px; height: 64px; transition: transform .2s var(--ease); }
.help-btn:hover { transform: translateY(-2px) rotate(4deg); }
.help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }
.help-btn svg { width: 90%; height: 90%; margin: 5%; overflow: visible; filter: drop-shadow(0 2px 4px var(--overlay)); }
.help-q { font: 900 58px/1 var(--font); fill: var(--layla); stroke: #fff; stroke-width: 6px; paint-order: stroke fill; }
:root[data-skin="dark"] .help-btn svg { filter: drop-shadow(0 0 1.5px #ffffffb0) drop-shadow(0 2px 4px var(--overlay)); }
.side-layla { border: 0; background: none; padding: 0; cursor: pointer; width: 100px; height: 100px; transition: transform .2s var(--ease); }
.side-layla:hover { transform: translateY(-2px) rotate(-4deg); }
/* Layla v2 on desktop (Q 11-21): she fills the sidebar's foot (160 px, face ~118 px) and her "?" becomes a small round
   badge on the top-right corner of her frame (her frame's corner sits at 86% x / 8.8% y of her button). Phones below. */
/* Her frame's dark rim (6.2%..96.3% of her button, measured on q-frame.png) centred in the 220 px sidebar: even black on
   both sides (Q 11-21). Her button's transparent edge reaches into the scrollbar lane, so the sidebar clips sideways. */
:root[data-avatar="v2"] .side-foot { --lw: 192px; justify-items: start; padding-inline: 0; margin-inline: -6px 0; }
@media (min-width: 821px) { :root[data-avatar="v2"] .shell { grid-template-columns: 209px 1fr; } }   /* Q 11-21: 18 px · her rim · 18 px */
@media (min-width: 821px) { :root[data-avatar="v2"] .side { overflow-x: hidden; } }   /* desktop only: on phones .side IS the sideways nav (Q 11-21) */
:root[data-avatar="v2"] .side-layla { width: var(--lw); height: var(--lw); }
:root[data-avatar="v2"] .foot-row { position: relative; }
/* Q 11-21: on desktop her name lives INSIDE her "?" button: the same Q-chat frame (navy rim, mint inside, tail at the
   bottom right), just wider: "Layla ?". It keeps the "?" button's hover tilt (it tells your hand it's a button). The old
   name label inside her own button is hidden. */
.help-name { display: none; }
@media (min-width: 821px) {
  :root[data-avatar="v2"] .side-name { display: none; }
  /* centred WITHOUT a transform: a transformed parent traps her position:fixed help menu inside the sidebar (Q 11-21) */
  :root[data-avatar="v2"] .foot-row > .pop-wrap { position: absolute; z-index: 2; left: 0; width: var(--lw); top: -16px; display: flex; justify-content: center; pointer-events: none; }
  :root[data-avatar="v2"] .foot-row > .pop-wrap > * { pointer-events: auto; }
  :root[data-avatar="v2"] .foot-row .help-btn { position: relative; width: auto; height: 34px; display: inline-flex; align-items: center; gap: 5px;
    padding: 0 11px 0 13px; border-radius: 11px; background: #C8F4E5; border: 3.5px solid #1F2E36; filter: drop-shadow(0 2px 4px var(--overlay)); }
  :root[data-avatar="v2"] .foot-row .help-btn::after { content: ""; position: absolute; right: 5px; bottom: -9px; width: 11px; height: 9px;
    background: #1F2E36; clip-path: polygon(0 0, 100% 0, 100% 100%); }   /* the frame's tail */
  :root[data-avatar="v2"] .foot-row .help-btn svg { display: none; }
  :root[data-avatar="v2"][data-skin="dark"] .foot-row .help-btn { filter: drop-shadow(0 0 1.5px #ffffffb0) drop-shadow(0 2px 4px var(--overlay)); }   /* same outline glow as her frames on Black */
  :root[data-avatar="v2"] .help-name { display: inline; font: 900 14px/1 var(--font); color: #1F2E36; letter-spacing: .03em; }
  :root[data-avatar="v2"] .help-name::after { content: "?"; margin-inline-start: 6px; font-size: 18px; color: var(--layla);
    -webkit-text-stroke: 1px #fff; paint-order: stroke fill; }
}
.side-layla img { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px var(--overlay)); }
/* Black Ops: a thin light rim, so her navy frame doesn't sink into the dark background. */
:root[data-skin="dark"] .chat-face, :root[data-skin="dark"] .side-layla img {
  filter: drop-shadow(0 0 1.5px #ffffffb0) drop-shadow(0 2px 4px var(--overlay)); }
@media (prefers-reduced-motion: reduce) { .chat-face.face-pop { animation: none; } } .layla-head strong { color: var(--layla); font-size: 18px; }
.layla-head .ui-btn { min-height: 30px; margin-inline-start: auto; }
.chat { display: grid; gap: 8px; max-height: min(360px, 50dvh); overflow: auto; align-content: start; }
.chat .me { justify-self: end; background: var(--brand-soft); color: var(--text); border-radius: var(--r-md); padding: 7px 11px; font-size: 13px; max-width: 85%; }
.chat .her { justify-self: start; background: var(--layla-soft); color: var(--text); border-radius: var(--r-md); padding: 7px 11px; font-size: 13px; max-width: 85%; white-space: pre-wrap; }
.chat .typing { display: flex; gap: 4px; padding: 10px 12px; }
.chat .typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--layla); animation: dot-bounce 1.2s infinite ease-in-out; }
.chat .typing i:nth-child(2) { animation-delay: .15s; } .chat .typing i:nth-child(3) { animation-delay: .3s; }
.chat .note { justify-self: center; font-size: 11px; color: var(--text-muted); }
.chat-form { display: flex; gap: 6px; }
.chat-form .ui-input { min-height: 38px; }
@media (prefers-reduced-motion: reduce) { .layla-panel { animation: none; } .lb-typing i { animation: none; } }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; align-items: center; overflow-x: auto; padding: 8px 10px; }
  .brand { padding: 0 8px 0 0; } .brand small, .brandline { display: none; }
  .side-foot { margin-inline-start: auto; margin-inline-end: 0; padding: 0; } .side-layla, :root[data-avatar="v2"] .side-layla { width: 52px; height: 52px; } .help-btn { width: 40px; height: 40px; }
  .side-name { display: none; } .foot-row { padding-top: 0; }
  .layla-fab:not(.moved) { inset-inline-start: auto; inset-inline-end: 12px; bottom: 12px; }
  .help-pop.up { position: fixed; bottom: auto; top: 64px; inset-inline-start: auto; inset-inline-end: 16px; width: min(290px, calc(100vw - 32px)); }
  .nav { white-space: nowrap; flex: none; }
  main { padding: 14px 16px 120px; }
  .xgrid { grid-template-columns: 1fr; }
  .xhead-row { display: none; }
  #item-rows { --cols: 1fr 56px 66px 0 0 0 20px; }
  #item-rows .xhead > span:nth-child(4), #item-rows .xhead > span:nth-child(5), #item-rows .xhead > span:nth-child(6) { display: none; }
  .xhead-row.item-cols { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0 4px; } .xhead-row.item-cols > span { display: none; }
  #rows { --cols: 1fr 110px 0 20px; } #rows .xhead > span:nth-child(3) { display: none; }
  /* Phones (Q 11-17): one line per field, a small ✎ instead of a big Edit button under every value. */
  .field { grid-template-columns: 72px 1fr auto; gap: 8px; padding: 8px 0; }
  .field [data-edit] { font-size: 0; min-width: 40px; height: 36px; padding: 0 10px; }
  .field [data-edit]::before { content: '✎'; font-size: 17px; line-height: 1; }
  .field:has(#edit-input) { grid-template-columns: 72px 1fr; }
  .field .edit-row { grid-column: 1 / -1; justify-self: end; }
}

/* ---- ERP v2: toolbar, add item, receive invoice, import, toast */
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
dialog.wide { width: min(980px, 96vw); max-height: 92dvh; overflow: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
.form-grid.three { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.ui-check { display: flex; gap: 8px; align-items: center; font-weight: 600; align-self: end; min-height: 40px; }
.cat-list { display: grid; gap: 4px; max-height: 210px; overflow: auto; }
.cat-row { display: grid; gap: 1px; text-align: start; border: 1px solid var(--line); background: var(--surface); color: var(--text);
           border-radius: var(--r-md); padding: 8px 10px; cursor: pointer; font: inherit; }
.cat-row:hover, .cat-row:focus-visible { border-color: var(--accent); background: var(--brand-soft); }
.lines-wrap { overflow-x: auto; }
table.lines { width: 100%; border-collapse: collapse; min-width: 760px; }
table.lines th { text-align: start; font-size: var(--fs-sm); color: var(--text-muted); padding: 4px; }
table.lines td { padding: 3px; vertical-align: middle; }
table.lines td:first-child { min-width: 200px; }
table.lines .ui-input { min-height: 36px; width: 100%; }
.row.between { justify-content: space-between; align-items: center; }
.linkish { border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.imp-errs { margin: 0; padding-inline-start: 18px; max-height: 160px; overflow: auto; font-size: var(--fs-sm); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: var(--fs-sm); }
.facts b { color: var(--text-muted); font-weight: 700; margin-inline-end: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 90;
         background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: var(--r-md); font-weight: 700;
         box-shadow: 0 8px 24px var(--overlay); transition: opacity .4s; }
.toast.out { opacity: 0; }
.side-foot { display: grid; gap: 8px; justify-items: start; }
.brandline { color: var(--on-header-muted); font-size: 11px; letter-spacing: .02em; }
.mini-face { width: 40px; height: 40px; flex: none; }
:root[data-skin="dark"] .mini-face { filter: drop-shadow(0 0 1.5px #ffffffb0); }

/* Rows right-to-left: numbers and "13 · 1365.00" pairs keep their own left-to-right order. */
[dir="rtl"] .num { direction: ltr; unicode-bidi: isolate; }

/* ---- Batch 4: who takes what, refills, notices */
.links { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.links-head { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.links-head h3 { margin: 0; }
.mini-table { display: grid; gap: 4px; overflow-x: auto; }
.mini-table .mt-head, .mini-table .mt-row { display: grid; grid-template-columns: minmax(180px, 2.4fr) 60px 80px 110px 80px 60px; gap: 10px; align-items: center; min-width: 600px; }
.mini-table.pick .mt-head, .mini-table.pick .mt-row { grid-template-columns: 24px minmax(150px, 2fr) 60px 80px 110px 110px; }
.mt-head { font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); padding: 0 10px; }
.mt-row { padding: 7px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 0; color: var(--text); font: inherit; text-align: start; }
button.mt-row { cursor: pointer; } button.mt-row:hover { background: var(--brand-soft); }
.mt-row.off { opacity: .55; }
.mt-row .linkish { text-align: start; font-weight: 700; text-decoration: none; color: var(--text); }
.mt-row .linkish:hover { color: var(--accent); text-decoration: underline; }
.notify-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.nb-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-inline-start: auto; }
.nb-actions .ui-btn { min-height: 34px; font-size: 13px; }
.offer { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--r-md);
         background: var(--layla-soft); font-weight: 600; }
.notice-text { min-height: 120px; resize: vertical; font: 500 15px/1.5 var(--font); }
#notice-result { display: flex; gap: 6px; flex-wrap: wrap; }

/* Dashboard tiles open their list (Q 11-17) */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0 0 8px; }
button.batch-line.go { width: 100%; border: 0; font: inherit; color: inherit; text-align: start; cursor: pointer; border-radius: 6px; }
button.batch-line.go:hover, button.batch-line.go:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------------------------------------------------------------- dashboard v2 (Q 11-17) */
.dash { display: grid; gap: 14px; }
.dash-head { display: flex; align-items: baseline; gap: 12px; }
.dash-head h2 { margin: 0; font-size: var(--fs-xl, 22px); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi { display: grid; gap: 4px; padding: 16px; align-content: start; }
.kpi strong { font: 900 var(--fs-2xl, 28px)/1.1 var(--font-num, inherit); }
.kpi strong small { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.kpi-sub { font-size: 13px; color: var(--text-muted); }
.trend { font-weight: 800; font-size: 12.5px; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.trend.up { color: var(--success); background: var(--success-soft); }
.trend.down { color: var(--danger); background: var(--danger-soft); }
.trend.flat { color: var(--text-muted); background: var(--surface-2); }
.dash-grid.wide { grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); align-items: start; }
@media (max-width: 900px) { .dash-grid.wide { grid-template-columns: 1fr; } }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .tick { font-size: 10px; fill: var(--text-muted); text-anchor: middle; }
.chart .tick.start { text-anchor: start; }
.chart .axis { stroke: var(--line); }
.chart .c-last { fill: none; stroke: var(--text-faint); stroke-width: 1.6; stroke-dasharray: 4 3; }
.chart .c-today { fill: none; stroke: var(--text); stroke-width: 1.5; }
.c-pos { fill: var(--brand); background: var(--brand); }
.c-wa { fill: var(--success-fill); background: var(--success-fill); }
.c-on { background: var(--purple); }
.c-rx { fill: var(--layla); background: var(--layla); }
.c-month { fill: var(--brand-soft); background: var(--brand-soft); }
.c-ly { fill: var(--purple); background: var(--purple); }
.c-now { fill: var(--brand); background: var(--brand); opacity: .75; }
.legend { display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: -6px; vertical-align: -1px; }
.legend i.c-last.line { height: 0; border-top: 2px dashed var(--text-faint); background: none; width: 14px; }
.stackbar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); margin: 4px 0 10px; }
.stackbar span { display: block; height: 100%; }
.chan { display: grid; grid-template-columns: 12px 1fr auto; gap: 2px 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.chan i { width: 10px; height: 10px; border-radius: 3px; }
.chan small { grid-column: 2 / 4; }
.chan.soon { opacity: .6; }
.mt { margin-top: 16px !important; }
.nm { display: flex; gap: 6px; align-items: baseline; min-width: 0; flex: 1; flex-wrap: wrap; }
.batch-line .nm small { font-weight: 400; }
.cust-line { display: flex; gap: 8px; align-items: baseline; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }

/* [ ? ] menu on phones (Q 11-17): it scrolls by itself; the page behind it doesn't move. */
.help-pop { max-height: min(70vh, 560px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
@media (max-width: 820px) { .help-pop.up { max-height: calc(100dvh - 88px); } }
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px; } .kpi strong { font-size: 22px; } .kpi-sub { font-size: 11.5px; }
}
.card-head { flex-wrap: wrap; } .card-head h3 { white-space: nowrap; }

/* Orders (Q 11-17) */
.order-cols { --cols: minmax(190px, 2fr) minmax(130px, 1fr) minmax(50px, .4fr) minmax(80px, .6fr) minmax(130px, 1fr) 28px; }
/* Mid widths (11-23): the Windows counter's narrowest window (900 px) left ~675 px beside the side menu, less than
   these columns' minimums, so orders and items scrolled sideways. Smaller minimums, same proportions. */
@media (min-width: 821px) and (max-width: 1100px) {
  .item-cols, #item-rows { --cols: minmax(140px, 2.2fr) minmax(56px, .6fr) minmax(60px, .7fr) minmax(80px, .9fr) minmax(90px, 1fr) minmax(76px, .8fr) 28px; }
  .order-cols { --cols: minmax(150px, 2fr) minmax(110px, 1fr) minmax(44px, .4fr) minmax(70px, .6fr) minmax(110px, 1fr) 28px; }
}
/* Phones (11-23): the desktop columns were ~600px wide, so total + driver were cut off out of sight and long Arabic
   statuses clipped. Two lines instead: order + status, then driver + total. Item count lives in the open row. */
@media (max-width: 820px) {
  #order-rows .xhead { grid-template-columns: minmax(0, 1fr) auto 20px; row-gap: 4px; }
  #order-rows .xhead > span:nth-child(1) { grid-column: 1; grid-row: 1; }
  #order-rows .xhead > span:nth-child(2) { grid-column: 2; grid-row: 1; justify-self: end; max-width: 46vw; }
  #order-rows .xhead > span:nth-child(3) { display: none; }
  #order-rows .xhead > span:nth-child(4) { grid-column: 2; grid-row: 2; justify-self: end; font-weight: 700; }
  #order-rows .xhead > span:nth-child(5) { grid-column: 1; grid-row: 2; font-size: var(--fs-sm); min-width: 0;
                                           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #order-rows .xhead > span:nth-child(6) { grid-column: 3; grid-row: 1 / span 2; }
  #order-rows .ui-pill { white-space: normal; text-align: center; line-height: 1.3; }
}
[data-ofilter].on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
#order-driver { max-width: 260px; }
.small { font-size: 12.5px; }

/* @-tags in Layla's chat (Q 11-17) */
.chat-form { position: relative; }
.mention-pop { position: absolute; bottom: calc(100% + 6px); inset-inline: 0; z-index: 5; padding: 4px; display: grid; gap: 2px;
  max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.mention { display: flex; gap: 8px; align-items: baseline; width: 100%; text-align: start; border: 0; background: none; color: var(--text);
  font: inherit; padding: 7px 9px; border-radius: 8px; cursor: pointer; }
.mention.on, .mention:hover { background: var(--layla-soft); }

/* ---------------------------------------------------------------- Staff Chat + staff on the web (Q 11-17) */
#view-team:not(.hidden) { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; height: calc(100dvh - 150px); min-height: 360px; }
.team-chat { min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md, 12px); padding: 12px; }
.team-chat.thinking::after { content: 'Layla is typing…'; color: var(--layla); font-size: 13px; padding: 2px 6px; }
.tmsg { max-width: min(78%, 620px); align-self: flex-start; background: var(--surface-2); border-radius: 12px; padding: 7px 11px; }
.tmsg.me { align-self: flex-end; background: var(--brand-soft); }
.tmsg.layla { background: var(--layla-soft); }
.tmeta { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--text-muted); margin-bottom: 2px; }
.tmsg.layla .tmeta b { color: var(--layla); }
.tface { width: 20px; height: 20px; border-radius: 6px; }
.tbody { white-space: pre-wrap; overflow-wrap: anywhere; }
.tbody .tag { color: var(--accent); font-weight: 700; }
.ttime { font-size: 11px; color: var(--text-faint); text-align: end; margin-top: 2px; }
.team-form .ui-input { min-height: 42px; }
.nav-dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; background: var(--layla); margin-inline-start: 6px; vertical-align: 2px; }
.staff-cols { --cols: minmax(180px, 2fr) minmax(140px, 1fr) minmax(90px, .7fr) max-content; }
/* Q 11-21: Staff cards in two halves. Left = the person (face beside the name, "hasn't joined" under it; role on the
   right of that half, devices under the role: 2 lines, not 3). Right = the action buttons, wrapping. On a narrow list
   (container query: the sidebar counts) the person block sits on top and the buttons wrap below it. */
#staff-rows { container-type: inline-size; }
#view-staff .xhead-row { display: none; }          /* the old Name/Role/Signed-in columns no longer line up */
/* name + role columns hug their content (capped), the buttons get the rest (Q 11-21: Remove went up far too late) */
.staff-cols .xhead { grid-template-columns: fit-content(300px) fit-content(220px) minmax(0, 1fr); grid-template-rows: auto auto;
  grid-template-areas: "main role acts" "main dev acts"; column-gap: 32px; row-gap: 2px; align-items: center; }
.staff-cols .xhead > .c-main { grid-area: main; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center; }
.staff-cols .xhead > .c-main > :first-child { grid-row: 1 / span 4; align-self: center; }
.staff-cols .xhead > .c-main > :not(:first-child) { grid-column: 2; }
.staff-cols .xhead > span:nth-child(2) { grid-area: role; align-self: end; }
.staff-cols .xhead > .staff-dev { grid-area: dev; align-self: start; color: var(--text-muted); font-size: var(--fs-sm); }
.staff-cols .xhead > span:nth-child(3):not(.staff-dev) { grid-area: dev; }   /* Layla's empty third cell */
.staff-cols .staff-acts { grid-area: acts; display: flex; flex-wrap: wrap; justify-content: flex-end; align-content: center; gap: 8px; }
@container (max-width: 760px) {
  .staff-cols .xhead { grid-template-columns: minmax(0, 1fr) minmax(0, max-content); grid-template-areas: "main role" "main dev" "acts acts"; row-gap: 6px; }
  .staff-cols .staff-acts { justify-content: flex-start; margin-top: 6px; }
}
.xhead.static { cursor: default; }
.row.wrap { flex-wrap: wrap; }
/* Q 11-28: the checklist links ran together with no space. */
.help-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
#join-url { width: 100%; margin: 6px 0 10px; font-size: 13px; }
.pin-gate { position: fixed; inset: 0; z-index: 2147482000; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.pin-gate[hidden] { display: none !important; }
.pin-card { width: min(360px, 100%); display: grid; gap: 10px; justify-items: center; text-align: center; padding: 26px; }
.pin-card .ui-input { text-align: center; font-size: 22px; letter-spacing: 6px; width: 100%; }
.j-back { display: grid; gap: 8px; width: 100%; } .j-back[hidden] { display: none; } .j-back .ui-btn { text-decoration: none; }
.pin-face { width: 72px; height: 72px; border-radius: 18px; }
body.staff-mode .owner-only { display: none !important; }
.danger-t { color: var(--danger); }

/* Join QR (Q 11-17): white quiet zone stays white in every skin so phones can read it. */
.join-qr { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.join-qr canvas { width: 150px; height: 150px; image-rendering: pixelated; background: #fff; border-radius: 6px; flex: none; }
.join-qr p { margin: 0; font-size: 13px; }
@media (max-width: 480px) { .join-qr { flex-direction: column; align-items: flex-start; } }

/* Online shop link (job90) and "call to confirm" on online orders. */
.shop-link { display: grid; gap: 8px; padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-2); }
.shop-link p { margin: 4px 0 0; }
.shop-link .ui-input { flex: 1 1 260px; min-width: 0; }
.call-first { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 12px; margin-bottom: 10px; border-radius: 8px; background: var(--warning-soft); }

/* @mention chips and their small card (Q 11-17). */
button.chip { border: 0; background: var(--surface-3); color: var(--accent); font: inherit; font-weight: 700;
  padding: 0 6px; border-radius: 6px; cursor: pointer; }
button.chip.k-medicine { color: var(--warning); }
button.chip:hover, button.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mcard { position: fixed; z-index: 60; width: min(290px, calc(100vw - 16px)); padding: 12px; display: grid; gap: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.mcard .mrow { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.mcard p { margin: 0; }

/* ---- Phone fixes, round 2 (Q 11-17) */
/* Staff Chat is the whole screen: the chat grows into the space and shrinks when the keyboard opens. */
body[data-view="team"] .shell { height: 100dvh; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
body[data-view="team"] main { overflow: hidden; padding-bottom: 12px; grid-template-rows: auto auto minmax(0, 1fr); }  /* title, Team tabs (Chat · Board), the chat */
body[data-view="team"] main:has(#system-notice-banner:not([hidden])) {
  grid-template-rows: auto auto auto minmax(0, 1fr);  /* title, visible notice, tabs, chat */
}
body[data-view="team"] #view-team:not(.hidden) { height: auto; min-height: 0; }
@media (max-width: 820px) {
  /* Items: the medicine name gets the whole first line, the numbers sit on the line below. */
  #item-rows .xhead { grid-template-columns: repeat(4, minmax(0, 1fr)) 20px; row-gap: 4px; }
  #item-rows .xhead > span:nth-child(4), #item-rows .xhead > span:nth-child(6) { display: block; font-size: 13px; }
  #item-rows .xhead > span:nth-child(5) { display: none; }
  /* The page layout never stretches the top bar when the list is short (Customers, empty views). */
  .shell { grid-template-rows: auto 1fr; align-content: start; }
  #item-rows .xhead > span:first-child { grid-column: 1 / -1; }
  /* The profile menu opens inside the screen, not off its left edge. */
  .me-pop { position: fixed; top: 64px; inset-inline: 12px; width: auto; max-height: calc(100dvh - 80px); overflow: auto; }
}

/* ---- Q 11-17: Layla and ? always in reach */
/* Desktop: the side bar stays on screen (a tall Dashboard used to push her corner below the fold). */
@media (min-width: 821px) {
  .side { position: sticky; top: 0; height: 100dvh; overflow-y: auto; z-index: 30; }
  /* The side bar scrolls (overflow), which clipped the ? menu and added a sideways scroll bar (Q 11-18): the menu is
     pinned to the window instead, above ? and over the page. */
  .help-pop.up { position: fixed; inset-inline-start: 12px; bottom: 150px; max-height: calc(100dvh - 170px); }
}
/* Phones: Layla + ? stay pinned at the right end of the top bar while the tabs scroll and the keyboard opens. */
@media (max-width: 820px) {
  .side { position: sticky; top: 0; z-index: 40; }
  .side { padding-inline-end: 112px; }
  .side-foot { position: fixed; top: 0; inset-inline-end: 0; height: 65px; padding-inline-end: 8px; z-index: 41; display: flex; align-items: center; gap: 6px;
    background: var(--header); padding-inline-start: 8px; box-shadow: -12px 0 12px -4px var(--header); }
}

/* Staff Chat @colleague (Q 11-18): the tag reads as a name; a message that tags YOU stands out. */
.chip-staff { color: var(--accent); font-weight: 800; }
.tmsg.tagged { box-shadow: inset 3px 0 0 var(--accent); background: var(--brand-soft); }
.tmsg.unread-at { animation: unread-at 1s ease-in-out 3; }
@keyframes unread-at { 50% { box-shadow: inset 3px 0 0 var(--accent), 0 0 0 3px var(--accent); } }
@media (prefers-reduced-motion: reduce) { .tmsg.unread-at { animation: none; outline: 3px solid var(--accent); } }

/* Everyone's face: inside Q's frame, the same Q-chat bubble as the logo and Layla (ui/layla/make_face_frame.py).
   .qf-in is clipped to the bubble's inside; the frame image sits on top. The hole box (%) is printed by the script. */
.staff-face { --qf: url(/ui/layla/moods/q-frame-96.png); --qh: url(/ui/layla/moods/q-hole-96.png);
  position:relative; display:inline-block; width:40px; height:40px; flex-shrink:0; vertical-align:middle; }
.staff-face.lg { --qf: url(/ui/layla/moods/q-frame-192.png); --qh: url(/ui/layla/moods/q-hole-192.png); width:96px; height:96px; }
.staff-face.sm { width:30px; height:30px; }
.staff-face:after { content:""; position:absolute; inset:0; background:var(--qf) center/contain no-repeat; pointer-events:none; }
.staff-face .qf-in { position:absolute; inset:0; background:var(--layla-soft);
  -webkit-mask:var(--qh) center/contain no-repeat; mask:var(--qh) center/contain no-repeat; }
.staff-face .qf-in > * { position:absolute; left:12.21%; top:11.42%; right:13.48%; bottom:20.14%; }
.staff-face img { width:74.31%; height:68.44%; object-fit:cover; }   /* = 100% minus the hole's side margins */
.staff-face .qf-in b { display:grid; place-items:center; color:var(--text); font-weight:900; font-size:14px; line-height:1; }
.staff-face.sm .qf-in b { font-size:10px; }
.staff-face.lg .qf-in b { font-size:32px; }
.profile-picture { display:flex; gap:14px; align-items:center; flex-wrap:wrap; margin:12px 0 20px; }
.tmeta { display:flex; align-items:center; gap:8px; } .tmeta .staff-face { width:34px; height:34px; }
.me-btn { display:inline-flex; align-items:center; gap:7px; }

/* Badges (Q 11-18): plain dot = new team messages; the "@" badge = you were tagged (Staff Chat + beside your name). */
.nav-dot.at, .me-at { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 99px;
  background: var(--accent); color: var(--surface); font: 800 11px/1 system-ui, sans-serif; vertical-align: 1px; }
.me-at { margin-inline-start: 6px; animation: face-pop .32s cubic-bezier(.3, 1.6, .5, 1); }
.me-at[hidden], .nav-dot[hidden], .mention-item[hidden] { display: none; }
.mention-item { color: var(--accent); font-weight: 700; }

/* Staff rows (Q 11-18): the action buttons in an even grid; each device on its own line, Revoke on the right. */
.staff-acts { display: grid; grid-template-columns: repeat(2, max-content); gap: 8px; justify-content: end; align-content: center; }
.staff-dev { display: grid; gap: 6px; align-content: center; }
.staff-dev small { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Tenant WhatsApp inbox: theme tokens only. */

#wa-nav.hidden { display:none; }
.wa-layout { display:grid; grid-template-columns:minmax(170px,32%) minmax(0,1fr); min-height:0; gap:10px; }
.wa-list,.wa-messages { overflow:auto;min-height:0; background:var(--surface);border:1px solid var(--line);border-radius:var(--r-md);padding:8px; }
.wa-chat { width:100%;text-align:start;display:grid;gap:4px;background:var(--surface);color:var(--text);border:0;border-bottom:1px solid var(--line);padding:12px;cursor:pointer;position:relative; }
.wa-chat small { overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
.wa-chat.on { background:var(--surface-2); }
.wa-unread { position:absolute;inset-inline-end:8px;top:10px;color:var(--layla); }
.wa-conversation { display:grid;grid-template-rows:auto minmax(0,1fr) auto;gap:8px;min-width:0; }
.wa-toolbar { display:flex;align-items:center;gap:8px;flex-wrap:wrap; }
.wa-message { max-width:85%;width:max-content;display:flex;align-items:start;gap:6px;white-space:pre-wrap;overflow-wrap:anywhere;background:var(--surface-2);color:var(--text);padding:9px;border-radius:12px;margin-bottom:8px; }
.wa-message.outgoing { margin-inline-start:auto;background:var(--surface);border:1px solid var(--line); }
.wa-message small { font-size:10px;opacity:.7; }
.wa-qr { min-height:220px;display:grid;place-items:center; }
#wa-link-dialog { max-width:min(94vw,450px); }
@media(max-width:600px){ .wa-layout {grid-template-columns:38% minmax(0,1fr);} }
/* Job93 owner history follows the current skin tokens. */
.history-filters { flex-wrap:wrap; align-items:end; }
.history-filters .ui-input { min-width:120px; max-width:220px; }
.history-cols { display:grid;grid-template-columns: 1fr 2fr 1fr 1fr 20px;gap:12px; }
#history-rows .xhead {display:grid;grid-template-columns:1fr 2fr 1fr 1fr 20px;gap:12px;}
.history-detail {padding:12px;border-top:1px solid var(--line);overflow-wrap:anywhere;}
.history-detail p {margin:6px 0;}

#wa-order-link-dialog, #wa-settings-dialog { width:min(94vw,530px);max-height:90dvh;overflow:auto; }
#wa-settings-form { display:grid;gap:9px; }
#wa-settings-form label {font-weight:600;}
#wa-settings-form .row {margin-top:8px;}

/* Board (job111): logical flow works identically in Arabic and English. */
.board-grid {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr));gap:12px;align-items:start;margin-block:12px;min-width:0}
.board-note {min-width:0;overflow-wrap:anywhere;display:grid;gap:8px;text-align:start}
.board-note-text {white-space:pre-wrap;margin:0;font-size:1.02rem}
.board-note-meta,.board-note-actions {display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0}
.board-due {border-inline-start:4px solid #c78322}
.board-check {display:flex;align-items:flex-start;gap:8px;min-width:0}
.board-check input {flex:none;margin-block-start:4px}.board-check span {min-width:0;overflow-wrap:anywhere}.board-check small {display:block}
.board-dialog {max-width:min(94vw,500px);width:100%;max-height:90dvh;overflow:auto;box-sizing:border-box}
.board-form {display:grid;gap:12px}.board-form label {display:grid;gap:4px}.board-form textarea,.board-form select,.board-form input {box-sizing:border-box;width:100%;min-width:0;font:inherit}
#view-board [hidden],.board-dialog [hidden],#board-due-badge[hidden] {display:none!important}
#board-error {margin:0;color:var(--danger,#a33)}

.ai-notice-inbox { flex: 1 1 100%; padding: 10px 14px; margin: 0 0 10px; }
.ai-notice-row { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.ai-notice-row + .ai-notice-row { margin-top:8px; }
/* Job114: narrow-screen money view and independent expanded item rows. */
.money-layout { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));gap:14px;margin-top:18px;align-items:start }
.money-layout > section { min-width:0;padding:16px; }
.money-line { display:grid;grid-template-columns:1fr auto;gap:5px 12px;padding:12px 0;border-bottom:1px solid var(--line, var(--border)); }
.money-line > small { grid-column:1/-1; }
.money-inline { display:flex;flex-wrap:wrap;gap:8px;align-items:end;grid-column:1/-1;padding-top:8px; }
.money-inline label { display:grid;gap:4px;font-size:12px;flex:1 1 120px;min-width:100px; }
.money-inline input, .money-inline select { width:100%;min-width:0; }
.money-inline .error { flex-basis:100%; }
.money-people { display:grid;gap:8px;margin:12px 0; }
.money-layout #money-nudge label {margin:5px 0;}
.money-top {margin-bottom:12px;}
.money-quick {margin-bottom:14px;}
.expiry-buckets {padding:14px;margin:12px 0;}
.expiry-bars {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;}
.expiry-bar {background:var(--surface-2);border-radius:8px;padding:10px;display:grid;gap:6px;}
@media(max-width:620px){.expiry-bars{grid-template-columns:repeat(2,minmax(0,1fr))}.money-layout{grid-template-columns:1fr}.money-quick .ui-btn{flex:1 1 120px}}
@media (max-width: 820px) {   /* phones: v2 keeps the normal top-bar layout (help button beside her) */
  :root[data-avatar="v2"] .foot-row { position: static; }
  :root[data-avatar="v2"] .foot-row > .pop-wrap { position: static; }
  :root[data-avatar="v2"] .foot-row .help-btn { width: 40px; height: 40px; }
  .side-foot .foot-row { gap: 4px; } .side-foot, :root[data-avatar="v2"] .side-foot { padding-inline-end: 8px; }   /* Q 11-21: her bubble closer to the "?", off the screen edge */
}

/* Job117: personal dashboard. All surfaces and states use skin tokens. */
.dash-toolbar { align-items:center; gap:10px; }
.dash-widgets { display:grid; grid-template-columns:repeat(12,minmax(0,1fr));gap:12px;align-items:start; }
.dash-widget { grid-column:span var(--dash-span,12);min-width:0; }
.dash-widget-body { min-width:0; }
.dash-widget-body > .ui-card { padding:16px; height:100%; }
.dash-widget[data-width="full"] { grid-column:1 / -1; }
.dash-widget[data-width="fit"] { width:max-content;max-width:100%; }
.dash-widget[data-width="fit"] .dash-widget-body > .kpis {display:flex; flex-wrap:wrap;align-items:stretch;}
.dash-widget[data-width="fit"] .dash-widget-body .kpi {flex:0 1 auto;min-width:max-content;max-width:100%;}
.dash-widget[data-width="fit"] .dash-widget-body > .ui-card {width:max-content;max-width:100%;}
.dash-widget[data-number-size="S"] {--dash-num:19px}
.dash-widget[data-number-size="M"] {--dash-num:var(--fs-2xl,28px)}
.dash-widget[data-number-size="L"] {--dash-num:34px}
.dash-widget[data-number-size="XL"] {--dash-num:42px}
.dash-widget .kpi strong,.dash-widget .num:not(small) {font-size:var(--dash-num);}
.dash-widget .batch-line .num,.dash-widget .chan .num,.dash-widget .cust-line .num,.dash-widget .expiry-bar .num {font-size:clamp(15px,calc(var(--dash-num) * .6),25px);}
.dash-widget[data-badge-size="S"] .trend {font-size:10px;padding:1px 5px;}
.dash-widget[data-badge-size="M"] .trend {font-size:12.5px;padding:1px 7px;}
.dash-widget[data-badge-size="L"] .trend {font-size:16px;padding:3px 10px;}
.dash-widget .chart {max-height:260px;}
.dash-widget .dash-head {min-height:32px;}
.dash-widgets.is-editing {gap:16px 12px;}
.dash-widgets.is-editing .dash-widget {border:1px dashed var(--line);border-radius:var(--radius,12px);padding:7px;}
.dash-grip {display:flex;align-items:center;gap:8px;margin-bottom:8px;min-height:35px;font-size:12px;color:var(--text-muted);}
.dash-grip b {flex:1;min-width:0;font-weight:700;}
.dash-grip button {background:var(--surface-2);color:var(--text);border:1px solid var(--line);border-radius:8px;min-width:30px;min-height:32px;cursor:pointer;}
.dash-grip button:disabled {opacity:.35;cursor:default;}
.dash-handle {touch-action:none;cursor:grab !important;user-select:none;-webkit-user-select:none;font-size:21px !important;}
.dash-grip-end {display:flex;align-items:center;gap:4px;margin-inline-start:auto;}
.dash-dragging {position:absolute !important;inset-inline-start:-200vw;opacity:.25;pointer-events:none;}
.dash-drop-placeholder {background:var(--brand-soft);border:2px dashed var(--brand);border-radius:var(--radius,12px);min-height:75px;}
.dash-panel {display:grid;gap:12px;padding:16px;}
.dash-panel .card-head {display:flex;gap:10px;align-items:center;justify-content:space-between;}
.dash-panel h3 {margin:0;}
.dash-checks {display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:8px 20px;}
.dash-checks label {display:flex;align-items:center;gap:9px;min-height:34px;cursor:pointer;}
.dash-checks input {accent-color:var(--brand);width:17px;height:17px;}
.dash-widget-settings {border-top:1px solid var(--line);padding-top:12px;display:grid;gap:10px;}
.dash-widget-settings label {display:grid;gap:5px;max-width:370px;font-size:13px;}
.dash-widget-settings select {width:100%;}
.dash-alert {display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:12px;}
.dash-widget [data-tour] {scroll-margin-top:15px;}
@media (max-width:900px) {
  .dash-widgets {grid-template-columns:repeat(2,minmax(0,1fr));}
  .dash-widget {grid-column:span 2;}
}
@media (max-width:600px) {
  .dash-widgets {grid-template-columns:minmax(0,1fr);}
  .dash-widget,.dash-widget[data-width="full"],.dash-widget[data-width="fit"] {grid-column:1 / -1;width:100%;}
  .dash-widget[data-width="fit"] .dash-widget-body > .kpis {display:grid;grid-template-columns:minmax(0,1fr);}
  .dash-widget[data-width="fit"] .dash-widget-body .kpi {min-width:0;}
  .dash-widget .kpis {grid-template-columns:minmax(0,1fr);}
  .dash-panel {position:fixed;inset:auto 0 0;max-height:min(78dvh,680px);overflow:auto;overscroll-behavior:contain;
    z-index:1100;border-radius:18px 18px 0 0;box-shadow:var(--shadow-2);padding:16px 18px calc(16px + env(safe-area-inset-bottom));}
  .dash-checks {grid-template-columns:1fr;}
  .dash-grip {gap:4px;}
  .dash-grip b {font-size:11px;}
}

/* Job119: human-approved notes, mobile-first and RTL-safe. */
.layla-customer-notes,.layla-order-notes { margin-block:16px; padding:14px; background:var(--surface-2);border:1px solid var(--line);border-radius:var(--r-md);min-width:0; }
.layla-note { display:grid;gap:8px;margin-block:10px;padding:12px;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-sm);overflow-wrap:anywhere; }
.layla-note p { margin:3px 0;white-space:pre-wrap;unicode-bidi:plaintext; }
.layla-note small {overflow-wrap:anywhere;}
.layla-note label,.note-edit-form label {display:grid;gap:6px;max-width:100%;}
.layla-note select {max-width:100%;}
.note-kind,.note-actions {display:flex;flex-wrap:wrap;gap:8px;align-items:center;}
.layla-note-dialog {max-width:min(94vw,460px);}
.note-edit-form {display:grid;gap:10px;margin-block:12px;}
.note-edit-form textarea {resize:vertical;min-height:90px;width:100%;box-sizing:border-box;}
@media(max-width:600px){.layla-order-notes,.layla-customer-notes{padding:10px}.note-actions .ui-btn{flex:1 1 42%}}

/* job123: consistently visible branch identity on narrow and wide screens */
.branch-switch { position:relative; min-width:0; }
.branch-current { display:flex; align-items:center; gap:8px; max-width:min(44vw,260px); }
#branch-label { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.branch-chip { display:inline-grid; place-items:center; width:28px; height:28px; min-width:28px; border-radius:8px; background:var(--surface-2); color:var(--text); border:1px solid var(--line); font-weight:900; }
.branch-chip[data-tint="0"] { border-style:solid; border-width:2px; }
.branch-chip[data-tint="1"] { border-style:dashed; }
.branch-chip[data-tint="2"] { border-style:double; border-width:3px; }
.branch-chip[data-tint="3"] { border-radius:50%; }
.branch-chip[data-tint="4"] { border-radius:3px; }
.branch-chip[data-tint="5"] { border-radius:12px 4px; }
.branch-popup { position:absolute; top:calc(100% + 8px); inset-inline-end:0; z-index:70; width:min(86vw,370px); padding:12px; display:grid; gap:10px; box-shadow:var(--shadow-2); }
.branch-options { display:grid; gap:3px; max-height:320px; overflow-y:auto; }
.branch-option { width:100%; min-height:44px; display:flex; align-items:center; gap:8px; border:0; border-radius:var(--r-sm); background:transparent; color:var(--text); text-align:start; padding:7px 10px; cursor:pointer; font:inherit; }
.branch-option:hover { background:var(--surface-2); }
.branch-option:disabled { opacity:.5; cursor:not-allowed; }
.branch-screen .ui-card { padding:16px; }
.branch-screen h2 { margin:0 0 8px; }
.branch-rows { display:grid; gap:8px; margin-top:12px; }
.branch-row { padding:12px; margin:8px 0; border:1px solid var(--line); border-radius:var(--r-md); overflow-wrap:anywhere; }
.branch-row p { color:var(--text-muted); margin:6px 0; }
.branch-row details { margin-top:10px; }
.branch-form { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:10px; margin:12px 0; }
.branch-form label, #branch-transfer-form label { display:grid; gap:5px; }
.transfer-line { display:flex !important; align-items:center; gap:12px; justify-content:space-between; padding:6px 0; }
.transfer-line input { width:94px; flex:none; }
#transfer-item-results { display:grid; }
#branch-transfer-form { display:grid; gap:12px; }
@media (max-width:650px) { .top-actions { justify-content:space-between; width:100%; } .branch-switch { order:-2; } .branch-current { max-width:70vw; } .branch-screen .ui-card { padding:12px; } }
/* Phones (C 11-22): branch, language and you in ONE row; the branch name takes the room, you show as your face. */
@media (max-width:650px) {
  .top-actions { flex-wrap:nowrap; gap:6px; }
  .top-actions .branch-switch { flex:1 1 auto; }
  .top-actions .branch-current { width:100%; max-width:none; min-height:44px; padding-inline:10px; }
  .top-actions #lang { padding-inline:10px; flex:0 0 auto; }
  .top-actions .pop-wrap { flex:0 0 auto; }
  .top-actions #me-name { display:none; }
  .branch-popup { inset-inline-start:0; inset-inline-end:auto; width:min(92vw,370px); }
}

/* Job123: compact, RTL-safe manager grant rows. */
.branch-manager {display:flex;gap:.65rem;align-items:center;justify-content:space-between;flex-wrap:wrap;padding:.45rem 0;border-bottom:1px solid var(--line,#ddd)}
.branch-confirm {padding:.4rem 0;display:flex;gap:.4rem;align-items:center;flex-wrap:wrap}
.branch-manager-form {margin:.6rem 0}
/* All branches tiles (C 11-22) */
.branch-stats { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin:10px 0; }
@media (min-width:560px) { .branch-stats { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media (min-width:1100px) { .branch-stats { grid-template-columns:repeat(6,minmax(0,1fr)); } }
.branch-stats div { background:var(--surface-2); border-radius:var(--r-sm); padding:8px 10px; min-width:0; }
.branch-stats dt { color:var(--text-muted); font-size:var(--fs-sm,13px); }
.branch-stats dd { margin:2px 0 0; font-weight:800; font-size:1.05rem; overflow-wrap:anywhere; }
.branch-total { border-color:var(--accent,var(--line)); }
.branch-here { display:inline-block; }
/* First-day checklist (onboarding 11-22) */
.first-steps { margin-bottom:14px; }
.first-steps .fs-head { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.first-steps h2 { margin:0; font-size:var(--fs-lg,1.15rem); }
.fs-list { list-style:none; margin:12px 0; padding:0; display:grid; gap:8px; }
.fs-list li { display:flex; align-items:center; gap:10px; padding:10px; border:1px solid var(--line); border-radius:var(--r-md); }
.fs-list li.done { opacity:.7; }
.fs-mark { width:26px; height:26px; min-width:26px; border-radius:50%; border:2px solid var(--line); display:grid; place-items:center; font-weight:900; color:var(--accent,var(--text)); }
.fs-list li.done .fs-mark { border-color:var(--accent,var(--line)); }
.fs-text { flex:1; min-width:0; display:grid; gap:2px; }
.fs-text small { overflow-wrap:anywhere; }
@media (max-width:600px) { .fs-list li { flex-wrap:wrap; } .fs-list li .ui-btn { width:100%; } }

/* job128: fast browser counter, responsive and print-friendly */
.counter-layout { display:grid; grid-template-columns:minmax(0, 1.7fr) minmax(260px, 1fr); gap:14px; align-items:start; }
.counter-left { display:grid; gap:14px; min-width:0; }
.counter-card { padding:16px; display:grid; gap:10px; min-width:0; }
.counter-card h2 { margin:0; font-size:var(--fs-lg, 19px); }
.counter-card label { font-weight:700; }
.counter-card .small { margin:0; }
.counter-results { display:grid; gap:6px; max-height:46dvh; overflow-y:auto; }
.counter-result { width:100%; background:var(--surface-2); color:var(--text); border:1px solid var(--line); border-radius:var(--r-sm); text-align:start; padding:10px; min-height:var(--tap); display:flex; gap:10px; justify-content:space-between; align-items:center; cursor:pointer; font:inherit; }
.counter-result:hover,.counter-result:focus-visible { border-color:var(--accent); }
.counter-result span,.counter-item { display:grid; gap:4px; min-width:0; }
.counter-result small,.counter-item small { display:block; }
.counter-basket-line { padding:10px 0; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; }
.counter-item { flex:1; min-width:140px; }
.counter-stepper { display:flex; align-items:center; gap:4px; }
.counter-stepper .ui-btn { min-width:34px; padding:7px; }
.counter-stepper input { width:60px; min-height:40px; text-align:center; font:700 16px var(--font-num); }
.counter-total { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:12px 0; border-bottom:1px solid var(--line); }
.counter-total strong { font:900 var(--fs-xl, 24px)/1.2 var(--font-num); }
.counter-checkout { position:sticky; top:8px; }
.counter-checkout #counter-submit { min-height:52px; width:100%; font-size:17px; }
.counter-customer-list { display:grid; gap:4px; max-height:160px; overflow-y:auto; }
.counter-receipt { max-width:650px; margin:auto; padding:24px; }
.counter-receipt header { text-align:center; }
.counter-receipt h2 { margin:0; }
.counter-receipt table { width:100%; border-collapse:collapse; margin:20px 0; }
.counter-receipt th,.counter-receipt td { padding:9px 4px; text-align:start; border-bottom:1px solid var(--line); }
.counter-receipt-actions { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
@media(max-width:760px) { .counter-layout { grid-template-columns:1fr; } .counter-card { padding:12px; } .counter-checkout { position:static; } .counter-results { max-height:34dvh; } }
@media print {
  body:not(.printing-shift-report):has(#view-counter:not(.hidden) #counter-receipt:not([hidden])) * { visibility:hidden !important; }
  body:has(#view-counter:not(.hidden) #counter-receipt:not([hidden])) #counter-receipt,
  body:has(#view-counter:not(.hidden) #counter-receipt:not([hidden])) #counter-receipt * { visibility:visible !important; }
  #counter-receipt { position:absolute; inset:0; width:100%; max-width:none; box-shadow:none; border:0; color:#000; background:#fff; }
  #counter-receipt .counter-receipt-actions { display:none; }
}

/* job121: web store editor + printable QR sheet. Colours only from skin tokens. */
.store-editor .store-link-card { margin-bottom: 14px; }
.store-editor .store-url { font-weight: 700; word-break: break-all; color: var(--q-primary); }
.store-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); gap: 16px; align-items: start; }
.store-form { display: grid; gap: 12px; }
.store-form label { display: grid; gap: 4px; margin: 6px 0; }
.store-form label.check { display: flex; gap: 8px; align-items: center; }
.store-form fieldset { border: 1px solid var(--q-border); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.store-themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.store-theme { border: 2px solid var(--q-border); border-radius: 10px; padding: 10px 6px; text-align: center; cursor: pointer; }
.store-theme input { position: absolute; opacity: 0; }
.store-theme:has(input:checked) { border-color: var(--q-primary); box-shadow: 0 0 0 3px var(--q-focus-ring); }
.store-theme.theme-fresh { background: var(--q-accent-bg); }
.store-theme.theme-paper { background: var(--q-warning-bg); }
.store-theme.theme-night { background: var(--q-text); color: var(--q-bg); }
.store-theme.theme-calm { background: var(--q-purple-bg); }
.store-pics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.store-pic { width: 96px; height: 96px; border: 1px dashed var(--q-border-strong); border-radius: 12px; display: grid; place-items: center; overflow: hidden; margin: 6px 0; background: var(--q-panel); }
.store-pic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.store-pic .muted { padding: 8px; text-align: center; font-size: 12px; line-height: 1.4; }
.store-secs { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 4px; }
.store-sec { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 8px; border: 1px solid var(--q-border); border-radius: 8px; }
.store-sec-move { display: flex; gap: 4px; }
.store-hidden { list-style: none; padding: 0; margin: 8px 0; max-height: 260px; overflow: auto; }
.store-actions { position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; padding: 10px 0; background: var(--q-bg); }
.store-preview { position: sticky; top: 12px; }
.store-preview-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.store-preview iframe { width: 100%; height: min(760px, 80vh); border: 2px solid var(--q-border-strong); border-radius: 22px; background: var(--q-panel); }
@media (max-width: 900px) {
  .store-grid { grid-template-columns: 1fr; }
  .store-preview { position: static; }
  .store-preview iframe { height: 620px; }
  .store-themes { grid-template-columns: repeat(2, 1fr); }
}
.store-qr-sheet { display: none; }
@media print {
  body.printing-store-qr * { visibility: hidden !important; }
  body.printing-store-qr .store-qr-sheet, body.printing-store-qr .store-qr-sheet * { visibility: visible !important; }
  body.printing-store-qr .store-qr-sheet { display: block !important; position: absolute; inset: 0; background: #fff; color: #000; }
  .store-qr-sheet .qr-row { display: flex; flex-wrap: wrap; gap: 6mm; justify-content: center; margin-bottom: 8mm; }
  .store-qr-sheet .qr-card { border: 1px dashed #999; border-radius: 4mm; padding: 4mm; display: grid; justify-items: center; text-align: center; gap: 1mm; break-inside: avoid; }
  .store-qr-sheet .qr-card.big { width: 85mm; }
  .store-qr-sheet .qr-card.big canvas { width: 60mm; height: 60mm; }
  .store-qr-sheet .qr-card.small { width: 42mm; font-size: 8pt; }
  .store-qr-sheet .qr-card.small canvas { width: 30mm; height: 30mm; }
}

/* job122: inside the Android app (?app=1) the app's bottom tabs pick the page; keep Layla + the account menu. */
.in-app .side > .side-nav, .in-app .side > .brand, .in-app #group-tabs[hidden] { display: none !important; }
.in-app .side { min-height: 0; }
.rx-photos { display: flex; gap: 8px; flex-wrap: wrap; }
.rx-photos img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--q-border); }
/* job164 cold-chain inspection log */
.fridge-page {display:grid;gap:12px;max-width:100%;min-width:0}
.fridge-page .ui-card {padding:12px;min-width:0}
.fridge-page form {display:flex;flex-wrap:wrap;align-items:end;gap:8px;margin:10px 0}
.fridge-page form label {display:grid;gap:4px;min-width:0;flex:1 1 145px}
.fridge-page form input {max-width:100%;min-width:0}
.fridge-table-wrap {overflow-x:auto;max-width:100%}
.fridge-table {width:100%;border-collapse:collapse;table-layout:fixed;font-size:.9rem}
.fridge-table th,.fridge-table td {padding:6px;border:1px solid var(--line,#bbb);vertical-align:top;overflow-wrap:anywhere;text-align:start}
.fridge-table th:first-child {width:26%}
.fridge-out {font-weight:bold;text-decoration:underline}
.fridge-reading + .fridge-reading {border-top:1px dashed currentColor;margin-top:4px;padding-top:4px}
.fridge-alert {border-top:1px solid var(--line,#bbb);padding:8px 0}
.fridge-tile {padding:8px;margin-bottom:8px}
#fridge-print {display:none}
@page fridge-inspection {size:A4 portrait;margin:12mm}
@media print {
  body.printing-fridge > :not(#fridge-print) {display:none!important}
  body.printing-fridge {display:block!important;overflow:visible!important;height:auto!important;background:white!important;color:black!important}
  body.printing-fridge #fridge-print {display:block!important;page:fridge-inspection;color:#000;background:#fff;font:10pt Arial,sans-serif}
  #fridge-print .fridge-table-wrap {overflow:visible}
  #fridge-print .fridge-table {font-size:9pt}
  #fridge-print .fridge-table th,#fridge-print .fridge-table td {border:1px solid #777;padding:4pt}
  #fridge-print thead {display:table-header-group}
  #fridge-print tr {break-inside:avoid}
}

.fridge-current {display:flex;flex-wrap:wrap;gap:8px 16px;font-weight:600;margin-bottom:8px}
.fridge-review-history {border-top:1px dotted currentColor;margin-top:4px;padding-top:4px;font-size:.85em}

.counselling-text { white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word; }
.counter-card { max-width:100%; }
[data-part="counselling-card"] form label { display:block; margin:8px 0; }
[data-part="counselling-card"] textarea { display:block; width:100%; min-height:5em; }
/* Job169: bounded learned list in the 375px embedded web tab too. */
#view-memory { max-width: 850px; margin-inline: auto; }
.memory-head, .memory-row { padding: 14px; min-width: 0; overflow-wrap: anywhere; }
.memory-head progress { width: 100%; margin-block: 4px 12px; }
.memory-list { display: grid; gap: 10px; margin-block: 12px; }
.memory-row-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.memory-row-top strong { min-width: 0; }
.memory-row-top .ui-pill { flex-shrink: 0; }
.memory-head .row, .memory-row .row { flex-wrap: wrap; }

.counter-tabs { display:flex; flex-wrap:wrap; gap:6px; align-items:center; min-width:0; }
.counter-tabs [data-basket-tab] { min-width:36px; padding-inline:8px; }
.counter-tabs [aria-pressed="true"] { font-weight:700; outline:2px solid currentColor; outline-offset:-2px; }

/* Job172: bounded product controls and receipt text in narrow RTL. */
#cust-usual, #counter-usual {min-width:0; overflow-wrap:anywhere;}
#cust-usual form {display:flex; flex-wrap:wrap; gap:.5rem; align-items:end; margin-block:.5rem;}
#cust-usual label {min-width:0; flex:1 1 8rem;}
#cust-usual input {width:100%; min-width:0;}
#cust-usual [data-usual-results] {display:flex; flex-wrap:wrap; gap:.25rem;}
#counter-usual button, #cust-usual button {max-width:100%; white-space:normal; overflow-wrap:anywhere;}
.receipt-note {overflow-wrap:anywhere; white-space:pre-wrap;}

/* Website shift summaries */
.shift-fields { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.35rem 1rem; margin:.65rem 0; }
.shift-fields dd { margin:0; text-align:end; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
#counter-shift { margin-bottom:.75rem; }
#view-shifts .ui-card { margin-top:.75rem; }

/* Job192: the temporary print root is a direct child of body, independent of the active view. */
#shift-report-print {display:none}
@media print {
  body.printing-shift-report > :not(#shift-report-print) {display:none!important}
  body.printing-shift-report {display:block!important;overflow:visible!important;height:auto!important;background:white!important;color:black!important}
  body.printing-shift-report #shift-report-print {display:block!important;color:#000;background:#fff;font:11pt/1.4 Arial,sans-serif;max-width:100%;overflow-wrap:anywhere}
  #shift-report-print h2,#shift-report-print p {text-align:center}
  #shift-report-print .shift-fields {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:4pt 8pt;break-inside:avoid}
  #shift-report-print .shift-fields dd {margin:0;text-align:end;unicode-bidi:plaintext;overflow-wrap:anywhere}
}

/* Customer Chats: use remaining space after the actual visible headers and notices. */
.side-nav {display:flex;flex-direction:column;gap:6px;min-height:0;overflow:auto;flex:1}
.side-nav .nav {flex-shrink:0}
.side-foot,.side .brand {flex-shrink:0}
body[data-view="whatsapp"] .shell {height:100dvh;min-height:0;grid-template-rows:minmax(0,1fr)}
body[data-view="whatsapp"] main {display:flex;flex-direction:column;min-height:0;overflow:hidden;padding-bottom:max(10px,env(safe-area-inset-bottom));gap:8px}
body[data-view="whatsapp"] main > :not(#view-whatsapp) {flex-shrink:0}
#view-whatsapp:not(.hidden) {display:flex;flex-direction:column;flex:1;min-height:0;gap:6px}
#wa-host-status {margin:0;overflow-wrap:anywhere}
#wa-host-status:empty {display:none}
.wa-layout {flex:1;min-height:0;min-width:0}
.wa-conversation {min-height:0;min-width:0;overflow:hidden}
.wa-chat strong,#wa-current {min-width:0;overflow-wrap:anywhere}
#wa-form {margin:0;min-width:0;flex-shrink:0}
#wa-input {min-width:0}
#wa-back {display:none}
.source-chart {display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.source-chart svg {width:112px;max-width:100%;flex:none;transform:rotate(-90deg)}
.source-arc {fill:none;stroke-width:13}
.source-arc.c-pos {stroke:var(--warning-fill);fill:none}
.source-legend .c-pos {background:var(--warning-fill)}
.source-arc.c-wa {stroke:var(--success-fill);fill:none}
.source-arc.c-on {stroke:var(--purple);fill:none}
.source-arc.c-other {stroke:var(--text-muted)}
.c-other {background:var(--text-muted)}
.source-total {transform:rotate(90deg);transform-origin:center;fill:var(--text);font-weight:700;font-size:14px}
.source-legend {flex:1;min-width:150px}
.source-card p {margin:4px 0 8px}
.business-headline {grid-template-columns:repeat(auto-fit,minmax(min(140px,100%),1fr))}
@media(max-width:820px){
 .side-nav {flex-direction:row;overflow:visible;flex:none}
 body[data-view="whatsapp"] .shell {grid-template-rows:auto minmax(0,1fr)}
 body[data-view="whatsapp"] main {padding:8px 10px max(8px,env(safe-area-inset-bottom))}
}
@media(max-width:600px){
 .wa-layout {grid-template-columns:minmax(0,1fr)}
 #view-whatsapp:not(.wa-thread-open) .wa-conversation {display:none}
 #view-whatsapp.wa-thread-open .wa-list {display:none}
 #wa-back {display:inline-flex}
}
@media(max-height:380px){body[data-view="whatsapp"] main {overflow:auto} #view-whatsapp:not(.hidden){min-height:210px}}
/* Compact short mobile windows without hiding status or the reply action. */
@media(max-width:600px) and (max-height:600px){
 body[data-view="whatsapp"] main {gap:4px;padding-block:4px}
 body[data-view="whatsapp"] .top {gap:4px;flex-wrap:nowrap}
 body[data-view="whatsapp"] .top h1 {font-size:18px;white-space:nowrap}
 body[data-view="whatsapp"] .top-actions {width:auto;min-width:0;justify-content:flex-end}
 body[data-view="whatsapp"] #system-notice-banner {padding:6px;gap:4px;flex-wrap:nowrap;max-height:90px;overflow:auto}
 body[data-view="whatsapp"] #system-notice-ack {width:auto;flex:none}
 #view-whatsapp:not(.hidden) {gap:4px}
 .chats-toolbar {gap:4px;flex-wrap:nowrap;overflow-x:auto}
 .chats-toolbar button {white-space:nowrap;flex:none;min-height:34px;font-size:12px;padding:4px 8px}
 .wa-toolbar {gap:4px;flex-wrap:nowrap;overflow:auto}
 .wa-toolbar > button {min-height:34px;flex:none;padding:4px 8px}
 #wa-current {white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:40px}
 #wa-state {font-size:11px;max-width:85px}
 .wa-conversation {gap:4px}
}

.chats-toolbar {justify-content:space-between;align-items:center;gap:8px;flex-shrink:0}
.chats-filters,.chats-settings {flex-wrap:nowrap;gap:4px;flex-shrink:0}
.chats-toolbar button[aria-pressed="true"] {background:var(--brand-soft);border-color:var(--brand-text);color:var(--brand-text)}
.chats-toolbar {overflow-x:auto}
#chats-webchat-slot {grid-template-rows:auto minmax(0,1fr)}
#chats-webchat-slot[hidden],.wa-website-open .wa-layout > .wa-conversation:not(#chats-webchat-slot) {display:none}
#chats-webchat-slot #webchat-handoff {min-height:0;overflow:hidden;display:flex;flex-direction:column;gap:4px;padding:8px}
#chats-webchat-slot #webchat-handoff[hidden] {display:none}
#chats-webchat-slot #webchat-handoff-thread:not([hidden]) {display:flex;flex-direction:column;flex:1;min-height:0;gap:4px}
#chats-webchat-slot #webchat-handoff-history {flex:1;min-height:0;overflow:auto;overflow-wrap:anywhere}
#chats-webchat-slot #webchat-handoff-form {margin:0;flex-shrink:0}
#chats-webchat-slot #webchat-handoff-text {min-width:0}
#website-chat-back {display:none}
@media(max-width:600px){#website-chat-back {display:inline-flex;justify-self:start}}

#team-webchat-slot {display:contents}
#chats-webchat-slot #webchat-handoff {grid-row:2}
#chats-webchat-slot #webchat-handoff > summary {display:none}
/* Chromium's details content wrapper is a flex item, not the thread itself. */
#chats-webchat-slot #webchat-handoff::details-content {display:flex;flex:1;min-height:0;flex-direction:column;gap:4px;overflow:hidden}

/* Round 5: a single living media host follows geometry-only slots, including the tour cursor. */
.dock-face-slot { display:block; position:absolute; inset:0; pointer-events:none; }
#living-layla { position:fixed; top:0; left:0; width:192px; height:192px; transform-origin:top left; pointer-events:none; z-index:51; visibility:hidden; }
#living-layla.tour-face { z-index:2147483003; }
#living-layla > img, #living-layla > .qclip { width:100%; height:100%; }
#living-layla > img { filter:drop-shadow(0 2px 4px var(--overlay)); }
#living-layla > img[hidden] { display:none; }
:root[data-skin="dark"] #living-layla > img { filter:drop-shadow(0 0 1.5px #ffffffb0) drop-shadow(0 2px 4px var(--overlay)); }
/* Keep the chip above the idle face; its own pivot is its center, as in FD. */
:root[data-avatar="v2"] .foot-row > .pop-wrap { z-index:52; }
.side-layla .lb-badge, .side-layla .lb-typing { z-index:53; }
.help-btn { transform-origin:50% 50%; transition:transform 200ms ease; }
.help-search-label { display:block; font-size:13px; margin-block:8px 4px; }
#help-search { width:100%; margin-block-end:8px; }
.help-topic { white-space:normal; text-align:start; }
.help-pop.up { width:min(340px,calc(100vw - 32px)); }
@media(prefers-reduced-motion:reduce) { .help-btn,.side-layla { transition:none; } .help-btn:hover,.side-layla:hover { transform:none; } }
#living-layla.dock-face { z-index:41; }
#help-pop { z-index:60; }

.wa-delivery-review {max-width:85%;margin-inline-start:auto;margin-bottom:8px;padding:10px;overflow-wrap:anywhere;}
.wa-review-actions {flex-wrap:wrap;gap:6px;margin-top:8px;}

/* Round 7: workspace adapters, not a second skin system. */
.first-steps {grid-column:1 / -1;margin:0 0 8px;}
.fs-next {display:flex;align-items:center;justify-content:space-between;gap:8px;margin-block:8px;flex-wrap:wrap;}
.first-steps summary,#wa-advanced summary,#counter-extras summary {cursor:pointer;color:var(--link);font-weight:700;padding-block:8px;}
#wa-advanced[open],#counter-extras[open] {display:grid;gap:8px;}
.wa-settings-actions {position:sticky;bottom:0;background:var(--surface);padding-block:8px;z-index:1;}
#wa-settings-dialog form {min-width:0;}
.wa-chat .ui-pill {justify-self:start;white-space:normal;}
#wa-host-status .q-connection-state {display:flex;align-items:center;flex-wrap:wrap;gap:6px 10px;}
#help-list.q-assistant-results {display:grid;grid-template-columns:minmax(0,1fr);}
#help-list .pop-item {width:100%;}
.q-phone-more {border:0;background:transparent;color:var(--on-header);border-radius:var(--r-md);font:700 14px var(--font);padding:6px;cursor:pointer;}
@media(max-width:820px){
 .side:has(.q-phone-nav) {overflow:visible;padding:6px 8px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px;}
 .side:has(.q-phone-nav) .brand {display:none;}
 .side-nav.q-phone-nav {display:flex;flex:1;min-width:0;align-items:center;gap:2px;}
 .side-nav.q-phone-nav > .nav {white-space:normal;min-width:0;padding:6px;font-size:13px;overflow-wrap:anywhere;}
 .side-nav.q-phone-nav > .q-phone-more {flex:1;min-width:0;max-width:100%;font-size:12px;}
 .side .side-foot,:root[data-avatar="v2"] .side .side-foot {position:static;inset:auto;margin:0;padding:0;height:auto;box-shadow:none;}
 .side-foot .foot-row {gap:2px;}
 .side .help-btn {width:34px;height:34px;}
 .side .side-layla,:root[data-avatar="v2"] .side .side-layla {width:46px;height:46px;}
 .side-nav .q-phone-destinations .nav {width:100%;}
 .side-nav .badge {font-size:0;}
 .side-nav .badge.at {font-size:12px;}
 #item-rows {--cols: minmax(0,1fr) minmax(0,1fr) 20px;}
 #item-rows .xhead {grid-template-columns:var(--cols);gap:6px 10px;}
 #item-rows .xhead > .c-main {grid-column:1 / 3;}
 #item-rows .xhead > span:nth-child(4),#item-rows .xhead > span:nth-child(6) {display:block;}
 #item-rows .xhead > span:nth-child(5) {display:none;}
 #item-rows .xhead > .chev {grid-column:3;grid-row:1;}
 #item-rows [data-item-label] {text-align:start;white-space:normal;overflow-wrap:anywhere;}
 #item-rows [data-item-label]::before {content:attr(data-item-label);display:block;font-size:11px;font-weight:400;color:var(--text-muted);}
}
@media(max-width:650px){
 #view-whatsapp:not(.wa-thread-open) .wa-conversation {display:none;}
 #view-whatsapp.wa-thread-open .wa-list {display:none;}
 #wa-back,#website-chat-back {display:inline-flex;}
 #view-whatsapp.q-thread-selected .wa-layout {grid-template-columns:minmax(0,1fr);}
 #view-whatsapp.q-thread-selected .wa-conversation:not([hidden]) {gap:4px;}
 #view-whatsapp.q-thread-selected.wa-website-open .wa-layout > .wa-conversation:not(#chats-webchat-slot) {display:none;}
 .chats-toolbar {flex-wrap:wrap;overflow:visible;}
 .chats-filters,.chats-settings {flex-wrap:wrap;flex-shrink:1;}
 .chats-toolbar .ui-btn {min-height:34px;padding:5px 8px;}
 #website-chat-state {overflow-wrap:anywhere;}
}

#wa-allowed-fields {display:grid;gap:8px;}
#wa-allowed-fields textarea,#wa-advanced input,#counter-extras input {width:100%;}
@media(max-width:820px){
 #item-rows .xhead > span:nth-child(2){grid-column:1;grid-row:2;}
 #item-rows .xhead > span:nth-child(3){grid-column:2;grid-row:2;}
 #item-rows .xhead > span:nth-child(4){grid-column:2;grid-row:3;}
 #item-rows .xhead > span:nth-child(6){grid-column:1;grid-row:3;}
}
@media(max-width:650px){
 #view-whatsapp.q-thread-selected #chats-webchat-slot #webchat-handoff {flex:1;}
 #view-whatsapp.q-thread-selected .wa-toolbar {flex-wrap:wrap;overflow:visible;}
 #view-whatsapp.q-thread-selected #wa-state {max-width:none;white-space:normal;}
 #view-whatsapp.q-thread-selected #wa-current {flex:1 1 80px;}
 .dash-widget[data-widget-id="headline"] .business-headline {grid-template-columns:repeat(2,minmax(0,1fr));}
 .business-headline .kpi {padding:10px;min-width:0;overflow-wrap:anywhere;}
 .business-headline .kpi strong {font-size:clamp(17px,var(--dash-num),24px);}
}

#counter-customer-details summary {cursor:pointer;color:var(--link);font-weight:700;padding-block:8px;}
#counter-customer-details[open] {display:grid;gap:8px;}
#counter-customer-details input {width:100%;}

/* Remote entry and offline state must not expose local UI. */
.remote-erp-entry:not(.remote-erp-ready) > :not(.remote-screen):not(script) { display: none !important; }
.remote-erp-entry .layla-fab, .remote-erp-entry [data-empty="import"] { display: none !important; }
.remote-report-table {overflow-x:auto;max-width:100%;margin-block:1rem;}
.remote-report-table table {border-collapse:collapse;min-width:100%;}
.remote-report-table th,.remote-report-table td {text-align:start;padding:.65rem;border-bottom:1px solid var(--line);white-space:nowrap;}
.remote-erp-entry #view-suppliers .field,.remote-erp-entry #view-purchases .field {display:grid;gap:.25rem;min-width:12rem;margin-block:.5rem;}
.remote-erp-entry #view-purchases fieldset {margin-block:.75rem;min-width:0;}

/* Local previews use the existing sidebar and Q-kit controls. */
#local-feature-menu{display:flex;flex-direction:column;gap:6px;flex-shrink:0} #local-feature-menu .nav{width:100%;text-align:start}

/* Account menu: use Q-kit surfaces, spacing, pill controls and focus treatment. */
.me-pop { width: 310px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 88px); overflow: auto; padding: var(--sp-3); gap: var(--sp-1); }
.me-pop .me-head { gap: var(--sp-1); padding: var(--sp-3); overflow-wrap: anywhere; }
.me-pop #me-full { font-size: var(--fs-lg); }
.me-pop #me-pharmacy { font-weight: 600; }
.me-pop .server-line { margin-block-start: var(--sp-1); }
.me-pop .pop-item { min-height: var(--tap); text-decoration: none; font-family: inherit; }
.me-pop .menu-settings { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--line); }
.me-pop .menu-settings:hover { background: var(--surface-3); }
.me-pop .menu-switch { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.menu-switch-label { display: grid; gap: var(--sp-1); }
.me-pop .menu-switch input { appearance: none; display: block; flex: 0 0 42px; width: 42px; height: 24px; margin: 0; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface-3); position: relative; cursor: pointer; }
.me-pop .menu-switch input::before { content: ''; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: var(--r-pill); background: var(--text-muted); }
.me-pop .menu-switch input:checked { background: var(--brand); border-color: var(--brand); }
.me-pop .menu-switch input:checked::before { inset-inline-start: 21px; background: var(--on-brand); }
.me-pop .menu-control { padding-block: var(--sp-2); }
.me-pop .ui-skin-switch { display: flex; flex-wrap: wrap; }
.me-pop .ui-skin-switch button { flex: 1 1 auto; min-height: 36px; }
.me-pop #logout { margin-block-start: var(--sp-1); border-block-start: 1px solid var(--line); }
@media (max-width: 820px) { .me-pop { width: auto; max-width: none; } }

/* The living avatar and its chat never cover an open application form. */
body:has(dialog[open]) #living-layla, body:has(dialog[open]) .layla-fab { opacity:0; pointer-events:none; }

#invoice-scans-dialog {width:min(860px,92vw);max-height:85vh;overflow:auto;}
.invoice-scan-entry {padding:1rem;border-bottom:1px solid var(--border, #8885);display:grid;gap:.4rem;}
.invoice-scan-entry p {margin:0;}
.invoice-scan-entry button {justify-self:start;}
