:root {
    /* Our custom aliases — built on top of Fluent design tokens with warm
       nougat fallbacks for the boot screen (before Fluent's JS fires).
       Fluent generates the brown primary-brand ramp from data-theme-color on
       <body>; we only need to set the pistachio-green slots ourselves. */
    --bg-accent: var(--colorBrandForeground1, #9b6238);
    --bg-green: #5f8f3c;
    --bg-link: var(--colorBrandForegroundLink, #5f8f3c);
    --bg-border: var(--colorNeutralStroke1, #e8dbc4);
    --bg-muted: var(--colorNeutralForeground3, #6e6253);
    --bg-fg: var(--colorNeutralForeground1, #2a2118);
    --bg-layer-1: var(--colorNeutralBackground1, #faf5ec);
    --bg-layer-3: #f2e6d2;
    --bg-max-width: 1400px;

    /* Fluent injects brand tokens as inline styles on :root via JS, which
       normally beats stylesheet rules. !important lets us permanently own
       the green slots (links, checkmarks, combobox focus) without touching
       the brown primary-brand ramp Fluent generates from data-theme-color.
       Light-mode values live here because Fluent *removes* data-theme in
       light mode, so body[data-theme="light"] never matches after boot. */
    --colorBrandForegroundLink: #5f8f3c !important;
    --colorBrandForegroundLinkHover: #4b702f !important;
    --colorBrandForegroundLinkPressed: #3d5c27 !important;
    --colorCompoundBrandForeground1: #5f8f3c !important;
    --colorCompoundBrandForeground1Hover: #4b702f !important;
    --colorCompoundBrandStroke: #5f8f3c !important;
    --colorCompoundBrandStrokeHover: #4b702f !important;
}

/* Dark mode: Fluent sets data-theme="dark" on body.
   Higher specificity than :root so these !important values win. */
body[data-theme="dark"] {
    --bg-green: #8fcb72;
    --bg-layer-3: #241e16;

    /* Green slots — dark-mode shades */
    --colorBrandForegroundLink: #8fcb72 !important;
    --colorBrandForegroundLinkHover: #a6d98a !important;
    --colorBrandForegroundLinkPressed: #7ab961 !important;
    --colorCompoundBrandForeground1: #8fcb72 !important;
    --colorCompoundBrandForeground1Hover: #a6d98a !important;
    --colorCompoundBrandStroke: #8fcb72 !important;
    --colorCompoundBrandStrokeHover: #a6d98a !important;

    /* Fluent's neutral scale is cool grey by default; warm it up. */
    --colorNeutralBackground1: #1b1712 !important;
    --colorNeutralBackground2: #201c14 !important;
    --colorNeutralBackground3: #261f16 !important;
    --colorNeutralBackground4: #2d2418 !important;
    --colorNeutralBackground5: #38291b !important;
    --colorNeutralBackground6: #43311f !important;
    --colorNeutralStroke1: #392f23 !important;
    --colorNeutralStroke2: #4a3c2a !important;
    --colorNeutralStroke3: #5c4c35 !important;
}

html, body {
    margin: 0;
    /* Fluent UI's auto-injected default-fuib.css pins body to
       height:100dvh; overflow:hidden. We accept that here — all scrolling
       (both axes) happens inside .bg-body-scroll so the header never moves. */
    height: 100dvh !important;
    overflow: hidden !important;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    color: var(--bg-fg, #2a2118);
    background: var(--bg-layer-1, #fff);
}

/* Blazor mounts into #app — it must propagate the viewport height down to .bg-page. */
#app {
    height: 100%;
}

/* Full-viewport flex column: header is a fixed-size item, body-scroll fills the rest. */
.bg-page {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Scrollable content area — handles both vertical and horizontal scroll
   independently of the header, so the header is never scrolled off-screen. */
.bg-body-scroll {
    flex: 1;
    min-height: 0; /* allow flex child to shrink below its content size */
    overflow-x: auto;
    overflow-y: auto;
}

a {
    color: var(--bg-link);
    text-decoration: none;
}

a:hover {
    text-decoration: none;
}

.bg-container {
    max-width: var(--bg-max-width);
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.bg-header {
    background: var(--bg-layer-3, #f2e6d2);
    border-bottom: 1px solid var(--bg-border);
}

.bg-header-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding-top: .75rem;
    padding-bottom: .75rem;
    flex-wrap: wrap;
}

.bg-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bg-accent, #9b6238);
    text-decoration: none;
}

.bg-brand:hover {
    text-decoration: none;
}

.bg-nav {
    display: flex;
    gap: 1rem;
}

.bg-nav-link {
    font-weight: 600;
    color: var(--bg-fg, #2a2118);
    padding: .25rem 0;
    text-decoration: none;
}

.bg-nav-link:hover {
    text-decoration: none;
}

.bg-nav-link.active {
    border-bottom: 2px solid var(--bg-accent);
}

.bg-search {
    display: flex;
    flex: 1 1 320px;
    gap: .5rem;
}

.bg-search-input {
    flex: 1;
    padding: .4rem .6rem;
    border: 1px solid var(--bg-border);
    border-radius: 4px;
    font-size: .95rem;
}

/* Main */
.bg-main {
    padding-top: 1.5rem;
    padding-bottom: 3rem;
}

/* Filters */
.bg-filters {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.bg-filter {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .85rem;
    color: var(--bg-muted);
}

.bg-filter.bg-filter-inline {
    flex-direction: row;
    align-items: center;
    gap: .5rem;
}

/* Custom dropdown — replaces native <select> for full theming control. */
.bg-select-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
}

.bg-select {
    position: relative;
    z-index: 101;
}

.bg-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    min-width: 12rem;
    padding: .35rem .5rem;
    border: 1px solid var(--bg-green);
    border-radius: 4px;
    background: var(--bg-layer-1);
    color: var(--bg-fg);
    font-size: inherit;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.bg-select-trigger:hover {
    border-color: var(--bg-accent);
}

.bg-select-trigger:focus-visible {
    outline: none;
    border-color: var(--bg-link);
    box-shadow: 0 0 0 2px rgba(95, 143, 60, 0.3);
}

.bg-select-chevron {
    font-size: .75rem;
    opacity: .6;
    flex-shrink: 0;
}

.bg-select-list {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    min-width: 100%;
    background: var(--bg-layer-1);
    border: 1px solid var(--bg-border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    overflow: hidden;
}

.bg-select-option {
    display: block;
    width: 100%;
    padding: .4rem .6rem;
    border: none;
    background: none;
    color: var(--bg-fg);
    font-size: inherit;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.bg-select-option:hover {
    background: var(--bg-layer-3);
}

.bg-select-option.selected {
    color: var(--bg-accent);
    font-weight: 600;
}

/* Native checkbox: accent-color makes the browser tint it with our green. */
.bg-filter input[type="checkbox"] {
    accent-color: var(--bg-green);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Search results */
.bg-result {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.bg-result-icon img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.bg-result-body {
    flex: 1;
    min-width: 0;
}

.bg-result-title {
    font-size: 1.4rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.bg-result-authors {
    margin-left: .5rem;
    color: var(--bg-muted);
    font-size: .9rem;
}

.bg-result-info {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0;
    margin: .5rem 0;
    color: var(--bg-muted);
    font-size: .9rem;
}

.bg-tags {
    color: var(--bg-muted, #6e6253);
}

.bg-result-desc {
    color: var(--bg-fg, #2a2118);
}

.bg-pager {
    display: flex;
    gap: .5rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.bg-center {
    display: flex;
    justify-content: center;
    padding: 3rem 0;
}

.bg-empty {
    text-align: center;
    padding: 2rem 0;
    color: var(--bg-muted);
}

/* Package details */
.bg-details {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 2rem;
}

@media (max-width: 800px) {
    .bg-details {
        grid-template-columns: 1fr;
    }
}

.bg-details-head {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.bg-details-head img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.bg-details-title {
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
    overflow-wrap: anywhere;
}

.bg-release-notes {
    border-top: 1px solid var(--bg-border);
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    overflow-wrap: anywhere;
}

.bg-release-notes h2 {
    font-size: 1.1rem;
    margin: 0 0 .5rem;
}

.bg-readme {
    border-top: 1px solid var(--bg-border);
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    overflow-wrap: anywhere;
    overflow-x: hidden;
}

.bg-readme img {
    max-width: 100%;
}

.bg-readme pre {
    overflow-x: auto;
    max-width: 100%;
}

.bg-readme table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

.bg-sidebar h3 {
    font-size: 1rem;
    margin: 1.25rem 0 .5rem;
}

.bg-versions {
    width: 100%;
    border-collapse: collapse;
}

.bg-versions th,
.bg-versions td {
    text-align: left;
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--bg-border);
    font-size: .9rem;
}

.bg-info-card {
    border: 1px solid var(--bg-border);
    border-radius: 6px;
    padding: .6rem .85rem .75rem;
    background: var(--bg-layer-1);
}

.bg-info-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 .4rem;
}

.bg-info-row {
    font-size: .875rem;
    line-height: 1.6;
}

.bg-dep-group {
    margin-bottom: .75rem;
}

.bg-dep-group > .bg-dep-fw {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--bg-muted-fg, #888);
    margin-bottom: .2rem;
}

.bg-dep-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.bg-dep-table td {
    padding: .15rem 0;
    vertical-align: middle;
}

.bg-dep-id {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
    width: 60%;
}

.bg-dep-ver {
    white-space: nowrap;
    padding-left: .4rem;
    color: var(--bg-muted-fg, #888);
    font-size: .8rem;
}

.bg-dep-ext {
    width: 20px;
    text-align: right;
    padding-left: .25rem;
}

.bg-dep-nuget {
    color: var(--bg-muted-fg, #aaa);
    opacity: .55;
    display: inline-flex;
    align-items: center;
    transition: opacity .15s;
}

.bg-dep-nuget:hover { opacity: 1; }

.bg-used-by {
    list-style: none;
    padding: 0;
}

/* Upload */
.bg-upload pre {
    background: var(--bg-layer-3, #f2e6d2);
    border: 1px solid var(--bg-border);
    border-radius: 4px;
    padding: .75rem 1rem;
    overflow-x: auto;
}

.bg-code {
    background: var(--bg-layer-3, #f2e6d2);
    padding: .1rem .35rem;
    border-radius: 3px;
    font-family: Consolas, "Courier New", monospace;
}

/* User area — username + déconnexion */
.bg-user-area {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-left: auto;
}

.bg-user-name {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .9rem;
    font-weight: 600;
    color: var(--bg-fg-muted, #6b5c4c);
}

.bg-nav-link-btn {
    background: none;
    border: none;
    padding: .25rem 0;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

.bg-nav-icon {
    display: inline-flex;
    align-items: center;
    color: var(--bg-fg-muted, #6b5c4c);
    padding: .25rem;
    border-radius: 4px;
    transition: color .15s;
}

.bg-nav-icon:hover {
    color: var(--bg-accent, #9b6238);
    text-decoration: none;
}

/* ── Language switcher ───────────────────────────────────────────────────── */
.bg-lang-switcher {
    display: flex;
    gap: .15rem;
    align-items: center;
}

.bg-lang-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--bg-text-muted, #8a7a6a);
    cursor: pointer;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .05em;
    padding: .2rem .35rem;
    transition: color .15s, border-color .15s;
}

.bg-lang-btn:hover {
    color: var(--bg-text, #2c1f0e);
    border-color: var(--bg-border, #c8b49a);
}

.bg-lang-btn.active {
    color: var(--bg-accent, #9b6238);
    border-color: var(--bg-accent, #9b6238);
}

/* ── Auth pages (Login / Setup) ──────────────────────────────────────────── */
.bg-auth-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 1rem;
    min-height: 60vh;
}

.bg-auth-card {
    background: var(--bg-layer-3, #f2e6d2);
    border: 1px solid var(--bg-border);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
}

.bg-auth-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 .25rem;
}

.bg-auth-subtitle {
    color: var(--bg-muted);
    margin: 0 0 1.5rem;
    font-size: .9rem;
}

.bg-auth-error {
    color: #c0392b;
    background: #fdf0ee;
    border: 1px solid #e8b4ae;
    border-radius: 4px;
    padding: .5rem .75rem;
    font-size: .9rem;
    margin-bottom: 1rem;
}

.bg-auth-success {
    color: #27ae60;
    background: #edfaf3;
    border: 1px solid #a8e0c0;
    border-radius: 4px;
    padding: .5rem .75rem;
    font-size: .9rem;
    margin-bottom: 1rem;
}

.bg-auth-separator {
    text-align: center;
    color: var(--bg-muted);
    font-size: .85rem;
    margin: 1rem 0;
    position: relative;
}

.bg-auth-separator::before,
.bg-auth-separator::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: var(--bg-border);
}
.bg-auth-separator::before { left: 0; }
.bg-auth-separator::after  { right: 0; }

/* ── Formulaires partagés ────────────────────────────────────────────────── */
.bg-auth-form,
.bg-config-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bg-form-field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.bg-form-field label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--bg-fg);
}

.bg-form-field input[type="text"],
.bg-form-field input[type="email"],
.bg-form-field input[type="password"],
.bg-form-field input[type="url"] {
    padding: .45rem .6rem;
    border: 1px solid var(--bg-border);
    border-radius: 4px;
    font-size: .95rem;
    font-family: inherit;
    background: var(--bg-layer-1, #fff);
    color: var(--bg-fg);
    transition: border-color .15s;
}

.bg-form-field input:focus {
    outline: none;
    border-color: var(--bg-accent);
}

.bg-form-optional {
    font-weight: 400;
    color: var(--bg-muted);
}

.bg-form-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    cursor: pointer;
}

.bg-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-accent, #9b6238);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: .55rem 1.25rem;
    font-size: .95rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}

.bg-btn-primary:hover { opacity: .88; }
.bg-btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.bg-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--bg-accent, #9b6238);
    border: 1.5px solid var(--bg-accent, #9b6238);
    border-radius: 4px;
    padding: .5rem 1.25rem;
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}

.bg-btn-secondary:hover {
    background: var(--bg-layer-3, #f2e6d2);
    text-decoration: none;
}

/* ── Admin config ────────────────────────────────────────────────────────── */
.bg-config-section {
    background: var(--bg-layer-3, #f2e6d2);
    border: 1px solid var(--bg-border);
    border-radius: 6px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
    margin-bottom: 1rem;
}

.bg-config-section h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.bg-config-actions {
    display: flex;
    gap: 1rem;
    margin-top: .5rem;
}

/* ── Loading splash (i18n gate) ─────────────────────────────────────────── */
.bg-loading-splash {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-layer-1, #faf5ec);
    z-index: 9999;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.bg-muted {
    color: var(--bg-muted);
}

.bg-mt {
    margin-top: 1rem;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.bg-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 99px;
    background: var(--bg-layer-3);
    border: 1px solid var(--bg-border);
    color: var(--bg-fg);
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
}

/* ── Buttons supplémentaires ─────────────────────────────────────────────── */
.bg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--bg-fg);
    border: 1px solid var(--bg-border);
    border-radius: 4px;
    padding: .45rem 1rem;
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s;
}

.bg-btn:hover { background: var(--bg-layer-3); }
.bg-btn:disabled { opacity: .55; cursor: not-allowed; }

.bg-btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--bg-fg);
    border: 1px solid var(--bg-border);
    border-radius: 4px;
    padding: .2rem .5rem;
    font-size: .8rem;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s;
    vertical-align: middle;
}

.bg-btn-sm:hover { background: var(--bg-layer-3); }
.bg-btn-sm:disabled { opacity: .55; cursor: not-allowed; }

.bg-btn-sm.bg-btn-primary {
    background: var(--bg-accent);
    color: #fff;
    border-color: transparent;
}
.bg-btn-sm.bg-btn-primary:hover { opacity: .88; }

.bg-btn-danger {
    color: #c0392b;
    border-color: #e8b4ae;
}
.bg-btn-danger:hover { background: #fdf0ee; border-color: #c0392b; }

.bg-btn-sm.bg-btn-danger {
    color: #c0392b;
    border-color: #e8b4ae;
}
.bg-btn-sm.bg-btn-danger:hover { background: #fdf0ee; border-color: #c0392b; }

.bg-btn-warn { color: #92400e; border-color: #f6d860; }
.bg-btn-warn:hover { background: #fef9e7; border-color: #b7791f; }
.bg-btn-warn:disabled { opacity: .55; cursor: not-allowed; }
.bg-btn-secondary { color: var(--bg-muted, #6e6253); }

/* ── Deprecation banner ─────────────────────────────────────────────────── */
.bg-deprecation-banner {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    background: #fef9e7;
    border: 1px solid #f6d860;
    border-left: 4px solid #d97706;
    border-radius: 6px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    font-size: .9rem;
}

.bg-deprecation-icon { color: #d97706; flex-shrink: 0; margin-top: .1rem; }
.bg-deprecation-msg { margin-top: .3rem; color: var(--bg-fg); }
.bg-deprecation-alt { margin-top: .3rem; }

body[data-theme="dark"] .bg-deprecation-banner {
    background: #2d2000;
    border-color: #7a5800;
    border-left-color: #d97706;
}

/* ── Unlisted version ────────────────────────────────────────────────────── */
.bg-version-unlisted { opacity: .6; }
.bg-version-unlisted:hover { opacity: 1; }

.bg-versions-grid { width: 100%; }
.bg-version-label { display: flex; align-items: center; gap: .4rem; overflow: hidden; }
.bg-version-label a, .bg-version-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bg-version-actions { display: flex; gap: .25rem; align-items: center; }

.bg-badge-unlisted {
    background: #f5e0c0;
    color: #7a4f00;
    border: 1px solid #e0c080;
    font-size: .7rem;
}

.bg-icon-btn-muted { color: var(--bg-muted, #6e6253); }
.bg-icon-btn-muted:hover { color: var(--bg-fg, #2a2118); background: var(--bg-layer-3, #f2e6d2); }

.bg-icon-btn-success { color: #2e7d32; }
.bg-icon-btn-success:hover { color: #1b5e20; background: #e8f5e9; }

.bg-icon-btn-warn { color: #d97706; }
.bg-icon-btn-warn:hover { color: #92400e; background: #fef9e7; }

.bg-badge-deprecated {
    background: #fef9e7;
    color: #92400e;
    border: 1px solid #f6d860;
    font-size: .7rem;
}

.bg-modal-deprecation { max-width: 480px; }
.bg-textarea { width: 100%; resize: vertical; min-height: 70px; }

body[data-theme="dark"] .bg-badge-unlisted {
    background: #4a3000;
    color: #f0c060;
    border-color: #7a5800;
}
body[data-theme="dark"] .bg-icon-btn-success { color: #66bb6a; }
body[data-theme="dark"] .bg-icon-btn-success:hover { background: #1b3a1c; }
body[data-theme="dark"] .bg-icon-btn-warn { color: #fbbf24; }
body[data-theme="dark"] .bg-icon-btn-warn:hover { background: #2d2000; }
body[data-theme="dark"] .bg-badge-deprecated { background: #2d2000; color: #fbbf24; border-color: #7a5800; }

/* ── Vulnerability banner ────────────────────────────────────────────────── */
.bg-vuln-banner {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    background: #fff1f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: 6px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    font-size: .9rem;
}

.bg-vuln-icon { color: #dc2626; flex-shrink: 0; margin-top: .1rem; }
.bg-vuln-item { display: flex; align-items: center; gap: .5rem; margin-top: .35rem; font-size: .875rem; }

.bg-vuln-sev {
    display: inline-flex;
    align-items: center;
    padding: .1rem .45rem;
    border-radius: 3px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.bg-vuln-sev-0 { background: #f0fdfa; color: #0f766e; border: 1px solid #99f6e4; }
.bg-vuln-sev-1 { background: #fef9e7; color: #92400e; border: 1px solid #f6d860; }
.bg-vuln-sev-2 { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.bg-vuln-sev-3 { background: #fff1f2; color: #b91c1c; border: 1px solid #fecaca; }

.bg-vuln-ghsa { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--bg-muted, #6e6253); }

.bg-badge-vulnerable {
    background: #fff1f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    font-size: .7rem;
}

/* Vulnerability admin section */
.bg-vuln-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.bg-vuln-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.bg-vuln-list-item {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: .85rem;
    padding: .4rem .5rem;
    background: var(--bg-layer-2, #fdf6eb);
    border: 1px solid var(--bg-border, #e8dbc4);
    border-radius: 5px;
}
.bg-vuln-list-item-info { flex: 1; min-width: 0; }
.bg-vuln-list-item-range { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--bg-muted, #6e6253); }
.bg-vuln-list-item-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .2rem; }

body[data-theme="dark"] .bg-vuln-banner {
    background: #2d0000;
    border-color: #7a0000;
    border-left-color: #dc2626;
}
body[data-theme="dark"] .bg-vuln-sev-0 { background: #042f2e; color: #5eead4; border-color: #0d9488; }
body[data-theme="dark"] .bg-vuln-sev-1 { background: #2d2000; color: #fbbf24; border-color: #7a5800; }
body[data-theme="dark"] .bg-vuln-sev-2 { background: #3a1800; color: #fb923c; border-color: #9a3412; }
body[data-theme="dark"] .bg-vuln-sev-3 { background: #2d0000; color: #fca5a5; border-color: #7a0000; }
body[data-theme="dark"] .bg-badge-vulnerable { background: #2d0000; color: #fca5a5; border-color: #7a0000; }
.bg-modal-vuln { max-width: 460px; }

/* ── Delete confirmation modal ───────────────────────────────────────────── */
.bg-modal-delete { max-width: 520px; }

.bg-delete-warning {
    display: flex;
    gap: .75rem;
    background: #fdf0ee;
    border: 1px solid #e8b4ae;
    border-radius: 6px;
    padding: .875rem 1rem;
    margin-bottom: 1rem;
    color: #7a1f17;
}
.bg-delete-warning-icon { flex-shrink: 0; margin-top: 1px; }
.bg-delete-warning strong { display: block; margin-bottom: .4rem; font-size: .9rem; }
.bg-delete-warning-list {
    margin: 0;
    padding-left: 1.2rem;
    font-size: .875rem;
    line-height: 1.6;
}

.bg-delete-code {
    font-family: ui-monospace, monospace;
    font-size: .875em;
    background: var(--bg-layer-3, #f2e6d2);
    border: 1px solid var(--bg-border, #e8dbc4);
    border-radius: 3px;
    padding: .1em .35em;
    color: var(--bg-fg, #2a2118);
    user-select: all;
}

body[data-theme="dark"] .bg-delete-warning {
    background: #3a1a18;
    border-color: #7a3a35;
    color: #f5b8b3;
}
body[data-theme="dark"] .bg-delete-code {
    background: var(--bg-layer-3);
    border-color: var(--bg-border);
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.bg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.bg-table th {
    text-align: left;
    padding: .5rem .75rem;
    border-bottom: 2px solid var(--bg-border);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bg-muted);
}

.bg-table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--bg-border);
    vertical-align: middle;
}

.bg-table tr:last-child td {
    border-bottom: none;
}

.bg-actions-cell {
    white-space: nowrap;
}

.bg-actions-cell > * {
    vertical-align: middle;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.bg-card {
    background: var(--bg-layer-3, #f2e6d2);
    border: 1px solid var(--bg-border);
    border-radius: 6px;
    padding: 1.25rem;
}

.bg-card h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 1rem;
}

/* ── Formulaires ─────────────────────────────────────────────────────────── */
.bg-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .75rem;
}

.bg-form-grid label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--bg-fg);
}

.bg-input {
    padding: .4rem .6rem;
    border: 1px solid var(--bg-border);
    border-radius: 4px;
    font-size: .9rem;
    font-family: inherit;
    background: var(--bg-layer-1);
    color: var(--bg-fg);
    transition: border-color .15s;
    width: 100%;
    box-sizing: border-box;
}

.bg-input:focus {
    outline: none;
    border-color: var(--bg-accent);
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.bg-pagination {
    display: flex;
    align-items: center;
    gap: .75rem;
    justify-content: center;
    margin-top: 1.25rem;
    color: var(--bg-muted);
    font-size: .9rem;
}

/* ── Admin layout (sidebar + contenu) ────────────────────────────────────── */

/* Pages admin : pleine largeur + hauteur héritée pour que la sidebar s'étire
   jusqu'en bas. bg-body-scroll (flex:1) a une hauteur définie ; main doit la
   propager avec min-height:100% pour que bg-admin-layout puisse s'y référer. */
main:has(.bg-admin-layout) {
    max-width: none;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

main:has(.bg-admin-layout) > .bg-admin-layout {
    flex: 1;
}

.bg-admin-layout {
    display: flex;
    gap: 0;
    /* annule le padding de bg-main pour que la sidebar touche les bords */
    margin: -1.5rem -1rem -3rem;
    min-height: 100%;
}

.bg-admin-sidebar {
    width: 190px;
    flex-shrink: 0;
    border-right: 1px solid var(--bg-border);
    background: var(--bg-layer-3);
    padding: 1.5rem 0;
    align-self: stretch;
}

.bg-admin-sidebar-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--bg-muted);
    padding: 0 1rem .75rem;
    margin: 0;
}

.bg-admin-nav-link {
    display: block;
    padding: .5rem 1rem;
    color: var(--bg-fg);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    border-left: 2.5px solid transparent;
    transition: background .12s;
}

.bg-admin-nav-link:hover {
    background: rgba(0, 0, 0, .06);
    text-decoration: none;
}

.bg-admin-nav-link.active {
    border-left-color: var(--bg-accent);
    color: var(--bg-accent);
    font-weight: 600;
}

.bg-admin-content {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 2rem 3rem;
}

/* ── Admin page header (titre + bouton d'action) ─────────────────────────── */
.bg-admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.bg-admin-page-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

/* ── FluentDataGrid — intégration design ─────────────────────────────────── */
.bg-users-grid {
    width: 100%;
}

/* Réduit le padding horizontal des cellules pour maximiser l'espace utile */
.bg-users-grid [role="gridcell"],
.bg-users-grid [role="columnheader"] {
    padding-inline: 8px !important;
}

.bg-user-cell {
    display: flex;
    align-items: baseline;
    gap: .4rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}

.bg-user-cell strong,
.bg-user-cell .bg-user-username {
    overflow: hidden;
    text-overflow: ellipsis;
}

.bg-user-cell .bg-user-sep {
    flex-shrink: 0;
    user-select: none;
}

.bg-grid-actions {
    display: flex;
    gap: .2rem;
    justify-content: flex-end;
}

/* ── Boutons icône (sans bordure, colorés) ───────────────────────────────── */
.bg-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: .3rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s;
    line-height: 0;
}

.bg-icon-btn:disabled {
    opacity: .3;
    cursor: not-allowed;
}

.bg-icon-btn-edit {
    color: var(--bg-accent, #9b6238);
}

.bg-icon-btn-edit:hover:not(:disabled) {
    background: rgba(155, 98, 56, .12);
}

.bg-icon-btn-delete {
    color: #c0392b;
}

.bg-icon-btn-delete:hover:not(:disabled) {
    background: rgba(192, 57, 43, .1);
}

/* ── Modal overlay ────────────────────────────────────────────────────────── */
.bg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.bg-modal {
    background: var(--bg-layer-1, #faf5ec);
    border: 1px solid var(--bg-border, #e8dbc4);
    border-radius: 8px;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
    max-height: 90dvh;
}

.bg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--bg-border, #e8dbc4);
    flex-shrink: 0;
}

.bg-modal-header strong {
    font-size: 1rem;
}

.bg-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--bg-muted, #6e6253);
    font-size: 1rem;
    padding: .2rem .4rem;
    border-radius: 4px;
    line-height: 1;
    transition: background .12s, color .12s;
}

.bg-modal-close:hover {
    color: var(--bg-fg, #2a2118);
    background: var(--bg-layer-3, #f2e6d2);
}

.bg-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.bg-modal-footer {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--bg-border, #e8dbc4);
    flex-shrink: 0;
}

/* ── Form grid — variante colonne unique pour le modal ───────────────────── */
.bg-form-grid.bg-form-grid-1col {
    grid-template-columns: 1fr;
}

/* ── Badges de rôle colorisés ─────────────────────────────────────────────── */
.bg-badge-admin {
    background: rgba(155, 98, 56, .12);
    border-color: var(--bg-accent, #9b6238);
    color: var(--bg-accent, #9b6238);
}

.bg-badge-publisher {
    background: rgba(95, 143, 60, .12);
    border-color: var(--bg-green, #5f8f3c);
    color: var(--bg-green, #5f8f3c);
}

.bg-badge-reader {
    background: rgba(30, 100, 180, .08);
    border-color: #3a7abf;
    color: #3a7abf;
}

.bg-badge-guest {
    /* same as base .bg-badge — no extra style needed */
}

body[data-theme="dark"] .bg-badge-reader {
    border-color: #7ab4e8;
    color: #7ab4e8;
    background: rgba(122, 180, 232, .1);
}

/* Boot loading screen — shown until the WASM app mounts into #app and
   replaces this markup. Adapted from the default Blazor template. */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--bg-border, #e8dbc4);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--bg-accent, #9b6238);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--bg-muted, #6e6253);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* Unhandled-error banner — hidden until Blazor flips it to display:block on a
   real error. Without this rule the div in index.html is shown permanently. */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    color: #1a1a1a;
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
