@charset "UTF-8";
/* ============================================================================
   TrustMatrix - professional polish layer
   ----------------------------------------------------------------------------
   ONE stylesheet that unifies the look. Everything here is an override;
   deleting this file and its <link> tags returns the application to exactly
   how it looked before.

   Written against measurements taken from the running application, not taste:

     * 106 Arabic text nodes on the dashboard alone rendered in THREE different
       typefaces, none of them chosen. The cause was one variable - Metronic
       sets --bs-font-sans-serif: Inter, Helvetica, and Inter carries no Arabic
       glyph at all, so every Arabic word fell to a silent browser default.
       Worse, 123 declarations across the views DID name Cairo or Tajawal, but
       no layout ever loaded those fonts, and 37 of them listed "Segoe UI"
       ahead of Cairo - so even once loaded, Segoe UI would still have won.
       For an Arabic-first product this was the largest single reason the
       interface read as unfinished.
     * Four blues were competing to be "the" accent: #009ef7 (the Metronic
       default), #6366f1 (the TrustMatrix logo), #3b82f6 and #0066cc. The logo
       decides: everything is unified onto indigo.
     * 7 shadows, 15 radii, 27 font sizes and 29 text colours on ONE page.
     * Only 24 places across 141 views aligned their numerals. In a financial
       statement, columns of figures that do not line up read as amateur.

   ON SPECIFICITY. The component rules below are written as `body .card`, not
   `.card`. That is deliberate and not decoration: views in this codebase carry
   84 inline <style> blocks, and several redeclare `.card { border: none }` at
   equal specificity but later in the document, which would silently win. A
   single `body` prefix lifts these primitives above that noise while leaving
   anything genuinely scoped - `.dashboard .card`, or any !important - free to
   override, so a view that really means something different still gets it.

   Conventions: logical properties only (inline-start / inline-end), so a rule
   written once is correct in both Arabic RTL and English LTR. Dark mode is
   carried through [data-bs-theme="dark"], the switch Metronic already uses.
   ============================================================================ */
/* The token blocks that stood here are now wwwroot/css/tm-tokens.css, linked before
   this file. This file owns the RULES; that one owns the VALUES. */


/* Metronic's dark .text-info is #883fff, a purple that reads 3.29:1 on a card - the only one
   of the four state utilities that fails there. Only the TEXT utility is redirected: --bs-info
   itself still drives .bg-info, which paints white on a solid fill and would be made worse,
   not better, by a lighter value. Specificity (0,2,0) beats Bootstrap's (0,1,0), and the
   !important matches the utility's own so document order cannot decide it. */
[data-bs-theme="dark"] .text-info,
[data-bs-theme="dark"] .text-info i {
  color: var(--tm-pro-info) !important;
}

/* .btn-light-* takes its label from var(--bs-<state>) - the FILL value - so it inherits the
   fill's job of carrying white and lands far too pale on its own tint. It needs the text
   token instead, which is already solved per theme. --bs-info is left alone (it drives
   .bg-info, whose white label a lighter value would ruin), so its light variant is named
   here too rather than through the token block. Rest, hover and active all repaint from
   --bs-<state> / --bs-<state>-inverse, which the token block above has already corrected. */
body .btn.btn-light-success,  body .badge.badge-light-success { color: var(--tm-pro-success); }
body .btn.btn-light-warning,  body .badge.badge-light-warning { color: var(--tm-pro-warning); }
body .btn.btn-light-danger,   body .badge.badge-light-danger  { color: var(--tm-pro-danger); }
body .btn.btn-light-info,     body .badge.badge-light-info    { color: var(--tm-pro-info); }

/* .badge-light-* is the same construction as .btn-light-* and is used 424 times across the
   views, so it carries the same defect at four times the surface - dark .badge-light-info
   alone measured 3.10 on 38 nodes of one page. Primary is included here rather than in the
   token block because --bs-primary must stay the STRONG step (it is a fill carrying a white
   label); as text on its own tint it needs the text step, and only in dark, where that tint
   goes dark too - 2.14 before. */
[data-bs-theme="dark"] .btn.btn-light-primary,
[data-bs-theme="dark"] .badge.badge-light-primary { color: var(--tm-pro-accent-text); }

/* Metronic flips --bs-gray-900 to #F5F5F5 for dark but leaves --bs-heading-color on the light
   near-black #071437, so any bare h1-h6 that does not carry a .text-* utility renders at
   1.06:1 - invisible. Headings that DO carry a utility were fine, which is why this survived
   twelve passes: it only shows on the ones that do not. */
[data-bs-theme="dark"] {
  --bs-heading-color: var(--tm-pro-text);
  /* Metronic's dark gray-600 is #808290 - 3.61 on the lightest dark ground, and it is the
     resting label colour of plain .btn. Lightening a text grey costs nothing where the same
     token draws a border, which carries no text requirement. */
  --bs-gray-600: #9799a4;   /* 4.85 lightest · 5.79 card  (was #808290 = 3.61) */
  /* .btn-light's label comes from --bs-light-inverse, and its ACTIVE-state rule is (0,3,0) -
     higher than the (0,2,1) .btn-light rule further down this file, so a pressed filter chip
     kept the old grey at 4.21 while the resting one was already correct. Fixing the token
     instead of adding a fourth selector keeps every state consistent. */
  --bs-light-inverse: #9799a4;
}

/* .alert-<state> paints its label from var(--bs-<state>) on var(--bs-<state>-light), the same
   construction as the buttons and badges, so it needs the same text step. Only info has to be
   named: success, warning and danger already follow the corrected tokens above. */
/* .alert-<state> paints its label from var(--bs-<state>) on var(--bs-<state>-light) - the same
   construction as the buttons and badges, so it needs the same text step, and all four states
   need it, not just info. Danger is the instructive one: --bs-danger was solved to carry a
   white label at 4.85, and contrast being symmetric that also makes it 4.85 as text ON WHITE -
   but an alert does not sit on white, it sits on its own tint, where the same value measures
   4.34. Trap 5, in a value I had just computed. --tm-pro-danger is solved against a tint. */
body .alert.alert-info    { color: var(--tm-pro-info); }
body .alert.alert-success { color: var(--tm-pro-success); }
body .alert.alert-warning { color: var(--tm-pro-warning); }
body .alert.alert-danger  { color: var(--tm-pro-danger); }
body .alert.alert-primary { color: var(--tm-pro-accent-text); }

/* An inline white background inside a dark theme is always wrong, and it kept turning up on
   every newly-swept surface - 73 white literals live across 34 views, 17 of them in style=
   attributes where only an attribute selector can reach them. Being inline, they need
   !important to override. Anything that must genuinely stay white in dark - a paper preview,
   a document mock-up - opts out with .tm-keep-white. */
[data-bs-theme="dark"] [style*="background:#fff"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background: #fff"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background:#FFF"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background: #FFF"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background-color:#fff"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background-color: #fff"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background:white"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background: white"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background-color:white"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background-color: white"]:not(.tm-keep-white) {
  background-color: var(--tm-pro-bg) !important;
}

/* The near-whites are the same defect but not the same surface: pure white was a CARD, while
   #fafafa / #f8f9fa are the INSET a card sits on, so they take the page tone, not the card
   tone. These six were what survived the first pass. */
[data-bs-theme="dark"] [style*="background:#fafafa"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background: #fafafa"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background:#f8f9fa"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background: #f8f9fa"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background:#f9fafb"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background: #f9fafb"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background:#f5f8fa"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background: #f5f8fa"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background-color:#fafafa"]:not(.tm-keep-white),
[data-bs-theme="dark"] [style*="background-color: #fafafa"]:not(.tm-keep-white) {
  background-color: var(--tm-pro-bg-alt) !important;
}

/* A checkbox or radio label is primary content - it is the question being asked - but
   Metronic leaves it on a mid grey that measures 2.58 in light and 3.17 in dark. Both
   theme-aware here, so one declaration serves both. */
body .form-check-label { color: var(--tm-pro-text); }

/* --------------------------------------------------------------------------
   ARABIC TYPE SCALE  (owner request: "صغّر شوية الخط العربي على مستوى المشروع كله")
   --------------------------------------------------------------------------
   Metronic's RTL bundle pins `html, body { font-size: 13px !important }`, and every size in
   the theme is a rem of that - so the root is the only single lever that reaches all of them
   at once, and moving it keeps the whole scale in proportion instead of shrinking type away
   from its padding. 13 -> 12.5px is a 4% step down: measured median text 11.7 -> 11.25px,
   largest heading 29.25 -> 28.13px, and no horizontal overflow at 1440.

   Measured BEFORE touching anything, though: 56 of the 198 text nodes on the dashboard were
   ALREADY under 10px, 41 of them Arabic, the smallest at 8.19px. Arabic is a connected script
   with ascenders, descenders and diacritics in the same band - 8px is not readable, and a
   blanket reduction would have pushed it to 7.9. So the small tier is FLOORED rather than
   scaled: 0.8rem x 12.5px = 10px. Net effect - the tier the eye reads as "too big" steps
   down, the tier that was too small steps up, and sub-10px nodes go 56 -> 0.
   Latin/LTR is untouched: every rule here is scoped to html[dir="rtl"]. */
html[dir="rtl"],
html[dir="rtl"] body {
  font-size: 12.5px !important;
}

/* the floor. These are the dashboard vocabulary's small classes (0.63-0.78rem); scoping to
   RTL keeps the English layout exactly as designed. */
html[dir="rtl"] .Z-c-tag,
html[dir="rtl"] .Z-hero-tag,
html[dir="rtl"] .Z-hero-hi,
html[dir="rtl"] .Z-rpt-badge,
html[dir="rtl"] .Z-team-sh,
html[dir="rtl"] .Z-btn-link,
html[dir="rtl"] .Z-ins-l,
html[dir="rtl"] .Z-ins-bot-l,
html[dir="rtl"] .Z-ins-mini span,
html[dir="rtl"] .Z-kpi-ft > div > small,
html[dir="rtl"] .Z-hero-s small,
html[dir="rtl"] .Z-rpt-tbl thead th,
html[dir="rtl"] .Z-team-total small {
  font-size: 0.8rem;
}

/* Metronic's .nav-line-tabs .nav-item .nav-link.active is specificity (0,4,0) and points at
   --bs-primary - the strong FILL step - so it beat the (0,2,1) .nav-tabs rule written in the
   earlier pass and rendered the active tab at 2.88 on dark. Matching its structure takes this
   to (0,5,1). Cascade order is !important, then specificity, then document order: being later
   in this file was never going to be enough. */
body .nav-line-tabs .nav-item .nav-link.active,
body .nav-line-tabs .nav-item.show .nav-link,
body .nav-line-tabs .nav-item .nav-link:hover:not(.disabled),
/* the -2x variant repeats the whole rule one class higher, (0,5,0), so the selector above
   still lost on the pages that use it - it has to be named as well */
body .nav-line-tabs.nav-line-tabs-2x .nav-item .nav-link.active,
body .nav-line-tabs.nav-line-tabs-2x .nav-item.show .nav-link,
body .nav-line-tabs.nav-line-tabs-2x .nav-item .nav-link:hover:not(.disabled) {
  color: var(--tm-pro-accent-text);
}

/* Profile's header card paints linear-gradient(#ffffff, #f8f9fa) from the view's own style
   block - a literal light gradient that stays light in dark mode, leaving its title at 1.88.
   A background that is a gradient hides from every audit that only reads background-color,
   which is why this one outlived the sweep that fixed the flat white grounds. */
[data-bs-theme="dark"] .card.shadow-sm.mb-4.mt-3 {
  background: linear-gradient(135deg, var(--tm-pro-bg) 0%, var(--tm-pro-bg-alt) 100%);
}

/* Ten views each carry their own copy of this Select2 skin, and every copy hard-codes the
   light grey rgb(245,248,250) for the control - so in dark mode the control stays a white
   card and the theme-aware placeholder on it drops to 2.29. Metronic's own
   .form-select-solid correctly uses --bs-gray-100, which IS dark in dark. Those copies declare
   the colour !important, and the cascade weighs !important BEFORE specificity - so the higher
   specificity here decided nothing until this rule was marked too. Trap 3, walked into after
   writing it down. With both important, (0,5,0) beats their (0,4,0) and one rule replaces ten
   file edits. */
[data-bs-theme="dark"] .form-select-solid.select2-hidden-accessible + .select2-container .select2-selection,
[data-bs-theme="dark"] .form-select-solid.select2-hidden-accessible + .select2-container .select2-selection--single {
  background-color: var(--bs-gray-100) !important;
  border-color: var(--tm-pro-border) !important;
}
[data-bs-theme="dark"] .form-select-solid.select2-hidden-accessible + .select2-container .select2-selection__rendered {
  color: var(--tm-pro-text) !important;
}

/* --------------------------------------------------------------------------
   2. TYPOGRAPHY
   -------------------------------------------------------------------------- */
body,
.text-gray-800, .text-gray-700, .text-dark,
input, select, textarea, button, .btn, .form-control, .form-select,
table, .table, .menu, .card, .modal, .dropdown-menu {
  font-family: var(--tm-font-ui);
}

/* Arabic needs more leading than Latin at the same size; without it the
   descenders and diacritics of Cairo crowd the line above. */
[dir="rtl"] body,
[dir="rtl"] .card-body,
[dir="rtl"] p,
[dir="rtl"] .menu-title,
[dir="rtl"] label,
[dir="rtl"] td,
[dir="rtl"] th {
  line-height: 1.65;
}

body h1, body h2, body h3, body h4, body h5, body h6,
body .card-title, body .page-heading, body .page-title {
  font-weight: 600;
  letter-spacing: -.01em;
}
/* negative tracking breaks the joins between Arabic letters */
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3,
[dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6,
[dir="rtl"] .card-title, [dir="rtl"] .page-heading {
  letter-spacing: 0;
}

/* Metronic's grey utilities, repointed at the accessible text tokens. These were in the
   first draft, dropped by mistake when this file was rewritten with `body` prefixes, and
   the loss showed up in a contrast sweep: links and labels carrying .text-muted were
   rendering in Metronic's #99a1b7, which measures 2.58:1 on white - the worst ratio left
   in the application. !important is required because the Metronic utilities carry it. */
body .text-muted, body .text-gray-500, body .text-gray-600 {
  color: var(--tm-pro-text-muted) !important;   /* 7.58 */
}
body .text-gray-400 {
  color: var(--tm-pro-text-light) !important;   /* 4.51 */
}

/* --------------------------------------------------------------------------
   3. NUMERALS - the financial one
   Proportional digits leave a column of figures ragged. Tabular digits share
   one advance width, so decimal points stack and a total lines up with the
   rows it sums.
   -------------------------------------------------------------------------- */
body table, body .table, body td, body th,
body .amount, body .figure, body .number, body .money, body .total,
body .text-end, body .text-right,
body input[type="number"], body .form-control[inputmode="decimal"],
body .statement-value, body .tb-amount, body .fs-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Keep a figure such as 1,234.56 from reordering inside an RTL cell. */
[dir="rtl"] td, [dir="rtl"] th { unicode-bidi: plaintext; }

/* --------------------------------------------------------------------------
   4. SURFACES
   -------------------------------------------------------------------------- */
body .card {
  background: var(--tm-pro-bg);
  border: 1px solid var(--tm-pro-border);
  border-radius: var(--tm-r-lg);
  box-shadow: var(--tm-elev-1);
  transition: box-shadow var(--tm-t-base), border-color var(--tm-t-base);
}
body .card:hover { box-shadow: var(--tm-elev-2); }
body .card.card-flush, body .card.shadow-none { box-shadow: none; }

body .card-header {
  background: transparent;
  border-bottom: 1px solid var(--tm-pro-border);
  min-height: 56px;
  padding-block: var(--tm-sp-3);
  padding-inline: var(--tm-sp-5);
}
body .card-header .card-title { margin: 0; font-size: 1rem; font-weight: 600; }
body .card-body { padding: var(--tm-sp-5); }
body .card-footer {
  background: var(--tm-pro-bg-alt);
  border-top: 1px solid var(--tm-pro-border);
  padding-block: var(--tm-sp-3);
  padding-inline: var(--tm-sp-5);
}

body .modal-content {
  border: 1px solid var(--tm-pro-border);
  border-radius: var(--tm-r-lg);
  box-shadow: var(--tm-elev-3);
}
body .modal-header, body .modal-footer { border-color: var(--tm-pro-border); }

body .dropdown-menu, body .menu-sub-dropdown {
  border: 1px solid var(--tm-pro-border);
  border-radius: var(--tm-r-md);
  box-shadow: var(--tm-elev-2);
}

/* --------------------------------------------------------------------------
   5. CONTROLS
   -------------------------------------------------------------------------- */
body .btn {
  --tm-btn-h: 38px;
  min-height: var(--tm-btn-h);
  border-radius: var(--tm-r-md);
  font-weight: 600;
  letter-spacing: 0;
  transition: background-color var(--tm-t-fast), border-color var(--tm-t-fast),
              box-shadow var(--tm-t-fast), transform var(--tm-t-fast);
}
body .btn:active { transform: translateY(1px); }
body .btn.btn-sm { --tm-btn-h: 32px; border-radius: var(--tm-r-sm); }
body .btn.btn-lg { --tm-btn-h: 46px; border-radius: var(--tm-r-lg); }

body .btn.btn-primary {
  background-color: var(--tm-pro-accent-strong);
  border-color: var(--tm-pro-accent-strong);
  color: #fff;
  box-shadow: 0 1px 2px rgba(var(--tm-pro-accent-strong-rgb), .28);
}
body .btn.btn-primary:hover,
body .btn.btn-primary:focus-visible,
body .btn.btn-primary:active {
  background-color: var(--tm-pro-accent-hover);
  border-color: var(--tm-pro-accent-hover);
  box-shadow: 0 2px 8px rgba(var(--tm-pro-accent-strong-rgb), .34);
}
body .btn.btn-light-primary { background-color: var(--tm-pro-accent-soft); color: var(--tm-pro-accent-text); }
body .btn.btn-light-primary:hover { background-color: var(--tm-pro-accent-strong); color: #fff; }

body .btn.btn-secondary, body .btn.btn-light {
  background-color: var(--tm-pro-bg);
  border: 1px solid var(--tm-pro-border-strong);
  color: var(--tm-pro-text-muted);
}
body .btn.btn-secondary:hover, body .btn.btn-light:hover {
  background-color: var(--tm-pro-bg-sunken);
  color: var(--tm-pro-text);
}

body .form-control, body .form-select {
  border: 1px solid var(--tm-pro-border-strong);
  border-radius: var(--tm-r-md);
  background-color: var(--tm-pro-bg);
  color: var(--tm-pro-text);
  transition: border-color var(--tm-t-fast), box-shadow var(--tm-t-fast);
}
body .form-control:hover, body .form-select:hover { border-color: var(--tm-pro-text-light); }
body .form-control::placeholder { color: var(--tm-pro-text-light); }
/* Select2 draws its placeholder from Metronic's --bs-gray-500 (#99a1b7 = 2.42:1 on the
   solid input background it uses). It is placeholder TEXT, so it needs the same treatment
   as a native one; --bs-gray-500 is not overridden globally because it is used for
   non-text purposes elsewhere.
   text-muted, NOT text-light: Select2's solid input sits on #f5f8fa, and text-light is
   computed against pure WHITE (4.51) - on that tint it drops to 4.23 and misses. Same
   trap as the badges below. */
body .select2-container--bootstrap5 .select2-selection__placeholder,
body .select2-selection__placeholder { color: var(--tm-pro-text-muted) !important; }
body .form-label {
  font-weight: 600;
  color: var(--tm-pro-text-muted);
  margin-bottom: var(--tm-sp-2);
}

/* One focus ring for the whole application. Keyboard users get a visible and
   consistent target, and it satisfies the accessibility requirement at the
   same time. */
body .form-control:focus, body .form-select:focus, body .btn:focus-visible,
body a:focus-visible, body button:focus-visible, body [tabindex]:focus-visible,
body .form-check-input:focus {
  outline: none;
  border-color: var(--tm-pro-accent);
  box-shadow: 0 0 0 3px rgba(var(--tm-pro-accent-rgb), .18);
}
body .form-check-input:checked {
  background-color: var(--tm-pro-accent);
  border-color: var(--tm-pro-accent);
}

/* --------------------------------------------------------------------------
   6. DATA TABLES - the workhorse of this product
   -------------------------------------------------------------------------- */
body .table > :not(caption) > * > * { padding-block: .7rem; }

body .table > thead > tr > th,
body .table > thead th {
  background: var(--tm-pro-bg-alt);
  color: var(--tm-pro-text-muted);
  font-weight: 600;
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--tm-pro-border-strong);
  white-space: nowrap;
}
/* Arabic has no upper case, and letter-spacing breaks its joins */
[dir="rtl"] .table > thead th {
  letter-spacing: 0;
  text-transform: none;
  font-size: .8125rem;
}

body .table > tbody > tr { transition: background-color var(--tm-t-fast); }
body .table > tbody > tr:hover > td { background-color: var(--tm-pro-accent-soft); }
body .table > tbody > tr > td { border-bottom: 1px solid var(--tm-pro-border); vertical-align: middle; }
body .table > tbody > tr:last-child > td { border-bottom: 0; }

/* a totals row should read as a conclusion, not as another row */
body .table tfoot tr > *, body .table tr.total-row > *, body .table tr.tm-total > * {
  font-weight: 700;
  background: var(--tm-pro-bg-sunken);
  border-top: 2px solid var(--tm-pro-border-strong);
}

body .table-responsive { border-radius: var(--tm-r-md); }

/* --------------------------------------------------------------------------
   7. STATUS
   -------------------------------------------------------------------------- */
body .badge {
  border-radius: var(--tm-r-pill);
  font-weight: 600;
  padding: .35em .75em;
  letter-spacing: 0;
}
/* Metronic's light badges put a saturated colour on a ~10% tint of the same hue, and the
   pairing is far below AA - measured on the live pages:
       #17c653 on #dfffea = 2.12   (118 nodes on the chart-of-accounts tree alone)
       #f6c000 on #fff8dd = 1.58   (89 nodes)
       #f8285a on #ffeef3 = 3.45   (29 nodes)
   The base state tokens are NOT dark enough here either - 4.25 / 4.25 / 4.32 - because
   they were computed against pure white, and a coloured tint is dimmer than white, so the
   same foreground scores lower on it. These three values are computed against the ACTUAL
   tints, to 4.8. That is why they are literals and not var() references: a token whose
   partner is white cannot also serve a partner that is not white. */
body .badge-light-success, body .badge.badge-light-success,
body .text-success:not(.app-sidebar *) {
  color: var(--tm-badge-success-text) !important;
}
body .badge-light-warning, body .badge.badge-light-warning,
body .text-warning:not(.app-sidebar *) {
  color: var(--tm-badge-warning-text) !important;
}
body .badge-light-danger, body .badge.badge-light-danger,
body .text-danger:not(.app-sidebar *) {
  color: var(--tm-badge-danger-text) !important;
}

body .alert {
  border: 1px solid transparent;
  border-radius: var(--tm-r-md);
  border-inline-start-width: 3px;
  padding: var(--tm-sp-4) var(--tm-sp-5);
}
body .alert-success { border-inline-start-color: var(--tm-pro-success); }
body .alert-warning { border-inline-start-color: var(--tm-pro-warning); }
body .alert-danger  { border-inline-start-color: var(--tm-pro-danger); }
body .alert-info,
body .alert-primary { border-inline-start-color: var(--tm-pro-accent); }

/* --------------------------------------------------------------------------
   8. APPLICATION CHROME
   -------------------------------------------------------------------------- */
body .app-main, body .app-content { background: var(--tm-pro-bg-alt); }

/* ── SIDEBAR: a DARK surface inside a LIGHT theme ─────────────────────────────────
   The layout runs Metronic's data-kt-app-layout="dark-sidebar", so the navigation sits
   on dark navy - measured rgb(32,43,70), and rgb(38,46,89) behind an active row - while
   [data-bs-theme="dark"] is NOT set, so the dark token block above does not apply here.
   A rendered sweep (597 text nodes, 8 pages, compositing every translucent layer) found
   135 failures in this element. Identified from the DOM, they were exactly two things:

   1. `.menu-link` is an <a>, so Metronic's  a { color: rgba(var(--bs-link-color-rgb)) }
      handed it the light-theme indigo this file sets for page links - #4f46e5 on navy is
      **2.06**. `.menu-title` merely inherits it (its own rule is `color: inherit`), so
      targeting .menu-title was targeting the wrong element. Giving the sidebar its own
      link channel fixes it at the source, and the .active rule below still wins for the
      current row because it is more specific.
   2. `.menu-heading` (the section captions) is painted from Metronic's own
      --bs-app-sidebar-dark-menu-heading-color with !important - 2.43. Overriding that
      variable is cleaner than fighting the !important.

   The default `.menu-link` text, #8d98af, was NEVER a failure - it measures 4.84. An
   earlier attempt recoloured it anyway, to the computed "minimum that reaches 4.5",
   which lands on 4.4996 and fails a >= 4.5 test - 225 nodes made worse, and that rule
   also masked fix 1. Both values below are computed to **4.8, not 4.5**: never target
   the threshold itself. */
body .app-sidebar {
  --bs-link-color-rgb: 153, 148, 240;                        /* #9994f0 - 4.84 on the active row */
  --bs-app-sidebar-dark-menu-heading-color: #9696a7;         /* 4.83 on rgb(32,43,70) */
}

body .app-sidebar .menu .menu-link {
  border-radius: var(--tm-r-md);
  position: relative;
  transition: background-color var(--tm-t-fast), color var(--tm-t-fast);
}
body .app-sidebar .menu .menu-item .menu-link.active,
body .app-sidebar .menu .menu-item.here > .menu-link {
  background-color: rgba(var(--tm-pro-accent-rgb), .16);
  color: #fff;
  font-weight: 600;
}
/* a quiet marker on the leading edge says where you are without shouting */
body .app-sidebar .menu .menu-item .menu-link.active::before,
body .app-sidebar .menu .menu-item.here > .menu-link::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block: 6px;
  width: 3px;
  border-radius: var(--tm-r-pill);
  background: var(--tm-pro-accent);
}

body .app-header {
  background: var(--tm-pro-bg);
  border-bottom: 1px solid var(--tm-pro-border);
  box-shadow: none;
}

body .nav-tabs { border-bottom: 1px solid var(--tm-pro-border); gap: var(--tm-sp-1); }
body .nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-weight: 600;
  color: var(--tm-pro-text-muted);
  padding-inline: var(--tm-sp-4);
}
body .nav-tabs .nav-link:hover { color: var(--tm-pro-text); }
body .nav-tabs .nav-link.active {
  color: var(--tm-pro-accent-text);
  border-bottom-color: var(--tm-pro-accent);
  background: transparent;
}

body .pagination .page-link {
  border-radius: var(--tm-r-sm);
  border: 0;
  color: var(--tm-pro-text-muted);
  font-weight: 600;
}
body .pagination .page-item.active .page-link { background: var(--tm-pro-accent-strong); color: #fff; }

/* --------------------------------------------------------------------------
   9. RTL SCRIPT CORRECTNESS
   The only !important rules in this file, and they are here because these are
   not matters of taste.

   Arabic is a joined script: letter-spacing forces gaps between letters that
   are supposed to connect, so a heading set with tracking comes out visibly
   broken. Views in this codebase apply `letter-spacing` and `text-transform:
   uppercase` to table headers - correct for the English UI, wrong for the
   Arabic one - and several do it through an ID selector (#tm_datatable_logs
   thead th), which outranks any sane class-based override. Hence !important,
   confined to the elements that actually carry Arabic UI labels.

   Deliberately NOT global: the wordmark and other Latin display text keep
   their tracking, because for Latin it is a real design choice.
   -------------------------------------------------------------------------- */
[dir="rtl"] .table > thead th,
[dir="rtl"] .table > thead > tr > th,
[dir="rtl"] table thead th,
[dir="rtl"] .menu-title,
[dir="rtl"] .card-title,
[dir="rtl"] .form-label,
[dir="rtl"] .badge {
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* Chart labels. plugins.bundle.css ships
     .apexcharts-text, .apexcharts-title-text, .apexcharts-legend-text
       { font-family: Inter, Helvetica, "sans-serif" !important }
   - a literal stack, marked !important, containing no Arabic glyph. It outranks
   even the font-family the chart writes onto the element itself, so Arabic
   legends ("أصول", "التزامات") were the one piece of text on the dashboard in a
   different typeface from everything around them. This file loads after that
   bundle, so an equally-important rule here wins. */
.apexcharts-text, .apexcharts-title-text, .apexcharts-legend-text {
  font-family: var(--tm-font-ui) !important;
}
/* ApexCharts colours the legend LABEL with the series colour, so a dark series turned the
   label into 1.49:1 text on a dark ground. The coloured swatch next to it already carries
   the series cue; the words themselves read better neutral, and this token is theme-aware
   so it holds in both. */
.apexcharts-legend-text { color: var(--tm-pro-text-muted) !important; }

/* DataTables paints its own header background at a specificity that outranks
   section 6, so the header of a sortable grid is restated here. */
[dir] .table.dataTable > thead > tr > th,
[dir] table.dataTable > thead > tr > th {
  background-color: var(--tm-pro-bg-alt);
  color: var(--tm-pro-text-muted);
  border-bottom: 1px solid var(--tm-pro-border-strong);
}

/* --------------------------------------------------------------------------
   10. MOTION AND ACCESSIBILITY
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* Printed statements are a deliverable here: they go to auditors and to the regulator.
   Strip the application away and leave the figures.

   Every selector below carries the same `body` prefix as its screen counterpart in
   sections 4-8, and that is not cosmetic. Written as plain `.card` and `body` these
   rules were OUTRANKED BY THIS FILE'S OWN screen rules - `body .card` (0,1,1) beats
   `.card` (0,1,0) - so the hiding worked but nothing else did: a test print still came
   out with card borders, drop shadows, a grey page and 13px type. Found by actually
   flipping this block to `screen` in a throwaway frame and measuring, not by reading it.
   `!important` on the surfaces is deliberate: paper is white, and no component rule
   should be able to spend the auditor's toner. */
@media print {
  body .app-sidebar, body .app-header, body .app-footer, body .btn, body .card-toolbar,
  body .no-print, body nav, body .pagination,
  .app-sidebar, .app-header, .app-footer { display: none !important; }

  html, body { background: #fff !important; }
  body .app-main, body .app-content, body .app-wrapper { background: #fff !important; }
  /* The base font-size is deliberately NOT changed for print. An earlier draft set 11pt,
     which is LARGER than the 13px screen size and would widen every column in a
     statement table - the one thing that must not reflow on paper. The screen size
     prints legibly; leave it. */

  body .card, body .card.shadow-sm, body .modal-content {
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  body .card-body, body .card-header { padding-inline: 0; }
  body .card-footer { background: #fff !important; border-top: 1px solid #000; }

  /* A printed statement is read as a document: black on white, ruled, not tinted.
     The .dataTable variants are named explicitly because section 9's DataTables rule
     - [dir] .table.dataTable > thead > tr > th, specificity (0,3,3) - outranks the
     plain (0,1,3) form and kept the header rule grey on the first test print. */
  body .table > thead > tr > th, body .table > thead th,
  [dir] .table.dataTable > thead > tr > th,
  [dir] table.dataTable > thead > tr > th {
    background: #fff !important;
    /* !important because views set the header colour through an ID selector
       (#tm_datatable_logs thead th and friends), which no class-based rule can beat.
       Without it the header printed in #6c757d grey - legible, but weaker than the
       figures underneath it on a document that goes to an auditor. */
    color: #000 !important;
    border-bottom: 1px solid #000 !important;
  }
  body .table > tbody > tr > td { border-bottom: 1px solid #ddd; }
  body .table > tbody > tr:hover > td { background: #fff !important; }
  body .table tfoot tr > *, body .table tr.total-row > *, body .table tr.tm-total > * {
    background: #fff !important;
    border-top: 2px solid #000;
  }

  a[href]::after { content: ""; }
}

/* ============================================================================
   13 — THE UI SIZE GRID. Measured on /Dashboard: 20 distinct font sizes with sixteen
   steps between 1.008 and 1.053 — differences too small to read as hierarchy and large
   enough to read as carelessness. Most came from hand-picked rem values in the layout's
   own style block (0.82 / 0.85 / 0.9 / 0.95), which is to say from my earlier pass, not
   from Metronic. Metronic's own scale is left alone: rewriting a theme's type across 31
   pages and two themes buys less than it risks.

   At the 12.5px root this surface uses, the grid lands on whole pixels. Every snap below
   moves a size by 0.3px or less, so nothing shifts visibly; what changes is that four
   near-identical sizes become three deliberate ones.
   ============================================================================ */
/* (the four --tm-ui-* values moved to tm-tokens.css; the rules that use them stay here) */

/* ============================================================================
   14 — TRACKING ON THE ARABIC UI. Measured across ten menu pages: 64 text nodes carrying
   Arabic were letter-spaced, from -0.125px to +0.40625px. Arabic joins its letters, so
   tracking pulls the joins apart rather than refining the fit — the damage is to the word
   shape, not the rhythm. The values come from Latin habits carried into a shared
   stylesheet: an uppercase eyebrow, a breadcrumb, a muted link.

   Scoped to the RTL app shell, so the Latin marketing surface keeps its own tracking and
   the handful of Latin tokens inside the Arabic UI lose a fraction of a pixel — a trade
   that costs nothing and gives the Arabic its joins back. Anything that genuinely needs
   tracking can opt back in with .tm-keep-tracking.
   ============================================================================ */
html[dir="rtl"] body:not(.tm-marketing) :where(
  p, span, div, li, td, th, a, small, strong, b, label, dt, dd,
  h1, h2, h3, h4, h5, h6, button, .menu-title, .card-title, .form-label
):not(.tm-keep-tracking) {
  letter-spacing: normal;
}

/* 15. Skip-to-content link (PROJECT_UX_JOURNEY.md, section 13.1). Off-screen until it
   receives keyboard focus, then a pill at the top of the page. The target #kt_app_content
   carries tabindex="-1" so the jump actually moves focus. */
.tm-skip-link {
  position: absolute;
  top: -100px;
  inset-inline-start: 12px;
  z-index: 2000;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--tm-pro-accent, #4f46e5);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(17, 24, 39, .18);
  transition: top .15s ease;
}
.tm-skip-link:focus,
.tm-skip-link:focus-visible {
  top: 12px;
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* 16. Command palette (PROJECT_UX_JOURNEY.md, section 7.2) - Ctrl+K / Cmd+K over the rendered
   sidebar. Colours come from the theme tokens, so the dark theme needs no second block. */
.tm-cmdk-trigger-wrap { margin: 2px 0 6px; }
.tm-cmdk-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: 10px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12);
  color: #c7d2fe; font: inherit; font-size: var(--tm-ui-sm, 12px); text-align: start; cursor: pointer;
  transition: background var(--tm-t-fast, .12s), border-color var(--tm-t-fast, .12s);
}
.tm-cmdk-trigger:hover, .tm-cmdk-trigger:focus-visible { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .28); color: #fff; }
.tm-cmdk-trigger .bi { font-size: 13px; opacity: .85; }
.tm-cmdk-trigger-text { flex: 1 1 auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tm-cmdk-trigger-kbd, .tm-cmdk-kbd, .tm-cmdk-hints kbd {
  font: 600 10px/1 var(--tm-font-ui, inherit); padding: 3px 6px; border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08); color: inherit; white-space: nowrap;
}
[data-kt-app-sidebar-minimize="on"] .tm-cmdk-trigger-text,
[data-kt-app-sidebar-minimize="on"] .tm-cmdk-trigger-kbd { display: none; }
[data-kt-app-sidebar-minimize="on"] .tm-cmdk-trigger { justify-content: center; padding: 9px 0; }

.tm-cmdk[hidden] { display: none; }
.tm-cmdk { position: fixed; inset: 0; z-index: 1085; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.tm-cmdk-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .45); backdrop-filter: blur(2px); }
.tm-cmdk-panel {
  position: relative; width: min(640px, 100%); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--tm-pro-bg, #fff); color: var(--tm-pro-text, #111827);
  border: 1px solid var(--tm-pro-border, #e5e7eb); border-radius: var(--tm-r-lg, 14px);
  box-shadow: var(--tm-sh-3, 0 24px 60px rgba(17, 24, 39, .25)); overflow: hidden;
}
.tm-cmdk-search { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--tm-pro-border, #e5e7eb); }
.tm-cmdk-search .bi { color: var(--tm-pro-text-muted, #6b7280); font-size: 16px; }
.tm-cmdk-input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; color: inherit; font: inherit; font-size: var(--tm-ui-lg, 15px); }
.tm-cmdk-input::placeholder { color: var(--tm-pro-text-muted, #6b7280); }
.tm-cmdk-kbd, .tm-cmdk-hints kbd { border-color: var(--tm-pro-border, #e5e7eb); background: var(--tm-pro-bg-alt, #f3f4f6); color: var(--tm-pro-text-muted, #6b7280); }
.tm-cmdk-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1 1 auto; }
.tm-cmdk-section { padding: 10px 12px 4px; font-size: var(--tm-ui-xs, 11px); font-weight: 700; color: var(--tm-pro-text-muted, #6b7280); }
.tm-cmdk-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.tm-cmdk-item.is-active { background: var(--tm-pro-accent-soft, rgba(79, 70, 229, .1)); color: var(--tm-pro-accent-text, inherit); }
.tm-cmdk-title { font-weight: 600; font-size: var(--tm-ui-md, 13px); }
.tm-cmdk-meta { font-size: var(--tm-ui-xs, 11px); color: var(--tm-pro-text-muted, #6b7280); white-space: nowrap; }
.tm-cmdk-empty { padding: 28px 12px; text-align: center; color: var(--tm-pro-text-muted, #6b7280); }
.tm-cmdk-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--tm-pro-border, #e5e7eb); font-size: var(--tm-ui-xs, 11px); color: var(--tm-pro-text-muted, #6b7280); }
.tm-cmdk-hints { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
body.tm-cmdk-open { overflow: hidden; }
@media (max-width: 640px) { .tm-cmdk { padding: 8px; } .tm-cmdk-panel { max-height: 90vh; } .tm-cmdk-hints { display: none; } }
