/*
 * edify-base.css — Global base styles.
 * Scoped carefully to NOT break MudBlazor/LeptonX structure.
 * Only targets: body text defaults, headings font stack, focus-visible ring,
 * reduced-motion kill-switch, and utility helpers.
 * All values reference var(--token) — NO hard-coded hex/size/font here.
 */

/* ── Box-sizing universal reset ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

/* ── Page scroll container (CR-049 / LAYOUT-FW-1) ──────────────────────
 * The document scrolls on <html> (the shell has no inner scroller). Reserving the scrollbar's gutter always means a scrollbar
 * appearing or disappearing (a tab with a longer table, a drawer closing) never narrows the content and re-flows every grid. */
html {
  scrollbar-gutter: stable;
}

/* ── Fixed-count card rows (CR-049 / LAYOUT-FW-1 fix round 1) ──────────────────────────────────────────────────────────────────────
 * A row with a KNOWN number of items (a KPI strip, a set of option cards) must never strand a lone card on its own line: 4 items go
 * 4 -> 2 -> 1 (never 3+1), 6 go 6 -> 3 -> 2 -> 1, and so on. `repeat(auto-fit, minmax(<min>, 1fr))` cannot do that (it steps through every
 * count in between), and a media/container query would key off the window or a wrapper. These classes are a PURE function of the row's own
 * width: the minmax() minimum is max() of one term per allowed count, and each term is switched off (a negative length) once the row is wide
 * enough for the next count up. The multiplier 1000000 turns "a fraction of a px short" (layout units are 1/64px) into a length wider than any row, so the switch is a step, not a ramp.
 * The 0.5px keeps rounding from ever dropping a column. Percentages resolve against the grid's own (definite) inline size, so no JS, no
 * container query, no breakpoint; the layout never depends on the previous width (no hysteresis) and is direction-neutral (RTL).
 *   --row-min  the narrowest a card may be (default 176px). The widest count is reached at N * min + (N-1) * gap.
 *   --row-gap  the gap between cards (default 14px). Set both on the row; the class itself sets `gap`.
 * Put the class on the row and set ONLY --row-min / --row-gap in the page's own CSS - never `grid-template-columns` on the same element
 * (a scoped page rule outranks these classes and silently reinstates the stranding). For a list whose item count VARIES, use
 * `repeat(auto-fill, minmax(min(100%, <min>), 1fr))` in the page instead (a lone item then keeps a card width instead of stretching).
 *   .edify-row-3  3 items: 3 -> 1
 *   .edify-row-4  4 items: 4 -> 2 -> 1
 *   .edify-row-5  5 items: 5 -> 3 -> 1   (3+2 is the only balanced split of five; a 2-column step would strand a card)
 *   .edify-row-6  6 items: 6 -> 3 -> 2 -> 1
 *   .edify-row-scroll  any count that must never wrap (a 7-day week): one row, every card at least --row-min, its own horizontal scroll */
.edify-row-3,
.edify-row-4,
.edify-row-5,
.edify-row-6 {
  display: grid;
  gap: var(--row-gap, 14px);
}

.edify-row-3 {
  grid-template-columns: repeat(auto-fit, minmax(
    max(
      calc(100% / 3 - var(--row-gap, 14px) * 2 / 3 - 0.5px),
      min(100%, calc((3 * var(--row-min, 176px) + 2 * var(--row-gap, 14px) - 100%) * 1000000))
    ), 1fr));
}

.edify-row-4 {
  grid-template-columns: repeat(auto-fit, minmax(
    max(
      calc(25% - var(--row-gap, 14px) * 3 / 4 - 0.5px),
      min(calc(50% - var(--row-gap, 14px) / 2 - 0.5px), calc((4 * var(--row-min, 176px) + 3 * var(--row-gap, 14px) - 100%) * 1000000)),
      min(100%, calc((2 * var(--row-min, 176px) + var(--row-gap, 14px) - 100%) * 1000000))
    ), 1fr));
}

.edify-row-5 {
  grid-template-columns: repeat(auto-fit, minmax(
    max(
      calc(20% - var(--row-gap, 14px) * 4 / 5 - 0.5px),
      min(calc(100% / 3 - var(--row-gap, 14px) * 2 / 3 - 0.5px), calc((5 * var(--row-min, 176px) + 4 * var(--row-gap, 14px) - 100%) * 1000000)),
      min(100%, calc((3 * var(--row-min, 176px) + 2 * var(--row-gap, 14px) - 100%) * 1000000))
    ), 1fr));
}

.edify-row-6 {
  grid-template-columns: repeat(auto-fit, minmax(
    max(
      calc(100% / 6 - var(--row-gap, 14px) * 5 / 6 - 0.5px),
      min(calc(100% / 3 - var(--row-gap, 14px) * 2 / 3 - 0.5px), calc((6 * var(--row-min, 176px) + 5 * var(--row-gap, 14px) - 100%) * 1000000)),
      min(calc(50% - var(--row-gap, 14px) / 2 - 0.5px), calc((3 * var(--row-min, 176px) + 2 * var(--row-gap, 14px) - 100%) * 1000000)),
      min(100%, calc((2 * var(--row-min, 176px) + var(--row-gap, 14px) - 100%) * 1000000))
    ), 1fr));
}

.edify-row-scroll {
  display: grid;
  gap: var(--row-gap, 10px);
  grid-auto-flow: column;
  grid-auto-columns: minmax(var(--row-min, 96px), 1fr);
  overflow-x: auto;
}

/* ── Body base ───────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 450;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* FIX-QA7 F1 (ed-jaxl, root cause) - the page text colour is the TEXT token in every theme.
 * Measured in a browser: LeptonX's `side-menu/css/bootstrap-dim.css` ships `body { color: var(--bs-body-color) }` (#686b6e, theme-blind) and its
 * stylesheet is emitted AFTER ours, so on equal specificity (0,0,1) it beat the `body` rule above and every inheriting surface (drawer values,
 * overlays, anything without its own colour) rendered grey in BOTH themes: 3.3:1 on the dark surface. `html body` is (0,0,2) and the layout-class form
 * is (0,1,2): both outrank any bare `body` rule whatever the load order, so no !important and no order dependency. */
html body,
html body.abp-application-layout {
  color: var(--text);
}

/* ── Heading font stack — Sora for display headings ─────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  margin: 0;
}

/* FIX-QA2 (R5, ed-wafa) - card headings keep the TEXT token in every theme.
 * Root cause (measured in a browser, dark theme): LeptonX's Bootstrap bundle ships `.card .card-title { color: #062a44 }`
 * (and `#eee` in its dark bundle). Its AppearanceStyles <link> is emitted AFTER our scoped CSS and the app's dark theme
 * is [data-theme], not LeptonX's own, so the LIGHT bundle is the one that loads: on equal specificity (0,2,0) it won
 * the cascade and the heading rendered rgb(6,42,68) on a #121829 surface. The body-prefixed selector is one type
 * selector stronger (0,2,1), so the token wins whatever the stylesheet load order is. Colour only - sizes/weights stay
 * each page's own. */
body .card .card-title {
  color: var(--text);
}

p {
  margin: 0;
}

/* ── Links ───────────────────────────────────────────────────────────── */
a {
  color: inherit;
  text-decoration: none;
}

/* ── Buttons inherit font ────────────────────────────────────────────── */
button {
  font-family: inherit;
  cursor: pointer;
}

/* ── Focus ring ──────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid transparent;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* CR-038 — text-entry fields keep the soft halo (--ring-field), not the strong control ring. A field turns its border Iris on focus
 * and that border carries the contrast; a second strong ring on top of it would draw three lines. This is the FALLBACK for a field
 * with no rule of its own (a bare input, the inner input of a MudBlazor or Syncfusion field). :where() keeps the specificity at (0,1,0),
 * the same as the global rule above, and the rule comes after it, so it replaces the global ring on fields only and every page's own
 * field rule (a class plus :focus) still wins. Checkboxes, radios, range, file, colour and button-like inputs are NOT fields: they
 * have no border change, so they keep the strong ring from the global rule. SharedUi3_FocusRingTests T3 welds this rule. */
:where(
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"],
            [type="button"], [type="submit"], [type="reset"], [type="image"]),
  select,
  textarea
):focus-visible {
  box-shadow: var(--ring-field);
}

/* ── Reduced motion kill-switch ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ── Utility helpers ─────────────────────────────────────────────────── */

/* Tabular numerics — for fees, counts, ledger figures */
.tnum {
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
}

/* Mono numerics with tabular figures */
.mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
}

/* Muted / soft text */
.text-muted  { color: var(--text-muted); }
.text-soft   { color: var(--text-soft); }
.text-strong { color: var(--text); font-weight: 600; }

/* Semantic color utilities */
.text-success { color: var(--success-fg); }
.text-warning { color: var(--warning-fg); }
.text-danger  { color: var(--danger-fg); }
.text-info    { color: var(--info-fg); }
.text-primary { color: var(--primary); }

/* FIX-6b (ed-5zq7.6.2) R4 — shared directional-glyph mirror. Apply to any
 * icon whose meaning is genuinely directional (e.g. "go forward" →, a
 * pagination chevron) — NOT to symmetric glyphs (+ add icons, spinners,
 * .chev-up/.sort-desc 180° rotations — those are direction-neutral by
 * construction and must NOT carry this class; ed-q68p's confirmed-sound
 * list is the guide). Horizontal flip only; icon geometry is otherwise
 * unaffected. Do NOT combine with another `transform` on the same
 * element -- CSS `transform` is a single property, so a later declaration
 * silently WINS rather than composing (Gate E round 6, all five current
 * .rtl-mirror sites verified clean). */
[dir="rtl"] .rtl-mirror {
  transform: scaleX(-1);
}

/* FIX-6b (ed-5zq7.6.2) R4-1/R5, CORRECTED FIX-6c Gate D (R2-2 REJECT — reviewer
 * proved the class was never actually closed) — canonical L2 (secondary-language)
 * input font-family fix, shared by every page that has a bilingual-name form
 * (StudentForm/Admissions/StaffHr/Drivers, more to come). Inputs are form controls;
 * the base class each page uses (.input, .field-inp, …) sets font-family: inherit,
 * which is dead on an LTR page (A7: a body rule wins the inheritance tie before
 * --font-sans is ever reached). ONE unscoped rule here (vs. duplicating the same
 * rule in every page-scoped .razor.css) is the single point of truth for present
 * AND future L2 input sites.
 *
 * THE REAL GUARANTEE (corrected — the previous comment overclaimed): Blazor CSS
 * isolation appends a `[b-scope]` attribute selector to every rule in a page's
 * .razor.css, so a page-scoped base-input rule (e.g. `.input[b-xxx]` or
 * `.field-inp[b-xxx]`) already carries specificity (0,0,2,0) — ONE class + ONE
 * attribute selector, not (0,0,1,0). The doubled class selector
 * `.l2-input.l2-input` is ALSO (0,0,2,0) — an exact TIE, not a win. App.razor loads
 * edify-base.css BEFORE the generated scoped-css bundle
 * (Byteforce.Edify.Blazor.styles.css), so on a tie the LATER-loaded scoped rule
 * wins the cascade — meaning this rule had been inert on every .field-inp page
 * (Admissions/StaffHr/Drivers) since it was introduced; it only happened to read
 * correctly on StudentForm because that page ALSO carried its own page-scoped
 * `.input.l2-input` rule (now restored below, defense in depth) at the same (0,0,2,0)
 * tie, which — being itself the LATER-loaded (page-scoped) rule of the tie against
 * a plain `.input[b-xxx]` — won on its own.
 *
 * THE FIX: `input.l2-input.l2-input` adds a TYPE selector (0,0,2,1) — strictly
 * greater than any (0,0,2,0) scoped rule regardless of the page's base class name
 * or load order, because it is an <input> element being styled in every one of
 * these sites. This beats the scoped tie unconditionally, closing the class for
 * real. See Fix6c_TokenDriftTests' generated-bundle specificity weld. */
input.l2-input.l2-input {
  font-family: var(--font-sans);
}

/* ── Badge component ─────────────────────────────────────────────────── */
.edify-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
}

.edify-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.edify-badge-success { background: var(--success-bg); color: var(--success-fg); }
.edify-badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.edify-badge-danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.edify-badge-info    { background: var(--info-bg);    color: var(--info-fg); }
.edify-badge-primary { background: var(--primary-soft); color: var(--primary); }
.edify-badge-neutral {
  background: var(--surface-sunken);
  color: var(--text-soft);
  border: 1px solid var(--border);
}

/* ── Avatar ──────────────────────────────────────────────────────────── */
.edify-avatar {
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: var(--n-0);
  flex: none;
  font-family: var(--font-display);
}

/* ── Card ────────────────────────────────────────────────────────────── */
.edify-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  overflow: hidden;
}

.edify-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.edify-card-head h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

/* EdifyCard's header-right slot (buttons, badges): pushed to the inline end, laid out in a row (FIX-QA4 R7, ed-z34s: was an inline style). */
.edify-card-head .card-actions {
  margin-inline-start: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.edify-card-body {
  padding: 18px;
}

/* ── Form: required-fields notice, field error, disabled-reason hint (FIX-QA4 R3, ed-qpit) ──────────────────────────────────────────
   A Save that stays disabled until the form is valid always says why: the notice (EdifyInvalidFieldsNotice) is an actionable
   "N required field(s) need attention" button that reveals every field's error and focuses the first invalid field; EdifyFieldError is
   the per-field message; .edify-form-hint is a plain reason line for a disabled action that has no field to fix (a finalized register,
   no students to mark). Tokens only; logical properties, so they flip in RTL. */
.edify-invalid-notice {
  display: inline-flex;
  align-items: center;
  margin-inline-end: auto;
  min-width: 0;
  font-size: 13px;
}

/* FIX-QA4 Gate D NOTE: the notice and the form hints are PERSISTENT live-region containers (present at first render so a screen reader
 * announces text that appears inside them). While empty they must take no space - not even a flex gap - but stay in the accessibility tree
 * (display:none would remove them): the standard visually-hidden recipe. */
.edify-invalid-notice:empty,
.edify-form-hint:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.edify-invalid-notice-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 4px 8px;
  margin-inline-start: -8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  text-align: start;
  color: var(--warning-fg);
  cursor: pointer;
  border-radius: var(--r-sm);
  min-width: 0;
}

.edify-invalid-notice-btn:hover {
  background: var(--warning-bg);
}

.edify-invalid-notice-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.edify-invalid-notice-text {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.edify-field-error {
  display: block;
  margin-block-start: 4px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--danger-fg);
}

/* FIX-QA4 Gate D MINOR-1: the invalid-field border/ring must WIN over a page's own field class. Blazor CSS isolation compiles a page's
 * `.field-inp { border: ... }` to `.field-inp[b-xxxx]` = (0,2,0) (one class + the scope attribute), which beat the old
 * `input[aria-invalid="true"]` (0,1,1) - so the red border never showed on a scoped page. The doubled attribute selector below is
 * (0,2,1): strictly greater than any bare scoped base-input rule, whatever its class name or load order (the same arithmetic as the
 * `input.l2-input.l2-input` rule above). :is() takes its most specific argument, so the type part counts once. The generated-bundle
 * weld is FixQa4_InvalidFieldSpecificityTests. */
:is(input, select, textarea)[aria-invalid="true"][aria-invalid] {
  border-color: var(--danger);
  box-shadow: var(--ring-danger);
}

.edify-form-hint {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-soft);
}

/* ── KPI / Stat tile ─────────────────────────────────────────────────── */
.edify-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--sh-xs);
}

.edify-kpi .kpi-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.edify-kpi .kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
}

.edify-kpi .kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.edify-kpi .kpi-value {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 12px 0 4px;
  font-feature-settings: "tnum" 1;
}

.edify-kpi .kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
}

.edify-kpi .kpi-delta.up   { color: var(--success-fg); }
.edify-kpi .kpi-delta.down { color: var(--danger-fg); }
.edify-kpi .kpi-delta.flat { color: var(--text-muted); }

/* KPI icon semantic variants (for EdifyStatCard) */
.edify-kpi .kpi-icon.kpi-icon-success { background: var(--success-bg); color: var(--success-fg); }
.edify-kpi .kpi-icon.kpi-icon-warning { background: var(--warning-bg); color: var(--warning-fg); }
.edify-kpi .kpi-icon.kpi-icon-danger  { background: var(--danger-bg);  color: var(--danger-fg); }

/* ── Button base ─────────────────────────────────────────────────────── */
.edify-btn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  transition: all 140ms var(--ease);
  white-space: nowrap;
  cursor: pointer;
  text-transform: none;
}

.edify-btn svg { width: 17px; height: 17px; }
.edify-btn:active { transform: translateY(1px); }

.edify-btn-primary {
  background: var(--primary);
  color: var(--n-0);
  box-shadow: var(--sh-sm);
}
.edify-btn-primary:hover { background: var(--primary-hover); }

.edify-btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.edify-btn-outline:hover { background: var(--surface-sunken); }

.edify-btn-ghost {
  background: transparent;
  color: var(--text-soft);
}
.edify-btn-ghost:hover {
  background: var(--surface-sunken);
  color: var(--text);
}

.edify-btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: var(--r-sm);
}

/* ── Active-nav rail (the signature gradient left-bar) ───────────────── */
/*
 * Usage: position:relative on the nav container; each item has class "navitem".
 * Active item gets "is-active" → the ::before pseudo-element renders
 * the 4px gradient bar on the leading edge (inset-inline-start for RTL).
 */
.edify-navitem {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: var(--sb-text);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 140ms var(--ease), color 140ms var(--ease);
  cursor: pointer;
  text-decoration: none;
}

.edify-navitem svg {
  width: 18.5px;
  height: 18.5px;
  opacity: 0.82;
  flex: none;
}

.edify-navitem:hover {
  background: color-mix(in srgb, var(--n-0) 5%, transparent);
  color: var(--sb-text-strong);
}

.edify-navitem.is-active {
  background: color-mix(in srgb, var(--n-0) 8%, transparent);
  color: var(--n-0);
}

.edify-navitem.is-active svg { opacity: 1; }

/* The gradient active rail — uses logical property for RTL correctness */
.edify-navitem.is-active::before {
  content: "";
  position: absolute;
  inset-inline-start: -12px;  /* RTL-safe: flips to trailing edge in dir="rtl" */
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: var(--r-full);
  background: var(--brand-gradient);
}

.edify-navitem .nav-count {
  margin-inline-start: auto;
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--n-0) 10%, transparent);
  color: var(--n-0);
  padding: 1px 7px;
  border-radius: var(--r-full);
}

.edify-navitem.is-active .nav-count {
  background: color-mix(in srgb, var(--n-0) 18%, transparent);
}

/* Scrollbar styling for dark sidebar */
.edify-sb-nav::-webkit-scrollbar { width: 6px; }
.edify-sb-nav::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--n-0) 10%, transparent);
  border-radius: 3px;
}

/* ──────────────────────────────────────────────────────────────────────── */
/* DS-3 COMPONENT PRIMITIVES                                                */
/* ──────────────────────────────────────────────────────────────────────── */

/* ── Button: danger + WhatsApp variants ──────────────────────────────── */
.edify-btn-danger {
  background: var(--danger);
  color: var(--n-0);
  box-shadow: var(--sh-sm);
}
.edify-btn-danger:hover { background: var(--danger-fg); }

.edify-btn-whatsapp {
  background: var(--whatsapp);
  color: var(--n-0);
  box-shadow: var(--sh-sm);
}
.edify-btn-whatsapp:hover { filter: brightness(0.96); }

/* CR-034 / ed-44wo — the keyboard focus ring on every clickable control. ONE ring, the design system's --ring (doc 05 section 13). The
 * mockups define a soft 3px halo under that name; CR-038 made --ring the stronger two-layer control ring and moved the halo to --ring-field,
 * which fields use. The rule selects ELEMENTS, not class names: buttons, links and the ARIA
 * button / tab / menuitem roles. A class list leaks by construction: the pages name their own button classes (.sp-docs-btn,
 * .rp-btn-primary, ...), most of them filled with a resting --sh-sm that beats the global :focus-visible ring (0,1,0), and a
 * new class would be unringed until someone remembered to list it. The element selectors cannot miss a button.
 * !important is deliberate, on both declarations: a page's scoped rule (e.g. .btn-primary[b-xxxx], (0,2,0) or more, in a
 * bundle that loads after this file) must never hide a focus indicator or swap it for another look (an outline, a green ring).
 * Mouse clicks do not match :focus-visible, so they are unaffected. Inputs, selects and textareas are NOT listed: they draw
 * their own border and ring, and a second ring would double up. Elements keep their own border-radius.
 * CR-038: --ring is now the two-layer control ring (a 2px gap in the surface colour, then a 2px solid ring, 3:1 or more on both themes);
 * fields use --ring-field (the old soft halo). SharedUi2_MobileTokensAndRingTests T3 welds this: the rule, every button-like element
 * in the markup being one of these elements, and no other !important box-shadow / outline in the stylesheets;
 * SharedUi3_FocusRingTests welds the tokens, the order of the three rules below and the field/control split. */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
[role="menuitem"]:focus-visible,
summary:focus-visible { outline: 2px solid transparent !important; box-shadow: var(--ring) !important; }

/* Tabs draw the ring INSIDE the tab (--ring-inset: 2px, the ring colour): a tab strip scrolls (overflow-x: auto) and clips an outer ring
 * at its top and bottom edges. Same specificity as the rule above and both !important, so this rule must stay AFTER it (source order
 * decides; T3d welds that). */
[role="tab"]:focus-visible { outline-offset: -2px !important; box-shadow: var(--ring-inset) !important; }

/* CR-038 — the opt-in inset ring, for a focusable element whose parent clips an outer ring (overflow: hidden or a scrolling strip) and
 * that is not a role="tab": a list row inside a .card, a link in a scrolling tab strip. Put the class on the element itself.
 * (0,2,0) beats the element rule's a:focus-visible / button:focus-visible (0,1,1) whatever the source order; it sits here, after the
 * element rule, so a reader finds the three ring rules together. Same box-shadow as the tab rule.
 * The outline is TRANSPARENT, not none: it paints nothing in normal colours, and under forced colors (Windows High Contrast), which drops
 * box-shadows and keeps outlines, the browser paints it in the system colour. `outline: none` here left a focused row (Transport's
 * div.routeitem, role="option") with no focus indicator at all (CR-038 Gate D, M1). The offset pulls the outline inside the element,
 * where the parent cannot clip it, like the inset shadow. */
.edify-focus-inset:focus-visible { outline: 2px solid transparent !important; outline-offset: -2px !important; box-shadow: var(--ring-inset) !important; }

/* Button loading spinner */
.edify-btn .btn-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid color-mix(in srgb, var(--n-0) 40%, transparent);
  border-top-color: var(--n-0);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex: none;
}
.edify-btn-outline .btn-spinner,
.edify-btn-ghost .btn-spinner {
  border-color: color-mix(in srgb, var(--text) 15%, transparent);
  border-top-color: var(--text-soft);
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-spinner { animation: none !important; opacity: 0.6; }
}

/* ── Tabs ────────────────────────────────────────────────────────────── */
/*
 * .edify-tabs        — the tab strip (flex row + bottom border)
 * .edify-tab         — individual tab button
 * .edify-tab.is-active — selected tab: primary color + 3px gradient underline
 * .edify-tab-panels  — content host; hides/shows panels
 */
.edify-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.edify-tabs::-webkit-scrollbar { display: none; }

.edify-tab {
  position: relative;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-muted);
  background: none;
  border: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: color 120ms var(--ease);
  flex: none;
}
.edify-tab:hover { color: var(--text); }
.edify-tab.is-active { color: var(--primary); }

/* The 3px gradient underline motif on the active tab */
.edify-tab.is-active::after {
  content: "";
  position: absolute;
  inset-inline-start: 14px;
  inset-inline-end: 14px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand-gradient);
}

/* Tab badge/count pill */
.edify-tab .tab-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-sunken);
  color: var(--text-soft);
  border: 1px solid var(--border);
  padding: 0 7px;
  border-radius: var(--r-full);
}
.edify-tab.is-active .tab-count {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-soft-border);
}

/* Tab panel host */
.edify-tab-panels { padding: 0; }
.edify-tab-panel  { display: none; }
.edify-tab-panel.is-active { display: block; }

/* ── Data table (.ltable) ─────────────────────────────────────────────── */
.edify-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}

.edify-ltable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

/* Sticky uppercase header */
.edify-ltable thead th {
  text-align: start;
  padding: 11px 16px;
  background: var(--surface-sunken);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
  user-select: none;
}

/* Numeric column alignment (mono) */
.edify-ltable th.col-num,
.edify-ltable td.col-num {
  text-align: end;
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

/* Body cells */
.edify-ltable tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.edify-ltable tbody tr {
  transition: background 120ms var(--ease);
}
.edify-ltable tbody tr:hover { background: var(--surface-sunken); }
.edify-ltable tbody tr:last-child td { border-bottom: none; }

/* Row selection: highlight + leading gradient active-rail */
.edify-ltable tbody tr.is-selected { background: var(--primary-soft); }
.edify-ltable tbody tr.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}

/* Debit/Credit semantic helpers */
.edify-ltable .col-cr,
.text-cr { color: var(--success-fg); font-weight: 600; }

.edify-ltable .col-dr,
.text-dr { color: var(--danger-fg); font-weight: 600; }

/* Reference / date columns in mono */
.edify-ltable .col-ref,
.edify-ltable .col-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-soft);
  white-space: nowrap;
}

/* Footer row */
.edify-ltable tfoot td {
  padding: 13px 16px;
  background: var(--surface-2);
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
}

/* ── Category dot ─────────────────────────────────────────────────────── */
.edify-cat-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

/* Category label wrapper (dot + text) */
.edify-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}
.edify-cat-fee   { background: var(--success-bg); color: var(--success-fg); }
.edify-cat-sal   { background: var(--info-bg);    color: var(--info-fg); }
.edify-cat-util  { background: var(--warning-bg); color: var(--warning-fg); }
.edify-cat-sup   { background: var(--primary-soft); color: var(--primary); }
.edify-cat-misc  { background: var(--surface-sunken); color: var(--text-soft); }

/* ── Empty state ──────────────────────────────────────────────────────── */
.edify-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
}

.edify-empty .empty-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.edify-empty .empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.edify-empty .empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.5;
}

/* The action row (the Clear-filters button, or the host page's data-empty CTA). This is a GLOBAL rule on purpose:
   EdifyEmptyState has no .razor.css, so a page-scoped rule can never reach it (Gate E MAJOR-1). The edify-tokens set
   defines no spacing scale, so the 8px step is the same literal rhythm .edify-empty uses for its own gap/padding. */
.edify-empty .empty-actions {
  margin-block-start: 8px;
}

/* ── Skeleton / shimmer ────────────────────────────────────────────────── */
.edify-skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-sunken) 25%,
    var(--border) 50%,
    var(--surface-sunken) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .edify-skeleton {
    animation: none !important;
    background: var(--surface-sunken);
  }
}

.edify-skeleton-text  { height: 14px; margin-bottom: 6px; }
.edify-skeleton-title { height: 20px; margin-bottom: 8px; }
.edify-skeleton-avatar {
  border-radius: 50%;
  width: 36px;
  height: 36px;
  flex: none;
}

/* ── Alert (inline error) ────────────────────────────────────────────── */
.edify-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid transparent;
}

.edify-alert .alert-icon {
  width: 20px;
  height: 20px;
  flex: none;
  margin-top: 1px;
}

.edify-alert .alert-body { flex: 1; }
.edify-alert .alert-title { font-weight: 600; margin-bottom: 2px; }
.edify-alert .alert-message { opacity: 0.9; white-space: pre-line; }
/* FIX-QA1: a multi-line validation message (FormatAny joins with a line break) on a non-alert error element. */
.edify-prewrap { white-space: pre-line; }

.edify-alert .alert-retry {
  margin-top: 8px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.edify-alert .alert-retry:hover { opacity: 1; }

.edify-alert-error {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}
.edify-alert-warning {
  background: var(--warning-bg);
  color: var(--warning-fg);
  border-color: color-mix(in srgb, var(--warning) 25%, transparent);
}
.edify-alert-info {
  background: var(--info-bg);
  color: var(--info-fg);
  border-color: color-mix(in srgb, var(--info) 25%, transparent);
}
.edify-alert-success {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: color-mix(in srgb, var(--success) 25%, transparent);
}

/* ── MudBlazor input / select restyling ──────────────────────────────── */
/*
 * Scoped to .edify-mud-inputs so we only restyle inputs inside product
 * surfaces. Does NOT touch LeptonX admin (which lives outside this class).
 * Wrapping product pages in <div class="edify-mud-inputs"> activates these.
 */
.edify-mud-inputs .mud-input-root,
.edify-mud-inputs .mud-input {
  background: var(--surface) !important;
  color: var(--text) !important;
}

.edify-mud-inputs .mud-input-outlined .mud-input-outlined-border {
  border-color: var(--border-strong) !important;
  border-radius: var(--r-md) !important;
}

.edify-mud-inputs .mud-input-outlined:hover .mud-input-outlined-border {
  border-color: var(--primary) !important;
}

.edify-mud-inputs .mud-input-outlined.mud-input-focused .mud-input-outlined-border {
  border-color: var(--primary) !important;
  box-shadow: var(--ring-field) !important;
}

.edify-mud-inputs .mud-label {
  color: var(--text-muted) !important;
  font-family: var(--font-sans) !important;
  font-size: 13px !important;
}

.edify-mud-inputs .mud-select-input {
  background: var(--surface) !important;
  border-radius: var(--r-md) !important;
}

/* MudChip restyled to badge style */
.edify-mud-inputs .mud-chip {
  border-radius: var(--r-full) !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  height: 24px !important;
  font-family: var(--font-sans) !important;
}

/* MudSwitch thumb to primary color */
.edify-mud-inputs .mud-switch-thumb {
  background: var(--surface) !important;
}
.edify-mud-inputs .mud-switch-track {
  background: var(--border-strong) !important;
}
.edify-mud-inputs input:checked ~ .mud-switch-track {
  background: var(--primary) !important;
}

/* MudSnackbar message typography */
.mud-snackbar .mud-snackbar-content {
  font-family: var(--font-sans) !important;
  font-size: 13.5px !important;
}

/* MudDialog: restyle to surface / border / shadow tokens */
.mud-dialog {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-xl) !important;
  box-shadow: var(--sh-lg) !important;
  color: var(--text) !important;
}
.mud-dialog .mud-dialog-title {
  font-family: var(--font-display) !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  color: var(--text) !important;
  padding: 20px 24px 0 !important;
}
.mud-dialog .mud-dialog-content {
  padding: 16px 24px !important;
  color: var(--text-soft) !important;
  font-size: 13.5px !important;
}
.mud-dialog .mud-dialog-actions {
  padding: 12px 24px 20px !important;
  gap: 10px !important;
}
