/* ==========================================================================
   Access-control surfaces — Roles & Permissions + Feature Entitlements
   --------------------------------------------------------------------------
   Domain layer over the Tansi UI grammar (ui.css). Components:
   AccessModelExplainer (Components/Shared/), RolesPermissions + RoleEditor
   (Components/Pages/Admin/Access/).

   Everything derives from the app.css design tokens (--card-*, --text-*,
   --radius-*) and MudBlazor palette vars; dark mode via the .mud-theme-dark
   ancestor, never media queries. Accent colors NON-TEXT signals only
   (fills, borders, icons) — running text stays neutral.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Accent derivation (same recipe as ui.css §0; the explainer also renders
      on pages without a TansiPage ancestor, so it falls back to primary).
   -------------------------------------------------------------------------- */
.access-explainer,
.perm-matrix {
    --ax-accent: var(--page-accent, var(--mud-palette-primary));
    --ax-accent-ink: var(--ax-accent);
    --ax-accent-soft: color-mix(in srgb, var(--ax-accent) 11%, transparent);
}

.mud-theme-dark .access-explainer,
.mud-theme-dark .perm-matrix {
    --ax-accent-ink: color-mix(in srgb, var(--ax-accent) 58%, #ffffff);
    --ax-accent-soft: color-mix(in srgb, var(--ax-accent) 16%, transparent);
}

/* --------------------------------------------------------------------------
   1. "How access works" explainer strip  (AccessModelExplainer.razor)
   -------------------------------------------------------------------------- */
.access-explainer {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 14px 20px 16px;
    margin-bottom: 24px;
}

.access-explainer__kicker {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-caption);
    margin-bottom: 10px;
}

.access-explainer__tiers {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.access-explainer__tier {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1 1 240px;
    min-width: 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm, 10px);
    border-left: 3px solid transparent;
}

/* The tiers are a pipeline; draw the flow arrow between adjacent tiers. */
.access-explainer__tier + .access-explainer__tier::before {
    content: "\2192" / "";
    align-self: center;
    margin: 0 2px 0 -8px;
    color: var(--text-caption);
    font-size: 0.875rem;
}

.access-explainer__tier--current {
    border-left-color: var(--ax-accent-ink);
    background: var(--ax-accent-soft);
}

.access-explainer__tier-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--ax-accent-ink);
    background: var(--ax-accent-soft);
}

.access-explainer__tier--current .access-explainer__tier-icon {
    color: var(--mud-palette-primary-text, #fff);
    background: var(--ax-accent);
}

.mud-theme-dark .access-explainer__tier--current .access-explainer__tier-icon {
    /* Lifted accents get too pale for white glyphs — keep the raw hue as fill
       and let the glyph go dark-canvas text. */
    color: var(--mud-palette-surface);
    background: var(--ax-accent-ink);
}

.access-explainer__tier-text {
    min-width: 0;
}

.access-explainer__tier-name {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.3;
}

.access-explainer__tier-copy {
    display: block;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-caption);
    margin-top: 1px;
}

/* --------------------------------------------------------------------------
   2. Permission ladder — the ordinal level control (RoleEditor.razor).
      Real <button>s (keyboard rule 1); every step at or below the chosen
      level fills, making "higher includes lower" visible.
   -------------------------------------------------------------------------- */
.perm-ladder {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

:where(button.perm-step) {
    appearance: none;
    font: inherit;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 9px;
    color: var(--mud-palette-text-secondary);
    min-height: 40px;
    padding: 4px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    line-height: 1.2;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.perm-step:hover {
    background: var(--ax-accent-soft);
}

.perm-step:focus-visible {
    outline: 2px solid var(--ax-accent-ink);
    outline-offset: 2px;
}

/* Steps included by the current selection — the filled track. */
.perm-step--on {
    background: var(--ax-accent-soft);
    border-color: color-mix(in srgb, var(--ax-accent) 38%, transparent);
    color: var(--mud-palette-text-primary);
}

/* The selected step itself. */
.perm-step--active {
    border: 2px solid var(--ax-accent-ink);
    padding: 3px 11px;
    font-weight: 700;
    color: var(--mud-palette-text-primary);
}

/* Sensitive-data steps carry a risk tint instead of the module accent. */
.perm-step--sens.perm-step--on {
    background: color-mix(in srgb, var(--mud-palette-warning) 14%, transparent);
    border-color: color-mix(in srgb, var(--mud-palette-warning) 45%, transparent);
}

.perm-step--sens.perm-step--active {
    border-color: var(--mud-palette-warning);
}

.perm-step__icon {
    display: grid;
    place-items: center;
}

.perm-step__icon .mud-icon-root {
    font-size: 1rem;
    width: 1rem;
    height: 1rem;
}

/* --------------------------------------------------------------------------
   3. Permission matrix rows (RoleEditor.razor)
   -------------------------------------------------------------------------- */
.perm-matrix {
    display: flex;
    flex-direction: column;
}

.perm-module {
    padding: 14px 0;
}

.perm-module + .perm-module {
    border-top: 1px solid var(--card-border);
}

.perm-module__row {
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr;
    gap: 10px 18px;
    align-items: start;
}

@media (max-width: 760px) {
    .perm-module__row {
        grid-template-columns: 1fr;
    }
}

.perm-module__name {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.perm-module__desc {
    margin: 2px 0 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-caption);
}

/* Feature-override disclosure — a real button under the module ladder. */
:where(button.perm-features-toggle) {
    appearance: none;
    font: inherit;
    cursor: pointer;
    background: transparent;
    border: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 6px 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ax-accent-ink);
}

.perm-features-toggle:hover {
    background: var(--ax-accent-soft);
}

.perm-features-toggle:focus-visible {
    outline: 2px solid var(--ax-accent-ink);
    outline-offset: 2px;
}

.perm-features-toggle .mud-icon-root {
    transition: transform 150ms ease;
}

.perm-features-toggle[aria-expanded="true"] .mud-icon-root {
    transform: rotate(180deg);
}

/* Feature rows hang off the module row on a hairline rail. */
.perm-features {
    margin: 6px 0 0 10px;
    padding-left: 16px;
    border-left: 2px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.perm-feature__name {
    margin: 0 0 2px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.perm-feature__desc {
    margin: 0 0 6px;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-caption);
}

/* --------------------------------------------------------------------------
   4. Role detail panel (RoleDetailPanel + assign/remove dialogs)
   -------------------------------------------------------------------------- */

/* About tab: label/value facts list. */
.role-facts {
    margin: 0;
}

.role-facts > div {
    display: flex;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    min-width: 0;
}

.role-facts > div:last-child {
    border-bottom: 0;
}

.role-facts dt {
    flex: none;
    width: 130px;
    font-size: 0.8125rem;
    color: var(--text-caption);
}

.role-facts dd {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 0;
    overflow-wrap: anywhere;
}

.role-facts__note {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-caption);
}

/* People tab: horizontal scroll stays inside the table region, keyboard-reachable. */
.role-people-scroll {
    overflow-x: auto;
}

.role-people-scroll:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
    border-radius: 6px;
}

.role-person__name {
    display: block;
    font-weight: 600;
}

.role-person__other {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-caption);
}

.role-person__never {
    color: var(--mud-palette-warning);
    font-weight: 600;
}

/* Permissions tab: one row per opened module. */
.role-perm-list {
    display: flex;
    flex-direction: column;
}

.role-perm-row {
    padding: 8px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.role-perm-row:last-child {
    border-bottom: 0;
}

.role-perm-row--sens {
    box-shadow: inset 3px 0 0 var(--mud-palette-warning);
    padding-left: 10px;
}

.role-perm-row__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.role-perm-row__name {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.role-perm-row__meaning {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-caption);
    margin-top: 2px;
}

/* Remove dialog: consequences list. */
.role-consequences {
    margin: 6px 0 0;
    padding-left: 18px;
}

.role-consequences li + li {
    margin-top: 4px;
}

/* Levels key dialog: mark the two sensitive steps beyond colour. */
.levels-key-table th[scope="row"] {
    white-space: nowrap;
}

.levels-key-sens {
    box-shadow: inset 3px 0 0 var(--mud-palette-warning);
}

/* --------------------------------------------------------------------------
   5. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .perm-step,
    .perm-features-toggle .mud-icon-root {
        transition: none;
    }
}

/* ==========================================================================
   6. Access Center (Components/Pages/Admin/AccessCenter/)
   --------------------------------------------------------------------------
   Plain answers first, controls second. Tone (yes / partly / no) is carried
   by words and icons; colour only reinforces it on borders and icons.
   ========================================================================== */
.ac-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ac-intro {
    max-width: 72ch;
    margin: 0 0 16px;
    color: var(--text-body, var(--mud-palette-text-primary));
    line-height: 1.55;
}

/* A workspace-wide rule: a switch with what it means, set apart from the
   detail it governs. */
.ac-rule {
    max-width: 80ch;
    margin: 0 0 18px;
    padding: 6px 14px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    background: color-mix(in srgb, var(--mud-palette-text-primary) 3%, var(--mud-palette-surface));
}

/* MudSwitch sizes itself to its track; the rule's name has to be free to wrap. */
.ac-rule__switch.mud-input-control {
    display: block;
    width: auto;
    max-width: 100%;
    margin: 0;
}

.ac-rule__switch .mud-switch {
    max-width: 100%;
}

.ac-rule__switch .mud-typography {
    min-width: 0;
    font-weight: 600;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Under the rule's name, clear of the switch itself. */
.ac-rule__meaning {
    margin: 0 0 0 58px;
    color: var(--text-body, var(--mud-palette-text-primary));
    font-size: 0.875rem;
    line-height: 1.5;
}

@media (max-width: 600px) {
    .ac-rule__meaning {
        margin-left: 0;
    }
}

.ac-hint,
.ac-muted,
.ac-note {
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.ac-hint {
    margin: 12px 0 0;
}

.ac-note {
    margin: 10px 0 0;
}

.ac-h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.005em;
    color: var(--text-heading, var(--mud-palette-text-primary));
}

/* Counts line up as they change. */
.ac-muted,
.ac-fact__lead,
.ac-group__count,
.ac-matrix__type {
    font-variant-numeric: tabular-nums;
}

/* Inline text buttons: underlined so they read as links without colour. */
.ac-link {
    display: inline;
    padding: 0;
    border: 0;
    background: none;
    color: var(--mud-palette-primary);
    font: inherit;
    /* A button centres wrapped text by default; a link reads left to right. */
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.ac-link + .ac-link::before {
    content: "\00B7";
    display: inline-block;
    margin: 0 6px;
    color: var(--mud-palette-text-secondary);
    text-decoration: none;
}

.ac-disclosure {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 4px 8px;
    border: 0;
    border-radius: var(--radius-sm, 6px);
    background: none;
    color: var(--mud-palette-primary);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.ac-disclosure:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

.ac-link:focus-visible,
.ac-disclosure:focus-visible,
.ac-cell:focus-visible,
.ac-person-chip:focus-visible,
.ac-matrix-wrap:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.ac-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

/* --- Choices (ChoiceCards.razor) ---------------------------------------
   Native radios under a fieldset; only the look changes. The whole card or
   segment is the target, the selected one is marked by tint, border AND a
   tick (cards) or a raised surface (segments), never by colour alone. */
.ac-choices {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.ac-choices__legend {
    margin-bottom: 8px;
    padding: 0;
    font-weight: 700;
    color: var(--text-heading, var(--mud-palette-text-primary));
}

.ac-choice {
    position: relative;
    display: block;
    cursor: pointer;
}

/* The input stays in the accessibility tree and takes focus; it's just not drawn. */
.ac-choice__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: inherit;
}

.ac-choice__body {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    height: 100%;
    border-radius: var(--radius-md, 10px);
    transition: background-color 120ms ease-out, border-color 120ms ease-out, box-shadow 120ms ease-out, transform 100ms ease-out;
}

.ac-choice__icon {
    flex: none;
    color: var(--mud-palette-text-secondary);
}

.ac-choice__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ac-choice__title {
    font-weight: 600;
    line-height: 1.35;
    color: var(--mud-palette-text-primary);
}

.ac-choice__desc {
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    line-height: 1.45;
}

.ac-choice__input:focus-visible + .ac-choice__body {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* Feedback on press, not on release. */
.ac-choice:active .ac-choice__body {
    transform: scale(0.985);
}

.ac-choices[disabled] .ac-choice {
    cursor: default;
}

.ac-choices[disabled] .ac-choice__body {
    opacity: 0.65;
}

/* Cards */
.ac-choices--cards .ac-choices__set {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
}

.ac-choices--cards .ac-choice__body {
    padding: 12px 14px;
    border: 1px solid var(--card-border, var(--mud-palette-lines-default));
    background: var(--mud-palette-surface);
}

.ac-choices--cards .ac-choice:hover .ac-choice__body {
    border-color: color-mix(in srgb, var(--mud-palette-primary) 45%, var(--mud-palette-lines-default));
}

.ac-choice__tick {
    flex: none;
    color: var(--mud-palette-primary);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 120ms ease-out, transform 160ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.ac-choices--cards .ac-choice.is-selected .ac-choice__body {
    border-color: var(--mud-palette-primary);
    box-shadow: inset 0 0 0 1px var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 7%, var(--mud-palette-surface));
}

.ac-choices--cards .ac-choice.is-selected .ac-choice__icon,
.ac-choices--cards .ac-choice.is-selected .ac-choice__tick {
    color: var(--mud-palette-primary);
    opacity: 1;
    transform: none;
}

/* Segmented: one track, the chosen segment raised out of it. */
.ac-question {
    margin: 0 0 18px;
}

.ac-choices--segmented .ac-choices__set {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 100%;
    padding: 4px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--mud-palette-text-primary) 6%, var(--mud-palette-surface));
}

.ac-choices--segmented .ac-choice__body {
    align-items: center;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 10px;
}

.ac-choices--segmented .ac-choice:hover .ac-choice__body {
    background: color-mix(in srgb, var(--mud-palette-text-primary) 5%, transparent);
}

.ac-choices--segmented .ac-choice.is-selected .ac-choice__body {
    background: var(--mud-palette-surface);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 2px 8px -2px rgb(0 0 0 / 0.12), 0 0 0 1px var(--mud-palette-lines-default);
}

.ac-choices--segmented .ac-choice.is-selected .ac-choice__icon {
    color: var(--mud-palette-primary);
}

.ac-choices--segmented .ac-choice.is-selected .ac-choice__title {
    font-weight: 700;
}

/* Narrow screens: the segments stack, full width, rather than squeeze. */
@media (max-width: 720px) {
    .ac-choices--segmented .ac-choices__set {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
}

.ac-ask-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 960px;
}

.ac-ask-row__field {
    flex: 1 1 0;
    min-width: 0;
}

.ac-ask-row__swap {
    margin-top: 8px;
}

@media (max-width: 720px) {
    .ac-ask-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ac-ask-row__swap {
        align-self: center;
        margin: 0;
        transform: rotate(90deg);
    }
}

/* --- Answers ----------------------------------------------------------- */
.ac-answer {
    max-width: 960px;
    margin-top: 16px;
    padding: 16px 18px;
    border: 1px solid var(--card-border, var(--mud-palette-lines-default));
    border-radius: var(--radius-md, 10px);
    background: var(--card-bg, var(--mud-palette-surface));
}

/* The answer: tone carried by words and the badge's icon; colour only tints. */
.ac-verdict {
    --ac-tone: var(--mud-palette-info);
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius-md, 10px);
    background: color-mix(in srgb, var(--ac-tone) 8%, var(--mud-palette-surface));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ac-tone) 22%, transparent);
    animation: ac-arrive 260ms cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

.ac-verdict--yes { --ac-tone: var(--mud-palette-success); }
.ac-verdict--partly { --ac-tone: var(--mud-palette-warning); }
.ac-verdict--no { --ac-tone: var(--mud-palette-error); }
.ac-verdict--info { --ac-tone: var(--mud-palette-info); }

.ac-verdict__badge {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--ac-tone) 16%, var(--mud-palette-surface));
}

.ac-verdict__icon {
    color: var(--ac-tone);
}

.ac-verdict__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text-heading, var(--mud-palette-text-primary));
}

.ac-verdict__detail {
    margin: 4px 0 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.ac-share-choice {
    margin-top: 20px;
}

/* New content arrives, it doesn't blink in: a short rise and fade that
   settles without overshoot. Reduced motion keeps only the fade. */
@keyframes ac-arrive {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

@keyframes ac-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Empty states (EmptyHint.razor) ------------------------------------ */
.ac-empty {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 960px;
    margin-top: 16px;
    padding: 18px 20px;
    border: 1px dashed color-mix(in srgb, var(--mud-palette-text-primary) 24%, transparent);
    border-radius: var(--radius-md, 10px);
}

.ac-empty__icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-surface));
    color: var(--mud-palette-primary);
}

.ac-empty__text {
    margin: 0;
    max-width: 64ch;
    color: var(--mud-palette-text-secondary);
    line-height: 1.5;
}

/* --- Tables -------------------------------------------------------------- */
.ac-table-wrap {
    margin-top: 10px;
    overflow-x: auto;
}

.ac-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.ac-table th,
.ac-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    text-align: left;
    vertical-align: top;
}

.ac-table thead th {
    color: var(--mud-palette-text-secondary);
    font-weight: 600;
}

/* The person (or location) column: wide enough that names don't break
   mid-word, and always left-aligned, wrapped or not. */
.ac-table tbody th {
    min-width: 12rem;
    font-weight: 600;
    text-align: left;
}

/* Long lists scroll with the page (the wheel never gets stuck inside a box)
   and keep their header row pinned under the app bar while you read. Inside
   a drawer the drawer body is what scrolls, so the header pins to its top. */
.ac-table-wrap--scroll {
    --ac-stick-top: 64px;
    overflow: visible;
    border: 1px solid var(--card-border, var(--mud-palette-lines-default));
    border-radius: var(--radius-md, 10px);
}

.ac-drawer__body .ac-table-wrap--scroll {
    --ac-stick-top: 0px;
}

.ac-table-wrap--scroll thead th {
    position: sticky;
    top: var(--ac-stick-top);
    z-index: 1;
    background: var(--mud-palette-surface);
    box-shadow: 0 1px 0 var(--mud-palette-lines-default);
}

/* Narrow screens: a table this wide has to scroll sideways, which means
   its header can no longer pin to the page. Reading wins over pinning. */
@media (max-width: 900px) {
    .ac-table-wrap--scroll {
        overflow-x: auto;
    }
}

.ac-table-wrap--scroll:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.ac-table tr.is-warning > th {
    box-shadow: inset 3px 0 0 var(--mud-palette-warning);
}

.ac-table__actions {
    white-space: nowrap;
    text-align: right !important;
}

.ac-cell-name,
.ac-cell-sub {
    display: block;
}

.ac-cell-sub {
    font-weight: 400;
}

.ac-yesno {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.ac-yesno--yes .mud-icon-root { color: var(--mud-palette-success); }
.ac-yesno--no .mud-icon-root { color: var(--mud-palette-text-secondary); }

.ac-warn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.ac-warn .mud-icon-root {
    color: var(--mud-palette-warning);
}

.ac-warn.ac-cell-sub {
    display: flex;
    margin-top: 4px;
    font-weight: 500;
}

/* "Which warehouse supplies them?": locations whose people see every
   warehouse's stock because no supplier is set. */
.ac-supply {
    max-width: 960px;
    margin: 0 0 16px;
    padding: 12px 16px;
    border: 1px solid var(--card-border, var(--mud-palette-lines-default));
    border-left: 4px solid var(--mud-palette-warning);
    border-radius: var(--radius-md, 10px);
    background: color-mix(in srgb, var(--mud-palette-warning) 6%, var(--mud-palette-surface));
}

.ac-supply__title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ac-supply__title .mud-icon-root {
    color: var(--mud-palette-warning);
}

.ac-supply__list {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.ac-supply__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 6px 0;
    border-top: 1px dashed var(--mud-palette-lines-default);
}

.ac-supply__name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.ac-supply__actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: auto;
}

.ac-person-chip:disabled {
    cursor: default;
    opacity: 0.6;
}

/* --- Tags and people ---------------------------------------------------- */
.ac-tag-list {
    display: inline;
}

/* "and 17 more" / "Show fewer": a real button, big enough to hit, that
   opens the rest of the row's locations in place. */
.ac-more {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
}

.ac-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 2px 4px 2px 0;
    padding: 2px 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 999px;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--mud-palette-text-primary);
}

.ac-tag--quiet {
    border-style: dashed;
    color: var(--mud-palette-text-secondary);
}

.ac-tag--changed {
    border-color: var(--mud-palette-info);
}

.ac-tag--changed .mud-icon-root {
    color: var(--mud-palette-info);
}

.ac-person {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.ac-person__avatar {
    display: grid;
    flex: none;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(145deg,
        color-mix(in srgb, var(--mud-palette-primary) 22%, var(--mud-palette-surface)),
        color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-surface)));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mud-palette-primary) 25%, transparent);
    color: var(--mud-palette-text-primary);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.ac-person__who {
    flex: 1 1 200px;
    min-width: 0;
}

.ac-person__name {
    margin: 0;
    font-weight: 700;
    font-size: 1.125rem;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text-heading, var(--mud-palette-text-primary));
}

.ac-person__meta {
    margin: 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
    overflow-wrap: anywhere;
}

.ac-tags {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 12px;
    margin: 14px 0 0;
}

.ac-tags dt {
    padding-top: 3px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
}

.ac-tags dd {
    margin: 0;
}

.ac-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin: 16px 0 0;
}

.ac-fact {
    padding: 14px 16px;
    border-radius: var(--radius-md, 10px);
    background: color-mix(in srgb, var(--mud-palette-text-primary) 3%, var(--mud-palette-surface));
    box-shadow: inset 0 0 0 1px var(--card-border, var(--mud-palette-lines-default));
}

.ac-fact dt {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
}

.ac-fact dd {
    margin: 4px 0 0;
}

.ac-fact__lead {
    margin: 0 0 4px;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--text-heading, var(--mud-palette-text-primary));
}

.ac-fact dd .ac-muted {
    margin: 0;
}

.ac-branches {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ac-branch {
    padding: 4px 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.ac-branch + .ac-branch {
    border-top: 1px dashed var(--mud-palette-lines-default);
}

.ac-branch__path {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.ac-branch__inside {
    margin-left: 4px;
    color: var(--mud-palette-text-secondary);
}

.ac-branch .ac-tag {
    margin-left: 6px;
}

.ac-group {
    margin-top: 14px;
}

.ac-group__title {
    margin: 0 0 6px;
    font-size: 0.9375rem;
    font-weight: 700;
}

.ac-group__count {
    margin-left: 6px;
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
}

.ac-people {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ac-people li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ac-person-chip {
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 999px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 120ms ease-out, background-color 120ms ease-out, transform 100ms ease-out;
}

.ac-person-chip:hover {
    border-color: var(--mud-palette-primary);
}

.ac-rule-list {
    margin: 0;
    padding-left: 18px;
    font-size: 0.875rem;
    line-height: 1.7;
}

/* --- Sharing grid -------------------------------------------------------- */
.ac-grid-pick {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    max-width: 960px;
    margin-bottom: 12px;
}

.ac-grid-pick > :first-child {
    flex: 1 1 320px;
    min-width: 0;
}

/* A data table: scrolling sideways inside its own region is allowed at
   narrow widths (WCAG 1.4.10 exempts two-dimensional data tables).
   It scrolls SIDEWAYS ONLY. Up and down is always the page, so the wheel
   never gets stuck in the grid; access-grid.js keeps the header row and a
   second sideways bar pinned under the app bar while the grid scrolls by. */
.ac-matrix-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--card-border, var(--mud-palette-lines-default));
    border-radius: var(--radius-md, 10px);
    /* The table's width must never widen the page: it scrolls in here. */
    contain: inline-size;
}

/* Never let the grid stretch the tab, and with it the whole page, sideways. */
.ac-sharing,
.ac-tabs .mud-tabs-panels {
    min-width: 0;
    max-width: 100%;
}

.ac-matrix__hint {
    margin: 0 0 8px;
}

.ac-matrix-frame {
    position: relative;
    min-width: 0;
    max-width: 100%;
}

/* With columns past the right edge, the header row grows a band at its
   bottom that holds a second sideways scrollbar (access-grid.js), so it is
   always right under the column names, whichever row you're on. */
.ac-matrix-frame.has-hbar .ac-matrix thead th,
.ac-matrix-frame.has-hbar .ac-matrix__corner {
    padding-bottom: 26px;
}

.ac-hbar {
    position: absolute;
    z-index: 4;
    height: 14px;
    overflow-x: scroll;
    overflow-y: hidden;
    scrollbar-width: auto;
    scrollbar-color: color-mix(in srgb, var(--mud-palette-text-secondary) 60%, transparent) var(--mud-palette-lines-default);
}

.ac-hbar[hidden] {
    display: none;
}

.ac-hbar__spacer {
    height: 1px;
}

/* One look for both sideways bars: a thumb you can see and grab. */
.ac-hbar::-webkit-scrollbar,
.ac-matrix-wrap::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

.ac-hbar::-webkit-scrollbar-track,
.ac-matrix-wrap::-webkit-scrollbar-track {
    background: var(--mud-palette-lines-default);
    border-radius: 999px;
}

.ac-hbar::-webkit-scrollbar-thumb,
.ac-matrix-wrap::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--mud-palette-text-secondary) 60%, transparent);
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.ac-hbar::-webkit-scrollbar-thumb:hover,
.ac-matrix-wrap::-webkit-scrollbar-thumb:hover {
    background-color: var(--mud-palette-primary);
}

.ac-matrix {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8125rem;
}


.ac-matrix th,
.ac-matrix td {
    padding: 6px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    border-right: 1px solid var(--mud-palette-lines-default);
    /* Opaque, not the card tint: sticky headers must hide what scrolls under them. */
    background: var(--mud-palette-surface);
}

/* The header row slides down by --ac-head-shift (set by access-grid.js) to
   stay under the app bar while the page scrolls past the grid. */
.ac-matrix thead th,
.ac-matrix__corner {
    position: relative;
    z-index: 2;
    transform: translateY(var(--ac-head-shift, 0px));
}

/* Pinned: a soft edge so rows clearly pass under the header. */
.ac-matrix-frame.is-pinned .ac-matrix thead th,
.ac-matrix-frame.is-pinned .ac-matrix__corner {
    box-shadow: 0 6px 8px -6px rgb(0 0 0 / 0.35);
}

/* The location names on the side stay put while the grid scrolls sideways. */
.ac-matrix tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
}

.ac-matrix__corner {
    position: sticky;
    left: 0;
    z-index: 3 !important;
    min-width: 150px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    vertical-align: bottom;
}

.ac-matrix__corner-row,
.ac-matrix__corner-col {
    display: block;
}

.ac-matrix__corner-col {
    text-align: right;
}

.ac-matrix__col {
    min-width: 116px;
    max-width: 160px;
    vertical-align: bottom;
    text-align: left;
}

.ac-matrix__row {
    min-width: 150px;
    max-width: 220px;
    text-align: left;
}

.ac-matrix__name {
    display: block;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.ac-matrix__type {
    display: block;
    color: var(--mud-palette-text-secondary);
    font-weight: 400;
}

/* Row and column highlight (access-grid.js): point at or focus a cell and
   its row and column tint, and their names on the side and on top light up
   with a bar along the edge facing the grid, so the cue isn't colour alone. */
.ac-matrix td.is-hot-line {
    background: color-mix(in srgb, var(--mud-palette-primary) 7%, var(--mud-palette-surface));
}

.ac-matrix th.is-hot,
.ac-matrix td.is-hot {
    background: color-mix(in srgb, var(--mud-palette-primary) 16%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
}

.ac-matrix thead th.is-hot {
    box-shadow: inset 0 4px 0 var(--mud-palette-primary);
}

.ac-matrix-frame.is-pinned .ac-matrix thead th.is-hot {
    box-shadow: inset 0 4px 0 var(--mud-palette-primary), 0 6px 8px -6px rgb(0 0 0 / 0.35);
}

.ac-matrix tbody th.is-hot {
    box-shadow: inset -4px 0 0 var(--mud-palette-primary);
}

@media (prefers-reduced-motion: no-preference) {
    .ac-matrix th,
    .ac-matrix td {
        transition: background-color 80ms linear;
    }
}

.ac-cell {
    --ac-cell: var(--mud-palette-lines-default);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid color-mix(in srgb, var(--ac-cell) 55%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--ac-cell) 12%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background-color 120ms ease-out, border-color 120ms ease-out, transform 100ms ease-out;
}

.ac-cell .mud-icon-root {
    color: var(--ac-cell);
}

.ac-cell--see { --ac-cell: var(--mud-palette-success); }
.ac-cell--order { --ac-cell: var(--mud-palette-info); }
/* The least a rule gives, so the quietest: neutral, told apart by its icon and words. */
.ac-cell--items { --ac-cell: var(--mud-palette-text-secondary); }

/* Empty cells stay quiet so shared ones are what the eye finds: a faint
   dash, no frame, until the pointer or keyboard arrives. */
.ac-cell--none {
    --ac-cell: var(--mud-palette-lines-default);
    align-items: center;
    justify-content: center;
    border-color: transparent;
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
}

.ac-cell__dash {
    font-size: 1rem;
    line-height: 1;
}

.ac-cell--none:hover,
.ac-cell--none:focus-visible {
    border-color: var(--mud-palette-lines-default);
    background: color-mix(in srgb, var(--mud-palette-primary) 6%, var(--mud-palette-surface));
}

.ac-cell--own {
    align-items: center;
    justify-content: center;
    border-color: transparent;
    background: repeating-linear-gradient(135deg,
        transparent 0 6px,
        color-mix(in srgb, var(--mud-palette-text-primary) 5%, transparent) 6px 7px);
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
    cursor: default;
}

.ac-cell.is-via {
    border-style: dashed;
    background: color-mix(in srgb, var(--ac-cell) 5%, var(--mud-palette-surface));
}

.ac-cell__via {
    color: var(--mud-palette-text-secondary);
    font-weight: 400;
    font-size: 0.75rem;
}

.ac-cell:not(.ac-cell--own):not(.ac-cell--none):hover {
    border-color: var(--mud-palette-primary);
}

/* Feedback on press, not on release. */
.ac-cell:not(.ac-cell--own):active,
.ac-person-chip:active,
.ac-drawer__tab:active,
.ac-disclosure:active {
    transform: scale(0.97);
}

.ac-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
}

.ac-legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ac-cell--sample {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    width: auto;
    min-height: 0;
    padding: 2px 8px;
    cursor: default;
}

/* --- Roles ------------------------------------------------------------- */
.ac-role-list {
    display: grid;
    gap: 12px;
}

.ac-role {
    padding: 14px 16px;
    border: 1px solid var(--card-border, var(--mud-palette-lines-default));
    border-radius: var(--radius-md, 10px);
    background: var(--card-bg, var(--mud-palette-surface));
}

.ac-role__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 10px;
}

.ac-role__name {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.ac-role__spacer {
    flex: 1 1 auto;
}

.ac-role__settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px 20px;
}

.ac-role__help {
    margin: 4px 2px 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    line-height: 1.45;
}

.ac-role__default {
    display: block;
    margin-top: 2px;
    font-weight: 600;
}

/* --- People -------------------------------------------------------------- */
.ac-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    max-width: 960px;
}

.ac-filter-row > :first-child {
    flex: 1 1 280px;
}

/* --- Drawers ------------------------------------------------------------ */
.ac-drawer {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.ac-drawer__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 12px;
}

.ac-drawer__head .ac-drawer__title {
    letter-spacing: -0.01em;
}

.ac-drawer__head > .mud-icon-root {
    margin-top: 4px;
}

.ac-drawer__titles {
    flex: 1;
    min-width: 0;
}

.ac-drawer__title {
    flex: 1;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.35;
}

.ac-drawer__titles .ac-muted {
    margin: 0;
    overflow-wrap: anywhere;
}

.ac-drawer__head .ac-person__avatar {
    flex: none;
}

.ac-drawer__tabs {
    display: flex;
    gap: 4px;
    padding: 0 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.ac-drawer__tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 12px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.ac-drawer__tab[aria-selected="true"] {
    border-bottom-color: var(--mud-palette-primary);
    color: var(--mud-palette-text-primary);
}

.ac-drawer__tab:hover {
    color: var(--mud-palette-text-primary);
}

.ac-drawer__tab:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

.ac-drawer__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
}

/* Scroll edge, not a hard divider: whatever sits right above the body (the
   header, or the tab bar in the person drawer) casts a soft shade only once
   content has scrolled under it. Progressive: browsers without
   scroll-driven animations simply show no shade. */
@supports (animation-timeline: scroll()) {
    .ac-drawer {
        timeline-scope: --ac-drawer-body;
    }

    .ac-drawer__body {
        scroll-timeline: --ac-drawer-body block;
    }

    .ac-drawer__head:has(+ .ac-drawer__body),
    .ac-drawer__tabs {
        position: relative;
        z-index: 1;
        animation: ac-scroll-edge linear both;
        animation-timeline: --ac-drawer-body;
        animation-range: 0 32px;
    }
}

@keyframes ac-scroll-edge {
    from { box-shadow: 0 0 0 0 transparent; }
    to { box-shadow: 0 8px 10px -8px rgb(0 0 0 / 0.3); }
}

.ac-drawer__body .ac-answer {
    margin-top: 0;
    padding: 0;
    border: 0;
    background: none;
}

.ac-drawer__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.ac-preview {
    --ac-tone: var(--mud-palette-info);
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-top: 16px;
    padding: 10px 12px;
    border-left: 4px solid var(--ac-tone);
    border-radius: var(--radius-sm, 6px);
    background: color-mix(in srgb, var(--ac-tone) 8%, transparent);
    font-size: 0.875rem;
    line-height: 1.5;
}

.ac-preview p {
    margin: 0;
}

.ac-preview .mud-icon-root {
    flex: none;
    margin-top: 2px;
    color: var(--ac-tone);
}

.ac-preview--warn {
    --ac-tone: var(--mud-palette-warning);
}

/* --- Preferences ---------------------------------------------------------
   Reduced motion: no rises, scales or springs, only fades and colour.
   More contrast: firm outlines instead of hairlines and tints.
   Forced colours: the selected choice keeps a system-coloured outline,
   since shadows and tints are dropped. */
@media (prefers-reduced-motion: reduce) {
    .ac-verdict {
        animation-name: ac-fade;
    }

    .ac-choice__body,
    .ac-choice__tick,
    .ac-cell,
    .ac-person-chip,
    .ac-matrix th,
    .ac-matrix td {
        transition: none;
    }

    .ac-choice:active .ac-choice__body,
    .ac-cell:not(.ac-cell--own):active,
    .ac-person-chip:active,
    .ac-drawer__tab:active,
    .ac-disclosure:active,
    .ac-choice__tick {
        transform: none;
    }
}

@media (prefers-contrast: more) {
    .ac-choices--cards .ac-choice__body,
    .ac-fact,
    .ac-answer,
    .ac-role,
    .ac-empty {
        border-color: var(--mud-palette-text-secondary);
        box-shadow: inset 0 0 0 1px var(--mud-palette-text-secondary);
    }

    .ac-choices--segmented .ac-choices__set {
        box-shadow: inset 0 0 0 1px var(--mud-palette-text-secondary);
    }

    .ac-cell--none {
        border-color: var(--mud-palette-lines-default);
    }
}

@media (forced-colors: active) {
    .ac-choice.is-selected .ac-choice__body {
        outline: 2px solid Highlight;
        outline-offset: -2px;
    }

    .ac-choice__input:focus-visible + .ac-choice__body {
        outline: 2px solid Highlight;
    }
}

/* Tab counts sit inside the label (the tab bar clips anything above it).
   Soft tint + primary text keeps 4.5:1 in both themes; the warning tint is
   paired with words for screen readers, so colour is never the only cue. */
.ac-tab-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ac-tab-count {
    --ac-count: var(--mud-palette-info);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--ac-count) 16%, var(--mud-palette-surface));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ac-count) 45%, transparent);
    color: var(--mud-palette-text-primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.ac-tab-count--warn {
    --ac-count: var(--mud-palette-warning);
}

/* --- Filters (every tab) --------------------------------------------------- */
.ac-filter-select {
    flex: 0 1 240px;
    min-width: 180px;
}

/* Four or more filters: equal columns that wrap as whole cells, so a filter
   that drops to the next line keeps the same width as the ones above it.
   The full-width row lets them sit on one line beside the view switch. */
.ac-filter-row--full {
    max-width: none;
    flex-wrap: nowrap;
    align-items: flex-start;
}

.ac-filter-row--full > .ac-filter-grid {
    flex: 1 1 auto;
    min-width: 0;
}

.ac-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: center;
    gap: 8px 16px;
}

.ac-filter-row--full > .ac-view-switch {
    flex: none;
}

@media (max-width: 720px) {
    .ac-filter-row--full {
        flex-wrap: wrap;
    }
}

.ac-filter-row--quiet {
    margin: 4px 0 8px;
}

.ac-ask-row__side {
    flex: 0 1 240px;
    min-width: 180px;
}

/* List / Grid: a two-button switch. aria-pressed carries the state; the
   filled background and the bold weight say it visually, never colour alone. */
.ac-view-switch {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    background: var(--mud-palette-surface);
}

.ac-view-switch__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 120ms ease-out, color 120ms ease-out, transform 100ms ease-out;
}

.ac-view-switch__btn[aria-pressed="true"] {
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
    font-weight: 700;
}

.ac-view-switch__btn:hover {
    color: var(--mud-palette-text-primary);
}

.ac-view-switch__btn:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.ac-view-switch__btn:active {
    transform: scale(0.97);
}

/* --- Reach grid (People › Grid) -------------------------------------------- */
.ac-cell--change { --ac-cell: var(--mud-palette-primary); }

/* Only part of the area: a dashed edge, plus the "x of y" line in words. */
.ac-cell.is-part {
    border-style: dashed;
    background: color-mix(in srgb, var(--ac-cell) 6%, var(--mud-palette-surface));
}

.ac-matrix--reach .ac-matrix__row .ac-matrix__type {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Supplies itself (sharing grid diagonal) ------------------------------- */
.ac-cell--own.is-self {
    border: 1px dashed color-mix(in srgb, var(--mud-palette-info) 55%, transparent);
    background: color-mix(in srgb, var(--mud-palette-info) 8%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
    font-weight: 600;
}

/* --- Catalogue ------------------------------------------------------------- */
/* Whose items: one dropdown, with the picked owner at a glance beside it.
   On a narrow screen the facts drop under the dropdown. */
.ac-owner-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin: 4px 0 14px;
}

/* MudBlazor wraps the field in its own .mud-select box, and that box is the
   flex item here: size it, or it grows and pushes the facts away. */
.ac-owner-row > .mud-select {
    flex: 0 1 360px;
    min-width: 240px;
}

.ac-catalog__summary {
    flex: 1 1 320px;
    min-width: 0;
}

/* A row in the dropdown: the owner's name over how much it owns and who sees it. */
.ac-owner-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-block: 2px;
}

.ac-owner-option .mud-icon-root {
    flex: none;
    color: var(--mud-palette-text-secondary);
}

.ac-owner-option__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ac-owner-option__name {
    font-weight: 600;
    line-height: 1.3;
}

.ac-owner-option__meta {
    font-size: 0.75rem;
    line-height: 1.35;
    color: var(--mud-palette-text-secondary);
}

/* The closed field repeats the picked row (MudBlazor shows the item's own
   content): keep it to the icon and the name on one line. The second line is
   in the facts beside it. */
.ac-owner-pick .mud-input-slot .ac-owner-option {
    display: inline-flex;
    padding-block: 0;
    vertical-align: middle;
}

.ac-owner-pick .mud-input-slot .ac-owner-option__meta {
    display: none;
}

.ac-catalog__summary p {
    margin: 0;
}

/* The owner at a glance: a row of small facts, each with its own icon. */
.ac-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ac-fact-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 4px 12px;
    border: 1px solid var(--card-border, var(--mud-palette-lines-default));
    border-radius: 999px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.ac-fact-chip .mud-icon-root {
    font-size: 1.05rem;
    color: var(--mud-palette-text-secondary);
}

.ac-fact-chip strong {
    font-weight: 700;
}

.ac-fact-chip.is-kept {
    border-color: color-mix(in srgb, var(--mud-palette-warning) 45%, transparent);
    background: color-mix(in srgb, var(--mud-palette-warning) 8%, var(--mud-palette-surface));
}

.ac-fact-chip.is-warn {
    border-style: dashed;
    border-color: color-mix(in srgb, var(--mud-palette-warning) 60%, transparent);
}

.ac-fact-chip.is-kept .mud-icon-root,
.ac-fact-chip.is-warn .mud-icon-root {
    color: var(--mud-palette-warning);
}

.ac-catalog__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 16px;
    margin-top: 10px;
}

.ac-catalog__bar > p {
    margin: 0;
}

.ac-catalog__tools {
    display: inline-flex;
    gap: 4px;
}

.ac-disclosure:disabled {
    background: none;
    color: var(--mud-palette-text-disabled);
    cursor: default;
}

/* The category tree. Rows centre on the line so the name, the count and the
   sharing switch read across as one; depth indents the whole head. */
.ac-table--catalog th,
.ac-table--catalog td {
    vertical-align: middle;
}

.ac-table--catalog tbody th {
    min-width: 16rem;
    font-weight: 500;
}

.ac-table--catalog tr.is-root > th {
    font-weight: 700;
}

.ac-table--catalog tr.ac-cat-row:hover > th,
.ac-table--catalog tr.ac-cat-row:hover > td {
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 3%, transparent);
}

.ac-table--catalog tr.is-kept > th,
.ac-table--catalog tr.is-kept > td {
    background: color-mix(in srgb, var(--mud-palette-warning) 6%, transparent);
}

.ac-table--catalog tr.ac-cat-row.is-kept:hover > th,
.ac-table--catalog tr.ac-cat-row.is-kept:hover > td {
    background-color: color-mix(in srgb, var(--mud-palette-warning) 10%, transparent);
}

/* Kept: a warning edge as well as the tint, so it doesn't rest on colour alone
   (the lock and the words say it too). */
.ac-table--catalog tr.ac-cat-row.is-kept > th {
    box-shadow: inset 3px 0 0 var(--mud-palette-warning);
}

.ac-cat-head {
    display: flex;
    align-items: center;
    padding-left: calc(var(--ac-depth, 0) * 22px);
}

.ac-cat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    margin-left: -4px;
    padding: 4px 10px 4px 4px;
    border: 0;
    border-radius: var(--radius-sm, 6px);
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 120ms ease-out;
}

.ac-cat-toggle.is-static {
    cursor: default;
}

button.ac-cat-toggle:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

button.ac-cat-toggle:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 1px;
}

.ac-cat-chevron {
    display: inline-block;
    flex: none;
    width: 20px;
    height: 20px;
    color: var(--mud-palette-text-secondary);
    transition: transform 150ms ease-out;
}

.ac-cat-toggle[aria-expanded="true"] .ac-cat-chevron {
    transform: rotate(90deg);
}

.ac-cat-folder {
    flex: none;
    color: color-mix(in srgb, var(--mud-palette-primary) 70%, var(--mud-palette-text-secondary));
}

.ac-cat-row.is-kept .ac-cat-folder {
    color: var(--mud-palette-warning);
}

.ac-cat-name {
    overflow-wrap: anywhere;
}

.ac-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ac-count {
    display: inline-block;
    min-width: 2.25rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--mud-palette-text-primary) 7%, transparent);
    font-weight: 600;
    text-align: center;
}

.ac-count.is-zero {
    background: none;
    color: var(--mud-palette-text-secondary);
    font-weight: 400;
}

.ac-cat-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--mud-palette-text-secondary);
}

.ac-cat-state .mud-icon-root {
    font-size: 1.05rem;
}

.ac-cat-state.is-kept {
    color: var(--mud-palette-text-primary);
    font-weight: 600;
}

.ac-cat-state.is-kept .mud-icon-root {
    color: var(--mud-palette-warning);
}

/* Who sees them: the List/Grid switch, compact, with "kept" pressed in the
   warning tint. aria-pressed carries the state; the fill and weight show it. */
.ac-view-switch--sharing .ac-view-switch__btn {
    min-height: 30px;
    padding: 3px 10px;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.ac-view-switch--sharing .ac-view-switch__btn .mud-icon-root {
    font-size: 1.05rem;
}

.ac-view-switch--sharing .ac-view-switch__btn--kept[aria-pressed="true"] {
    background: color-mix(in srgb, var(--mud-palette-warning) 22%, var(--mud-palette-surface));
}

.ac-view-switch--sharing .ac-view-switch__btn:disabled {
    cursor: progress;
}

.ac-cat-move .mud-button-root {
    text-transform: none;
    letter-spacing: 0;
}

/* An open category's items sit in a band joined to its row. */
.ac-table--catalog tr.ac-cat-row:has(+ tr.ac-cat-items) > th,
.ac-table--catalog tr.ac-cat-row:has(+ tr.ac-cat-items) > td {
    border-bottom-color: transparent;
}

.ac-table--catalog tr.ac-cat-items > td {
    padding: 0 10px 14px;
    background: color-mix(in srgb, var(--mud-palette-text-primary) 2.5%, transparent);
}

.ac-table--catalog tr.ac-cat-items.is-kept > td {
    background: color-mix(in srgb, var(--mud-palette-warning) 6%, transparent);
}

/* Lines the cards up under the category name (past the chevron). */
.ac-cat-items__body {
    padding: 2px 0 0 calc(var(--ac-depth, 1) * 22px + 4px);
}

.ac-cat-items__lead {
    margin: 0 0 8px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
}

.ac-item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Each item is a button that opens the quick view, so the whole card is the
   target. The name keeps a link-like underline so it reads as clickable
   without relying on colour. */
.ac-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    width: 100%;
    height: 100%;
    min-width: 0;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--card-border, var(--mud-palette-lines-default));
    border-radius: var(--radius-sm, 8px);
    background: var(--mud-palette-surface);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
}

.ac-item:hover {
    border-color: color-mix(in srgb, var(--mud-palette-primary) 45%, var(--mud-palette-lines-default));
    box-shadow: 0 1px 4px color-mix(in srgb, var(--mud-palette-text-primary) 10%, transparent);
}

.ac-item:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* The one showing in the quick view. */
.ac-item.is-active {
    border-color: var(--mud-palette-primary);
    box-shadow: inset 3px 0 0 var(--mud-palette-primary);
}

.ac-item__name {
    color: var(--mud-palette-primary);
    font-weight: 600;
    line-height: 1.35;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}

.ac-item:hover .ac-item__name {
    text-decoration-color: currentColor;
}

.ac-item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    line-height: 1.4;
}

.ac-item__sku {
    color: var(--mud-palette-text-primary);
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Consolas, monospace);
}

/* The Access Center's facts at the top of the item quick view. */
/* A neutral lift on whatever surface the drawer has, edged in the Catalogue
   tab's hue (the tab it was opened from), like the tab intros. A tinted
   border glowed against the dark drawer. */
.ac-item-context {
    padding: 12px 14px 12px 17px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--radius-md, 10px);
    background: color-mix(in srgb, var(--mud-palette-text-primary) 3%, transparent);
    box-shadow: inset 3px 0 0 var(--ac-c-catalog, var(--mud-palette-primary));
}

.ac-item-context__title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    color: var(--mud-palette-text-primary);
    font-size: 0.875rem;
    font-weight: 700;
}

.ac-item-context__title .mud-icon-root {
    color: var(--ac-c-catalog, var(--mud-palette-primary));
}

.ac-item-context__dl {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 6px 12px;
    margin: 0;
    font-size: 0.875rem;
}

.ac-item-context__dl dt {
    color: var(--mud-palette-text-secondary);
}

.ac-item-context__dl dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.ac-item-context__note {
    margin: 10px 0 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
}

@media (max-width: 420px) {
    .ac-item-context__dl {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .ac-item-context__dl dd + dt {
        margin-top: 6px;
    }
}

/* Phones: less indent per level so deep categories keep room for their names. */
@media (max-width: 600px) {
    .ac-cat-head {
        padding-left: calc(var(--ac-depth, 0) * 12px);
    }

    .ac-cat-items__body {
        padding-left: 0;
    }

    .ac-item-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Page identity: hero, figures, tab sheet, section colours --------------
   One colour per section, the way a settings app gives each pane its own
   tile: a tab's icon, its figure in the hero, the slider under it when it's
   active and the edge of its intro all share one hue. Hues mark non-text
   things only (icon tiles, edges, fills); text stays on the neutral text
   colours. The light hexes take white on top at 4.5:1 or better; in dark mode
   they're lifted for the dark canvas and icons go hue-on-tint instead. */
.ac-page {
    --ac-c-check: var(--mud-palette-primary);
    --ac-c-sharing: var(--mud-palette-info);
    --ac-c-roles: #4f46e5;
    --ac-c-people: var(--mud-palette-tertiary);
    --ac-c-catalog: #7c3aed;
    --ac-c-warn: var(--mud-palette-warning);
    --ac-c-ok: var(--mud-palette-success);
}

.mud-theme-dark .ac-page {
    --ac-c-roles: #a5b4fc;
    --ac-c-catalog: #c4b5fd;
}

.ac-hue-check,
.ac-check { --ac-hue: var(--ac-c-check); }
.ac-hue-sharing,
.ac-sharing { --ac-hue: var(--ac-c-sharing); }
.ac-hue-roles,
.ac-roles { --ac-hue: var(--ac-c-roles); }
.ac-hue-people,
.ac-people-panel { --ac-hue: var(--ac-c-people); }
.ac-hue-catalog,
.ac-catalog { --ac-hue: var(--ac-c-catalog); }
.ac-hue-warn { --ac-hue: var(--ac-c-warn); }
.ac-hue-ok { --ac-hue: var(--ac-c-ok); }

/* The hero: a card with a faint wash of the page's two lead hues coming in
   from the top corners, so the most important page in Admin reads as one. */
.ac-hero {
    position: relative;
    margin-bottom: 20px;
    padding: 22px 24px 20px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg, 20px);
    background:
        radial-gradient(120% 150% at 0% 0%, color-mix(in srgb, var(--ac-c-check) 12%, transparent) 0%, transparent 55%),
        radial-gradient(90% 130% at 100% 0%, color-mix(in srgb, var(--ac-c-roles) 10%, transparent) 0%, transparent 60%),
        var(--card-bg);
    box-shadow: var(--shadow-card);
}

.ac-hero .tansi-header {
    margin-bottom: 18px;
}

.ac-hero > .tansi-header:last-child {
    margin-bottom: 0;
}

/* The header tile becomes the page's mark, brand teal into indigo. Fixed dark
   stops in both themes so the white icon keeps its contrast. */
.ac-hero .tansi-header__icon {
    color: #ffffff;
    background: linear-gradient(135deg, #0a728f 0%, #4338ca 100%);
    box-shadow: 0 8px 18px -8px rgba(67, 56, 202, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.ac-hero .ac-hero__action {
    background: var(--card-bg);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
}

/* The figures: each one a shortcut to the tab that explains it. A thin edge
   of its hue along the top, the hue's tile, the number, the words. */
.ac-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

.ac-kpi {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    margin: 0;
    padding: 14px 12px 14px 16px;
    border: 1px solid color-mix(in srgb, var(--ac-hue) 22%, var(--card-border));
    border-radius: var(--radius-md, 14px);
    background: color-mix(in srgb, var(--card-bg) 80%, transparent);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
    backdrop-filter: blur(8px) saturate(140%);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    transition: transform 160ms ease-out, box-shadow 200ms ease-out, border-color 160ms ease-out;
}

.ac-kpi::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ac-hue), color-mix(in srgb, var(--ac-hue) 12%, transparent));
    opacity: 0.6;
    transition: opacity 160ms ease-out;
}

/* Needs attention: the edge stays solid and the card takes a hint of the hue. */
.ac-kpi.is-marked {
    border-color: color-mix(in srgb, var(--ac-hue) 45%, var(--card-border));
    background: color-mix(in srgb, var(--ac-hue) 7%, var(--card-bg));
}

.ac-kpi.is-marked::before {
    height: 4px;
    opacity: 1;
}

.ac-kpi:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--ac-hue) 45%, var(--card-border));
    box-shadow: 0 12px 24px -14px color-mix(in srgb, var(--ac-hue) 55%, transparent), var(--shadow-card);
}

.ac-kpi:hover::before {
    opacity: 1;
}

/* Feedback on the press itself, not the release. */
.ac-kpi:active {
    transform: scale(0.98);
    transition-duration: 80ms;
}

.ac-kpi:focus-visible {
    outline: 2px solid var(--ac-hue);
    outline-offset: 2px;
}

.ac-kpi__icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--ac-hue), color-mix(in srgb, var(--ac-hue) 72%, #000000));
    box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--ac-hue) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.mud-theme-dark .ac-kpi__icon {
    color: var(--ac-hue);
    background: color-mix(in srgb, var(--ac-hue) 18%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ac-hue) 35%, transparent);
}

.ac-kpi__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.ac-kpi__value {
    color: var(--text-heading);
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums lining-nums;
}

.ac-kpi__label {
    margin-top: 2px;
    color: var(--text-caption);
    font-size: 0.8125rem;
    line-height: 1.35;
}

/* Points the way it goes: nudges right on hover. */
.ac-kpi__go {
    flex: none;
    color: var(--text-caption);
    transition: transform 160ms ease-out, color 160ms ease-out;
}

.ac-kpi:hover .ac-kpi__go {
    transform: translateX(2px);
    color: var(--ac-hue);
}

.ac-hero__alert {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 14px;
    padding: 10px 12px 10px 14px;
    border: 1px solid color-mix(in srgb, var(--ac-c-warn) 35%, transparent);
    border-radius: var(--radius-md, 14px);
    background: color-mix(in srgb, var(--ac-c-warn) 9%, var(--card-bg));
    color: var(--text-heading);
    font-size: 0.875rem;
    line-height: 1.5;
}

.ac-hero__alert > .mud-icon-root {
    flex: none;
    color: var(--ac-c-warn);
}

.ac-hero__alert-text {
    flex: 1 1 320px;
}

/* The tabs and what's under them sit on one sheet, so the content has a
   surface of its own instead of floating on the page. No overflow clip here:
   the tables' headers pin to the page while it scrolls. */
.ac-tabs {
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg, 20px);
    background: var(--card-bg);
    box-shadow: var(--shadow-card);
}

.ac-tabs .mud-tabs-tabbar {
    padding: 6px 10px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--radius-lg, 20px) var(--radius-lg, 20px) 0 0;
    background: transparent;
}

.ac-tabs .mud-tab {
    min-height: 54px;
    padding: 6px 14px;
    border-radius: 10px 10px 0 0;
    color: var(--text-caption);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.ac-tabs .mud-tab:hover {
    background: color-mix(in srgb, var(--text-heading) 4%, transparent);
    color: var(--text-heading);
}

.ac-tabs .mud-tab.mud-tab-active {
    color: var(--text-heading);
}

.ac-tab-label__icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    color: var(--ac-hue);
    background: color-mix(in srgb, var(--ac-hue) 13%, transparent);
    transition: background-color 160ms ease-out, color 160ms ease-out;
}

.mud-tab-active .ac-tab-label__icon {
    color: #ffffff;
    background: linear-gradient(135deg, var(--ac-hue), color-mix(in srgb, var(--ac-hue) 72%, #000000));
}

.mud-theme-dark .mud-tab-active .ac-tab-label__icon {
    color: var(--ac-hue);
    background: color-mix(in srgb, var(--ac-hue) 26%, transparent);
}

/* The slider under the active tab takes that tab's hue. */
.ac-tabs .mud-tab-slider.mud-tab-slider-horizontal {
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--ac-c-check);
}

.ac-tabs--sharing .mud-tab-slider.mud-tab-slider-horizontal { background: var(--ac-c-sharing); }
.ac-tabs--roles .mud-tab-slider.mud-tab-slider-horizontal { background: var(--ac-c-roles); }
.ac-tabs--people .mud-tab-slider.mud-tab-slider-horizontal { background: var(--ac-c-people); }
.ac-tabs--catalog .mud-tab-slider.mud-tab-slider-horizontal { background: var(--ac-c-catalog); }

.ac-tabs .ac-tabs__panel {
    padding: 20px 24px 24px;
}

/* Each tab opens on its intro, edged in the tab's hue. */
.ac-tabs .ac-intro {
    padding: 2px 0 2px 14px;
    border-left: 3px solid var(--ac-hue, var(--ac-c-check));
}

@media (max-width: 600px) {
    .ac-hero {
        padding: 16px;
    }

    .ac-tabs .ac-tabs__panel {
        padding: 16px;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .ac-kpi {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background: var(--card-bg);
    }
}

@media (prefers-contrast: more) {
    .ac-hero,
    .ac-tabs,
    .ac-kpi {
        border-color: var(--mud-palette-text-secondary);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ac-view-switch__btn,
    .ac-cat-toggle,
    .ac-cat-chevron,
    .ac-item,
    .ac-kpi,
    .ac-kpi::before,
    .ac-kpi__go,
    .ac-tab-label__icon {
        transition: none;
    }

    .ac-view-switch__btn:active,
    .ac-kpi:hover,
    .ac-kpi:active,
    .ac-kpi:hover .ac-kpi__go {
        transform: none;
    }
}

@media (forced-colors: active) {
    .ac-view-switch__btn[aria-pressed="true"] {
        outline: 2px solid ButtonText;
    }

    .ac-kpi {
        border: 1px solid ButtonText;
    }

    .ac-kpi.is-marked {
        border-width: 3px;
    }

    .ac-cell.is-part,
    .ac-cell--own.is-self {
        border: 1px dashed ButtonText;
    }
}

/* --- Busy: something is being saved or worked out again ------------------
   Saving a change and working the answers out again can take a few seconds
   on a large workspace. BusyNote puts a spinner and a few words beside the
   thing being saved; the status pill (.ac-activity) says it once for the whole
   page, stays in view wherever you have scrolled and sits above drawers. */
.ac-busy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--mud-palette-text-primary);
    font-size: 0.875rem;
    line-height: 1.35;
}

.ac-busy__spin {
    flex: none;
}

/* Across the top of a card whose answer is being worked out again. */
.ac-busy--banner {
    display: flex;
    width: 100%;
    margin: 0 0 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mud-palette-primary) 28%, transparent);
}

.ac-share-choice__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
}

.ac-share-choice__head .ac-h3 {
    margin-right: auto;
}

.ac-rule__busy {
    margin: 2px 0 6px;
}

.ac-cat-busy {
    margin-right: 6px;
}

.ac-activity {
    position: fixed;
    top: calc(var(--mud-appbar-height, 64px) + 12px);
    left: 50%;
    z-index: calc(var(--mud-zindex-appbar, 1300) + 50); /* over drawers, under dialogs and snackbars */
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 32px);
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    color: var(--mud-palette-text-primary);
    font-weight: 500;
    line-height: 1.35;
}

/* Fades in after a moment, so a quick save doesn't flash it. */
.ac-activity.is-on {
    padding: 8px 18px 8px 12px;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 35%, var(--mud-palette-lines-default));
    border-radius: 999px;
    background: var(--mud-palette-surface);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
    animation: ac-activity-in 180ms ease-out 150ms both;
}

@keyframes ac-activity-in {
    from {
        opacity: 0;
        transform: translate(-50%, -6px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.ac-activity__spin {
    flex: none;
}

@media (prefers-reduced-motion: reduce) {
    .ac-activity.is-on {
        animation: none;
        opacity: 1;
    }
}

@media (forced-colors: active) {
    .ac-activity.is-on,
    .ac-busy--banner {
        border: 1px solid CanvasText;
    }
}

/* The People list's count, with its download on the right. */
.ac-list-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    margin-bottom: 8px;
}

.ac-list-bar > p {
    margin: 0;
}
