/* =====================================================================================================================
   YUDEER «مسار» — COMPONENTS for the real product's vanilla interface (TASK-007 «MASAR M0/M1», agent A).
   Ported from the approved prototype (MASAR.UX.1 identity/masar-components.css); each block names its source in the live
   Masar section (pm-app/src/ui/css/*.css) or the approval version. «مقترح» = not in the sources (kept from the prototype).
   Load after masar-tokens.css; masar/masar-ui.js (window.MasarUI) builds money, icons, errors, toasts and dialogs.

   SCOPING (binding):
   - Every selector starts with html[data-masar="on"]: with the switch off nothing here matches anything.
   - Every rule is inside @media screen: print is never affected.
   - Only m-* classes and [data-m-*] markers are styled. Legacy markup carries neither, so legacy screens look exactly as
     before until a later batch (M2+) adopts a component. Element defaults (h1, a, p, focus ring …) apply only inside an
     element marked .m-scope (a region built with Masar) or <body class="m-body"> (a whole Masar page, e.g. the gallery).
   - No @font-face (fonts come from pm/pm-fonts.css). No copied asset: the logo uses ../assets/brand/*.png of the product.
   - Layout hooks a host may set (defaults 0px, so nothing bleeds or hides behind fixed chrome it does not know about):
       --m-chrome-top     height of a sticky/fixed top bar above the page (toast region on wide screens)
       --m-chrome-bottom  height of a fixed bottom bar on phones (toast region, sticky page confirm bar)
       --m-chrome-start   width of a side rail on the start side (toast region on wide screens)
       --m-page-pad       the page column's inline padding on phones (the page confirm bar bleeds to the edges by it)

   DROPPED from the prototype (and why):
   - m-demo-tag, m-demo-strip — prototype marker of synthetic data (the gallery styles its own «بيانات تجريبية» note).
   - m-shell, m-rail, m-rail__nav, m-brand, m-navlink, m-shell__col, m-topbar, m-status, m-main, m-bottomnav — the
     prototype's app shell. The product keeps its own shell markup; agent B restyles it (masar-shell.css).
   - .m-main-scoped phone link targets now hang off .m-scope / .m-body / .m-dialog; keyframes renamed masar-rise/-fade.

   CLASS INDEX (B = block, __ = part, -- = variant; state is carried by ARIA attributes, not by classes)
   Scope ....... m-scope (a Masar region: type, links, focus ring) · m-body (the same for a whole <body>)
   Base ........ m-skip · m-sr-only · m-nw · m-num · m-muted · m-prose · m-stack · m-cluster · m-grid-2
   Brand ....... m-logo(--horizontal|--icon) (the product's own PNGs, cropped; never recolored)
   Page ........ m-page · m-page-head(__row|__sub) · m-back · m-crumbs · m-ledge(--sm) · m-rule
                 m-section(__head|__title|__count) · m-fold(__summary)
   Buttons ..... m-btn(--primary|--outline|--quiet|--danger|--link|--sm|--wide) [disabled|aria-disabled|aria-busy]
                 m-why (the written reason beside a disabled button) · m-actions(--stack|--end)
   Fields ...... m-fields · m-fields-row · m-field(--error) · m-field__label(--strong) · m-field__opt · m-field__req
                 m-field__hint · m-field__note · m-field__msg · m-input(--money|--num) [aria-invalid] · m-fieldset
                 m-riyal-unit (the currency in a label)
   Choices ..... m-choice(--grid|--col) · m-choice__btn [aria-pressed] · m-choice__card (native radio/checkbox)
                 m-chips · m-chip [aria-pressed] · m-seg(__item|__count) [aria-current|aria-pressed|aria-selected] · m-ack
   Surfaces .... m-card(__head|__title) · m-doc(__head|__title|__meta)
   Key–value ... m-facts · m-receipt(__missing) · m-figures(__net) · m-pairs · m-pair(__label)
   Table ....... m-table(--stack) · m-table__num · m-table__nil · m-table-wrap   (MasarUI.stackTable / [data-m-stack])
   Status ...... m-tag(--ok|--warn|--due|--info|--neutral|--action)
   Money ....... m-money(--sm|--md|--lg|--xl|--inline|--neg|--in|--out|--invalid) [data-money-state=valid|invalid]
                 m-money__num · m-money__words · m-money__mark + m-money__invalid (invalid) · m-riyal · m-riyal-unit
   Notices ..... m-note(--info|--warn|--due|--ok|--neutral; aliases --warning --error --success) · m-note__title
   Toast ....... m-toast-region · m-toast(--due|--static) · m-toast__mark · m-toast__line · m-toast__actions
                 live region: <div class="m-sr-only" aria-live="polite" data-m-live> (MasarUI.announce)
   Layers ...... m-layer(--sheet|--panel) · m-dialog(__head|__sub|__body) · m-confirm-bar(--page|__note|__label)
   Empty/load .. m-empty(__text) · m-loading · m-skel(--line|--title|--block)
   Steps ....... m-steps · m-steps__item(--done|--current) · m-steps__bar · m-steps__word
   Work list ... m-tasks · m-task · m-task__index(--due|--warn|--info|--ok) · m-task__plate · m-task__body
                 m-task__who · m-task__context · m-task__settle · m-task__fact · m-cells · m-cell(--hi|--step|--ok|--warn|--due)
   Icons ....... m-icon(--16|--20|--24|--flip) — drawn by MasarUI.icon(name) or <svg data-m-icon="name">
   ===================================================================================================================== */

/* ============================== Motion keyframes (source base.css y-rise / y-fade) ============================== */
@media screen {
  @keyframes masar-rise { from { opacity: 0; transform: translateY(0.375rem); } }
  @keyframes masar-fade { from { opacity: 0; } }
}

/* ============================== Scope and base (source base.css) ============================== */
@media screen {
  html[data-masar="on"] [class^="m-"],
  html[data-masar="on"] [class*=" m-"],
  html[data-masar="on"] [class^="m-"]::before,
  html[data-masar="on"] [class*=" m-"]::before,
  html[data-masar="on"] [class^="m-"]::after,
  html[data-masar="on"] [class*=" m-"]::after,
  html[data-masar="on"] .m-scope *,
  html[data-masar="on"] .m-scope *::before,
  html[data-masar="on"] .m-scope *::after,
  html[data-masar="on"] .m-body *,
  html[data-masar="on"] .m-body *::before,
  html[data-masar="on"] .m-body *::after { box-sizing: border-box; }

  html[data-masar="on"] .m-scope,
  html[data-masar="on"] .m-body {
    color-scheme: light;
    color: var(--y-c-text); font-family: var(--y-font-ui); font-size: var(--y-fs-base); line-height: var(--y-lh-body); font-weight: var(--y-fw-regular);
    -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
  }
  html[data-masar="on"] body.m-body { margin: 0; min-height: 100vh; background: var(--y-c-canvas); }

  html[data-masar="on"] :where(.m-scope, .m-body) h1,
  html[data-masar="on"] :where(.m-scope, .m-body) h2,
  html[data-masar="on"] :where(.m-scope, .m-body) h3 { margin: 0; color: var(--y-c-text); text-wrap: balance; }
  /* Alexandria is the page title's face alone (OD-PM-018 §2); a section title is the UI face one weight up. */
  html[data-masar="on"] :where(.m-scope, .m-body) h1 { font-family: var(--y-font-display); font-size: var(--y-fs-xl); font-weight: var(--y-fw-semibold); line-height: var(--y-lh-tight); }
  html[data-masar="on"] :where(.m-scope, .m-body) h2 { font-family: var(--y-font-ui); font-size: var(--y-fs-lg); font-weight: var(--y-fw-bold); line-height: var(--y-lh-snug); }
  html[data-masar="on"] :where(.m-scope, .m-body) h3 { font-size: var(--y-fs-base); font-weight: var(--y-fw-semibold); line-height: var(--y-lh-snug); }
  html[data-masar="on"] :where(.m-scope, .m-body) p { margin: 0; }
  html[data-masar="on"] :where(.m-scope, .m-body) strong,
  html[data-masar="on"] :where(.m-scope, .m-body) b { font-weight: var(--y-fw-semibold); }
  html[data-masar="on"] :where(.m-scope, .m-body) a { color: var(--y-c-action); text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
  html[data-masar="on"] :where(.m-scope, .m-body) a:hover { text-decoration-thickness: 2px; }
  html[data-masar="on"] :where(.m-scope, .m-body) ::selection { background: var(--y-c-action-wash-2); color: var(--y-c-text); }
  /* One focus look everywhere: a 2px ring in the action color with a 2px gap (≥ 10.09 on every surface). */
  html[data-masar="on"] :where(.m-scope, .m-body) :focus-visible { outline: var(--y-bw-focus) solid var(--y-c-focus); outline-offset: 2px; }
  html[data-masar="on"] :where(.m-scope, .m-body) :focus:not(:focus-visible) { outline: none; }
  /* The same ring on Masar components used outside a scope (zero added specificity: a component's own rule still wins). */
  html[data-masar="on"] :where(.m-btn, .m-chip, .m-choice__btn, .m-seg__item, .m-back, .m-crumbs a, .m-fold__summary, .m-ack input,
    .m-skip, .m-toast, .m-task__who a, .m-note a, .m-dialog a):focus-visible { outline: var(--y-bw-focus) solid var(--y-c-focus); outline-offset: 2px; }
  /* Long references, IBANs and phone numbers may break; Arabic words never do. */
  html[data-masar="on"] :where(.m-scope, .m-body) [dir='ltr'] { overflow-wrap: anywhere; }

  html[data-masar="on"] .m-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  /* «مقترح»: «انتقل إلى المحتوى» — off screen until focused. */
  html[data-masar="on"] .m-skip { position: absolute; inset-inline-start: var(--y-sp-2); top: -10rem; z-index: 100; padding: 0.5rem 1rem; background: var(--y-c-surface); color: var(--y-c-action); border: var(--y-bw-focus) solid var(--y-c-action); border-radius: var(--y-r-md); font-family: var(--y-font-ui); font-weight: var(--y-fw-semibold); text-decoration: none; }
  html[data-masar="on"] .m-skip:focus { top: var(--y-sp-2); }
  html[data-masar="on"] .m-nw { white-space: nowrap; }
  html[data-masar="on"] .m-num { font-variant-numeric: var(--y-num); }
  html[data-masar="on"] .m-muted { color: var(--y-c-text-3); font-size: var(--y-fs-sm); }
  html[data-masar="on"] .m-prose { max-width: var(--y-prose); }
  html[data-masar="on"] .m-stack { display: grid; gap: var(--y-sp-4); }
  html[data-masar="on"] .m-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--y-sp-2) var(--y-sp-3); }
  html[data-masar="on"] .m-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: var(--y-sp-4); }
}
@media screen and (min-width: 47.5em) { html[data-masar="on"] :where(.m-scope, .m-body) h1 { font-size: var(--y-fs-2xl); } }
@media screen and (max-width: 22.49em) { html[data-masar="on"] :where(.m-scope, .m-body) h1 { font-size: 1.25rem; } }

/* ============================== Icons (source icons.css, Icon.tsx) ==============================
   Lucide geometry on a 24 grid, stroke 1.75, square ends, round joins. Sizes 16 / 20 / 24 only. Decorative by default
   (aria-hidden): the word beside it carries the meaning. A glyph that runs along the reading line is mirrored in RTL. */
@media screen {
  html[data-masar="on"] .m-icon { width: 1.25em; height: 1.25em; flex: none; display: inline-block; vertical-align: -0.25em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: square; stroke-linejoin: round; }
  html[data-masar="on"] .m-icon--16 { width: 1rem; height: 1rem; }
  html[data-masar="on"] .m-icon--20 { width: 1.25rem; height: 1.25rem; }
  html[data-masar="on"] .m-icon--24 { width: 1.5rem; height: 1.5rem; }
  html[data-masar="on"] [dir='rtl'] .m-icon--flip { transform: scaleX(-1); }
}

/* ============================== Logo (source brand.tsx Logo, shell.css) ==============================
   Cropped by CSS from the product's own 2000×2000 brand PNGs (artwork boxes measured from the files: horizontal
   1574×364 at 213,818; icon 824×592 at 588,704). Drawn as given: never recolored, filtered or stretched.
   <span class="m-logo m-logo--icon" role="img" aria-label="يدير"></span> — set its height with --h. */
@media screen {
  html[data-masar="on"] .m-logo { --h: 1.75rem; display: inline-block; flex: none; height: var(--h); background-repeat: no-repeat; }
  html[data-masar="on"] .m-logo--horizontal { width: calc(var(--h) * 1574 / 364); background-image: url('../assets/brand/yudeer-logo-horizontal-primary.png'); background-size: calc(var(--h) * 2000 / 364) auto; background-position: calc(var(--h) * -213 / 364) calc(var(--h) * -818 / 364); }
  html[data-masar="on"] .m-logo--icon { width: calc(var(--h) * 824 / 592); background-image: url('../assets/brand/yudeer-icon-primary.png'); background-size: calc(var(--h) * 2000 / 592) auto; background-position: calc(var(--h) * -588 / 592) calc(var(--h) * -704 / 592); }
}

/* ============================== Page (source layout.css: .page-head, .crumbs, .fold) ============================== */
@media screen {
  html[data-masar="on"] .m-page { display: grid; gap: var(--y-sp-2); }
  html[data-masar="on"] .m-page-head { display: grid; gap: 0.25rem; }
  html[data-masar="on"] .m-page-head__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--y-sp-2) var(--y-sp-4); }
  html[data-masar="on"] .m-page-head__sub { margin: 0; font-size: var(--y-fs-md); color: var(--y-c-text-2); line-height: var(--y-lh-snug); }
  html[data-masar="on"] .m-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.25rem; margin: 0; font-size: var(--y-fs-sm); color: var(--y-c-text-3); }
  html[data-masar="on"] .m-crumbs a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--y-tap); min-width: var(--y-tap); padding-inline: 0.125rem; color: var(--y-c-text-2); font-weight: var(--y-fw-medium); }
  html[data-masar="on"] .m-crumbs a:hover { color: var(--y-c-action); }
  /* The back link: one place to go back to, named («رجوع إلى المهام»), the arrow pointing to the start side. «مقترح» */
  html[data-masar="on"] .m-back { display: inline-flex; align-items: center; gap: 0.375rem; width: fit-content; min-height: var(--y-tap); padding-inline: 0.125rem; color: var(--y-c-text-2); font-size: var(--y-fs-sm); font-weight: var(--y-fw-medium); text-decoration: none; }
  html[data-masar="on"] .m-back:hover { color: var(--y-c-action); text-decoration: underline; }
  html[data-masar="on"] .m-back .m-icon { width: 1rem; height: 1rem; }

  /* The ledge (الدرجة, source data.css .ledge): the logo's stroke at page scale — high under the start of the title, a 42°
     fall, then the lower level to the end. One per page, under the page title only. A picture: aria-hidden. */
  html[data-masar="on"] .m-ledge {
    --t: var(--y-ledge-t); --rise: var(--y-ledge-rise); --w: 3.25rem;
    --d: calc(var(--rise) * var(--y-run)); --k: calc(var(--t) * 0.384);
    display: block; width: 100%; min-width: 3rem; height: calc(var(--t) + var(--rise)); flex: none; pointer-events: none;
    background: linear-gradient(to left, var(--y-c-ledge) 0 calc(var(--w) + var(--d)), var(--y-c-pine-300) 0);
    clip-path: polygon(100% 0, calc(100% - var(--w)) 0, calc(100% - var(--w) - var(--d)) var(--rise), 0 var(--rise), 0 100%,
      calc(100% - var(--w) - var(--d) + var(--k)) 100%, calc(100% - var(--w) + var(--k)) var(--t), 100% var(--t));
  }
  html[data-masar="on"] .m-ledge--sm { --t: var(--y-ledge-t-sm); --rise: var(--y-ledge-rise-sm); --w: 2.25rem; background: linear-gradient(to left, var(--y-c-ledge) 0 calc(var(--w) + var(--d)), var(--y-c-pine-200) 0); }
  /* The quiet rule (source .rule): sections open on a 1px hairline in the space a section ledge took. */
  html[data-masar="on"] .m-rule { display: block; pointer-events: none; height: calc(var(--y-ledge-t-sm) + var(--y-ledge-rise-sm)); background: linear-gradient(var(--y-c-line), var(--y-c-line)) left center / 100% 1px no-repeat; }

  html[data-masar="on"] .m-section { display: grid; gap: var(--y-sp-2); }
  html[data-masar="on"] .m-section__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--y-sp-2); }
  html[data-masar="on"] .m-section__title { display: flex; align-items: center; gap: var(--y-sp-2); font-size: 1.0625rem; }
  html[data-masar="on"] .m-section__title > .m-icon { width: 1.25rem; height: 1.25rem; color: var(--y-c-text-2); }
  html[data-masar="on"] .m-section__count { font-size: var(--y-fs-md); font-weight: var(--y-fw-medium); color: var(--y-c-text-3); font-variant-numeric: var(--y-num); }

  /* Disclosure with a visible open/closed sign (source .fold). */
  html[data-masar="on"] .m-fold { border: var(--y-bw) solid var(--y-c-line); border-radius: var(--y-r-md); background: var(--y-c-surface); padding: 0 var(--y-sp-4); }
  html[data-masar="on"] .m-fold[open] { padding-bottom: var(--y-sp-3); }
  html[data-masar="on"] .m-fold__summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.375rem; min-height: var(--y-tap); font-weight: var(--y-fw-semibold); cursor: pointer; list-style: none; }
  html[data-masar="on"] .m-fold__summary::-webkit-details-marker { display: none; }
  html[data-masar="on"] .m-fold__summary::after {
    content: ''; width: 0.9375rem; height: 0.9375rem; margin-inline-start: 0.25rem; background: currentColor; transition: transform var(--y-dur-1) var(--y-ease);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  html[data-masar="on"] .m-fold[open] > .m-fold__summary::after { transform: rotate(180deg); }
}
@media screen and (min-width: 47.5em) {
  html[data-masar="on"] .m-page { gap: var(--y-sp-5); }
  html[data-masar="on"] .m-page-head { gap: var(--y-sp-2); }
  html[data-masar="on"] .m-page-head > .m-ledge,
  html[data-masar="on"] .m-page-head > .m-cells { margin-top: var(--y-sp-1); }
  html[data-masar="on"] .m-section__title { font-size: var(--y-fs-lg); }
}

/* ============================== Buttons (source controls.css .btn*) ==============================
   Solid #0F3C3D only for the one primary action of a place. Every button ≥ 44 px. Busy: the label says «جارٍ …», the
   button is disabled and aria-busy (MasarUI.busy). Disabled: a written reason (.m-why) beside it, tied by aria-describedby. */
@media screen {
  html[data-masar="on"] .m-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--y-sp-2);
    min-height: var(--y-tap); min-width: var(--y-tap); padding: 0.5rem 1rem; margin: 0; /* min-width «مقترح»: «لا» stays a 44 px target */
    border: var(--y-bw) solid var(--y-c-line-control); border-radius: var(--y-r-md);
    background: var(--y-c-surface); color: var(--y-c-text);
    font-family: var(--y-font-ui); font-size: var(--y-fs-md); font-weight: var(--y-fw-medium); line-height: 1.4;
    text-decoration: none; text-align: center; cursor: pointer;
    transition: background-color var(--y-dur-1) var(--y-ease), border-color var(--y-dur-1) var(--y-ease), color var(--y-dur-1) var(--y-ease), transform var(--y-dur-1) var(--y-ease);
  }
  html[data-masar="on"] .m-btn .m-icon { width: 1.25rem; height: 1.25rem; }
  html[data-masar="on"] .m-btn:hover:not(:disabled):not([aria-disabled='true']) { border-color: var(--y-c-action); background: var(--y-c-pine-50); }
  html[data-masar="on"] .m-btn:active:not(:disabled):not([aria-disabled='true']) { transform: translateY(1px); }
  html[data-masar="on"] .m-btn--primary {
    background: var(--y-c-action); border-color: var(--y-c-action); color: var(--y-c-text-on-action); font-weight: var(--y-fw-semibold);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08), 0 1px 2px rgb(15 60 61 / 0.25);
  }
  html[data-masar="on"] .m-btn--primary:hover:not(:disabled):not([aria-disabled='true']) { background: var(--y-c-action-hover); border-color: var(--y-c-action-hover); }
  html[data-masar="on"] .m-btn--primary:active:not(:disabled):not([aria-disabled='true']) { background: var(--y-c-action-press); }
  /* Two answers of equal weight: the same outline, neither looks like the default. */
  html[data-masar="on"] .m-btn--outline { border: var(--y-bw-strong) solid var(--y-c-action); color: var(--y-c-action); font-weight: var(--y-fw-semibold); }
  html[data-masar="on"] .m-btn--outline:hover:not(:disabled):not([aria-disabled='true']) { background: var(--y-c-action-wash); }
  html[data-masar="on"] .m-btn--quiet { border-color: transparent; background: transparent; color: var(--y-c-text-2); }
  html[data-masar="on"] .m-btn--quiet:hover:not(:disabled):not([aria-disabled='true']) { background: var(--y-c-surface-2); border-color: transparent; color: var(--y-c-text); }
  html[data-masar="on"] .m-btn--danger { background: var(--y-c-danger); border-color: var(--y-c-danger); color: #fff; font-weight: var(--y-fw-semibold); }
  html[data-masar="on"] .m-btn--danger:hover:not(:disabled):not([aria-disabled='true']) { background: var(--y-c-danger-hover); border-color: var(--y-c-danger-hover); }
  html[data-masar="on"] .m-btn--link {
    min-width: var(--y-tap); padding: 0 0.375rem; border: 0; background: none; color: var(--y-c-action); font-weight: var(--y-fw-medium);
    text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.22em; vertical-align: middle;
  }
  html[data-masar="on"] .m-btn--link:hover:not(:disabled):not([aria-disabled='true']) { background: none; text-decoration-thickness: 2px; }
  html[data-masar="on"] .m-btn--link .m-icon { width: 1rem; height: 1rem; }
  html[data-masar="on"] .m-btn--sm { font-size: var(--y-fs-sm); padding: 0.375rem 0.75rem; }
  html[data-masar="on"] .m-btn--sm .m-icon { width: 1rem; height: 1rem; }
  html[data-masar="on"] .m-btn--wide { width: 100%; }
  html[data-masar="on"] .m-btn:disabled,
  html[data-masar="on"] .m-btn[aria-disabled='true'] { background: var(--y-c-surface-2); border-color: var(--y-c-line); color: var(--y-c-text-disabled); box-shadow: none; cursor: not-allowed; }
  html[data-masar="on"] .m-btn--link:disabled,
  html[data-masar="on"] .m-btn--link[aria-disabled='true'] { background: none; }
  html[data-masar="on"] .m-btn[aria-busy='true'] { cursor: progress; }
  html[data-masar="on"] .m-why { margin: 0; font-size: var(--y-fs-sm); color: var(--y-c-text-2); line-height: var(--y-lh-snug); max-width: var(--y-prose); }
  html[data-masar="on"] .m-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--y-sp-2); }
  html[data-masar="on"] .m-actions--stack { flex-direction: column; align-items: stretch; }
  html[data-masar="on"] .m-actions--end { justify-content: flex-end; }
}

/* ============================== Fields (source controls.css .field*, .input; primitives.tsx Field) ==============================
   Label above, then the control, then the note (date or amount in words), the hint, the error. The control gets
   aria-describedby for each of them and aria-invalid when wrong (MasarUI.setFieldError). Optional fields say «(اختياري)». */
@media screen {
  html[data-masar="on"] .m-fields { display: grid; gap: var(--y-sp-4); }
  html[data-masar="on"] .m-fields-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(10.5rem, 100%), 1fr)); gap: var(--y-sp-3) var(--y-sp-4); }
  html[data-masar="on"] .m-field { display: grid; gap: 0.375rem; min-width: 0; align-content: start; }
  html[data-masar="on"] .m-field__label { font-size: var(--y-fs-sm); font-weight: var(--y-fw-medium); color: var(--y-c-text-2); line-height: var(--y-lh-snug); }
  html[data-masar="on"] .m-field__label--strong { font-size: var(--y-fs-md); font-weight: var(--y-fw-semibold); color: var(--y-c-text); } /* the form's first, main field (source .pay-form) */
  html[data-masar="on"] .m-field__opt { font-weight: var(--y-fw-regular); color: var(--y-c-text-3); }
  html[data-masar="on"] .m-field__req { font-weight: var(--y-fw-regular); color: var(--y-c-text-3); } /* «مقترح» — the sources mark optional fields, not required ones */
  html[data-masar="on"] .m-field__hint { font-size: var(--y-fs-sm); color: var(--y-c-text-3); line-height: var(--y-lh-snug); max-width: var(--y-prose); }
  html[data-masar="on"] .m-field__note { font-size: var(--y-fs-sm); color: var(--y-c-text-2); line-height: var(--y-lh-snug); font-variant-numeric: var(--y-num); }
  html[data-masar="on"] .m-field__msg { display: flex; gap: var(--y-sp-1); align-items: baseline; margin: 0; font-size: var(--y-fs-sm); font-weight: var(--y-fw-medium); color: var(--y-c-due); line-height: var(--y-lh-snug); }
  html[data-masar="on"] .m-field__msg::before { content: ''; flex: none; width: 0.5rem; height: 0.5rem; background: var(--y-c-due-mark); clip-path: polygon(40% 0, 100% 0, 60% 100%, 0 100%); transform: translateY(-0.0625rem); }
  html[data-masar="on"] .m-field__msg[hidden] { display: none; }
  html[data-masar="on"] .m-input {
    width: 100%; min-height: var(--y-field); padding: 0 0.875rem; margin: 0;
    border: var(--y-bw) solid var(--y-c-line-control); border-radius: var(--y-r-md);
    background: var(--y-c-surface); color: var(--y-c-text); font-family: var(--y-font-ui); font-size: var(--y-fs-base); line-height: normal;
    transition: border-color var(--y-dur-1) var(--y-ease), box-shadow var(--y-dur-1) var(--y-ease);
  }
  html[data-masar="on"] .m-input:hover { border-color: var(--y-c-text-3); }
  html[data-masar="on"] .m-input:focus-visible,
  html[data-masar="on"] .m-input:focus { outline: var(--y-bw-focus) solid var(--y-c-focus); outline-offset: 1px; border-color: var(--y-c-action); }
  html[data-masar="on"] .m-input::placeholder { color: var(--y-c-text-3); opacity: 1; }
  html[data-masar="on"] .m-input:disabled,
  html[data-masar="on"] .m-input[readonly] { background: var(--y-c-surface-2); color: var(--y-c-text-disabled); }
  html[data-masar="on"] .m-input[readonly] { color: var(--y-c-text-2); }
  html[data-masar="on"] textarea.m-input { min-height: 6rem; padding-block: 0.625rem; line-height: var(--y-lh-snug); resize: vertical; } /* «مقترح»: the sources have no textarea */
  html[data-masar="on"] select.m-input {
    appearance: none; padding-inline-end: 2.5rem; cursor: pointer;
    background: var(--y-c-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475754' stroke-width='1.75' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat left 0.875rem center / 1.125rem;
  }
  html[data-masar="on"] .m-field--error .m-input,
  html[data-masar="on"] .m-input[aria-invalid='true'] { border: var(--y-bw-strong) solid var(--y-c-due); }
  /* Money input (source .input-money): the receipt's figure — big lining tabular numerals. The currency is in the label
     (m-riyal-unit), read «ريال سعودي»; the amount read back as money is the field's note (data-m-amount-note). */
  html[data-masar="on"] .m-input--money { min-height: 3.5rem; font-size: 1.625rem; font-weight: var(--y-fw-semibold); font-variant-numeric: var(--y-num); text-align: right; }
  html[data-masar="on"] .m-input--num { font-variant-numeric: var(--y-num); text-align: right; max-width: 14rem; }
  /* Native date field in Arabic RTL (source base.css, QA-ID1-06): each part resolves its own direction, so the empty
     placeholders read «يوم/شهر/سنة» from the right and a filled value reads «28/10/2026». The native field stays. */
  html[data-masar="on"] input.m-input[type='date'] { direction: rtl; text-align: right; }
  html[data-masar="on"] input.m-input[type='date']::-webkit-datetime-edit,
  html[data-masar="on"] input.m-input[type='date']::-webkit-datetime-edit-fields-wrapper { direction: rtl !important; }
  html[data-masar="on"] input.m-input[type='date']::-webkit-datetime-edit-day-field,
  html[data-masar="on"] input.m-input[type='date']::-webkit-datetime-edit-month-field,
  html[data-masar="on"] input.m-input[type='date']::-webkit-datetime-edit-year-field,
  html[data-masar="on"] input.m-input[type='date']::-webkit-datetime-edit-text { unicode-bidi: plaintext !important; }
  /* A group of fields under one legend (source .field-set): no box, a quiet rule. */
  html[data-masar="on"] .m-fieldset { display: grid; gap: var(--y-sp-3); min-width: 0; margin: 0; padding: var(--y-sp-3) 0 0; border: 0; border-top: var(--y-bw) solid var(--y-c-line); }
  html[data-masar="on"] .m-fieldset > legend { float: left; width: 100%; padding: 0; margin-bottom: var(--y-sp-1); font-weight: var(--y-fw-semibold); color: var(--y-c-text); }
  html[data-masar="on"] .m-fieldset > legend + * { clear: both; }
}

/* ============================== Choices (source controls.css .choice*, .chip, .seg, .ack) ============================== */
@media screen {
  html[data-masar="on"] .m-choice { display: flex; flex-wrap: wrap; gap: var(--y-sp-2); }
  html[data-masar="on"] .m-choice--col { flex-direction: column; }
  html[data-masar="on"] .m-choice--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(8.5rem, 100%), 1fr)); }
  html[data-masar="on"] .m-choice--grid > * { width: 100%; }
  html[data-masar="on"] .m-choice__btn,
  html[data-masar="on"] .m-choice__card,
  html[data-masar="on"] .m-chip {
    position: relative; display: inline-flex; align-items: center; gap: var(--y-sp-2);
    min-height: var(--y-tap); padding: 0.375rem 0.875rem; margin: 0;
    border: var(--y-bw) solid var(--y-c-line-control); border-radius: var(--y-r-md);
    background: var(--y-c-surface); color: var(--y-c-text); font-family: var(--y-font-ui); font-size: var(--y-fs-md); line-height: 1.4;
    cursor: pointer; text-align: start;
    transition: background-color var(--y-dur-1) var(--y-ease), border-color var(--y-dur-1) var(--y-ease), color var(--y-dur-1) var(--y-ease);
  }
  html[data-masar="on"] .m-choice__btn .m-icon,
  html[data-masar="on"] .m-choice__card .m-icon { width: 1.25rem; height: 1.25rem; color: var(--y-c-text-2); }
  html[data-masar="on"] .m-choice__btn:hover:not(:disabled),
  html[data-masar="on"] .m-choice__card:hover:not(:has(input:disabled)) { border-color: var(--y-c-action); background: var(--y-c-pine-50); }
  /* Selected: action edge, wash, action ink and a check — never color alone (WCAG 1.4.1). */
  html[data-masar="on"] .m-choice__btn[aria-pressed='true'],
  html[data-masar="on"] .m-choice__card:has(input:checked),
  html[data-masar="on"] .m-chip[aria-pressed='true'] {
    border-color: var(--y-c-action); box-shadow: inset 0 0 0 1px var(--y-c-action); background: var(--y-c-action-wash); color: var(--y-c-action); font-weight: var(--y-fw-semibold);
  }
  html[data-masar="on"] .m-choice__btn[aria-pressed='true'] .m-icon,
  html[data-masar="on"] .m-choice__card:has(input:checked) .m-icon { color: var(--y-c-action); }
  html[data-masar="on"] .m-choice__btn[aria-pressed='true']::after,
  html[data-masar="on"] .m-choice__card:has(input:checked)::after,
  html[data-masar="on"] .m-chip[aria-pressed='true']::before {
    content: ''; flex: none; width: 0.9375rem; height: 0.9375rem; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='square'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='square'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  html[data-masar="on"] .m-choice__btn[aria-pressed='true']::after,
  html[data-masar="on"] .m-choice__card:has(input:checked)::after { margin-inline-start: auto; }
  html[data-masar="on"] .m-choice__btn:disabled,
  html[data-masar="on"] .m-choice__card:has(input:disabled) { color: var(--y-c-text-disabled); background: var(--y-c-surface-2); border-color: var(--y-c-line); cursor: not-allowed; }
  /* «مقترح» (resolves A11Y-M-20 in a vanilla build): the same look on a native radio/checkbox — real radiogroup semantics, arrow keys. */
  html[data-masar="on"] .m-choice__card > input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
  html[data-masar="on"] .m-choice__card:has(input:focus-visible) { outline: var(--y-bw-focus) solid var(--y-c-focus); outline-offset: 2px; }
  html[data-masar="on"] .m-field--error .m-choice__btn,
  html[data-masar="on"] .m-field--error .m-choice__card { border-color: var(--y-c-due); }

  /* Quick amounts (source .chip): they replace the amount (never add), name what they cover, the matching one is pressed. */
  html[data-masar="on"] .m-chips { display: flex; flex-wrap: wrap; gap: var(--y-sp-2); }
  html[data-masar="on"] .m-chip { border-color: var(--y-c-pine-300); border-radius: var(--y-r-full); padding-inline: 1rem; font-weight: var(--y-fw-medium); font-variant-numeric: var(--y-num); }
  html[data-masar="on"] .m-chip:hover:not([aria-pressed='true']):not(:disabled) { background: var(--y-c-pine-50); border-color: var(--y-c-action); }

  /* Segmented filter / index tabs (source .seg): every option visible at once over one hairline; the current one carries a
     short stroke with the logo's slant in the action color. aria-current (navigation), aria-pressed (filter) or aria-selected (tab). */
  html[data-masar="on"] .m-seg { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 0; border-bottom: var(--y-bw) solid var(--y-c-line); }
  html[data-masar="on"] .m-seg__item {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
    min-width: 0; min-height: 3rem; padding: 0.25rem 0.375rem 0.5rem; margin: 0; border: 0; background: none; font-family: var(--y-font-ui); cursor: pointer;
    color: var(--y-c-text-2); text-decoration: none; font-size: var(--y-fs-md); font-weight: var(--y-fw-medium); line-height: 1.3; text-align: center;
    transition: background-color var(--y-dur-1) var(--y-ease), color var(--y-dur-1) var(--y-ease);
  }
  html[data-masar="on"] .m-seg__item:hover { color: var(--y-c-text); background: var(--y-c-pine-50); }
  html[data-masar="on"] .m-seg__item:focus-visible { outline-offset: -2px; }
  html[data-masar="on"] .m-seg__item[aria-current='page'],
  html[data-masar="on"] .m-seg__item[aria-pressed='true'],
  html[data-masar="on"] .m-seg__item[aria-selected='true'] { color: var(--y-c-action); font-weight: var(--y-fw-semibold); }
  html[data-masar="on"] .m-seg__item[aria-current='page']::after,
  html[data-masar="on"] .m-seg__item[aria-pressed='true']::after,
  html[data-masar="on"] .m-seg__item[aria-selected='true']::after {
    content: ''; position: absolute; bottom: -1px; inset-inline: 14%; height: 4px; background: var(--y-c-action);
    clip-path: polygon(4.5px 0, 100% 0, calc(100% - 4.5px) 100%, 0 100%);
  }
  html[data-masar="on"] .m-seg__count { font-size: var(--y-fs-xs); color: var(--y-c-text-3); font-variant-numeric: var(--y-num); font-weight: var(--y-fw-medium); }
  html[data-masar="on"] .m-seg__item[aria-current='page'] .m-seg__count,
  html[data-masar="on"] .m-seg__item[aria-pressed='true'] .m-seg__count,
  html[data-masar="on"] .m-seg__item[aria-selected='true'] .m-seg__count { color: var(--y-c-action); }

  /* Acknowledgement: a checkbox with its full sentence (source .ack). */
  html[data-masar="on"] .m-ack { display: flex; gap: var(--y-sp-3); align-items: flex-start; min-height: var(--y-tap); padding: 0.625rem 0.75rem; border: var(--y-bw) solid var(--y-c-line-control); border-radius: var(--y-r-md); background: var(--y-c-surface); font-size: var(--y-fs-md); line-height: var(--y-lh-snug); cursor: pointer; }
  html[data-masar="on"] .m-ack:has(input:checked) { border-color: var(--y-c-action); background: var(--y-c-action-wash); }
  html[data-masar="on"] .m-ack input { width: 1.25rem; height: 1.25rem; margin: 0.125rem 0 0; flex: none; accent-color: var(--y-c-action); cursor: pointer; }
}
@media screen and (max-width: 47.49em) { html[data-masar="on"] .m-seg__item { min-height: 2.875rem; } }

/* ============================== Surfaces ==============================
   Masar has no resting cards (OD-PM-017): structure comes from rules, the ledge and pine bands. Use m-card only for a
   self-contained group that needs an edge; use m-doc for a document (receipt, statement). */
@media screen {
  html[data-masar="on"] .m-card { display: grid; gap: var(--y-sp-3); min-width: 0; padding: var(--y-sp-4); background: var(--y-c-surface); border: var(--y-bw) solid var(--y-c-line); border-radius: var(--y-r-md); }
  html[data-masar="on"] .m-card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--y-sp-2); }
  html[data-masar="on"] .m-card__title { margin: 0; font-size: var(--y-fs-base); font-weight: var(--y-fw-semibold); }
  /* A document (source .doc / .st-doc): warm paper, a paper hairline, barely rounded, the one resting shadow. */
  html[data-masar="on"] .m-doc { display: grid; gap: var(--y-sp-3); min-width: 0; padding: var(--y-sp-4) var(--y-sp-5); background: var(--y-c-paper); border: var(--y-bw) solid var(--y-c-paper-line); border-radius: var(--y-r-xs); box-shadow: var(--y-sh-1); }
  html[data-masar="on"] .m-doc__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--y-sp-1) var(--y-sp-3); padding-bottom: var(--y-sp-2); border-bottom: var(--y-bw) solid var(--y-c-paper-line); }
  html[data-masar="on"] .m-doc__title { margin: 0; font-size: var(--y-fs-lg); font-weight: var(--y-fw-semibold); }
  html[data-masar="on"] .m-doc__meta { font-size: var(--y-fs-sm); color: var(--y-c-text-2); }
}
@media screen and (max-width: 47.49em) {
  html[data-masar="on"] .m-doc { padding: var(--y-sp-3); }
  html[data-masar="on"] .m-doc__title { font-size: 1.0625rem; }
}

/* ============================== Key–value ============================== */
@media screen {
  /* Facts (source .facts): label over value, ruled cells, no boxes. */
  html[data-masar="on"] .m-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(12.5rem, 100%), 1fr)); gap: 0 var(--y-sp-6); margin: 0; border-top: var(--y-bw) solid var(--y-c-line); }
  html[data-masar="on"] .m-facts > div { min-width: 0; padding: 0.625rem 0; border-bottom: var(--y-bw) solid var(--y-c-line); }
  html[data-masar="on"] .m-facts dt { font-size: var(--y-fs-sm); color: var(--y-c-text-3); }
  html[data-masar="on"] .m-facts dd { margin: 0; font-weight: var(--y-fw-medium); }
  /* The receipt (source .pay-sum): what will be (or was) recorded — each fact on a dotted leader, the amount first and large. */
  html[data-masar="on"] .m-receipt { display: grid; gap: 0; margin: 0; padding: 0.25rem 0.875rem 0.375rem; background: var(--y-c-surface); border: var(--y-bw) solid var(--y-c-line); border-radius: var(--y-r-sm); font-size: var(--y-fs-md); }
  html[data-masar="on"] .m-receipt > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.5rem; min-height: 1.875rem; min-width: 0; }
  html[data-masar="on"] .m-receipt > div + div { border-top: var(--y-bw) dashed var(--y-c-line); }
  html[data-masar="on"] .m-receipt dt { display: flex; flex: 1 0 auto; align-items: baseline; gap: 0.5rem; color: var(--y-c-text-3); font-size: var(--y-fs-sm); }
  html[data-masar="on"] .m-receipt dt::after { content: ''; flex: 1; min-width: 1rem; border-bottom: 2px dotted var(--y-c-pine-300); transform: translateY(-0.25rem); }
  html[data-masar="on"] .m-receipt dd { margin: 0; min-width: 0; font-weight: var(--y-fw-semibold); text-align: start; }
  html[data-masar="on"] .m-receipt > div:first-child { min-height: 2.5rem; align-items: center; }
  html[data-masar="on"] .m-receipt > div:first-child dd .m-money { font-size: var(--y-money-lg); font-weight: var(--y-fw-bold); }
  html[data-masar="on"] .m-receipt__missing { color: var(--y-c-due); font-weight: var(--y-fw-medium); }
  html[data-masar="on"] .m-doc .m-receipt { background: transparent; border: 0; padding: 0; }
  /* Statement figures (source .figures / .st-figs): label … value rows on paper hairlines; the net (balance) under a double rule. */
  html[data-masar="on"] .m-figures { display: grid; margin: 0; }
  html[data-masar="on"] .m-figures > div { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 var(--y-sp-3); padding: 0.5rem 0; border-top: var(--y-bw) solid var(--y-c-paper-line); }
  html[data-masar="on"] .m-figures > div:first-child { border-top: 0; }
  html[data-masar="on"] .m-figures dt { font-size: var(--y-fs-sm); color: var(--y-c-text-2); }
  html[data-masar="on"] .m-figures dd { margin: 0; }
  html[data-masar="on"] .m-figures > .m-figures__net { padding: 0.625rem 0 0.25rem; border-top: 3px double var(--y-c-text-2); }
  html[data-masar="on"] .m-figures__net dt { color: var(--y-c-text); font-weight: var(--y-fw-bold); font-size: var(--y-fs-base); }
  /* A word and its number kept on one line (source .pairs / .pair, IX-M-14). */
  html[data-masar="on"] .m-pairs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--y-sp-4); }
  html[data-masar="on"] .m-pair { white-space: nowrap; }
  html[data-masar="on"] .m-pair__label { font-size: var(--y-fs-sm); color: var(--y-c-text-3); margin-inline-end: 0.25rem; }
}

/* ============================== Table (source .sts-entry; phones: source .unit-table rows) ==============================
   A real <table> from 47.5em. Below it, .m-table--stack turns each row into a ruled block of «label: value» lines;
   MasarUI.stackTable(table) (or [data-m-stack] on load) copies each column head into data-label and adds ARIA table
   roles, so the table is still announced as a table after display changes. Figures: lining tabular numerals. */
@media screen {
  html[data-masar="on"] .m-table-wrap { max-width: 100%; overflow-x: auto; }
  html[data-masar="on"] .m-table { width: 100%; border-collapse: collapse; font-size: var(--y-fs-md); line-height: var(--y-lh-snug); }
  html[data-masar="on"] .m-table caption { padding-bottom: var(--y-sp-2); text-align: start; font-weight: var(--y-fw-semibold); color: var(--y-c-text); }
  html[data-masar="on"] .m-table th,
  html[data-masar="on"] .m-table td { padding: 0.5rem 0.75rem; border-bottom: var(--y-bw) solid var(--y-c-line); text-align: start; vertical-align: top; }
  html[data-masar="on"] .m-table thead th { font-size: var(--y-fs-sm); font-weight: var(--y-fw-semibold); color: var(--y-c-text-2); background: var(--y-c-pine-50); white-space: nowrap; }
  html[data-masar="on"] .m-table tbody th { font-weight: var(--y-fw-semibold); color: var(--y-c-text); }
  html[data-masar="on"] .m-table tbody tr:hover { background: var(--y-c-pine-50); }
  html[data-masar="on"] .m-table tfoot th,
  html[data-masar="on"] .m-table tfoot td { border-top: 2px solid var(--y-c-text-3); border-bottom: 0; font-weight: var(--y-fw-bold); }
  html[data-masar="on"] .m-table__num { font-variant-numeric: var(--y-num); white-space: nowrap; }
  html[data-masar="on"] .m-table__nil { color: var(--y-c-text-3); }
}
@media screen and (max-width: 47.49em) {
  html[data-masar="on"] .m-table--stack,
  html[data-masar="on"] .m-table--stack tbody,
  html[data-masar="on"] .m-table--stack tfoot,
  html[data-masar="on"] .m-table--stack tr,
  html[data-masar="on"] .m-table--stack th,
  html[data-masar="on"] .m-table--stack td { display: block; }
  html[data-masar="on"] .m-table--stack caption { display: block; }
  html[data-masar="on"] .m-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  html[data-masar="on"] .m-table--stack tr { padding: 0.5rem 0; border-bottom: var(--y-bw) solid var(--y-c-line); }
  html[data-masar="on"] .m-table--stack tbody tr:hover { background: none; }
  html[data-masar="on"] .m-table--stack th,
  html[data-masar="on"] .m-table--stack td { display: flex; flex-wrap: wrap; gap: 0 var(--y-sp-2); padding: 0.125rem 0; border: 0; }
  html[data-masar="on"] .m-table--stack td[data-label]::before,
  html[data-masar="on"] .m-table--stack tfoot th[data-label]::before { content: attr(data-label); flex: 0 0 auto; min-width: 6.5rem; font-size: var(--y-fs-sm); font-weight: var(--y-fw-regular); color: var(--y-c-text-3); }
  html[data-masar="on"] .m-table--stack tbody th { font-size: var(--y-fs-base); }
  html[data-masar="on"] .m-table--stack tfoot tr { border-top: 2px solid var(--y-c-text-3); border-bottom: 0; }
  html[data-masar="on"] .m-table--stack tfoot th,
  html[data-masar="on"] .m-table--stack tfoot td { border-top: 0; }
  html[data-masar="on"] .m-table--stack .m-table__nil { display: none; } /* an empty cell («—») is not repeated as a line on phones */
}

/* ============================== Status tag (source data.css .badge; tags.tsx) ==============================
   One state: its word, usually its icon, a calm tint, and the logo's slant on the end edge. Never color alone. */
@media screen {
  html[data-masar="on"] .m-tag {
    display: inline-flex; align-items: center; gap: 0.3125rem; min-height: 1.625rem;
    padding-block: 0; padding-inline: 0.5rem calc(0.5rem + var(--y-slant) * 0.6);
    font-size: var(--y-fs-xs); font-weight: var(--y-fw-semibold); line-height: 1.3; white-space: nowrap;
    clip-path: polygon(calc(var(--y-slant) * 0.6) 0, 100% 0, 100% 100%, 0 100%);
    background: var(--y-c-neutral-wash); color: var(--y-c-neutral);
  }
  html[data-masar="on"] .m-tag .m-icon { width: 1rem; height: 1rem; vertical-align: 0; }
  html[data-masar="on"] .m-tag--neutral { background: var(--y-c-neutral-wash); color: var(--y-c-neutral); }
  html[data-masar="on"] .m-tag--ok { background: var(--y-c-ok-wash); color: var(--y-c-ok); }
  html[data-masar="on"] .m-tag--warn { background: var(--y-c-warn-wash); color: var(--y-c-warn); }
  html[data-masar="on"] .m-tag--due { background: var(--y-c-due-wash); color: var(--y-c-due); }
  html[data-masar="on"] .m-tag--info { background: var(--y-c-info-wash); color: var(--y-c-info); }
  /* «معتمد» / «صادر» are states, not actions: a pine tint with charcoal ink, never the solid action color. */
  html[data-masar="on"] .m-tag--action { background: var(--y-c-pine-100); color: var(--y-c-text); }
}

/* ============================== Money (source money.css; Money.tsx; OD-PM-018 §1) ==============================
   Seen: the official SAMA riyal symbol LEFT of the number, one word space away, negatives included («⃁ -1,000»).
   The amount is one LTR-isolated unit that never wraps; Western lining tabular digits; halalas at the figure's size.
   Heard and copied: «12,500 ريال سعودي» (.m-money__words is real text, visually hidden but inline).
   INVALID (TASK-007 binding fix): a value that is not a safe integer of halalas is never shown as a number — the element
   carries .m-money--invalid and data-money-state="invalid" and SHOWS the words «مبلغ غير صالح» in the error ink after a
   small error mark (aria-hidden). Never a bare «—»: in the product a dash means "no value", and a broken amount must not
   pass for an empty one.
   Build with MasarUI.money(halalas) / MasarUI.setMoney(el, halalas) or <span data-m-money="1250000"></span>. */
@media screen {
  html[data-masar="on"] .m-money {
    display: inline; direction: ltr; unicode-bidi: isolate; white-space: nowrap; overflow-wrap: normal;
    font-variant-numeric: var(--y-num); font-weight: var(--y-fw-semibold); color: var(--y-c-money);
  }
  html[data-masar="on"] .m-money .m-riyal { display: inline-block; width: auto; height: 0.72em; margin: 0 0.25em 0 0; vertical-align: baseline; fill: currentColor; color: inherit; overflow: visible; }
  html[data-masar="on"] .m-money__num { color: inherit; }
  html[data-masar="on"] .m-money__words,
  html[data-masar="on"] .m-riyal-unit .m-money__words { display: inline-block; width: 1px; height: 1px; margin-inline-start: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; vertical-align: baseline; }
  html[data-masar="on"] .m-money--sm { font-size: var(--y-money-sm); }
  html[data-masar="on"] .m-money--md { font-size: var(--y-money-md); }
  html[data-masar="on"] .m-money--lg { font-size: var(--y-money-lg); font-weight: var(--y-fw-bold); line-height: 1.3; }
  html[data-masar="on"] .m-money--xl { font-size: var(--y-money-xl); font-weight: var(--y-fw-bold); line-height: 1.2; }
  html[data-masar="on"] .m-money--inline { font-size: inherit; font-weight: inherit; color: inherit; }
  /* A negative keeps its minus sign and takes the «due» ink; inline amounts keep their sentence's ink. */
  html[data-masar="on"] .m-money--neg:not(.m-money--inline) { color: var(--y-c-money-neg); }
  html[data-masar="on"] .m-money--in:not(.m-money--inline) { color: var(--y-c-money-in); }   /* «مقترح» — always with its word («مستلم»، «وارد») */
  html[data-masar="on"] .m-money--out:not(.m-money--inline) { color: var(--y-c-money-out); } /* «مقترح» — always with its word («مصروف»، «مدفوع») */
  /* Invalid (review R-02): visible words in the error ink (6.83 on surface, 6.64 on canvas) after a small error mark; no
     number, no riyal sign. The words are Arabic, so the unit runs right to left (the mark at the start). Inline in a solid
     button it keeps the button's ink so it stays legible there. */
  html[data-masar="on"] .m-money--invalid { direction: rtl; display: inline-flex; align-items: center; gap: 0.3em; vertical-align: baseline; color: var(--y-c-due); font-weight: var(--y-fw-semibold); }
  html[data-masar="on"] .m-money--invalid .m-money__mark { width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }
  html[data-masar="on"] .m-money__invalid { color: inherit; }
  html[data-masar="on"] .m-btn--primary .m-money--invalid,
  html[data-masar="on"] .m-btn--danger .m-money--invalid { color: inherit; }
  /* The currency of a field or column without an amount beside it: «المبلغ المستلم (⃁)», read «(ريال سعودي)». */
  html[data-masar="on"] .m-riyal-unit { white-space: nowrap; unicode-bidi: isolate; }
  html[data-masar="on"] .m-riyal-unit .m-riyal { display: inline-block; width: auto; height: 0.72em; margin-inline: 0.08em; vertical-align: baseline; fill: currentColor; }
}

/* ============================== Notices (source feedback.css .note) ==============================
   A word first; the icon (drawn by CSS) and the tint only support it. Error = due. */
@media screen {
  html[data-masar="on"] .m-note {
    --m-note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='square'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E");
    position: relative; display: grid; gap: 0.25rem; margin: 0; padding: 0.6875rem 0.875rem; padding-inline-start: 2.5rem;
    border: var(--y-bw) solid var(--y-c-info-line); border-radius: var(--y-r-md);
    background: var(--y-c-info-wash); color: var(--y-c-info); font-size: var(--y-fs-md); line-height: var(--y-lh-snug); max-width: 48rem;
  }
  html[data-masar="on"] .m-note::before {
    content: ''; position: absolute; inset-inline-start: 0.875rem; top: 0.8125rem; width: 1.125rem; height: 1.125rem; background: currentColor;
    -webkit-mask: var(--m-note-icon) center / contain no-repeat; mask: var(--m-note-icon) center / contain no-repeat;
  }
  html[data-masar="on"] .m-note__title { font-weight: var(--y-fw-semibold); }
  html[data-masar="on"] .m-note a,
  html[data-masar="on"] .m-note .m-btn--link { color: inherit; font-weight: var(--y-fw-semibold); }
  html[data-masar="on"] .m-note--warn,
  html[data-masar="on"] .m-note--warning {
    --m-note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='square' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
    background: var(--y-c-warn-wash); border-color: var(--y-c-warn-line); color: var(--y-c-warn);
  }
  html[data-masar="on"] .m-note--due,
  html[data-masar="on"] .m-note--error {
    --m-note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='square'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E");
    background: var(--y-c-due-wash); border-color: var(--y-c-due-line); color: var(--y-c-due);
  }
  html[data-masar="on"] .m-note--ok,
  html[data-masar="on"] .m-note--success {
    --m-note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='square'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E");
    background: var(--y-c-ok-wash); border-color: var(--y-c-ok-line); color: var(--y-c-ok);
  }
  html[data-masar="on"] .m-note--neutral { background: var(--y-c-surface); border-color: var(--y-c-line); color: var(--y-c-text-2); }
}

/* ============================== Toast and live region (source feedback.css .result; ResultBanner, A11Y-M-18) ==============================
   What was just done, a link to it, a natural next step. It stays until closed or replaced (no timer by default).
   It is NOT itself a live region: MasarUI.toast() also writes the words into one permanent polite region
   (<div class="m-sr-only" aria-live="polite" data-m-live>, created on first use if the page has none).
   Placement follows the host's chrome through --m-chrome-top / --m-chrome-bottom / --m-chrome-start (default 0px). */
@media screen {
  html[data-masar="on"] .m-toast-region { position: fixed; z-index: var(--y-z-toast); inset-inline: var(--y-sp-2); bottom: calc(var(--m-chrome-bottom, 0px) + 0.5rem + env(safe-area-inset-bottom)); display: grid; gap: var(--y-sp-2); pointer-events: none; font-family: var(--y-font-ui); }
  html[data-masar="on"] .m-toast-region > * { pointer-events: auto; }
  html[data-masar="on"] .m-toast {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--y-sp-2) var(--y-sp-3);
    padding: 0.5rem 0.75rem; background: var(--y-c-surface); color: var(--y-c-text); border: var(--y-bw) solid var(--y-c-ok-line); border-inline-start: 4px solid var(--y-c-ok-mark); border-radius: var(--y-r-md);
    box-shadow: var(--y-sh-2); font-size: var(--y-fs-md); line-height: var(--y-lh-snug);
    animation: masar-rise var(--y-dur-2) var(--y-ease);
  }
  html[data-masar="on"] .m-toast:focus { outline: none; }
  html[data-masar="on"] .m-toast:focus-visible { outline: var(--y-bw-focus) solid var(--y-c-focus); outline-offset: 2px; }
  html[data-masar="on"] .m-toast__mark { display: inline-grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: var(--y-r-sm); background: var(--y-c-ok-wash); color: var(--y-c-ok); }
  html[data-masar="on"] .m-toast__mark .m-icon { width: 1.25rem; height: 1.25rem; }
  html[data-masar="on"] .m-toast__line { flex: 1 1 14rem; margin: 0; color: var(--y-c-text); }
  html[data-masar="on"] .m-toast__actions { display: flex; flex-wrap: wrap; gap: var(--y-sp-2); }
  /* «مقترح»: a failure that must be seen after the place is gone («لم يُحفظ شيء»). Normally a refusal is shown at its place. */
  html[data-masar="on"] .m-toast--due { border-color: var(--y-c-due-line); border-inline-start-color: var(--y-c-due-mark); }
  html[data-masar="on"] .m-toast--due .m-toast__mark { background: var(--y-c-due-wash); color: var(--y-c-due); }
  html[data-masar="on"] .m-toast--static { position: static; box-shadow: none; animation: none; } /* a specimen in the gallery */
}
@media screen and (min-width: 47.5em) {
  html[data-masar="on"] .m-toast-region { top: calc(var(--m-chrome-top, 0px) + var(--y-sp-2)); bottom: auto; inset-inline: calc(var(--m-chrome-start, 0px) + var(--y-sp-6)) var(--y-sp-6); max-width: 48rem; }
  html[data-masar="on"] .m-toast { padding: 0.625rem 0.875rem; }
}

/* ============================== Layers: dialog, bottom sheet, side panel (source modal.ts, shell.css .op-modal/.op-panel) ==============================
   <div class="m-layer" hidden id="x"><section class="m-dialog" role="dialog" aria-modal="true" aria-labelledby="x-title">…
   MasarUI.openDialog('x') / data-m-open="x": shows it, makes the rest of the page inert, traps Tab, Escape closes, focus
   returns to the opener. A light veil, never dark. Phones: dialogs and panels are full screen; a sheet rises from the
   bottom. ≥ 64em: the panel stands beside the page at the end side. Put the layer as a direct child of <body>. */
@media screen {
  html[data-masar="on"] .m-layer { position: fixed; inset: 0; z-index: var(--y-z-modal); display: grid; align-items: start; justify-items: center; padding: 5vh 0.75rem; overflow-y: auto; background: var(--y-c-scrim); backdrop-filter: blur(2px); animation: masar-fade var(--y-dur-2) var(--y-ease); font-family: var(--y-font-ui); color: var(--y-c-text); line-height: var(--y-lh-body); }
  html[data-masar="on"] .m-layer[hidden] { display: none; }
  html[data-masar="on"] .m-dialog {
    display: flex; flex-direction: column; width: min(var(--y-dialog), 100%); max-height: 90vh; overflow-y: auto; overscroll-behavior: contain;
    background: var(--y-c-surface); border: var(--y-bw) solid var(--y-c-line); border-radius: var(--y-r-xl); box-shadow: var(--y-sh-3);
    animation: masar-rise var(--y-dur-2) var(--y-ease); scroll-padding-top: 6.5rem; scroll-padding-bottom: 12rem;
  }
  html[data-masar="on"] .m-dialog:focus { outline: none; }
  html[data-masar="on"] .m-dialog__head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: var(--y-sp-2); padding: 0.75rem var(--y-sp-4) 0.625rem; background: var(--y-c-pine-100); border-start-start-radius: inherit; border-start-end-radius: inherit; }
  html[data-masar="on"] .m-dialog__head > div { flex: 1; min-width: 0; padding-top: 0.25rem; }
  html[data-masar="on"] .m-dialog__head h2 { margin: 0; font-family: var(--y-font-ui); font-size: 1.25rem; font-weight: var(--y-fw-bold); line-height: var(--y-lh-snug); color: var(--y-c-text); }
  html[data-masar="on"] .m-dialog__head h2:focus { outline: none; }
  html[data-masar="on"] .m-dialog__head > .m-btn { flex: none; white-space: nowrap; }
  html[data-masar="on"] .m-dialog__head > .m-btn--quiet:hover:not(:disabled) { background: rgb(255 255 255 / 0.6); }
  html[data-masar="on"] .m-dialog__sub { margin: 0; font-size: var(--y-fs-sm); color: var(--y-c-text-2); line-height: var(--y-lh-snug); }
  html[data-masar="on"] .m-dialog__body { flex: 1 0 auto; display: flex; flex-direction: column; gap: var(--y-sp-4); padding: var(--y-sp-4); }
  html[data-masar="on"].m-has-layer { overflow: hidden; }
  /* Side panel (source .op-panel): beside the page from 64em, full screen below. */
  html[data-masar="on"] .m-layer--panel { padding: 0; justify-items: end; align-items: stretch; }
  html[data-masar="on"] .m-layer--panel .m-dialog { width: min(var(--y-panel), 100%); max-height: none; height: 100%; border: 0; border-inline-start: var(--y-bw) solid var(--y-c-line); border-radius: 0; animation-name: masar-fade; }
  /* Confirm bar (source .actions-sticky): pinned to the bottom of the dialog, within thumb reach, on a pine band, with the
     consequence and the receipt of what will be recorded beside the button. */
  html[data-masar="on"] .m-confirm-bar {
    position: sticky; bottom: 0; z-index: 1; display: grid; gap: var(--y-sp-2); margin-top: auto;
    padding: 0.75rem var(--y-sp-4) calc(0.75rem + env(safe-area-inset-bottom));
    background: var(--y-c-pine-50); border-top: var(--y-bw) solid var(--y-c-line); box-shadow: var(--y-sh-up);
  }
  /* When the bar closes a form page instead of a dialog: it bleeds to the page edges by the host's --m-page-pad (default 0). */
  html[data-masar="on"] .m-confirm-bar--page { margin-inline: calc(-1 * var(--m-page-pad, 0px)); }
  html[data-masar="on"] .m-confirm-bar__note { display: flex; gap: 0.375rem; align-items: baseline; margin: 0; font-size: var(--y-fs-sm); font-weight: var(--y-fw-semibold); color: var(--y-c-due); line-height: var(--y-lh-snug); }
  html[data-masar="on"] .m-confirm-bar__note::before { content: ''; flex: none; width: 0.5rem; height: 0.5rem; background: var(--y-c-due-mark); clip-path: polygon(40% 0, 100% 0, 60% 100%, 0 100%); }
  html[data-masar="on"] .m-confirm-bar__label { margin: 0; font-size: var(--y-fs-sm); font-weight: var(--y-fw-semibold); }
}
@media screen and (max-width: 63.99em) {
  html[data-masar="on"] .m-layer--panel .m-dialog { width: 100%; border: 0; }
}
@media screen and (max-width: 47.49em) {
  html[data-masar="on"] .m-layer { padding: 0; }
  html[data-masar="on"] .m-dialog { width: 100%; max-height: none; min-height: 100%; border: 0; border-radius: 0; }
  html[data-masar="on"] .m-confirm-bar--page { position: sticky; bottom: calc(var(--m-chrome-bottom, 0px) + env(safe-area-inset-bottom)); }
  /* Bottom sheet «مقترح»: on phones a short choice rises from the bottom (thumb reach); wider, it is a dialog. */
  html[data-masar="on"] .m-layer--sheet { align-items: end; }
  html[data-masar="on"] .m-layer--sheet .m-dialog { min-height: 0; max-height: 88vh; border-top: var(--y-bw) solid var(--y-c-line); border-start-start-radius: var(--y-r-xl); border-start-end-radius: var(--y-r-xl); }
}
@media screen and (min-width: 47.5em) {
  html[data-masar="on"] .m-confirm-bar--page { margin-inline: 0; border: var(--y-bw) solid var(--y-c-line); border-radius: var(--y-r-md); }
}
@media screen and (max-height: 50em) {
  html[data-masar="on"] .m-confirm-bar { gap: 0.375rem; padding-block: 0.5rem calc(0.5rem + env(safe-area-inset-bottom)); }
}
@media screen and (max-height: 30em) {
  html[data-masar="on"] .m-dialog__head { position: static; padding-block: 0.375rem; }
  html[data-masar="on"] .m-confirm-bar { position: static; box-shadow: none; }
}

/* ============================== Empty and loading (source feedback.css .empty/.loading/.skel) ============================== */
@media screen {
  html[data-masar="on"] .m-empty {
    display: flex; align-items: center; flex-wrap: wrap; gap: var(--y-sp-3); margin: 0; padding: var(--y-sp-3) var(--y-sp-4);
    border: var(--y-bw) dashed var(--y-c-pine-300); border-radius: var(--y-r-md); background: var(--y-c-pine-50); color: var(--y-c-text-2); font-size: var(--y-fs-md); line-height: var(--y-lh-snug);
  }
  /* The mark is the logo's step (custom icon «step»), in the ledge color. */
  html[data-masar="on"] .m-empty::before {
    content: ''; flex: none; width: 2.25rem; height: 2.25rem; border-radius: var(--y-r-sm); background: var(--y-c-surface) no-repeat center / 1.375rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f9a91' stroke-width='1.75' stroke-linecap='square'%3E%3Cpath d='M21.5 7.5H16.5l-8 8h-6'/%3E%3C/svg%3E");
  }
  html[data-masar="on"] .m-empty__text { flex: 1 1 14rem; margin: 0; max-width: var(--y-prose); }
  html[data-masar="on"] .m-loading { margin: 0; padding: var(--y-sp-4) 0; color: var(--y-c-text-2); }
  html[data-masar="on"] .m-skel { display: block; background: var(--y-c-surface-3); border-radius: var(--y-r-sm); }
  html[data-masar="on"] .m-skel--line { height: 0.875rem; }
  html[data-masar="on"] .m-skel--title { height: 1.5rem; width: 40%; }
  html[data-masar="on"] .m-skel--block { height: 6.5rem; border-radius: var(--y-r-md); background: var(--y-c-pine-50); border: var(--y-bw) solid var(--y-c-line); }
}

/* ============================== Steps (source screens-statements .steps): a short path on the ledge ==============================
   Done steps run high in the ledge color; the current step carries the 42° fall; steps to come run low. Each has its
   word; the current one has aria-current="step". Up to ~5 steps; set --n to their number. */
@media screen {
  html[data-masar="on"] .m-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 0; }
  html[data-masar="on"] .m-steps__item { display: grid; gap: 0.25rem; min-width: 0; }
  html[data-masar="on"] .m-steps__bar { --t: 5px; --rise: 8px; --d: calc(var(--rise) * var(--y-run)); --k: calc(var(--t) * 0.384); position: relative; display: block; height: calc(var(--t) + var(--rise)); }
  html[data-masar="on"] .m-steps__bar::before { content: ''; position: absolute; inset-inline: 1px; top: var(--rise); height: var(--t); background: var(--y-c-pine-200); }
  html[data-masar="on"] .m-steps__item--done .m-steps__bar::before { top: 0; background: var(--y-c-ledge); }
  html[data-masar="on"] .m-steps__item--current .m-steps__bar::before {
    top: 0; height: 100%; inset-inline-end: 1px; inset-inline-start: 0;
    background: linear-gradient(to left, var(--y-c-ledge) 0 calc(var(--d) + 1px), var(--y-c-pine-200) 0);
    clip-path: polygon(100% 0, calc(100% - var(--d)) var(--rise), 0 var(--rise), 0 100%, calc(100% - var(--d) + var(--k)) 100%, 100% var(--t));
  }
  html[data-masar="on"] .m-steps__word { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.1875rem 0.25rem; font-size: var(--y-fs-xs); color: var(--y-c-text-3); line-height: 1.3; }
  html[data-masar="on"] .m-steps__word .m-icon { width: 1rem; height: 1rem; }
  html[data-masar="on"] .m-steps__item--done .m-steps__word,
  html[data-masar="on"] .m-steps__item--current .m-steps__word { color: var(--y-c-text); font-weight: var(--y-fw-semibold); }
}

/* ============================== Work list (source screens-work .work-card; brand.tsx CountCells) ==============================
   A task row: a pine index column (a number or a state icon), what it is and for whom, the fact (amount, date) and its
   one action. Phone: index + body, the fact and action under the body. 47.5em: three columns. 64em: four. */
@media screen {
  html[data-masar="on"] .m-tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: var(--y-bw) solid var(--y-c-line); }
  html[data-masar="on"] .m-task { display: grid; grid-template-columns: 3.75rem minmax(0, 1fr); grid-template-areas: 'idx body' 'idx settle'; align-items: stretch; gap: 0; border-bottom: var(--y-bw) solid var(--y-c-line); transition: background-color var(--y-dur-1) var(--y-ease); }
  html[data-masar="on"] .m-task:hover { background: var(--y-c-pine-50); }
  html[data-masar="on"] .m-task__index { grid-area: idx; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0.25rem; padding: 0.75rem 0.25rem; background: var(--y-c-pine-100); border-inline-end: var(--y-bw) solid var(--y-c-line); color: var(--y-c-text-2); }
  html[data-masar="on"] .m-task:hover .m-task__index { background: var(--y-c-pine-200); }
  html[data-masar="on"] .m-task__index .m-icon { width: 1.25rem; height: 1.25rem; }
  html[data-masar="on"] .m-task__index--due { color: var(--y-c-due); }
  html[data-masar="on"] .m-task__index--warn { color: var(--y-c-warn); }
  html[data-masar="on"] .m-task__index--info { color: var(--y-c-info); }
  html[data-masar="on"] .m-task__index--ok { color: var(--y-c-ok); }
  html[data-masar="on"] .m-task__plate { font-size: 1rem; font-weight: var(--y-fw-bold); line-height: 1.3; color: var(--y-c-text); font-variant-numeric: var(--y-num); white-space: nowrap; }
  html[data-masar="on"] .m-task__body { grid-area: body; display: grid; gap: 0.125rem; align-content: start; min-width: 0; padding: 0.625rem var(--y-sp-4) 0; }
  html[data-masar="on"] .m-task__who { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.625rem; margin: 0; font-weight: var(--y-fw-semibold); font-size: 1.0625rem; line-height: var(--y-lh-snug); }
  html[data-masar="on"] .m-task__who a { color: var(--y-c-text); text-decoration: none; }
  html[data-masar="on"] .m-task__who a:hover { color: var(--y-c-action); text-decoration: underline; }
  html[data-masar="on"] .m-task__context { margin: 0; font-size: var(--y-fs-sm); color: var(--y-c-text-3); }
  html[data-masar="on"] .m-task__settle { grid-area: settle; display: grid; gap: 0.125rem; align-content: start; min-width: 0; padding: 0.375rem var(--y-sp-4) 0.75rem; }
  html[data-masar="on"] .m-task__fact { margin: 0; font-size: var(--y-fs-md); color: var(--y-c-text); line-height: var(--y-lh-snug); }
  html[data-masar="on"] .m-task__settle .m-actions { margin-top: var(--y-sp-2); }
  /* Count cells (source .cells): one cell per item, 2px apart, on the ledge's two levels; the stroke falls at 42° on the
     first item still to do. Counts only — never money; the words beside it say the numbers. aria-hidden. */
  html[data-masar="on"] .m-cells { --t: var(--y-ledge-t); --rise: var(--y-ledge-rise); --d: calc(var(--rise) * var(--y-run)); --k: calc(var(--t) * 0.384); display: flex; gap: 2px; width: 100%; min-width: 4rem; height: calc(var(--t) + var(--rise)); flex: none; pointer-events: none; }
  html[data-masar="on"] .m-cell { display: block; flex: 1 1 0; min-width: 0; height: var(--t); margin-top: var(--rise); background: var(--y-c-pine-200); }
  html[data-masar="on"] .m-cell--hi { margin-top: 0; background: var(--y-c-pine-500); }
  html[data-masar="on"] .m-cell--step { height: calc(var(--t) + var(--rise)); margin-top: 0; clip-path: polygon(100% 0, calc(100% - var(--d)) var(--rise), 0 var(--rise), 0 100%, calc(100% - var(--d) + var(--k)) 100%, 100% var(--t)); }
  html[data-masar="on"] .m-cell--ok { background: var(--y-c-ok-mark); }
  html[data-masar="on"] .m-cell--warn { background: var(--y-c-warn-mark); }
  html[data-masar="on"] .m-cell--due { background: var(--y-c-due-mark); }
}
@media screen and (max-width: 47.49em) {
  html[data-masar="on"] .m-task__settle .m-actions > .m-btn--primary { flex: 1 1 8rem; }
  html[data-masar="on"] .m-task__settle .m-actions > * { flex: 1 1 auto; }
}
@media screen and (min-width: 47.5em) {
  html[data-masar="on"] .m-task { grid-template-columns: 4.5rem minmax(0, 1fr) minmax(14rem, 18.5rem); grid-template-areas: 'idx body settle'; }
  html[data-masar="on"] .m-task__index { padding-top: 1rem; }
  html[data-masar="on"] .m-task__plate { font-size: 1.125rem; }
  html[data-masar="on"] .m-task__body { padding: 0.875rem var(--y-sp-5); }
  html[data-masar="on"] .m-task__settle { padding: 0.875rem var(--y-sp-5); border-inline-start: var(--y-bw) dashed var(--y-c-line); }
}
@media screen and (min-width: 64em) {
  html[data-masar="on"] .m-tasks { max-width: 56rem; }
  html[data-masar="on"] .m-task { grid-template-columns: 4.5rem minmax(15rem, 1fr) 12.5rem max-content; grid-template-areas: 'idx body fact act'; align-items: center; }
  html[data-masar="on"] .m-task > .m-task__index { align-self: stretch; }
  html[data-masar="on"] .m-task > .m-task__body { padding: 0.75rem 1.25rem; }
  html[data-masar="on"] .m-task > .m-task__settle { display: contents; }
  html[data-masar="on"] .m-task > .m-task__settle > .m-task__fact { grid-area: fact; padding: 0.75rem 1rem; border-inline-start: var(--y-bw) dashed var(--y-c-line); }
  html[data-masar="on"] .m-task > .m-task__settle > .m-actions { grid-area: act; flex-wrap: nowrap; margin: 0; padding-block: 0.75rem; padding-inline: 0.5rem 0.75rem; }
}

/* ============================== Phone touch targets (source layout.css, QA-ID1-11) ==============================
   Inline links in text get a 44 px target without moving their line. */
@media screen and (max-width: 47.49em) {
  html[data-masar="on"] :where(.m-scope, .m-body, .m-dialog) p a:not([class]),
  html[data-masar="on"] :where(.m-scope, .m-body, .m-dialog) li a:not([class]) { padding-block: 0.8125rem; margin-block: -0.8125rem; }
}

/* ============================== Reduced motion: no movement at all; state changes happen instantly ============================== */
@media screen and (prefers-reduced-motion: reduce) {
  html[data-masar="on"] [class^="m-"],
  html[data-masar="on"] [class*=" m-"],
  html[data-masar="on"] [class^="m-"]::before,
  html[data-masar="on"] [class*=" m-"]::before,
  html[data-masar="on"] [class^="m-"]::after,
  html[data-masar="on"] [class*=" m-"]::after,
  html[data-masar="on"] :where(.m-scope, .m-body) *,
  html[data-masar="on"] :where(.m-scope, .m-body) *::before,
  html[data-masar="on"] :where(.m-scope, .m-body) *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
