@font-face {
    font-family: "Merriweather Sans";
    src: url("fonts/merriweather-sans/MerriweatherSans_Light.ttf") format("truetype");
    font-weight: 300;
    font-display: swap;
}

@font-face {
    font-family: "Merriweather Sans";
    src: url("fonts/merriweather-sans/MerriweatherSans_Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Merriweather Sans";
    src: url("fonts/merriweather-sans/MerriweatherSans_Medium.ttf") format("truetype");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Merriweather Sans";
    src: url("fonts/merriweather-sans/MerriweatherSans_Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "Merriweather Sans";
    src: url("fonts/merriweather-sans/MerriweatherSans_ExtraBold.ttf") format("truetype");
    font-weight: 800;
    font-display: swap;
}

:root {
    --bg: light-dark(#f4eff2, #141113);
    --surface: light-dark(#fbfbfb, #1d191b);
    --container: light-dark(#efe7eb, #262124);
    --container-high: light-dark(#e8dee3, #312a2e);
    --border: light-dark(#e5e5e5, #3a3236);
    --outline: light-dark(#bcabae, #7d6f75);
    --text: light-dark(#28302f, #ece4e7);
    --muted: light-dark(#5f5a5d, #b3a8ad);
    --accent: light-dark(#77556e, #e3b8d4);
    --accent-strong: light-dark(#5f4258, #f2cfe6);
    --on-accent: light-dark(#ffffff, #44283c);
    --accent-soft: light-dark(#f6d8ec, #5d3e55);
    --on-accent-soft: light-dark(#4a2f43, #ffd7ef);
    --status-normal: #8bc34a;
    --level-warning: #7e57c2;
    --level-alert: #fb8c00;
    --level-alarm: #e53935;
    --status-unknown: #9e9e9e;
    --danger: light-dark(#c62828, #ff8a80);
    --danger-strong: light-dark(#a51f1f, #ffb4ab);
    --danger-soft: light-dark(#fde8e7, #3d1816);
    --success: light-dark(#3f6f1e, #a5d67a);
    --success-soft: light-dark(#edf6e2, #22301a);
    --warning: light-dark(#b34a00, #ffb562);
    --warning-soft: light-dark(#fff1e0, #3a2610);
    --info-soft: light-dark(#f6d8ec, #3b2a35);
    --shadow-color: light-dark(rgba(40, 48, 47, 0.08), rgba(0, 0, 0, 0.4));
    --shadow-tint: light-dark(rgba(119, 85, 110, 0.08), rgba(0, 0, 0, 0.3));
    --shadow: 0 1px 3px var(--shadow-color), 0 4px 16px var(--shadow-tint);
    --scrim: light-dark(rgba(40, 48, 47, 0.32), rgba(0, 0, 0, 0.6));
    --font: "Merriweather Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 28px;
    --radius-full: 999px;
    --sidebar-width: 15rem;
    color-scheme: light dark;
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
}

h1 {
    font-size: 1.85rem;
    font-weight: 400;
    line-height: 1.2;
    margin: 0 0 1.5rem;
}

h2 {
    font-size: 1.3rem;
    font-weight: 500;
    line-height: 1.3;
    margin: 0 0 1rem;
}

h3 {
    font-size: 1.05rem;
    font-weight: 500;
    margin: 1.5rem 0 0.75rem;
}

h1:focus {
    outline: none;
}

p {
    margin: 0 0 1rem;
}

a {
    color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

kbd,
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--container);
    border-radius: 6px;
    padding: 0.1rem 0.4rem;
}

.shell {
    display: flex;
    min-height: 100vh;
    background: var(--surface);
}

.topbar,
.scrim {
    display: none;
}

.menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border: 0;
    border-radius: var(--radius-full);
    background: none;
    color: var(--text);
    cursor: pointer;
}

    .menu-button:hover {
        background: var(--container-high);
    }

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100vh;
    padding: 1.25rem 0.75rem;
    background: var(--container);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0 0.75rem 1.5rem;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--accent);
    text-decoration: none;
}

.brand-logo {
    width: 2.25rem;
    height: 2.25rem;
    flex: none;
    background: var(--accent);
    -webkit-mask: url("images/logo.png") center / contain no-repeat;
    mask: url("images/logo.png") center / contain no-repeat;
}

.brand-name {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

    .brand-name small {
        font-weight: 400;
        color: var(--muted);
        font-size: 0.75rem;
    }

.icon {
    width: 1.35rem;
    height: 1.35rem;
    flex: none;
    fill: currentColor;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar a:not(.brand),
.link-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 1rem;
    border: 0;
    border-radius: var(--radius-full);
    background: none;
    color: var(--muted);
    font: inherit;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

    .sidebar a:not(.brand):hover,
    .link-button:hover {
        background: var(--container-high);
        color: var(--text);
    }

.sidebar a.active,
.sidebar a.active:hover {
    background: var(--accent-soft);
    color: var(--on-accent-soft);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.manager {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem 0.5rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 300;
}

    .manager span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.content {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem;
}

.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: var(--bg);
}

.panel {
    width: 100%;
    max-width: 26rem;
    padding: 2rem;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

    .panel .brand {
        margin: 0 0 1.5rem;
    }

.panel:has(> .document) {
    max-width: 42rem;
}

.manage {
    max-width: 44rem;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

    .tabs a {
        padding: 0.6rem 1rem;
        margin-bottom: -1px;
        border-bottom: 3px solid transparent;
        color: var(--muted);
        font-weight: 500;
        text-decoration: none;
    }

        .tabs a:hover {
            color: var(--text);
        }

        .tabs a.active {
            border-bottom-color: var(--accent);
            color: var(--accent);
        }

.manage-body h2 {
    margin-top: 0;
}

.form-floating {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

    .form-floating > label {
        order: -1;
        font-size: 0.85rem;
        font-weight: 500;
        color: var(--muted);
    }

.mb-3 {
    margin-bottom: 1rem;
}

.form-control,
input[type=search] {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.65rem 1rem;
    line-height: 1.25;
    border: 1px solid var(--outline);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

    .form-control::placeholder,
    input[type=search]::placeholder {
        color: var(--muted);
        font-weight: 300;
    }

    .form-control:focus,
    input[type=search]:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: inset 0 0 0 1px var(--accent);
    }

    .form-control:disabled {
        background: var(--container);
        border-color: var(--border);
        color: var(--muted);
    }

select.form-control {
    appearance: none;
    padding-right: 2.5rem;
    background-color: var(--surface);
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 1.25rem) 50%, calc(100% - 0.9rem) 50%;
    background-size: 0.35rem 0.35rem;
    background-repeat: no-repeat;
    cursor: pointer;
}

input[type=search] {
    border-color: transparent;
    border-radius: var(--radius-full);
    background: var(--container-high);
    padding-inline: 1.25rem;
}

input[type=checkbox] {
    accent-color: var(--accent);
    width: 1.1rem;
    height: 1.1rem;
}

.checkbox label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn,
button[type=submit],
.pager button {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    border: 1px solid var(--outline);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-size: 0.93rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

    .btn:hover,
    button[type=submit]:hover,
    .pager button:hover:not(:disabled) {
        background: var(--container);
    }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

    .pager button:disabled {
        opacity: 0.45;
        cursor: default;
    }

.btn-primary,
button[type=submit].btn-primary,
.search button[type=submit] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

    .btn-primary:hover,
    button[type=submit].btn-primary:hover,
    .search button[type=submit]:hover {
        background: var(--accent-strong);
        border-color: var(--accent-strong);
    }

.btn-danger,
button[type=submit].btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--surface);
}

    .btn-danger:hover,
    button[type=submit].btn-danger:hover {
        background: var(--danger-strong);
        border-color: var(--danger-strong);
    }

.btn-delete,
button[type=submit].btn-delete {
    border-color: var(--danger);
    color: var(--danger);
}

    .btn-delete:hover,
    button[type=submit].btn-delete:hover {
        background: var(--danger-soft);
    }

.btn-link,
button[type=submit].btn-link {
    border-color: transparent;
    background: none;
    color: var(--accent);
}

.sidebar .link-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 0;
    padding: 0.65rem 1rem;
    background: none;
    color: var(--muted);
    font-size: 1rem;
    text-align: left;
}

    .sidebar .link-button:hover {
        background: var(--container-high);
        color: var(--text);
    }

.w-100 {
    width: 100%;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    margin: 0 0 1.5rem;
}

    .details dt {
        color: var(--muted);
        font-size: 0.85rem;
        font-weight: 500;
    }

    .details dd {
        margin: 0;
    }

.alternative {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--muted);
}

.alert {
    padding: 0.85rem 1.1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    color: var(--text);
}

    .alert p:last-child {
        margin-bottom: 0;
    }

.alert-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-soft);
}

.alert-info {
    background: var(--info-soft);
    color: var(--on-accent-soft);
}

.text-danger,
.validation-message {
    color: var(--danger);
}

.validation-message {
    font-size: 0.85rem;
}

.validation-errors {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
    color: var(--danger);
}

.text-muted {
    color: var(--muted);
}

.invalid {
    border-color: var(--danger);
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 0.5rem 1.5rem;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

    .filters label {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        color: var(--muted);
        font-size: 0.85rem;
        font-weight: 500;
        flex: 1 1 8rem;
        max-width: 14rem;
    }

    .filters select,
    .filters input {
        min-width: 0;
        height: 2.75rem;
    }

    .filters button {
        height: 2.75rem;
        padding-block: 0;
    }

.table {
    width: 100%;
    border-collapse: collapse;
}

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

        .table td:last-child {
            text-align: right;
        }

.search {
    display: flex;
    gap: 0.5rem;
    max-width: 32rem;
    margin-bottom: 1.25rem;
}

.grid {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-variant-numeric: tabular-nums;
}

    .grid table {
        width: 100%;
        border-collapse: collapse;
    }

    .grid th,
    .grid td {
        padding: 0.75rem 1rem;
        text-align: left;
        white-space: nowrap;
    }

    .grid td {
        font-weight: 300;
    }

        .grid td:first-child {
            font-weight: 500;
        }

    .grid thead th {
        border-bottom: 1px solid var(--outline);
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 500;
    }

    .grid tbody tr + tr td {
        border-top: 1px solid var(--border);
    }

    .grid tbody tr:hover td {
        background: var(--container);
    }

    .grid tbody tr:not([aria-rowindex]) {
        display: none;
    }

    .grid .col-title {
        font-weight: 500;
    }

    .grid th.col-sort-asc .sort-indicator,
    .grid th.col-sort-desc .sort-indicator {
        background: var(--accent);
        -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M 2 3.25 L 12 20.75 L 22 3.25 L 12 10 z" /></svg>') center / 0.7rem no-repeat;
        mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M 2 3.25 L 12 20.75 L 22 3.25 L 12 10 z" /></svg>') center / 0.7rem no-repeat;
    }

    .grid tr:has([data-row-open]) {
        cursor: pointer;
        user-select: none;
    }

    .grid .row-actions {
        position: sticky;
        right: 0;
        width: 1%;
        background: var(--surface);
        text-align: right;
    }

    .grid tbody tr:hover td.row-actions {
        background: var(--container);
    }

.icon-button,
button[type=submit].icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--outline);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

    .icon-button:hover:not(:disabled) {
        background: var(--container);
    }

    .icon-button.icon-only {
        width: 2.25rem;
        height: 2.25rem;
        padding: 0;
    }

    .icon-button:disabled {
        opacity: 0.4;
        cursor: default;
    }

    .icon-button .icon {
        width: 1.15rem;
        height: 1.15rem;
    }

.level {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

    .level::before {
        content: "";
        width: 0.6rem;
        height: 0.6rem;
        border-radius: var(--radius-full);
        background: var(--status-unknown);
    }

.level-warning::before {
    background: var(--level-warning);
}

.level-alert::before {
    background: var(--level-alert);
}

.level-alarm::before {
    background: var(--level-alarm);
}

.mention {
    margin-left: 0.5rem;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-full);
    background: var(--accent-soft);
    color: var(--on-accent-soft);
    font-size: 0.75rem;
    font-weight: 500;
}

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: var(--warning-soft);
    color: var(--text);
    box-shadow: var(--shadow);
}

    #blazor-error-ui .dismiss {
        position: absolute;
        top: 0.4rem;
        right: 0.75rem;
        border: 0;
        background: none;
        color: inherit;
        font-size: 1.2rem;
        cursor: pointer;
    }

.blazor-error-boundary {
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--danger-soft);
    color: var(--danger);
}

    .blazor-error-boundary::after {
        content: "Une erreur s'est produite.";
    }

@media (max-width: 720px) {
    .shell {
        flex-direction: column;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 10;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        padding: 0.5rem 1rem 0.5rem 0.5rem;
        background: var(--container);
    }

        .topbar .brand {
            margin: 0;
            font-size: 1.1rem;
        }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        width: min(20rem, 85vw);
        height: 100dvh;
        overflow-y: auto;
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
        box-shadow: var(--shadow);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0.2s;
    }

    .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 20;
        background: var(--scrim);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s;
    }

    .shell[data-menu-open] .sidebar,
    .shell[data-menu-open] .scrim {
        transform: none;
        opacity: 1;
        visibility: visible;
    }

    :root:has(.shell[data-menu-open]) {
        overflow: hidden;
    }

    .content {
        padding: 1.25rem 1rem;
    }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
    .sidebar,
    .scrim {
        transition: none;
    }
}

[data-edit-form][data-lang="fr"] [data-lang-field="en"],
[data-edit-form][data-lang="en"] [data-lang-field="fr"] {
    display: none;
}
