/*
    App-wide font family. The Figma design uses "Open Sans", so we override MudBlazor's
    default (Roboto) for every typography variant plus non-MudBlazor content.

    MudBlazor injects the --mud-typography-*-family variables at runtime via the theme
    provider, which lands later in the DOM than this static stylesheet. !important therefore
    wins the variable cascade regardless of source order (matching the framework-wide override
    pattern already used in CustomChanges.css). If a single spot ever needs a different font,
    make that an explicit, local exception rather than changing this default.
*/
:root {
    --mud-typography-default-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-h1-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-h2-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-h3-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-h4-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-h5-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-h6-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-subtitle1-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-subtitle2-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-body1-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-body2-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-button-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-caption-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    --mud-typography-overline-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
}

/*
    There used to be a rule here giving the shrunk floating label of an OUTLINED field a solid
    surface background, because an outlined label shrinks onto the top border and the border line
    would otherwise cut through the text.

    It is gone because nothing renders that label any more. Since the 2026-08 UI/UX decision every
    input is Variant.Filled except the search fields, and a filled label shrinks INTO the field's
    own tinted box, never onto a border. The remaining outlined fields are exactly those search
    fields, and they carry a Placeholder and NO Label by design — so `.mud-input-label-outlined`
    is never emitted either way. Restore from git history if an outlined field ever gains a Label.
*/

/*
    Dark-mode visibility fixes. The active MudTheme is supplied by the Ranger package (the local
    MudTheme in MainLayout.razor.Theme.cs is dead code), so these are CSS-only. MudBlazor toggles
    dark mode purely by swapping CSS variables (there is NO .mud-theme-dark wrapper class in the
    DOM), so we scope to `.app-dark`, a wrapper MainLayout stamps when dark mode is active — this
    leaves light mode untouched. MudBlazor/Ranger rules use !important + high specificity, so we
    match/exceed both. Loads after MudBlazor.min.css. Colours are palette-variable based; tune live.
*/

/* 1) Unchecked checkboxes were invisible: MudBlazor fills the outline glyph with --checkbox-color
      and the Ranger override sets it to --mud-palette-dark-lighten (≈ black) in dark mode. Force a
      visible neutral for the UNCHECKED box only (checked keeps its colour). */
.app-dark .mud-checkbox .mud-button-root.mud-checkbox-false .mud-icon-root.mud-svg-icon,
.app-dark .mud-checkbox .mud-button-root.mud-checkbox-false svg path:last-child {
    fill: var(--mud-palette-text-secondary) !important;
}

/* 2) Switch OFF-state track used --mud-palette-action-default, which ≈ the surface/card colour
      it sits on, so an "off" switch was invisible. Give the off track a contrasting neutral. */
.app-dark .mud-switch-base:not(.mud-checked) + .mud-switch-track {
    background-color: var(--mud-palette-text-secondary) !important;
    opacity: 0.6 !important;
}

/* 3) Left navigation drawer: it keeps Color.Secondary in both modes, so it turns grey-blue in dark
      mode exactly like RangerNavigation in ManagementPortal.Ui. Do not repaint its background here
      (DarkModeLayoutGuardTests). Only keep the nav text/icons legible against it. */
.app-dark .nav-drawer .nav-item-text,
.app-dark .nav-drawer .mud-nav-link,
.app-dark .nav-drawer .mud-treeview-item-label,
.app-dark .nav-drawer .mud-icon-root {
    color: var(--mud-palette-text-primary) !important;
}

/* The rule above also hid the orange of the active link. Keep it primary in dark mode too, as in light
   mode, so the selected entry stays recognisable (decided against the lower contrast on grey-blue). */
.app-dark .nav-drawer .mud-nav-link.active,
.app-dark .nav-drawer .mud-nav-link.active .mud-nav-link-text,
.app-dark .nav-drawer .mud-nav-link.active .mud-icon-root {
    color: var(--mud-palette-primary) !important;
}

/* Tint of an expanded partner group in the nav. Light mode keeps its former inline value. */
.nav-group-expanded {
    background-color: rgba(var(--mud-palette-background-rgb), 0.06) !important;
}

.app-dark .nav-group-expanded {
    background-color: var(--mud-palette-action-default-hover) !important;
}

/*
    Expanded child row of a MudTable ("sub-panel") — the app-wide pattern for every table that expands
    into a sub-table. Reference implementation: Pages/Campaign/Campaign.razor.

    Two classes, and both are needed: the cell strips MudTable's own row padding and background so the
    panel (not the cell) owns the spacing, and the panel indents past the expand column and ties itself
    to its parent row with a left rule. Sub-tables inside a panel render flat (Elevation="0", Dense) —
    the panel is already the visual container, a second card would nest two frames.

    border-bottom is off for the same reason the background is: MudBlazor draws one on every
    .mud-table-cell, and on this cell it ran the FULL width of the outer table — past the panel's own
    left indent — so the panel looked closed off by a line belonging to the parent row. The panel's left
    rule and the sub-table's own row lines are what tie the block together; the parent's separator
    reappears under the next regular row where it belongs. Wins over `.mud-table-cell` on source order
    (this sheet loads after MudBlazor.min.css), same specificity, so no !important.
*/
.loki-subpanel-cell {
    padding-top: 0;
    padding-bottom: 0;
    background-color: transparent;
    border-bottom: none;
}

.loki-subpanel {
    margin-left: 48px;
    padding-top: 5px;
    border-left: 1px solid var(--mud-palette-table-lines);
}

.loki-subpanel-title {
    color: var(--mud-palette-text-primary) !important;
}

.loki-subpanel-actions {
    padding: 0px 10px;
}

/*
    Table headers on one line (opt-in, put the class on the MudTable).

    A wrapped header makes the whole header row two lines tall and pushes the first data row down, which
    is the worst place in a table to spend vertical space. Applied per table rather than globally: a
    fixed-layout table only keeps its headers on one line if the matching <col> is wide enough, so the
    class and the column widths have to be decided together (see the ColGroup of Campaign.razor).

    Has to live in this global sheet: MudTh renders the <th>, so it never carries a Blazor scope
    attribute and a scoped .razor.css cannot reach it. Note that `white-space` on the <col> would not
    work either — col only honours width/background/border/visibility, and the property does not inherit
    into the cells.
*/
.loki-th-nowrap .mud-table-head .mud-table-cell {
    white-space: nowrap;
}

/*
    Row-action clusters (the round edit/delete/duplicate buttons in a table's Actions column) must
    never wrap onto a second line.

    The break opportunity is a real whitespace text node: Razor only trims whitespace-only nodes that
    are leading or trailing inside an element, so the newline+indent between two sibling
    MudIconButtons survives into the DOM. Since .mud-button-root is inline-flex and .mud-table-cell
    declares no white-space, that space is the cell's ONLY soft-wrap opportunity — which means the
    cell's min-content width is one button (30 + 32px padding) instead of the whole cluster. Under
    auto table layout the browser then happily squeezes the column into that band and the last button
    drops to line two. Removing the break opportunity also raises min-content back to the full
    cluster, so the column can no longer be squeezed there at all.

    Same reason as .loki-th-nowrap above for living in this global sheet: MudTd renders the <td>, so
    it never carries a Blazor scope attribute and a scoped .razor.css cannot reach it.

    flex-wrap is for the cells whose cluster sits in a MudStack or a d-flex div (PoolNumbersTab,
    RoleMembers), where white-space does not apply. Those are already nowrap by flex default — the
    declaration states the invariant instead of inheriting it from a default a refactor could remove.
*/
.loki-actions-cell {
    white-space: nowrap;
    flex-wrap: nowrap;
}

/*
    Role editor (Pages/Identity/RoleEditor) — Divisions tab.

    The Divisions tab embeds a horizontal sub-MudTabs inside the outer vertical
    MudTabs. MudBlazor renders that sub-tab bar's wrapper at width:max-content and
    "scrolls" it by translating the wrapper, relying on overflow:hidden +
    flex:1 1 auto on .mud-tabs-tabbar-content to clip it and keep the scroll
    buttons inside. In this app those MudBlazor rules do not take effect on the
    element (it computes as a plain block with overflow:visible), so:
      - scrolled-out tabs stay visible and overlap the content on the left, and
      - the right scroll button spills past the card edge.
    Additionally, flex items default to min-width:auto, so the max-content width
    propagates up the flex chain and pushes the panel (and its checkbox grids)
    past the card.

    Fix: allow the panel chain to shrink (min-width:0), and re-assert the three
    intended properties on the tab-bar content so it clips and its buttons stay in.
    Placed here (loaded last) so it wins over MudBlazor by both source order and
    specificity — no !important needed.
*/
.custom-role-editor-tabs,
.custom-role-editor-tabs > .mud-tabs-panels,
.custom-role-editor-tabs .mud-tab-panel {
    min-width: 0;
}

.custom-role-editor-tabs .mud-tabs-tabbar-content {
    overflow: hidden;
    flex: 1 1 auto;
    min-width: 0;
}

/*
    Row and cell states of the MudTable-based pages.

    These live here rather than in a component-scoped stylesheet on purpose. Blazor's CSS isolation stamps
    its scope attribute only on plain HTML elements authored in the component, and these classes land on
    <tr>/<td> elements that MudTable renders. The components in question (Regions, RegionDetail, Campaign and
    its two tables) also start with <MudPaper>, so no element carries the scope attribute at all and even
    `::deep` has nothing to anchor to. The class names are distinctive enough that global scope is safe.
*/

/* A fully locked region stays readable but recedes... */
.region-row-locked td {
    opacity: 0.55;
}

/* ...except the cells carrying controls: a dimmed Lock/Edit/Delete button reads as disabled, and these stay
   clickable on a locked region. MudButton and MudIconButton both render <button>. */
.region-row-locked td:has(button) {
    opacity: 1;
}

/* ...and except the cell of the inert "Region locked" chip. The chip is the only thing that cell holds,
   it is not a button, so the exemption above misses it and the row dimming washed the yellow padlock out
   to a pale beige. opacity cannot be undone by a descendant -- it composites the whole subtree -- so the
   exemption has to sit on the CELL, which is what .region-locked-chip is a hook for. Deliberately NOT
   broadened to any `td:has(.mud-chip)`: the Area column carries a chip in every row and would stop
   dimming with it. Specificity 0-2-1 against the 0-1-1 of the dimming rule, so it wins by weight, not by
   the order of these two blocks. */
.region-row-locked td:has(.region-locked-chip) {
    opacity: 1;
}

/* The leading lock indicator is an icon-only column, in the overview and in both detail tables. */
.region-lock-column {
    width: 36px;
    padding-right: 0;
}

/* "Lock", "Lock all" and "Unlock" differ in text length. Without a shared width the buttons would sit at
   different x positions down the column. */
.region-lock-button {
    min-width: 110px;
}

/* The "i" beside the "Lock" column header (RegionLockColumnHeader, used by the overview and by the
   Inclusions area table). It annotates the label, so the design puts it at 10x10 px in a light grey rather than
   letting it compete with the padlocks in the column below. Both of its former attributes were wrong --
   Size.Small is 1.25rem (20px), and Color.Secondary is the BRAND secondary, not a grey -- so they are
   gone from the markup and the box is defined here instead.

   The box takes two of the three declarations below: the glyph is a Font Awesome webfont, so its box follows
   font-size via MudBlazor's `.mud-icon-root { width:1em; height:1em }` -- except Font Awesome's
   runtime-injected `width: var(--fa-width, 1.25em)` overrides the width at equal specificity from a
   later sheet (see the --fa-width block below, where the same collision turns icon buttons into
   ellipses). Resetting --fa-width rather than width sidesteps that race and leaves 1em x 1em = 10px.

   The colour is a palette variable because this app has a dark mode, and it is the TEXT family, not the
   gray one: --mud-palette-text-secondary is the theme's own de-emphasised-text grey and flips with the
   theme, while the gray family does not -- gray-light measures #E8E8E8 in this app (see the
   confirm-dialog icon block below) and would all but vanish on the light header. */
.loki-lock-info-icon {
    font-size: 10px;
    --fa-width: 1em;
    color: var(--mud-palette-text-secondary);
}

/* Description cell of the Regions overview: one line, truncated with an ellipsis, never wrapped -- a
   wrapping description makes the row two lines tall and drops its lock button out of line with the rows
   above and below. Same recipe as `.identifier-cell` on Divisions, plus a cap, and that addition is the
   point: Divisions caps its columns with a ColGroup, the Regions table has none, and `nowrap` alone
   shortens nothing -- it raises the cell's MIN-content width to its max-content width, so under auto
   table layout the column simply grows and the ellipsis never triggers.

   The cap sits on the CELL and the clipping on the span inside it, deliberately not both on the span:
   `.mud-table-root` is width:100%, so auto layout hands the slack of a wide window to the columns. A
   span capped at 320px inside a td that grew to 500px would clip its text at 320px and leave 180px of
   empty cell beside the ellipsis. Capping the td instead keeps the column itself at 320px and lets the
   span fill whatever the column actually is. 320px is ~40 characters at the table's body text: more
   than any neighbouring column needs, short enough that one pathological description cannot claim half
   the table. The full text stays reachable as the native title tooltip.

   Here rather than in a scoped sheet: MudTd renders the <td>, so it never carries a Blazor scope
   attribute -- and the Region row/cell rules above already live here. */
.region-description-cell {
    max-width: 320px;
}

.region-description-cell > span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The "Partially locked" note in front of the lock button. Two words, one break opportunity, and taking
   it makes the row two lines tall -- in the one column where the row height also decides whether the
   buttons of neighbouring rows stay aligned. MudBlazor ships no nowrap utility class, so this is a real
   rule rather than a class on the MudText. */
.region-lock-note {
    white-space: nowrap;
}

/* Campaigns that are over or not scheduled are dimmed rather than hidden. */
.campaign-row-inactive td {
    opacity: 0.55;
}

/* Read-only product rows of a special campaign: shown, but visibly not editable. */
.campaign-product-row-readonly td {
    opacity: 0.65;
}

/*
    CodeMirror 6 (mail body source editor). CodeMirror builds its DOM at runtime, so its elements never
    carry a Blazor scope attribute and component-scoped CSS cannot reach them — the same reason the
    dark-mode fixes above live here. Colours are NOT set here: the editor is constructed with
    CodeMirror's own oneDark theme in dark mode and its default theme in light mode, which is far more
    robust than styling CodeMirror's generated highlight classes (those names are not stable).
*/
.mail-source-editor {
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: var(--mud-default-borderradius);
    overflow: hidden;
}

.mail-source-editor .cm-editor {
    height: 460px;
    font-size: 0.8125rem;
}

.mail-source-editor .cm-scroller {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.55;
}

.mail-source-editor .cm-editor.cm-focused {
    outline: none;
}
/* Hidden, not removed: the editor is created once and kept, so switching modes cannot make CodeMirror
   re-measure itself into a thin strip. */
.mail-source-editor-hidden {
    display: none;
}
/*
    Mail body editor (Mail Service page).

    These live here rather than in a component-scoped MailBodyEditor.razor.css because CodeMirror builds its
    DOM at runtime, which scoped CSS cannot reach. (The second original reason — the app not linking the
    Blazor scoped-CSS bundle at all — no longer applies: index.html links it as of this branch.) Colours come
    from the MudBlazor palette variables so both themes are covered without a second rule set.
*/
.mail-body-editor-placeholders {
    min-height: 200px;
    max-height: 420px;
    overflow-y: auto;
}

.mail-body-editor-source textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875rem;
}

/* --- Preview: an envelope header (From / Subject) above the rendered mail. --- */
.mail-preview {
    overflow: hidden;
}

.mail-preview-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background-color: var(--mud-palette-background-grey);
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

/* Two columns: the labels form an aligned gutter, the values take the rest. */
.mail-preview-fields {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: baseline;
    column-gap: 1rem;
    row-gap: 0.35rem;
    flex: 1 1 auto;
    min-width: 0;
}

.mail-preview-key {
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

.mail-preview-key-standalone {
    display: block;
    margin-bottom: 0.5rem;
}

.mail-preview-value {
    font-size: 0.875rem;
    line-height: 1.3;
    color: var(--mud-palette-text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-preview-value-subject {
    font-size: 1rem;
    font-weight: 600;
}

.mail-preview-placeholder {
    color: var(--mud-palette-text-disabled);
    font-style: italic;
}

.mail-preview-body {
    padding: 1rem 1.25rem 1.25rem;
}

/* The iframe is the mail surface itself: white paper, full width, no device simulation. */
.mail-preview-frame {
    display: block;
    width: 100%;
    min-height: 420px;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: var(--mud-default-borderradius);
    background: #fff;
}

.mail-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    border: 1px dashed var(--mud-palette-lines-inputs);
    border-radius: var(--mud-default-borderradius);
}


/* ============================================================================
   App shell height chain

   Every page renders one full-bleed card (a MudPaper) inside
   MudMainContent > MudContainer. Those cards each used to hardcode
   Style="min-height:86vh" -- a guess at "most of the viewport" that left a gap
   below the card on tall windows and overshot on short ones.

   Instead the height is handed down from the top. body needs an explicit height
   because nothing above it has one; #app is the Blazor root from index.html.
   .mud-layout already carries height:100% from MudBlazor.min.css and
   .mud-main-content gets it from app.css, so neither is repeated here.

   The container uses min-height (not height) and lays its child out as a flex
   column: at rest the card grows into the free space, and when a page is taller
   than the viewport the container grows with it so the 48px bottom inset
   survives and the document scrolls. With height:100% the card would instead be
   pinned to the viewport and -- being a flex column itself -- would compress its
   own content rather than scroll.
   ============================================================================ */
body {
    height: 100vh;
}

#app {
    height: 100%;
}

/* MudBlazor reserves room for an app bar via padding-top: calc(--mud-appbar-height ...).
   This layout has no MudAppBar, so that reservation is dead space -- it was previously
   masked by Class="pa-2" (MudBlazor spacing utilities are !important) and reappeared as a
   64px gap above the card when that class was removed. */
.mud-main-content {
    padding: 0;
}

.mud-main-content > .mud-container {
    min-height: 100%;
    padding: 48px;
    display: flex;
    flex-direction: column;
}

/* The page card. Direct-child only, so nested MudPapers (section boxes, dialogs)
   are untouched. Components that render no DOM of their own -- NavigationLock,
   PageTitle -- do not break the relationship. */
.mud-main-content > .mud-container > .mud-paper {
    flex: 1 1 auto;
}


/* ============================================================================
   LokiPageToolbar -- filter button exactly as tall as the search field

   All of this is measured in the running app, not inferred from a screenshot.
   Before these rules, on the Products page at Size.Large:

     row (py-3)                          81.6px   top 192.0  bottom 273.6
     search wrapper                      57.6px   top 204.0  bottom 261.6
     .mud-input.mud-input-outlined       49.6px   top 208.0  bottom 257.6  <-- what you see
     filter button                       57.6px   top 204.0  bottom 261.6

   The trap is in the third row: the *visible* bordered box is 8px shorter than
   the wrapper it sits in, because .mud-input-control-margin-dense carries
   margin: 4px 0. Stretching the button to the wrapper therefore made it
   overhang the visible field by 4px top and bottom -- the button was correctly
   sized, just to the wrong box. Zeroing that margin makes wrapper and visible
   field the same box, and then everything below lines up:

     .mud-input.mud-input-outlined       49.6px   top 204.0  bottom 253.6
     filter button                       49.6px   top 204.0  bottom 253.6

   The search field is Variant.OUTLINED and that is deliberate, even though the
   2026-08 UI/UX decision put every other input on Variant.Filled. A search
   field carries a Placeholder and no Label, and a filled input reserves its
   label gutter regardless: dense filled pads 23px top + 6px bottom
   (`1lh + 29px`) where dense outlined pads a symmetric 10.5px (`1lh + 21px`).
   Dropping the Label does not reclaim it -- MudBlazor 8.15 has NO code path
   that emits `mud-input-root-hidden-label` (the class is absent from
   MudBlazor.dll entirely; the rules for it in MudBlazor.min.css are its own
   leftovers). Filled here therefore bought 8px of empty gutter above a
   placeholder and made the search box look inflated next to the button, which
   is why search stayed outlined. Do not "fix" it to Filled for consistency.

   Why the button rules are shaped the way they are -- two earlier attempts
   failed because only part of this held:

   1. height: auto -- the RangerTheme gives MudButton an explicit height per
      Size, and a flex item with a definite cross-size ignores stretch. That is
      why align-items: stretch alone left the button pinned to the top.
   2. zero vertical padding -- with height: auto the button's content height at
      Size.Large came out *larger* than the field, so the button became the
      tallest item, set the row height and had nothing to stretch into: the
      mismatch flipped sides. Reduced to one line of text it is reliably the
      shorter item, so the field always sets the row height. The label stays
      centred because MudButton is inline-flex with align-items and
      justify-content center.
   3. align-self per item, not align-items on the row -- the row itself stays
      align-items: center (see LokiPageToolbar.razor.css), which is the safe
      fallback for anything in the row these rules do not reach.

   This applies to every button in the row, not just the filter button: the Extra
   slot (Regions) puts an import and an add button there, and they line up on the
   same edges. A button wrapped in a MudTooltip needs its wrapper pulled into the
   same mechanism, hence the .mud-tooltip-root rule -- display: flex is what lets
   the button inside it stretch.

   No pixel constant anywhere: the height is whatever the search field measures.
   Same for the radius -- the field follows --mud-default-borderradius (10px at
   runtime; note the 12px in MainLayout.razor.Theme.cs is overridden by the
   RangerTheme), while MudButton hardcodes 12px. Pointing the buttons at the same
   variable makes them track the theme with the field.

   !important because the theme's own selectors
   (.mud-button-root.mud-button-*-size-large) are more specific than any sane
   class selector here, and MudBlazor's spacing utilities are !important too.

   Lives in this global sheet, not the scoped one, because it targets DOM
   MudBlazor renders -- see the styling section of CLAUDE.md. The class names are
   ours and unique, so no scope attribute is involved.

   Measured on Products and Regions after these rules: search field and every
   button at height 49.6px on identical top and bottom edges.
   ============================================================================ */
.loki-page-toolbar-search .mud-input-control {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.loki-page-toolbar .mud-tooltip-root {
    align-self: stretch;
    display: flex;
}

.loki-page-toolbar .mud-button-root {
    align-self: stretch;
    height: auto !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-radius: var(--mud-default-borderradius) !important;
}

/* ============================================================================
   Flat buttons (app-wide)

   No button in this app carries a drop shadow. That was already the intent, but
   it was only enforced where someone remembered `DropShadow="false"` on the call
   site -- 33 of 331 button usages -- which left 94 buttons shadowed: 87 filled
   MudButtons, 4 filled MudIconButtons and 3 MudFabs. Hence one rule here instead
   of an attribute on every button.

   In CSS rather than per call site because MudBlazor offers no global switch:
   `MudGlobal.ButtonDefaults` exposes only Color and Variant (checked against the
   shipped MudBlazor.xml, 8.15), so `DropShadow` can only be set per component.
   CSS also covers the buttons this app never writes itself -- pagination pages,
   button groups, a menu activator -- which an attribute sweep cannot reach.

   Why exactly these selectors: every button shadow in the app comes from
   MudBlazor.min.css. Ranger.Blazor.Components.Core adds none (its only button
   box-shadow is a `none !important` on a filled ButtonGroup's hovered child).
   MudBlazor shadows `.mud-button-filled`, `.mud-fab`, `.mud-button-group-filled`
   and `.mud-pagination-filled`, and repeats each with a heavier value for
   :hover, :focus-visible and :active -- so every state needs its own entry.
   `.mud-button-outlined` and `.mud-button-text` carry no box-shadow declaration
   at all, which is why they are absent below: there is nothing to switch off,
   and that is also why only filled buttons ever looked inconsistent.

   No !important, deliberately. Not one shadow-adding button rule in MudBlazor
   8.15 uses !important, the highest specificity among them is three class units,
   and this sheet loads after MudBlazor.min.css -- so merely matching that
   specificity already wins on source order. !important here would instead make
   the shadow impossible to reinstate for a single button that ever needs one,
   and would override the `mud-button-disable-elevation` class that
   `DropShadow="false"` still adds.

   Two spellings of focus are in play: MudBlazor's shadow rules use the
   `:focus-visible` pseudo-class, its own disable-elevation rules use a
   `.mud-focus-visible` class. Both are matched.

   Buttons only -- this does not touch the popover/menu/card shadows, which the
   design does use (see the Elevation="25" notes in ContractEditorWizard and
   ContractTemplateRecursive).
   ============================================================================ */
.mud-button-filled,
.mud-button-filled:hover,
.mud-button-filled:focus-visible,
.mud-button-filled:active,
.mud-button-filled.mud-focus-visible,
.mud-fab,
.mud-fab:hover,
.mud-fab:focus-visible,
.mud-fab:active,
.mud-fab.mud-focus-visible,
.mud-button-group-filled,
.mud-button-group-filled .mud-button-root,
.mud-button-group-filled .mud-button-root:hover,
.mud-button-group-filled .mud-button-root:focus-visible,
.mud-button-group-filled .mud-button-root:active,
.mud-pagination-filled .mud-pagination-item .mud-button {
    box-shadow: none;
}

/* ============================================================================
   Round icon buttons (table row actions, dialogs, inline actions)

   Ranger.Blazor.Components.Core already wants these round: mb-iconbutton-overrides
   gives every .mud-icon-button `border-radius: 999px` plus symmetric padding, which
   is a circle only while the icon box is square. Font Awesome breaks that. The kit
   script injects Font Awesome's stylesheet at runtime, so it lands after
   MudBlazor.min.css in the cascade and its
   `.fa, .fa-solid, ... { width: var(--fa-width, 1.25em) }` beats MudBlazor's
   `.mud-icon-root { width: 1em }` -- same specificity, later source. The icon box is
   then 1.25em wide by 1em tall, and the pill radius renders as an ellipse: measured
   40x36px for Size.Medium and 33x30px for Size.Small in the Products and Divisions
   tables. Material SVG icons are unaffected, which is why only the Font Awesome
   actions look wrong.

   Resetting --fa-width on the button restores the square box, so the 999px radius
   from the package produces the intended circle. This is a workaround for a bug in
   Ranger.Blazor.Components.Core -- drop it once the package ships the fix.
   ============================================================================ */
.mud-button-root.mud-icon-button {
    --fa-width: 1em;
}

/* ============================================================================
   Pill-shaped button (opt-in)

   Ranger.Blazor.Components.Core makes a MudButton a pill only at Size.Medium; from
   Size.Large it switches to the 12px corner. This class asks for the pill regardless
   of size -- used for the "Add range" button inside the expanded Pool-Number panel,
   where the round shape marks the button as the panel's own action rather than a
   page-level one.

   !important for the same reason as the rules below: the package's selectors carry
   several :not() arguments and outrank any plain class selector.
   ============================================================================ */
.loki-btn-pill {
    border-radius: 999px !important;
}

/* ============================================================================
   Required marker off (opt-in: put loki-no-required-mark on the MudForm, or on
   the MudPaper wrapping the fields)

   MudBlazor draws the asterisk from the field's Required flag:

       .mud-input-control.mud-input-required
         > .mud-input-control-input-container
           > .mud-input-label::after { content: "*" }

   The design does not mark mandatory fields with a glyph on every label -- but
   Required is also what drives MudForm validation, so dropping Required to lose
   the star would silently drop the validation with it. Hence the marker is
   suppressed here and Required stays on the field where it belongs.

   Five class units against MudBlazor's four, so this wins on specificity and not
   merely because this sheet loads last -- it survives a reorder. `content: none`
   suppresses the pseudo-element outright instead of rendering an empty box.

   Opt-in rather than global: a form whose labels are the only hint that a field
   is mandatory must keep its markers.
   ============================================================================ */
.loki-no-required-mark .mud-input-control.mud-input-required > .mud-input-control-input-container > .mud-input-label::after {
    content: none;
}

/* ============================================================================
   Dialog action buttons (app-wide)

   The design gives every dialog the same pair of buttons -- 48px tall, 12px corner
   radius, outlined dismiss next to a filled confirm; only colour and label differ, in
   confirmation and form dialogs alike. Ranger.Blazor.Components.Core
   styles MudButton as a 36px pill instead, through selectors of the shape
   `.mud-button:not(...):not(...):not(...):not(...).mud-button-outlined-size-medium` -- six
   compound classes, because :not() contributes the specificity of its argument. No practical
   selector here outranks that, so these declarations carry !important, the same way the page
   toolbar rules above do.

   Padding and gap follow the Figma spacing (p-5 = 20px, gap 16px); MudBlazor's own 8px sits the
   buttons almost on the dialog edge. Those two need no !important -- same specificity as
   MudBlazor's rule, but this sheet loads later.

   Deliberately global rather than an opt-in class: the design has one button treatment for all
   dialogs, three Identity dialogs already duplicated these exact values as an inline Style, and
   every new dialog would otherwise have to remember them. Checked that no dialog in this UI puts
   a MudIconButton in its actions -- min-width would deform one.

   Lives in this global sheet rather than a scoped .razor.css because the elements are rendered by
   MudBlazor and therefore never get the Blazor scope attribute -- see the styling section of
   CLAUDE.md.
   ============================================================================ */
.mud-dialog .mud-dialog-actions {
    padding: 20px;
    gap: 16px;
}

/* The second selector extends the treatment to the buttons a dialog puts in its BODY -- "Upload new PDF",
   "Add condition", "Select file", "Regenerate secret". Without it a single dialog shows two button shapes:
   the 48px/12px pair in the footer and the package's 36px pill above it.

   The :not(.mud-icon-button) is load-bearing here, unlike in the footer: dialog bodies do carry icon
   buttons (the row delete and add buttons of ContractTemplateFieldItemListDialog), and min-width plus the
   horizontal padding would stretch those circles into pills -- the exact defect this block exists to
   remove. MudBlazor renders checkboxes, switches and radios as icon buttons too, so the same exclusion
   keeps them untouched. */
.mud-dialog .mud-dialog-actions .mud-button-root,
.mud-dialog .mud-dialog-content .mud-button-root:not(.mud-icon-button) {
    height: 48px !important;
    min-width: 88px !important;
    border-radius: 12px !important;
    padding-left: 20px;
    padding-right: 20px;
}

/* One exception to the rule above: the page numbers of a LokiTablePager inside a dialog body.
   MudPagination renders each page as a plain MudButton, so the block above caught them too and turned
   "1 2 3" into a row of 48x88px dialog buttons (the nav arrows escaped it — those are icon buttons).
   These are navigation chips, not dialog actions, so restore MudBlazor's own pagination metrics
   (.mud-pagination .mud-pagination-item > *). !important because it is what we are overriding here,
   and the four leading classes outrank the three of MudBlazor's rule anyway. */
.mud-dialog .mud-dialog-content .mud-pagination .mud-pagination-item > .mud-button-root {
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 16px !important;
    padding-left: 6px;
    padding-right: 6px;
}

/* ============================================================================
   Filter chip set (opt-in: put loki-filter-chips on the MudChipSet)

   A chip that filters a list is a toggle, and the design wants the two states clearly apart: outlined
   in the secondary colour while off, solid secondary while on. MudBlazor does not do the second half --
   for Variant.Outlined it keeps the outline when selected and only washes the background with
   `--mud-palette-secondary-hover`, a tint that reads as a hover state rather than as "on". So the
   selected state is painted here, mirroring MudBlazor's own `.mud-chip-filled.mud-chip-color-secondary`
   declarations.

   The selectors deliberately do NOT name a variant class: MudChip swaps its variant on selection for
   some Variant values, so pinning `.mud-chip-outlined` would make the rule state-dependent for no gain.
   `:not(.mud-disabled)` on the interaction rules is not a filter but a specificity match -- MudBlazor's
   own hover/focus/active rules carry it, and ours have to outrank them.
   ============================================================================ */
.loki-filter-chips .mud-chip.mud-chip-color-secondary.mud-chip-selected {
    color: var(--mud-palette-secondary-text);
    background-color: var(--mud-palette-secondary);
    border-color: var(--mud-palette-secondary);
}

.loki-filter-chips .mud-chip.mud-chip-color-secondary.mud-chip-selected:hover:not(.mud-disabled),
.loki-filter-chips .mud-chip.mud-chip-color-secondary.mud-chip-selected:focus-visible:not(.mud-disabled),
.loki-filter-chips .mud-chip.mud-chip-color-secondary.mud-chip-selected:active:not(.mud-disabled) {
    background-color: var(--mud-palette-secondary-darken);
    border-color: var(--mud-palette-secondary-darken);
}

/* Check mark behind the label instead of in front of it. MudChip renders the mark first inside the
   inline-flex `.mud-chip-content`, so `order` moves it past the label (a bare text node is an anonymous
   flex item and keeps order 0) without touching the markup. The two margins are MudBlazor's own,
   mirrored: the -4px pull now sits on the outer side. */
.loki-filter-chips .mud-chip .mud-chip-icon {
    order: 1;
    margin-left: 4px;
    margin-right: -4px;
    margin-inline-start: 4px;
    margin-inline-end: -4px;
}
/*
    Tinted icon disc of LokiConfirmDialog.

    MudBlazor defines CSS for the Filled and Outlined avatar variants only; the Text variant falls
    through to plain .mud-avatar, which paints var(--mud-palette-gray-light) -- a grey disc, measured
    #E8E8E8 in the app. The design wants a wash of the icon colour instead, so each semantic colour
    gets its own rule here. A colour without a rule keeps MudBlazor's grey, which is a readable
    fallback rather than a broken one.
*/
.loki-confirm-icon.loki-confirm-icon-error {
    background-color: rgba(var(--mud-palette-error-rgb), 0.12);
}

.loki-confirm-icon.loki-confirm-icon-info {
    background-color: rgba(var(--mud-palette-info-rgb), 0.12);
}

.loki-confirm-icon.loki-confirm-icon-primary {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.12);
}

.loki-confirm-icon.loki-confirm-icon-warning {
    background-color: rgba(var(--mud-palette-warning-rgb), 0.12);
}

.loki-confirm-icon.loki-confirm-icon-success {
    background-color: rgba(var(--mud-palette-success-rgb), 0.12);
}

/* ============================================================================
   Outlined card = the frame around a form section (app-wide)

   Every wizard and settings page groups its form into `<MudPaper Outlined="true">`
   boxes. MudBlazor draws that frame with

       .mud-paper-outlined { border: 1px solid var(--mud-palette-lines-default) }

   but the design uses the table hairline for these frames, not the generic line
   colour -- the same token the expanded sub-panel above already points at. Only
   the colour is overridden; width, style and radius stay MudBlazor's.

   Deliberately global rather than an opt-in class: in this UI every outlined
   MudPaper IS such a section frame, and each new one would otherwise have to
   remember the class. Both palette entries swap with the theme, so light and
   dark are covered by this one rule.

   Lives in this global sheet because the border sits on DOM MudBlazor renders,
   which never carries a Blazor scope attribute -- see the styling section of
   CLAUDE.md. The doubled class only raises specificity above MudBlazor's own
   single-class rule; source order would already suffice.
   ============================================================================ */
.mud-paper.mud-paper-outlined {
    border-color: var(--mud-palette-table-lines);
}

/*
    Same frame for a section that is an expansion panel rather than a MudPaper (Product wizard,
    Links). MudExpansionPanels is not a MudPaper, so the rule above does not reach it and the
    section would be the only one on the page without a frame. Radius matches MudBlazor's own
    `.mud-expansion-panels`, which already rounds to --mud-default-borderradius.

    Whoever uses this class must also pass `Outlined="false"` to the MudExpansionPanels. That
    parameter defaults to TRUE and borders each panel INSIDE this frame: MudBlazor itself only draws a
    bottom hairline there, but Ranger.Blazor.Components.Core promotes the same class to a full
    `1px solid` box with a 12px radius (mb-expansionpanel-overrides.css, !important) -- the section
    then shows two nested rectangles. Not suppressed here on purpose: the class is the frame, and
    silently disarming a MudBlazor parameter from a global sheet would hide the cause from the markup.
*/
.mud-expansion-panels.loki-panel-card {
    border: 1px solid var(--mud-palette-table-lines);
}

/*
    Shared table treatment from the design (Product wizard, Figma 7677:70948 and 7677:70945): 48px rows,
    6px/4px cell padding, 1px row separators and a 2px rule under the header. Also used by the campaign
    wizard's provision table, which is the same thing in a different section: a fixed list of sales
    channels with a numeric field per column.

    The rules live here rather than in a scoped sheet because they have to outrank MudBlazor's own
    `.mud-simple-table table * tr>td` and `.mud-simple-table.mud-table-dense * tr td`, which a scoped
    selector cannot reach. Three classes beats their two, so the ordering is not load-order luck.
*/
.mud-table.mud-simple-table.loki-table-48 th,
.mud-table.mud-simple-table.loki-table-48 td {
    height: 48px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--mud-palette-table-lines);
}

/* Also re-asserts the separator on the last row, which MudBlazor strips by default. */
.mud-table.mud-simple-table.loki-table-48 th {
    border-bottom-width: 2px;
    font-weight: 600;
}

/* Channel column is fixed so the remaining input columns stay equal (three in the product wizard, two
   in the campaign wizard's provision table). */
.mud-table.mud-simple-table.loki-channel-defaults th:first-child,
.mud-table.mud-simple-table.loki-channel-defaults td:first-child {
    width: 168px;
}

/*
    Links section: the description column takes the slack, everything else is fixed to the design so
    the two tables line up with each other.
*/
.mud-table.mud-simple-table.loki-link-table .loki-col-name {
    width: 230px;
}

.mud-table.mud-simple-table.loki-link-table .loki-col-tier {
    width: 157px;
}

.mud-table.mud-simple-table.loki-link-table .loki-col-date {
    width: 161px;
}

.mud-table.mud-simple-table.loki-link-table .loki-col-action {
    width: 76px;
}

/*
    Two separate things push the field past the design's 36px, and both have to go:
    `mud-input-control-margin-dense` adds 4px of vertical margin, and the dense filled input sizes
    itself as `1lh + 29px` of content-box padding (~48px). Pinning a border-box height makes it exact
    regardless of the inherited line height.

    These cells hold placeholder-only MudNumericFields on purpose: the COLUMN HEADER is their label
    (see the tables in ProductWizard / CampaignWizard). Giving them a Label instead would both
    duplicate the header and overflow this 36px -- a dense FILLED input pads itself 23px top + 6px
    bottom, i.e. `1lh + 29px` (MudBlazor.min.css 8.15), 8px more than the dense outlined input these
    fields used before 2026-08. Note that dropping the Label does NOT shrink that padding: MudBlazor
    8.15 emits no `mud-input-root-hidden-label` anywhere (the class is absent from MudBlazor.dll --
    the rules for it in its stylesheet are leftovers), so the label gutter is always reserved. Which
    is exactly why this override has to exist at all.

    The selector carries six classes, one more than the tallest MudBlazor rule it has to beat, so it
    wins on specificity rather than on this sheet merely loading later -- the 36px holds even if one
    of these fields later gains a Label or an adornment.
*/
.loki-channel-defaults .mud-input-control.mud-input-control-margin-dense {
    margin: 0;
}

.loki-channel-defaults .mud-input-control .mud-input.mud-input-filled > input.mud-input-root.mud-input-root-filled {
    box-sizing: border-box;
    height: 36px;
    padding: 6px 12px;
    line-height: 24px;
}

/* Trailing "open in new tab" affordance on a hint line — sits on the text baseline, not above it. */
.loki-hint-link {
    vertical-align: text-bottom;
}

.loki-hint-link .mud-icon-root {
    font-size: 12px;
}

/* ============================================================================
   ContractMeta template editor — three columns that scroll on their own

   The editor's three cards (Assignments / Fields / Configurations) used to grow
   with their content, so a long list in any ONE of them scrolled the whole page
   and pushed the other two out of view. Capping every card at the viewport minus
   the wizard's sticky header and its fixed save bar, and letting it scroll
   internally, keeps all three aligned and leaves the page itself static.

   The 260px is the wizard's chrome, added up from the markup and MudBlazor's own
   metrics rather than guessed — the inline 160px this replaced only covered the
   space ABOVE the card, which is why the page still scrolled by the remainder:

     above   72px  top bar     (MudPaper py-1 + MudStack py-3 + 40px h2 line)
           + 64px  tab strip   (.mud-tab min-height 48px + MudTabs py-1 + MudStack py-1)
           + 20px  content pt-5
                   MudGrid contributes 0: spacing-6 puts padding-top:24px on the
                   item and margin-top:-24px on the container, which cancel out
     below   40px  content pb-10
           + 55px  spacer that keeps the FIXED save bar (~58px) off the Settings
                   tab's content — shared markup, so it counts here too
     ------------
            251px, rounded up to 260 for a little slack

   No position:sticky: once a card cannot outgrow the viewport the page does not
   scroll, so sticky would never engage in the wide layout and would only pin the
   stacked cards oddly on a narrow one.

   Global sheet rather than a scoped .razor.css because the element carrying the
   class is a MudPaper — Blazor never stamps a scope attribute on a component's
   own root.
   ============================================================================ */
.loki-template-column {
    max-height: calc(100vh - 260px);
    overflow-y: auto;
}

/* The collapsible groups inside the "Fields" card. Outlined="true" would draw
   --mud-palette-lines-default; the design calls for the inputs line instead. The
   shadow comes from Elevation="25" on the MudPaper itself. */
.loki-template-field-card {
    border: 1px solid var(--mud-palette-lines-inputs);
}

/* Save bar state dot. MudBlazor's Size.Small is 1.25rem (20px), which next to a
   body1 label (16px) reads as an oversized badge rather than punctuation. */
.loki-savebar-status-icon {
    font-size: 1rem;
}

/* ============================================================================
   Role management (restored from d6f7364): card action menu and the members
   table selection. The rules sat in an inline <style> of RoleManagement.razor.
   PopoverClass/RowClassFunc land on DOM that MudBlazor renders, so a scoped
   sheet cannot reach it. The old custom box-shadow is gone: the menu keeps
   MudBlazor's own popover elevation, like every other menu of the app.
   ============================================================================ */
.role-action-menu-popover {
    border-radius: 12px;
    overflow: hidden;
}

.role-action-menu-popover .role-menu-item {
    height: 48px;
    min-width: 150px;
}

.role-member-row--selected {
    background-color: var(--mud-palette-primary-hover);
}

/* Logo tile of the main-tenant card and wizard (the button is MudBlazor DOM, so it cannot be scoped). */
.loki-logo-tile {
    width: 64px;
    height: 64px;
    padding: 0;
}

.loki-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* Template proposal dialog: rows "apply" does not send (ignored or left out). RowClassFunc lands on the <tr>. */
.mud-table-row.proposal-row-skipped {
    opacity: 0.55;
}

/* ---- FAQ (Pages/FAQ) ---- */
/* Three columns: topic menu | questions of the topic | answer. Menu and questions collapse to an icon rail. */
.loki-faq-layout {
    --loki-faq-topics: 260px;
    --loki-faq-questions: 360px;
    display: grid;
    grid-template-columns: var(--loki-faq-topics) var(--loki-faq-questions) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.loki-faq-layout.loki-faq-topics-collapsed { --loki-faq-topics: 56px; }
.loki-faq-layout.loki-faq-questions-collapsed { --loki-faq-questions: 56px; }
.loki-faq-column { min-width: 0; }
.loki-faq-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 4px 4px 4px 16px;
}
.loki-faq-topics-collapsed .loki-faq-column:first-child .loki-faq-column-header,
.loki-faq-questions-collapsed .loki-faq-column:nth-child(2) .loki-faq-column-header {
    justify-content: center;
    padding: 4px;
}
.loki-faq-topic {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.loki-faq-question-list {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}
@media (max-width: 959.98px) {
    .loki-faq-layout,
    .loki-faq-layout.loki-faq-topics-collapsed,
    .loki-faq-layout.loki-faq-questions-collapsed { grid-template-columns: minmax(0, 1fr); }
    .loki-faq-question-list { max-height: none; }
}
.loki-faq-answer p:last-child,
.loki-faq-answer ol:last-child,
.loki-faq-answer ul:last-child { margin-bottom: 0; }
.loki-faq-answer ol,
.loki-faq-answer ul { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.loki-faq-answer p { margin-bottom: 0.75rem; }
.loki-faq-answer pre {
    padding: 0.75rem;
    border-radius: 4px;
    overflow-x: auto;
    background: var(--mud-palette-background-gray);
}
.loki-faq-answer code { font-family: monospace; overflow-wrap: anywhere; }
.loki-faq-answer pre code { overflow-wrap: normal; }
.loki-faq-answer table { border-collapse: collapse; margin-bottom: 0.75rem; }
.loki-faq-answer th,
.loki-faq-answer td { border: 1px solid var(--mud-palette-lines-default); padding: 0.25rem 0.5rem; }

/*
    Dark-mode illustrations. The empty-state SVGs are navy on transparent and vanish on
    the dark background. Inverting and rotating the hue by 180 degrees turns navy light while orange keeps
    its hue. Light mode has no rule. Guarded by DarkModeColorGuardTests.
*/
.app-dark .loki-illustration {
    filter: invert(1) hue-rotate(180deg);
}

/* ============================================================================
    Fullscreen header bars (ContractEntry, ContractEditorWizard). They are Color.Secondary like the nav
    drawer: navy in light, grey-blue in dark. The orange title and close button read well on navy but only
    reach 1.75:1 on the grey-blue, so in dark mode they take the secondary contrast colour. Light mode keeps
    the orange. Guarded by DarkModeLayoutGuardTests.
*/
.app-dark .loki-fullscreen-header .mud-typography,
.app-dark .loki-fullscreen-header .mud-icon-button {
    color: var(--mud-palette-secondary-text) !important;
}