/* User Management admin pages. Global, not scoped: these classes are shared by the Admin components and the pages
   that compose them. Colours come only from the portal tokens in app.css, so dark mode follows automatically.
   Generic mock-up class names (.btn, .input, .chip, .field, .tip) are confined to the admin roots through :where(),
   which adds no specificity, so they cannot leak into the dashboard or search pages that use the same names. */

.admin-page {
    padding: 20px 24px 48px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--tx);
}

/* The mock-up's dark muted text and soft fill differ from the portal's, so they are re-declared for the admin roots only. */

html[data-theme="dark"] :is(.admin-page, .admin-dialog) {
    --mut: rgba(255, 255, 255, .72);
    --mut2: rgba(255, 255, 255, .5);
    --soft: rgba(255, 157, 92, .14);
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) :is(.admin-page, .admin-dialog) {
        --mut: rgba(255, 255, 255, .72);
        --mut2: rgba(255, 255, 255, .5);
        --soft: rgba(255, 157, 92, .14);
    }
}

/* Breadcrumbs and page head */

.breadcrumbs {
    font-size: 12px;
    color: var(--mut);
    margin-bottom: -8px;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumbs li + li::before {
    content: "/";
    margin-right: 6px;
    color: var(--mut);
}

.breadcrumbs a {
    color: var(--link);
    font-weight: 500;
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs [aria-current="page"] {
    color: var(--tx);
}

.page-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 34px;
}

.page-title {
    font-size: 21px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -.01em;
    color: var(--tx);
    margin: 0;
}

.page-head .badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.page-note {
    font-size: 12.5px;
    color: var(--mut);
}

.head-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Cards. Element-qualified so it outranks the FluentCard defaults whatever order the stylesheets load in. */

div.fluent-card.admin-card,
section.admin-card {
    background: var(--card);
    color: var(--tx);
    border: 1px solid var(--bd);
    border-radius: 10px;
    padding: 16px 18px;
    box-shadow: none;
    min-width: 0;
    margin: 0;
}

.admin-card .card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.admin-card .card-label {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--mut);
    margin: 0 0 10px;
}

.admin-card .card-head .card-label {
    margin: 0;
}

.admin-card .card-side,
.admin-card .card-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-card .card-side {
    margin-left: auto;
}

.admin-card .card-help {
    margin: -4px 0 12px;
    font-size: 12px;
    color: var(--mut);
}

.req-note {
    margin: 0;
    font-size: 12px;
    color: var(--mut);
}

.req,
.required-mark {
    color: var(--red);
    font-weight: 700;
}

/* Record layout: main column with a related aside */

.detail-cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

.detail-cols.no-aside {
    grid-template-columns: minmax(0, 1fr);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    margin: 0;
}

@media (max-width: 1100px) {
    .detail-cols {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Details: a two-column list, each label stacked above its value */

.dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
    margin: 0;
}

.dl-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 0;
    border-bottom: 1px solid var(--bd);
    min-width: 0;
}

.dl-row dt {
    font-size: 11px;
    font-weight: 600;
    color: var(--mut);
}

.dl-row dd {
    margin: 0;
    font-size: 13px;
    color: var(--tx);
    min-width: 0;
    overflow-wrap: anywhere;
}

.span2,
.span-2 {
    grid-column: 1 / -1;
}

/* Aside cards: record meta, chips and notes */

.meta {
    margin: 0;
    display: flex;
    flex-direction: column;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--bd);
}

.meta-row:last-child {
    border-bottom: 0;
}

.meta-row dt {
    color: var(--mut);
    font-size: 12px;
}

.meta-row dd {
    margin: 0;
    font-size: 12.5px;
    font-weight: 600;
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

:where(.admin-page, .admin-dialog) .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--bd);
    background: var(--bg);
    color: var(--tx);
    border-radius: 14px;
    padding: 4px 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

:where(.admin-page, .admin-dialog) a.chip:hover {
    border-color: var(--acc);
}

.chip-sub {
    color: var(--mut);
    font-weight: 400;
    font-size: 11px;
}

.more {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--mut);
}

.side-note {
    margin: 0;
    font-size: 12.5px;
    color: var(--mut);
    line-height: 1.55;
}

.mini-empty {
    padding: 14px 0 4px;
    color: var(--mut);
    font-size: 12.5px;
}

/* Buttons and links drawn as toolkit markup (anchors and plain buttons); Fluent buttons keep their own look. */

:where(.admin-page, .admin-dialog, .state-card) .btn {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    height: 36px;
    padding: 0 14px;
    border-radius: 4px;
    border: 1px solid var(--bd2);
    background: var(--card);
    color: var(--tx);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    text-decoration: none;
}

:where(.admin-page, .admin-dialog, .state-card) .btn:hover {
    background: var(--hover);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.primary {
    background: var(--acc);
    border-color: var(--acc);
    color: var(--on-acc);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.primary:hover {
    background: var(--acc-hover);
    border-color: var(--acc-hover);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.danger {
    background: var(--red);
    border-color: var(--red);
    color: var(--on-red);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.danger:hover {
    filter: brightness(.92);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.danger-outline {
    color: var(--red);
    border-color: var(--red);
    background: var(--card);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.danger-outline:hover {
    background: var(--red-soft);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.subtle {
    border-color: transparent;
    background: transparent;
}

:where(.admin-page, .admin-dialog, .state-card) .btn.subtle:hover {
    background: var(--hover);
    border-color: var(--bd);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.danger-text {
    color: var(--red);
}

:where(.admin-page, .admin-dialog, .state-card) .btn.small {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
}

:where(.admin-page, .admin-dialog, .state-card) .btn:disabled,
:where(.admin-page, .admin-dialog, .state-card) .btn:disabled:hover {
    opacity: .5;
    cursor: not-allowed;
    filter: none;
}

.btn .ic {
    width: 14px;
    height: 14px;
}

.linkbtn {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--link);
    cursor: pointer;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
}

.linkbtn:hover {
    text-decoration: underline;
}

.danger-link {
    color: var(--red);
}

/* Destructive Fluent buttons. fluent-button styles its host element and exposes no control part, and a document rule on the
   host outranks the component's own :host rules; disabled keeps the component's look. */

fluent-button.btn-danger:not(:disabled, [disabled], [disabled-focusable]) {
    color: var(--red);
    border-color: var(--red);
}

fluent-button.btn-danger:not(:disabled, [disabled], [disabled-focusable]):hover {
    background-color: var(--red-soft);
}

fluent-button.btn-danger-solid:not(:disabled, [disabled], [disabled-focusable]) {
    color: var(--on-red);
    background-color: var(--red);
    border-color: var(--red);
}

fluent-button.btn-danger-solid:not(:disabled, [disabled], [disabled-focusable]):hover {
    background-color: var(--red);
    filter: brightness(.92);
}

/* Inline SVG icons */

.ic {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: admin-spin .7s linear infinite;
    flex: none;
}

@keyframes admin-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Forms */

.admin-form,
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
    align-items: start;
}

/* A Fluent field in a form sits 12px down (its vertical margin), then a 20px label, a 4px gap and the control; a plain
   field beside one takes the same offsets so the labels and the controls of a row share one height. */
:where(.admin-form, .form-grid, .hat-row) > .field:not(:has(fluent-field)) {
    padding-top: 12px;
    gap: 4px;
}

:where(.admin-form, .form-grid, .hat-row) > .field:not(:has(fluent-field)) > .flabel {
    line-height: 20px;
}

:where(.admin-page, .admin-dialog) .field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    position: relative;
}

.flabel {
    font-size: 12px;
    font-weight: 600;
    color: var(--tx);
}

.fhint {
    color: var(--mut);
    font-size: 11.5px;
}

.ferr {
    color: var(--red);
    font-size: 12px;
    display: flex;
    gap: 5px;
    align-items: flex-start;
}

.ferr .ic {
    width: 13px;
    height: 13px;
    margin-top: 2px;
}

:where(.admin-page, .admin-dialog) .input {
    font: inherit;
    font-size: 13px;
    height: 36px;
    width: 100%;
    padding: 0 10px;
    border: 1px solid var(--bd2);
    border-bottom-color: var(--bd-strong);
    border-radius: 4px;
    background: var(--input);
    color: var(--tx);
    min-width: 0;
}

:where(.admin-page, .admin-dialog) .input:focus {
    outline: none;
    border-color: var(--acc);
    box-shadow: inset 0 -1px 0 var(--acc);
}

:where(.admin-page, .admin-dialog) select.input {
    padding-right: 6px;
}

:where(.admin-page, .admin-dialog) .input::placeholder {
    color: var(--mut2);
}

:where(.admin-page, .admin-dialog) .input:disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* Fluent controls draw 32px inside their shadow roots; a document rule outranks those, so they match the toolkit's 36px.
   A dropdown's control part is not exposed, so its slotted button or input carries the extra height instead. */
:where(.admin-page, .admin-dialog) fluent-text-input::part(root) {
    min-height: 36px;
}

:where(.admin-page, .admin-dialog) fluent-dropdown > [slot="control"] {
    padding-block: 2px;
}

:where(.admin-page, .admin-dialog, .state-card) fluent-button {
    min-height: 36px;
}

:where(.admin-page, .admin-dialog) fluent-button[icon-only] {
    min-width: 36px;
    max-width: 36px;
}

/* Locked field: read-only value with a lock icon and the reason as a tooltip */

.locked {
    position: relative;
}

:where(.admin-page, .admin-dialog) .locked .input {
    background: var(--lock-bg);
    color: var(--mut);
    padding-right: 32px;
    cursor: not-allowed;
    border-bottom-color: var(--bd2);
}

.lock-ic {
    position: absolute;
    right: 9px;
    top: 10px;
    width: 15px;
    height: 15px;
    color: var(--mut);
}

.tipwrap {
    position: relative;
    display: inline-flex;
}

:where(.admin-page, .admin-dialog) .tip {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    background: var(--tip-bg);
    color: var(--tip-tx);
    font-size: 11.5px;
    font-weight: 500;
    padding: 5px 9px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 25;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
    text-transform: none;
    letter-spacing: 0;
}

.tipwrap:hover .tip,
.tipwrap:focus-within .tip,
.locked:hover .tip,
.locked:focus-within .tip {
    display: block;
}

/* Sticky form footer: a card of its own below the form's cards */

.sticky-foot {
    position: sticky;
    bottom: 12px;
    z-index: 6;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 18px;
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: 10px;
    box-shadow: 0 -4px 22px var(--shadow);
}

.foot-note {
    margin-right: auto;
    font-size: 12px;
    color: var(--mut);
}

/* Message bars */

.msgbar {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 4px;
    border: 1px solid;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--tx);
}

.msgbar > .ic {
    width: 16px;
    height: 16px;
    margin-top: 1px;
}

.msgbar-body {
    min-width: 0;
    flex: 1;
    overflow-wrap: anywhere;
}

.msgbar-actions {
    display: inline-flex;
    gap: 12px;
    margin-left: 4px;
}

.mb-error {
    background: var(--red-soft);
    border-color: var(--red-bd);
}

.mb-error > .ic {
    color: var(--red);
}

.mb-warn {
    background: var(--amber-soft);
    border-color: var(--amber-bd);
}

.mb-warn > .ic {
    color: var(--amber);
}

.mb-info {
    background: var(--info-soft);
    border-color: var(--info-bd);
}

.mb-info > .ic {
    color: var(--info-fg);
}

.mb-success {
    background: var(--info-soft);
    border-color: var(--info-bd);
}

.mb-success > .ic {
    color: var(--ok);
}

.msg-list {
    margin: 4px 0 0;
    padding-left: 18px;
}

.msg-list li {
    margin: 2px 0;
}

/* 403 and 404 state cards */

section.admin-card.state-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 56px 24px;
}

.state-code {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .1em;
    color: var(--acc-text);
    border: 1px solid var(--acc);
    border-radius: 20px;
    padding: 2px 10px;
}

.state-card .state-ic {
    width: 34px;
    height: 34px;
    color: var(--tx);
}

.state-card h1 {
    margin: 4px 0 0;
    font-size: 21px;
    font-weight: 800;
    color: var(--tx);
}

.state-card p {
    margin: 0;
    color: var(--mut);
    max-width: 440px;
}

.state-card .btn,
.state-card fluent-button {
    margin-top: 10px;
}

/* Confirm dialog: the Fluent dialog host restyled; its dialog part is the only element the component exposes. */

fluent-dialog.admin-dialog::part(dialog) {
    background: var(--card);
    color: var(--tx);
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .3);
    width: min(470px, calc(100% - 32px));
    padding: 22px 24px;
}

fluent-dialog.admin-dialog::part(dialog)::backdrop {
    background: var(--scrim);
}

/* Busy overlay: under the sticky top bar, over the sticky form footer; its spinner centred in the viewport, not in a tall page. */

fluent-overlay[data-busy-overlay] {
    z-index: 8;
}

fluent-overlay[data-busy-overlay]::part(dialog) {
    top: 50dvh !important;
}

.confirm-dialog {
    font-size: 13px;
    line-height: 1.45;
    color: var(--tx);
}

.confirm-dialog .dlg-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--tx);
}

.confirm-dialog .dlg-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.confirm-dialog .dlg-body {
    margin: 0;
    color: var(--mut);
    font-size: 13px;
    line-height: 1.55;
}

.confirm-dialog .dlg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

/* Toast. The Fluent toast exposes only its dialog part; its inner regions colour themselves from Fluent tokens, which
   inherit through the shadow boundary, so those tokens are re-pointed on the host. */

fluent-toast-b.admin-toast {
    --colorNeutralForeground1: var(--toast-tx);
    --colorNeutralForeground2: var(--toast-tx);
    --colorBrandForeground1: var(--toast-tx);
    --colorStatusSuccessForeground1: var(--toast-ok);
    --colorStatusDangerForeground1: var(--red);
}

fluent-toast-b.admin-toast::part(dialog) {
    background: var(--toast-bg);
    color: var(--toast-tx);
    border: 0;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    padding: 11px 10px 11px 14px;
    min-width: 250px;
    max-width: calc(100% - 48px);
    align-items: center;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
}

/* Data grids */

.row-clickable {
    cursor: pointer;
}

.admin-card .fluent-data-grid {
    font-size: 13px;
}

.admin-card .fluent-data-grid td {
    color: var(--tx);
    border-bottom-color: var(--bd);
}

.admin-card .fluent-data-grid th[cell-type=columnheader],
.admin-card .fluent-data-grid [col-title-text] {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--mut);
}

/* Status pills, badges and codes */

.status-pill,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    line-height: 1.35;
    padding: 2px 8px;
    border: 1px solid currentColor;
    border-radius: 20px;
    white-space: nowrap;
}

.pill-ok,
.p-green {
    color: var(--ok);
}

.pill-amber,
.p-amber {
    color: var(--amber);
}

.pill-red,
.p-red {
    color: var(--red);
}

.pill-muted,
.p-grey {
    color: var(--mut);
}

.pill-accent,
.p-accent {
    color: var(--acc-text);
}

.pill-gold,
.p-gold {
    color: var(--gold-text);
    background: var(--gold-soft);
    border-color: var(--acc2);
}

.badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    background: var(--soft);
    color: var(--tx);
    border-radius: 4px;
    padding: 2px 8px;
    white-space: nowrap;
}

.mono {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12px;
}

/* Text utilities */

.muted {
    margin: 0;
    color: var(--mut);
}

.visually-hidden,
.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    margin: -1px;
}

/* Compact table */

.compact-table {
    width: 100%;
    border-collapse: collapse;
}

.compact-table th,
.compact-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--bd);
    text-align: left;
    vertical-align: middle;
}

.compact-table th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--mut);
}

/* List toolbars: the filters above a grid */

:where(.admin-page, .admin-dialog) .toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--bd);
}

.tb-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 140px;
}

/* A Fluent field carries a 12px top offset, a 20px label and a message area below its 36px control; a plain field matches
   the label line and the control top so every control in the row sits at one height. */
.tb-field:not(:has(fluent-field)) {
    padding-top: 12px;
}

.tb-field > .tb-label,
.tb-field > .flabel {
    line-height: 20px;
}

.tb-field.wide {
    min-width: 210px;
    flex: 0 1 240px;
}

.tb-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--tx);
}

.tb-clear {
    margin-left: auto;
    align-self: flex-start;
    margin-top: 34px;
}

/* The "or" between two alternative filters, on the controls' line. */
.tb-or {
    align-self: flex-start;
    margin-top: 34px;
    height: 36px;
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--mut);
}

/* Segmented control and filter chips */

:where(.admin-page, .admin-dialog) .seg {
    display: inline-flex;
    border: 1px solid var(--bd2);
    border-radius: 4px;
    overflow: hidden;
    height: 36px;
    background: var(--input);
}

:where(.admin-page, .admin-dialog) .seg button {
    border: 0;
    border-right: 1px solid var(--bd2);
    background: transparent;
    color: var(--tx);
    font: inherit;
    font-size: 12px;
    padding: 0 12px;
    cursor: pointer;
}

:where(.admin-page, .admin-dialog) .seg button:last-child {
    border-right: 0;
}

:where(.admin-page, .admin-dialog) .seg button:hover {
    background: var(--hover);
}

:where(.admin-page, .admin-dialog) .seg button.on {
    background: var(--soft);
    color: var(--acc-text);
    font-weight: 700;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 36px;
    align-items: center;
}

.fchip {
    height: 28px;
    padding: 0 11px;
    border: 1px solid var(--bd2);
    border-radius: 14px;
    background: var(--input);
    color: var(--tx);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.fchip:hover {
    border-color: var(--acc);
}

.fchip.on {
    background: var(--soft);
    border-color: var(--acc);
    color: var(--acc-text);
    font-weight: 700;
}

.fchip:focus-visible {
    outline: 2px solid var(--acc);
    outline-offset: 2px;
}

/* Grid cells */

.cell-link {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

:where(.admin-page, .admin-dialog) .small {
    font-size: 12px;
}

/* Empty state, drawn in place of a grid */

:where(.admin-page, .admin-dialog) .empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 48px 16px;
    color: var(--mut);
    text-align: center;
}

:where(.admin-page, .admin-dialog) .empty .big-ic {
    width: 34px;
    height: 34px;
    margin-bottom: 4px;
    color: var(--mut2);
}

:where(.admin-page, .admin-dialog) .empty strong {
    color: var(--tx);
    font-size: 14px;
}

:where(.admin-page, .admin-dialog) .empty .btn {
    margin-top: 8px;
}

/* Option cards: a checkbox with a name and its code */

:where(.admin-page, .admin-dialog) .opt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

:where(.admin-page, .admin-dialog) .opt {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--bd);
    border-radius: 6px;
    background: var(--card);
    cursor: pointer;
}

:where(.admin-page, .admin-dialog) .opt:hover {
    border-color: var(--acc);
}

:where(.admin-page, .admin-dialog) .opt.is-disabled {
    cursor: not-allowed;
    opacity: .75;
}

:where(.admin-page, .admin-dialog) .opt input {
    margin: 2px 0 0;
    accent-color: var(--acc);
}

:where(.admin-page, .admin-dialog) .opt-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

:where(.admin-page, .admin-dialog) .opt-name {
    font-size: 13px;
    font-weight: 600;
}

:where(.admin-page, .admin-dialog) .opt-slug {
    font-size: 11.5px;
    color: var(--mut);
}

/* Permission groups: option rows grouped under their resource */

.perm-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
}

.perm-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    margin: 0;
    padding: 10px 12px 12px;
    border: 1px solid var(--bd);
    border-radius: 8px;
}

.perm-res {
    padding: 0 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--acc-text);
}

:where(.admin-page, .admin-dialog) .perm-group .opt {
    padding: 4px 2px;
    border: 0;
    background: none;
}

:where(.admin-page, .admin-dialog) .perm-group .opt input {
    width: 16px;
    height: 16px;
    flex: none;
}

:where(.admin-page, .admin-dialog) .perm-group .opt-text {
    gap: 1px;
}

/* Data access rows: role, target and a remove button */

.hat-row {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr) 36px;
    gap: 12px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid var(--bd);
}

.hat-row:last-of-type {
    border-bottom: 0;
}

.hat-row .hat-del {
    margin-top: 24px;
}

/* Kind tiles and the chosen kind's line */

:where(.admin-page, .admin-dialog) .tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

:where(.admin-page, .admin-dialog) .tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    min-height: 118px;
    padding: 16px;
    border: 1px solid var(--bd);
    border-radius: 10px;
    background: var(--card);
    color: var(--tx);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

:where(.admin-page, .admin-dialog) .tile:hover {
    border-color: var(--acc);
    background: var(--soft);
}

:where(.admin-page, .admin-dialog) .tile:focus-visible {
    outline: 2px solid var(--acc);
    outline-offset: 2px;
}

:where(.admin-page, .admin-dialog) .tile .tile-ic {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
    color: var(--acc-text);
}

:where(.admin-page, .admin-dialog) .tile strong {
    font-size: 14px;
}

:where(.admin-page, .admin-dialog) .tile span {
    font-size: 12px;
    line-height: 1.45;
    color: var(--mut);
}

.kind-line {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: -2px 0 14px;
}

/* Mailing address: a six-column grid, wide fields spanning three */

.mail-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
}

.mail-grid .s3 {
    grid-column: span 3;
}

/* Combobox: a search input with its icon, a clear button and a listbox beneath */

.combo {
    position: relative;
}

:where(.admin-page, .admin-dialog) .combo .input {
    padding-left: 30px;
    padding-right: 28px;
}

.combo-ic {
    position: absolute;
    left: 9px;
    top: 10px;
    width: 15px;
    height: 15px;
    color: var(--mut);
    pointer-events: none;
}

.combo-clear {
    position: absolute;
    right: 5px;
    top: 6px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--mut);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.combo-clear:hover {
    background: var(--hover);
    color: var(--tx);
}

.combo-clear .ic {
    width: 13px;
    height: 13px;
}

.combo-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 30;
    min-width: 220px;
    max-height: 280px;
    overflow: auto;
    padding: 4px;
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: 6px;
    box-shadow: 0 12px 30px var(--shadow);
}

.combo-empty {
    padding: 10px;
    color: var(--mut);
    font-size: 12.5px;
}

.combo-empty.err {
    color: var(--red);
}

.searching {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Account picker: the combobox while searching, a badge once an account is chosen */

.acct-pick {
    position: relative;
    min-width: 0;
}

.acct-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    min-width: 0;
    padding: 0 4px 0 10px;
    border: 1px solid var(--acc);
    border-radius: 4px;
    background: var(--soft);
}

.acct-badge .mono {
    font-weight: 700;
}

.acct-badge .combo-clear {
    position: static;
    flex: none;
}

.acct-owner {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acct-list {
    min-width: 340px;
}

.acct-opt {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 7px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.acct-opt:hover {
    background: var(--hover);
}

.acct-opt.on {
    background: var(--hover);
    box-shadow: inset 3px 0 0 var(--acc);
}

.ao-1 {
    display: flex;
    gap: 8px;
    align-items: baseline;
    min-width: 0;
    font-size: 13px;
}

.ao-1 .mono {
    font-weight: 700;
}

.ao-2 {
    font-size: 11.5px;
    color: var(--mut);
}

/* A muted second line under a grid cell's value */

.cell-sub {
    display: block;
    font-size: 11.5px;
    color: var(--mut);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* A dismiss button inside a message bar */

.toast-x {
    margin-left: auto;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 4px;
    background: none;
    color: inherit;
    opacity: .7;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.toast-x:hover {
    opacity: 1;
    background: rgba(127, 127, 127, .2);
}

.toast-x .ic {
    width: 13px;
    height: 13px;
}

/* Radio cards: one choice of several, each with a line of explanation */

.radio-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 8px;
}

.radio-opt {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 9px 11px;
    border: 1px solid var(--bd);
    border-radius: 6px;
    background: var(--card);
    cursor: pointer;
}

.radio-opt:hover {
    background: var(--hover);
}

.radio-opt input {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--acc);
    flex: none;
}

/* Account list: a search input with its icon, the ticked count, a ticking grid, its pager and the sticky assign bar */

.input-ic {
    position: relative;
}

.input-ic > .ic {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--mut);
    pointer-events: none;
}

:where(.admin-page, .admin-dialog) .input-ic .input {
    padding-left: 32px;
}

.sel-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 0 8px;
}

.sel-count {
    font-size: 12.5px;
    color: var(--mut);
}

.sel-right {
    margin-left: auto;
    display: flex;
    gap: 14px;
    align-items: center;
}

:where(.admin-page) .grid-wrap {
    overflow-x: auto;
}

.dgrid {
    min-width: 760px;
}

.drow {
    display: grid;
    align-items: center;
    border-bottom: 1px solid var(--bd);
}

.drow > div {
    padding: 9px 10px;
    min-width: 0;
}

.dhead > div {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--mut);
    padding-top: 8px;
    padding-bottom: 8px;
}

.dbody .drow:hover {
    background: var(--hover);
}

.cols-bulk .drow {
    grid-template-columns: 48px minmax(220px, 2fr) minmax(170px, 1.5fr) 100px minmax(150px, 1.3fr);
}

.dbody .drow.sel {
    background: var(--soft);
}

.row-check {
    width: 16px;
    height: 16px;
    accent-color: var(--acc);
    margin: 0;
    display: block;
    cursor: pointer;
}

.cell-txt {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

label.cell-txt {
    cursor: pointer;
}

:where(.admin-page) .skel {
    height: 10px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--skel, rgba(127, 127, 127, .16)) 0, var(--skel2, rgba(127, 127, 127, .06)) 50%, var(--skel, rgba(127, 127, 127, .16)) 100%);
    background-size: 200% 100%;
    animation: admin-shimmer 1.2s ease-in-out infinite;
}

:where(.admin-page) .skel.w1 {
    width: 72%;
}

:where(.admin-page) .skel.w2 {
    width: 55%;
}

:where(.admin-page) .skel.w3 {
    width: 40%;
}

:where(.admin-page) .skel.w4 {
    width: 64%;
}

:where(.admin-page) .skel.skel-check {
    width: 16px;
}

@keyframes admin-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    :where(.admin-page) .skel {
        animation: none;
    }
}

:where(.admin-page) .pager {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding-top: 12px;
}

:where(.admin-page) .range {
    color: var(--mut);
    font-size: 12.5px;
}

:where(.admin-page) .pg-size {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--mut);
}

:where(.admin-page) .pg-size select {
    width: auto;
    height: 28px;
}

:where(.admin-page) .pg-btns {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

:where(.admin-page) .pg {
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: none;
    color: var(--tx);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    display: grid;
    place-items: center;
}

:where(.admin-page) .pg:hover {
    background: var(--hover);
    border-color: var(--bd);
}

:where(.admin-page) .pg.on {
    background: var(--soft);
    color: var(--acc-text);
    font-weight: 800;
    border-color: var(--acc);
}

:where(.admin-page) .pg:disabled {
    opacity: .4;
    cursor: not-allowed;
    background: none;
    border-color: transparent;
}

:where(.admin-page) .pg .ic {
    width: 14px;
    height: 14px;
}

:where(.admin-page) .pg-gap {
    color: var(--mut);
    padding: 0 2px;
}

.bulk-bar {
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px 14px;
}

/* Top-aligned so an error grows its field downward only. Every control sits 22px below its field's top (a 20px label, a 2px
   gap, as a Fluent field lays it out), so the locked field matches that and the button is padded down to it. */
.bulk-bar fluent-field {
    margin: 0;
}

.bulk-bar .locked-field {
    gap: 2px;
}

.bulk-bar .locked-field > .flabel {
    line-height: 20px;
}

.bar-user {
    min-width: 240px;
    flex: 0 1 300px;
}

.bar-date {
    width: 180px;
}

.bar-end {
    margin-left: auto;
    padding-top: 22px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

/* The batch result: a round mark, the outcome and the accounts left unassigned */

.mb-ok {
    background: var(--soft);
    border-color: var(--ok);
}

.res-bar {
    align-items: flex-start;
}

.res-ic {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    flex: none;
    margin-top: 1px;
    color: #fff;
    background: var(--amber);
}

.mb-ok .res-ic {
    background: var(--ok);
}

html[data-theme="dark"] .res-ic {
    color: #2b2b2b;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .res-ic {
        color: #2b2b2b;
    }
}

.res-body {
    flex: 1;
    min-width: 0;
}

.fail-list {
    margin: 6px 0 0;
    padding-left: 18px;
}

.fail-list li {
    margin: 3px 0;
}

@media (max-width: 700px) {
    .admin-page {
        padding: 16px 16px 40px;
    }

    .dl,
    .admin-form,
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .hat-row {
        grid-template-columns: minmax(0, 1fr) 36px;
    }

    .bar-user,
    .bar-date {
        flex: 1 1 100%;
        width: auto;
        min-width: 0;
    }

    .bar-end {
        margin-left: 0;
        padding-top: 0;
        align-items: stretch;
        width: 100%;
    }

    :where(.admin-page) .pg-btns {
        margin-left: 0;
    }
}
