/* Global app styles — now driven by the design tokens in css/tokens.css.
   Every color resolves to a --tl-* token so the page re-themes when
   <html data-theme> changes. Loads after Bootstrap + tokens.css so these
   rules win over the Bootstrap defaults. */

html, body {
    font-family: var(--tl-font-sans);
    background-color: var(--tl-bg);
    color: var(--tl-text-primary);
}

/* Smooth the light/dark/high-contrast transition on the surfaces that change. */
body,
.content,
.card {
    transition: background-color var(--tl-transition-base), color var(--tl-transition-base),
                border-color var(--tl-transition-base);
}

a, .btn-link {
    color: var(--tl-primary);
}

a:hover, .btn-link:hover {
    color: var(--tl-primary-hover);
}

.btn-primary {
    color: #fff;
    background-color: var(--tl-primary);
    border-color: var(--tl-primary);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--tl-primary-hover);
    border-color: var(--tl-primary-hover);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: var(--tl-focus-ring);
    border-color: var(--tl-primary);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--tl-success);
}

.invalid {
    outline: 1px solid var(--tl-error);
}

.validation-message {
    color: var(--tl-error);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgN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LjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--tl-error);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: var(--tl-gray-400);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--tl-text-tertiary);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ================================================================= */
/* Admin read pages (FSD §12.3) — shared card / table / badge kit.    */
/* All colors resolve to --tl-* tokens so the pages re-theme with the */
/* rest of the app across the 7 themes.                               */
/* ================================================================= */

.tl-page-head {
    margin-bottom: var(--tl-space-6);
}

.tl-page-head h1 {
    margin-bottom: var(--tl-space-1);
}

.tl-page-sub {
    color: var(--tl-text-secondary);
    margin-bottom: 0;
}

.tl-card {
    background-color: var(--tl-surface);
    border: 1px solid var(--tl-border);
    border-radius: var(--tl-radius-lg);
    box-shadow: var(--tl-shadow-sm);
    padding: var(--tl-space-5) var(--tl-space-6);
    margin-bottom: var(--tl-space-5);
}

.tl-card-flush {
    padding: 0;
    overflow: hidden;
}

/* Destructive-action card (the tenant-delete danger zone on the Sensitive-operations page).
   A tinted surface and an error-toned left accent set it visually apart from the neutral
   editor cards so an irreversible action never blends into the routine ones. */
.tl-card-danger {
    border-color: color-mix(in srgb, var(--tl-error) 45%, var(--tl-border));
    border-left: 4px solid var(--tl-error);
    background-color: color-mix(in srgb, var(--tl-error) 5%, var(--tl-surface));
}

/* Collapsible card (the manual-credentials fallback): a 44px-tall summary row, the heading
   inline, a visible focus ring from the global :focus-visible rule. */
.tl-disclosure > .tl-disclosure-summary {
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.tl-disclosure > .tl-disclosure-summary h2 {
    display: inline;
    margin: 0;
}
.tl-disclosure[open] > .tl-disclosure-summary {
    margin-bottom: var(--tl-space-3, 0.75rem);
}

/* Light in-card separator between the set and clear tamper-password controls. */
.tl-rule {
    border: 0;
    border-top: 1px solid var(--tl-border);
    margin: var(--tl-space-5) 0;
}

.tl-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--tl-space-3);
    margin-bottom: var(--tl-space-4);
}

.tl-card-head h2 {
    font-size: 1.15rem;
    margin: 0;
}

.tl-defs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--tl-space-3) var(--tl-space-6);
    margin: 0;
}

.tl-defs > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tl-defs dt {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--tl-text-tertiary);
}

.tl-defs dd {
    margin: 0;
    color: var(--tl-text-primary);
}

.tl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tl-table th,
.tl-table td {
    text-align: left;
    padding: var(--tl-space-3) var(--tl-space-4);
    border-bottom: 1px solid var(--tl-border);
}

.tl-table thead th {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--tl-text-tertiary);
    background-color: var(--tl-hover);
}

.tl-table tbody tr:last-child th,
.tl-table tbody tr:last-child td {
    border-bottom: none;
}

.tl-table tbody tr:hover {
    background-color: var(--tl-hover);
}

.tl-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tl-mono {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
    font-size: 0.85rem;
}

.tl-nowrap {
    white-space: nowrap;
}

.tl-change {
    color: var(--tl-text-secondary);
}

.tl-muted {
    color: var(--tl-text-secondary);
    font-size: 0.9rem;
}

.tl-inline-icon,
.tl-alert-icon {
    font-size: 18px;
    vertical-align: text-bottom;
}

.tl-table-scroll {
    overflow-x: auto;
}

/* Status / category pills. */
.tl-badge {
    display: inline-block;
    padding: 2px var(--tl-space-2);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    background-color: var(--tl-hover);
    color: var(--tl-text-secondary);
}

.tl-badge-success {
    background-color: color-mix(in srgb, var(--tl-success) 18%, transparent);
    color: var(--tl-success);
}

.tl-badge-danger {
    background-color: color-mix(in srgb, var(--tl-error) 18%, transparent);
    color: var(--tl-error);
}

.tl-badge-warning {
    background-color: color-mix(in srgb, var(--tl-warning) 20%, transparent);
    color: var(--tl-warning);
}

.tl-badge-info {
    background-color: color-mix(in srgb, var(--tl-info) 18%, transparent);
    color: var(--tl-info);
}

.tl-badge-muted {
    background-color: var(--tl-hover);
    color: var(--tl-text-secondary);
}

/* Inline action link with a leading icon (team roster "View", member back-link). */
.tl-link {
    display: inline-flex;
    align-items: center;
    gap: var(--tl-space-1);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.tl-link:hover {
    text-decoration: underline;
}

/* Filter bar (allowlist scope, audit-log range). */
.tl-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--tl-space-4);
    margin-bottom: var(--tl-space-5);
    padding: var(--tl-space-4);
    background-color: var(--tl-surface);
    border: 1px solid var(--tl-border);
    border-radius: var(--tl-radius-md);
}

.tl-field {
    display: flex;
    flex-direction: column;
    gap: var(--tl-space-1);
    border: none;
    margin: 0;
    padding: 0;
}

.tl-field > span {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--tl-text-tertiary);
}

.tl-field .form-control,
.tl-field .form-select {
    min-width: 10rem;
}

.tl-field-actions {
    flex: 1 1 20rem;
}

.tl-checks {
    display: flex;
    flex-wrap: wrap;
    gap: var(--tl-space-2) var(--tl-space-4);
}

.tl-check {
    display: inline-flex;
    align-items: center;
    gap: var(--tl-space-1);
    font-size: 0.85rem;
    color: var(--tl-text-primary);
}

.tl-filters-apply {
    margin-left: auto;
}

.tl-pager {
    display: flex;
    justify-content: center;
    margin-top: var(--tl-space-5);
}

/* Load-error alert (LoadErrorAlert.razor). */
.tl-alert {
    display: flex;
    align-items: center;
    gap: var(--tl-space-2);
    padding: var(--tl-space-3) var(--tl-space-4);
    border-radius: var(--tl-radius-md);
    border: 1px solid transparent;
    font-size: 0.9rem;
}

.tl-alert-warning {
    background-color: color-mix(in srgb, var(--tl-warning) 12%, transparent);
    border-color: color-mix(in srgb, var(--tl-warning) 35%, transparent);
    color: var(--tl-text-primary);
}

.tl-alert-info {
    background-color: color-mix(in srgb, var(--tl-info) 12%, transparent);
    border-color: color-mix(in srgb, var(--tl-info) 35%, transparent);
    color: var(--tl-text-primary);
}

.tl-alert-danger {
    background-color: color-mix(in srgb, var(--tl-error) 12%, transparent);
    border-color: color-mix(in srgb, var(--tl-error) 35%, transparent);
    color: var(--tl-text-primary);
}

.tl-alert-success {
    background-color: color-mix(in srgb, var(--tl-success) 12%, transparent);
    border-color: color-mix(in srgb, var(--tl-success) 35%, transparent);
    color: var(--tl-text-primary);
}

/* ================================================================= */
/* Admin editor forms (FSD §12.3 writes) — static-SSR EditForm kit.   */
/* Reuses .tl-field from the filter bar for the label/control pair so */
/* read filters and write editors stay visually identical.            */
/* ================================================================= */

.tl-form {
    margin-top: var(--tl-space-4);
}

.tl-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: var(--tl-space-4);
    align-items: start;
}

/* A field that shouldn't be squeezed into the auto-fill track (session id). */
.tl-form-grid .tl-field-wide {
    grid-column: 1 / -1;
}

.tl-form .tl-field .form-control {
    min-width: 0;
}

.tl-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--tl-space-3);
    margin-top: var(--tl-space-4);
}

/* Per-field validation text from <ValidationMessage>. */
.tl-form-invalid {
    font-size: 0.8rem;
    color: var(--tl-error);
}

/* Secondary action inside a form's action row — "apply recommended values" is a GET
   link styled as a button, so it must read as an alternative to Save, not a rival to it. */
.tl-btn-secondary {
    color: #fff;
    background-color: var(--tl-secondary);
    border-color: var(--tl-secondary);
}

.tl-btn-secondary:hover, .tl-btn-secondary:focus {
    color: #fff;
    background-color: var(--tl-secondary-hover);
    border-color: var(--tl-secondary-hover);
}

/* Row-scale destructive action (allowlist delete). Sized down from .btn so a column of
   them doesn't dominate the table it sits in. */
.tl-btn-danger {
    color: #fff;
    background-color: var(--tl-error);
    border-color: var(--tl-error);
    font-size: 0.8rem;
    padding: 2px var(--tl-space-3);
}

.tl-btn-danger:hover, .tl-btn-danger:focus {
    color: #fff;
    background-color: color-mix(in srgb, var(--tl-error) 82%, #000);
    border-color: color-mix(in srgb, var(--tl-error) 82%, #000);
}

/* The control-less form that per-row delete buttons target by id. It renders nothing
   visible — only the antiforgery/handler inputs — so it must not open up vertical space. */
.tl-row-form {
    margin: 0;
}

/* Table cell holding a row's actions: hugs the right edge and never wraps a button. */
.tl-row-actions {
    text-align: right;
    white-space: nowrap;
}

/* Label text present for screen readers only (an actions column needs a name but not a
   visible heading). Standard clip-rect recipe — `display: none` would hide it from AT too. */
.tl-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Multi-line text control (the suspension reason). Bootstrap sizes it from `rows`; this
   just guarantees a usable minimum inside the form grid's auto-fill track. */
.tl-textarea {
    min-height: 4.5rem;
    width: 100%;
    resize: vertical;
}
