/* ============================================================================
   OTT-SYS DS — composants (Portal, P4-E1)

   Boutons, badges, cartes, indicateurs, alertes, tableaux, formulaires, menus,
   modales, notifications, squelettes, pagination, fil d'Ariane, en-têtes,
   états vides, blocs de code. Uniquement des tokens de tokens.css.
   ========================================================================== */

/* Icônes ------------------------------------------------------------------- */

.icon {
    width: 20px;
    height: 20px;
}

.icon--sm {
    width: 16px;
    height: 16px;
}

.icon--lg {
    width: 24px;
    height: 24px;
}

/* Boutons ------------------------------------------------------------------ */

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ott-space-2);
    min-height: var(--ott-control-h);
    padding: 0 var(--ott-space-4);
    border: 1px solid transparent;
    border-radius: var(--ott-radius-md);
    background: transparent;
    color: var(--ott-text);
    font: inherit;
    font-size: var(--ott-text-md);
    font-weight: var(--ott-weight-semibold);
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--ott-dur-fast) var(--ott-ease), border-color var(--ott-dur-fast) var(--ott-ease), color var(--ott-dur-fast) var(--ott-ease), box-shadow var(--ott-dur-fast) var(--ott-ease);
}

.btn:hover {
    text-decoration: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--ott-focus-ring);
}

.btn .icon {
    width: 18px;
    height: 18px;
}

.btn--primary {
    background: var(--ott-primary-fill);
    color: var(--ott-on-primary);
    box-shadow: var(--ott-shadow-xs);
}

.btn--primary:hover {
    background: var(--ott-primary-fill-hover);
    color: var(--ott-on-primary);
}

.btn--secondary {
    border-color: var(--ott-border-strong);
    background: var(--ott-surface);
    color: var(--ott-text);
    box-shadow: var(--ott-shadow-xs);
}

.btn--secondary:hover {
    border-color: var(--ott-text-faint);
    background: var(--ott-surface-2);
    color: var(--ott-text);
}

.btn--tertiary {
    padding: 0 var(--ott-space-3);
    color: var(--ott-primary);
}

.btn--tertiary:hover {
    background: var(--ott-primary-subtle);
    color: var(--ott-primary-hover);
}

.btn--danger {
    background: var(--ott-danger-fill);
    color: var(--ott-on-danger);
    box-shadow: var(--ott-shadow-xs);
}

.btn--danger:hover {
    background: var(--ott-danger-fill-hover);
    color: var(--ott-on-danger);
}

.btn--danger-quiet {
    border-color: var(--ott-danger-border);
    background: var(--ott-surface);
    color: var(--ott-danger);
}

.btn--danger-quiet:hover {
    background: var(--ott-danger-subtle);
    color: var(--ott-danger);
}

.btn--sm {
    min-height: var(--ott-control-h-sm);
    padding: 0 var(--ott-space-3);
    font-size: var(--ott-text-sm);
}

.btn--lg {
    min-height: var(--ott-control-h-lg);
    padding: 0 var(--ott-space-5);
    font-size: var(--ott-text-base);
}

.btn--block {
    width: 100%;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* Chargement : libellé conservé, indicateur à droite. */
.btn[aria-busy="true"] {
    cursor: progress;
    pointer-events: none;
}

.btn[aria-busy="true"]::after {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: ott-spin 0.7s linear infinite;
}

@keyframes ott-spin {
    to {
        transform: rotate(360deg);
    }
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ott-control-h);
    height: var(--ott-control-h);
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--ott-radius-md);
    background: transparent;
    color: var(--ott-text-muted);
    cursor: pointer;
    transition: background-color var(--ott-dur-fast) var(--ott-ease), color var(--ott-dur-fast) var(--ott-ease);
}

.icon-btn:hover {
    background: var(--ott-surface-3);
    color: var(--ott-text);
}

.icon-btn:focus-visible {
    outline: none;
    box-shadow: var(--ott-focus-ring);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ott-space-3);
}

.actions form {
    margin: 0;
}

.actions--end {
    justify-content: flex-end;
}

@media (max-width: 767.98px) {
    .btn,
    .icon-btn {
        min-height: var(--ott-control-h-lg);
    }

    .icon-btn {
        width: var(--ott-control-h-lg);
        height: var(--ott-control-h-lg);
    }

    .btn--sm {
        min-height: 2.25rem;
    }
}

/* Badges et statuts -------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 1.5rem;
    padding: 0 var(--ott-space-2);
    border: 1px solid var(--ott-neutral-border);
    border-radius: var(--ott-radius-pill);
    background: var(--ott-neutral-subtle);
    color: var(--ott-neutral);
    font-size: var(--ott-text-xs);
    font-weight: var(--ott-weight-semibold);
    line-height: 1.2;
    white-space: nowrap;
    vertical-align: middle;
}

.badge--dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge--success {
    border-color: var(--ott-success-border);
    background: var(--ott-success-subtle);
    color: var(--ott-success);
}

.badge--info {
    border-color: var(--ott-info-border);
    background: var(--ott-info-subtle);
    color: var(--ott-info);
}

.badge--warning {
    border-color: var(--ott-warning-border);
    background: var(--ott-warning-subtle);
    color: var(--ott-warning);
}

.badge--danger {
    border-color: var(--ott-danger-border);
    background: var(--ott-danger-subtle);
    color: var(--ott-danger);
}

.badge--primary {
    border-color: var(--ott-primary-border);
    background: var(--ott-primary-subtle);
    color: var(--ott-primary);
}

.counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 6px;
    border-radius: var(--ott-radius-pill);
    background: var(--ott-surface-3);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-xs);
    font-weight: var(--ott-weight-semibold);
    font-variant-numeric: tabular-nums;
}

/* Cartes ------------------------------------------------------------------- */

.card {
    min-width: 0;
    border: 1px solid var(--ott-border);
    border-radius: var(--ott-radius-lg);
    background: var(--ott-surface);
    box-shadow: var(--ott-shadow-sm);
}

.card__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--ott-space-3);
    padding: var(--ott-space-5) var(--ott-space-6) 0;
}

.card__title {
    display: flex;
    align-items: center;
    gap: var(--ott-space-2);
    font-size: var(--ott-text-lg);
    font-weight: var(--ott-weight-semibold);
}

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

.card__subtitle {
    width: 100%;
    margin-top: calc(-1 * var(--ott-space-2));
    color: var(--ott-text-muted);
    font-size: var(--ott-text-md);
}

.card__body {
    display: grid;
    gap: var(--ott-space-4);
    padding: var(--ott-space-5) var(--ott-space-6) var(--ott-space-6);
}

.card__body > p {
    max-width: 80ch;
}

.card__body--flush {
    padding: var(--ott-space-4) 0 0;
}

.card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--ott-space-3);
    padding: var(--ott-space-3) var(--ott-space-6);
    border-top: 1px solid var(--ott-border);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
}

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

.card--danger .card__title .icon {
    color: var(--ott-danger);
}

@media (max-width: 599.98px) {
    .card__header {
        padding: var(--ott-space-4) var(--ott-space-4) 0;
    }

    .card__body {
        padding: var(--ott-space-4);
    }

    .card__body--flush {
        padding: var(--ott-space-3) 0 0;
    }

    .card__footer {
        padding: var(--ott-space-3) var(--ott-space-4);
    }
}

/* Indicateurs (chiffres clés) --------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: var(--ott-space-4);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: var(--ott-space-1);
    min-width: 0;
    padding: var(--ott-space-5);
    border: 1px solid var(--ott-border);
    border-radius: var(--ott-radius-lg);
    background: var(--ott-surface);
    box-shadow: var(--ott-shadow-sm);
}

.stat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ott-space-2);
}

.stat__label {
    margin: 0;
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
    font-weight: var(--ott-weight-medium);
}

.stat__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--ott-radius-md);
    background: var(--ott-primary-subtle);
    color: var(--ott-primary);
}

.stat__icon .icon {
    width: 18px;
    height: 18px;
}

.stat__value {
    margin: 0;
    color: var(--ott-text);
    font-size: var(--ott-text-3xl);
    font-weight: var(--ott-weight-semibold);
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat__value--sm {
    font-size: var(--ott-text-xl);
}

.stat__foot {
    margin-top: auto;
    padding-top: var(--ott-space-2);
    font-size: var(--ott-text-sm);
}

.stat__foot a {
    display: inline-flex;
    align-items: center;
    gap: var(--ott-space-1);
    font-weight: var(--ott-weight-medium);
}

/* Listes de propriétés (clé / valeur) -------------------------------------- */

.dl {
    display: grid;
    grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr);
    margin: 0;
}

.dl dt,
.dl dd {
    margin: 0;
    padding: var(--ott-space-3) 0;
    border-bottom: 1px solid var(--ott-border);
}

.dl dt {
    padding-right: var(--ott-space-4);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-md);
}

.dl dd {
    min-width: 0;
    color: var(--ott-text);
    overflow-wrap: anywhere;
}

.dl dt:last-of-type,
.dl dd:last-of-type {
    border-bottom: 0;
}

.dl code {
    color: var(--ott-text-body);
}

@media (max-width: 599.98px) {
    .dl {
        grid-template-columns: minmax(0, 1fr);
    }

    .dl dt {
        padding-bottom: 0;
        border-bottom: 0;
        font-size: var(--ott-text-sm);
    }

    .dl dd {
        padding-top: var(--ott-space-1);
    }
}

/* Alertes ------------------------------------------------------------------ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--ott-space-3);
    padding: var(--ott-space-3) var(--ott-space-4);
    border: 1px solid var(--ott-info-border);
    border-radius: var(--ott-radius-md);
    background: var(--ott-info-subtle);
    color: var(--ott-text);
    font-size: var(--ott-text-md);
}

.alert > .icon {
    margin-top: 1px;
    color: var(--ott-info);
}

.alert__body {
    display: grid;
    gap: var(--ott-space-1);
    min-width: 0;
}

.alert__title {
    color: var(--ott-text);
    font-weight: var(--ott-weight-semibold);
}

.alert__body ul {
    padding-left: var(--ott-space-5);
}

.alert--success {
    border-color: var(--ott-success-border);
    background: var(--ott-success-subtle);
}

.alert--success > .icon {
    color: var(--ott-success);
}

.alert--warning {
    border-color: var(--ott-warning-border);
    background: var(--ott-warning-subtle);
}

.alert--warning > .icon {
    color: var(--ott-warning);
}

.alert--danger {
    border-color: var(--ott-danger-border);
    background: var(--ott-danger-subtle);
}

.alert--danger > .icon {
    color: var(--ott-danger);
}

/* Tableaux ----------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--ott-text-md);
    font-variant-numeric: tabular-nums;
}

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

.table th:first-child,
.table td:first-child {
    padding-left: var(--ott-space-6);
}

.table th:last-child,
.table td:last-child {
    padding-right: var(--ott-space-6);
}

.table thead th {
    background: var(--ott-surface-2);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
    font-weight: var(--ott-weight-semibold);
    white-space: nowrap;
}

.table tbody tr {
    transition: background-color var(--ott-dur-fast) var(--ott-ease);
}

.table tbody tr:hover {
    background: var(--ott-row-hover);
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table td {
    color: var(--ott-text-body);
}

.table .cell-strong {
    color: var(--ott-text);
    font-weight: var(--ott-weight-medium);
}

.table .cell-sub {
    display: block;
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
}

.table .cell-muted,
.table code {
    color: var(--ott-text-muted);
}

.table .num {
    text-align: right;
}

.table .cell-actions {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

.table .cell-actions form {
    display: inline;
}

/* Vue en cartes sous 768 px pour les tableaux marqués .table--stack. */
@media (max-width: 767.98px) {
    .table--stack thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .table--stack,
    .table--stack tbody,
    .table--stack tr,
    .table--stack td {
        display: block;
    }

    .table--stack tr {
        padding: var(--ott-space-3) var(--ott-space-4);
        border-bottom: 1px solid var(--ott-border);
    }

    .table--stack tbody tr:last-child {
        border-bottom: 0;
    }

    .table--stack td,
    .table--stack td:first-child,
    .table--stack td:last-child {
        display: flex;
        justify-content: space-between;
        gap: var(--ott-space-4);
        padding: var(--ott-space-1) 0;
        border: 0;
        text-align: right;
    }

    .table--stack td::before {
        content: attr(data-label);
        flex: none;
        color: var(--ott-text-muted);
        font-size: var(--ott-text-sm);
        text-align: left;
    }

    .table--stack td[data-label=""]::before {
        content: none;
    }

    .table--stack td.cell-primary {
        display: block;
        margin-bottom: var(--ott-space-1);
        text-align: left;
        font-size: var(--ott-text-base);
    }

    .table--stack td.cell-primary::before {
        content: none;
    }

    .table--stack td.cell-actions {
        width: auto;
        justify-content: flex-end;
        padding-top: var(--ott-space-2);
    }

    .table--stack .num {
        text-align: right;
    }
}

/* Formulaires -------------------------------------------------------------- */

.form {
    display: grid;
    gap: var(--ott-space-5);
}

.form__section {
    display: grid;
    gap: var(--ott-space-4);
    padding-top: var(--ott-space-5);
    border-top: 1px solid var(--ott-border);
}

.form__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ott-space-3);
    padding-top: var(--ott-space-1);
}

.form-row {
    display: grid;
    gap: var(--ott-space-5);
}

@media (min-width: 640px) {
    .form-row--2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.field {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
}

.field__label {
    color: var(--ott-text);
    font-size: var(--ott-text-md);
    font-weight: var(--ott-weight-semibold);
}

.field__required {
    margin-left: 2px;
    color: var(--ott-danger);
}

.field__optional {
    color: var(--ott-text-muted);
    font-weight: var(--ott-weight-regular);
}

.field__hint {
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
}

.field__error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    color: var(--ott-danger);
    font-size: var(--ott-text-sm);
    font-weight: var(--ott-weight-medium);
}

.field__error .icon {
    width: 16px;
    height: 16px;
    margin-top: 1px;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: var(--ott-control-h);
    padding: 0 var(--ott-space-3);
    border: 1px solid var(--ott-control-border);
    border-radius: var(--ott-radius-md);
    background: var(--ott-surface);
    color: var(--ott-text);
    font: inherit;
    font-size: var(--ott-text-base);
    transition: border-color var(--ott-dur-fast) var(--ott-ease), box-shadow var(--ott-dur-fast) var(--ott-ease);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--ott-text-faint);
}

.input:hover,
.select:hover,
.textarea:hover {
    border-color: var(--ott-text-muted);
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--ott-focus);
    outline: none;
    box-shadow: var(--ott-focus-ring);
}

.select {
    padding-right: 2.5rem;
    background-image: var(--ott-select-arrow);
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.textarea {
    min-height: 7rem;
    padding: var(--ott-space-2) var(--ott-space-3);
    line-height: var(--ott-leading);
    resize: vertical;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    border-color: var(--ott-border);
    background-color: var(--ott-surface-3);
    color: var(--ott-text-muted);
    cursor: not-allowed;
}

.input[readonly],
.textarea[readonly] {
    background: var(--ott-surface-2);
    color: var(--ott-text-body);
}

.field--error .input,
.field--error .select,
.field--error .textarea {
    border-color: var(--ott-danger);
}

.field--error .input:focus,
.field--error .select:focus,
.field--error .textarea:focus {
    box-shadow: 0 0 0 3px var(--ott-danger-subtle);
}

.input--code {
    font-family: var(--ott-font-mono);
    letter-spacing: 0.12em;
}

.choice {
    display: flex;
    align-items: flex-start;
    gap: var(--ott-space-3);
    min-height: 1.5rem;
    color: var(--ott-text-body);
    font-size: var(--ott-text-md);
    cursor: pointer;
}

.choice input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--ott-primary-fill);
    cursor: pointer;
}

.choice input:focus-visible {
    outline: 2px solid var(--ott-focus);
    outline-offset: 2px;
}

@media (max-width: 767.98px) {
    .input,
    .select {
        min-height: var(--ott-control-h-lg);
        font-size: 1rem;
    }

    .choice {
        min-height: var(--ott-control-h-lg);
        align-items: center;
    }

    .choice input {
        margin-top: 0;
    }
}

/* Barre de filtres */
.filters {
    display: grid;
    gap: var(--ott-space-4);
    align-items: end;
    padding: var(--ott-space-4) var(--ott-space-6);
    border-bottom: 1px solid var(--ott-border);
}

@media (min-width: 640px) {
    .filters {
        grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    }
}

@media (max-width: 599.98px) {
    .filters {
        padding: var(--ott-space-4);
    }
}

/* Champ piège anti-robot : hors écran, hors tabulation, masqué aux aides techniques. */
.hp-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Révélation (disclosure) -------------------------------------------------- */

.disclosure {
    border: 1px solid var(--ott-border);
    border-radius: var(--ott-radius-md);
    background: var(--ott-surface-2);
}

.disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ott-space-2);
    min-height: var(--ott-control-h);
    padding: 0 var(--ott-space-4);
    color: var(--ott-primary);
    font-size: var(--ott-text-md);
    font-weight: var(--ott-weight-semibold);
    list-style: none;
    cursor: pointer;
}

.disclosure > summary::-webkit-details-marker {
    display: none;
}

.disclosure > summary .icon {
    transition: transform var(--ott-dur) var(--ott-ease);
}

.disclosure[open] > summary .icon {
    transform: rotate(180deg);
}

.disclosure > summary:focus-visible {
    outline: none;
    border-radius: var(--ott-radius-md);
    box-shadow: var(--ott-focus-ring);
}

.disclosure__body {
    padding: 0 var(--ott-space-4) var(--ott-space-4);
}

/* Menus déroulants (details/summary, amélioré par Alpine) ------------------ */

.menu {
    position: relative;
}

.menu > summary {
    list-style: none;
    cursor: pointer;
}

.menu > summary::-webkit-details-marker {
    display: none;
}

.menu__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    min-width: 14rem;
    padding: 6px;
    border: 1px solid var(--ott-border);
    border-radius: var(--ott-radius-lg);
    background: var(--ott-surface);
    box-shadow: var(--ott-shadow-md);
    animation: ott-pop var(--ott-dur-fast) var(--ott-ease);
}

@keyframes ott-pop {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
}

.menu__header {
    padding: var(--ott-space-2) var(--ott-space-3) var(--ott-space-3);
    margin-bottom: 6px;
    border-bottom: 1px solid var(--ott-border);
}

.menu__header strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu__header span {
    display: block;
    overflow: hidden;
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu__label {
    padding: var(--ott-space-2) var(--ott-space-3) var(--ott-space-1);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-xs);
    font-weight: var(--ott-weight-semibold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.menu__item {
    display: flex;
    align-items: center;
    gap: var(--ott-space-3);
    width: 100%;
    min-height: 2.25rem;
    padding: 0 var(--ott-space-3);
    border: 0;
    border-radius: var(--ott-radius-md);
    background: transparent;
    color: var(--ott-text-body);
    font: inherit;
    font-size: var(--ott-text-md);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu__item .icon {
    width: 18px;
    height: 18px;
    color: var(--ott-text-muted);
}

.menu__item:hover,
.menu__item:focus-visible {
    background: var(--ott-surface-3);
    color: var(--ott-text);
    text-decoration: none;
    outline: none;
}

.menu__item[aria-pressed="true"] {
    color: var(--ott-primary);
    font-weight: var(--ott-weight-semibold);
}

.menu__item[aria-pressed="true"] .icon {
    color: var(--ott-primary);
}

.menu__item--danger,
.menu__item--danger .icon {
    color: var(--ott-danger);
}

.menu__item--danger:hover {
    background: var(--ott-danger-subtle);
    color: var(--ott-danger);
}

.menu__separator {
    height: 1px;
    margin: 6px 0;
    background: var(--ott-border);
}

.menu form {
    margin: 0;
}

@media (max-width: 767.98px) {
    .menu__item {
        min-height: var(--ott-control-h-lg);
    }
}

/* Menu utilisateur (barre haute) */
.user-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--ott-space-2);
    min-height: var(--ott-control-h);
    padding: 0 var(--ott-space-2) 0 4px;
    border-radius: var(--ott-radius-pill);
    color: var(--ott-text);
    font-size: var(--ott-text-md);
    font-weight: var(--ott-weight-medium);
}

.user-trigger:hover {
    background: var(--ott-surface-3);
}

.user-trigger:focus-visible {
    outline: none;
    box-shadow: var(--ott-focus-ring);
}

.user-trigger .icon {
    color: var(--ott-text-muted);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--ott-rail);
    color: #ffffff;
    font-size: var(--ott-text-xs);
    font-weight: var(--ott-weight-bold);
    letter-spacing: 0.02em;
}

@media (max-width: 767.98px) {
    .user-trigger__name {
        display: none;
    }
}

/* Modales (dialog natif : Échap, focus contenu, arrière-plan inerte) ------- */

.modal {
    width: min(30rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 1px solid var(--ott-border);
    border-radius: var(--ott-radius-xl);
    background: var(--ott-surface);
    color: var(--ott-text-body);
    box-shadow: var(--ott-shadow-lg);
}

.modal[open] {
    animation: ott-pop var(--ott-dur) var(--ott-ease);
}

.modal::backdrop {
    background: var(--ott-backdrop);
}

.modal__header {
    display: flex;
    align-items: flex-start;
    gap: var(--ott-space-3);
    padding: var(--ott-space-6) var(--ott-space-6) 0;
}

.modal__icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--ott-danger-subtle);
    color: var(--ott-danger);
}

.modal__title {
    padding-top: var(--ott-space-2);
    font-size: var(--ott-text-lg);
}

.modal__body {
    padding: var(--ott-space-3) var(--ott-space-6) 0;
    color: var(--ott-text-muted);
}

.modal__footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--ott-space-3);
    padding: var(--ott-space-6);
}

/* Notifications (toasts) --------------------------------------------------- */

.toasts {
    position: fixed;
    right: var(--ott-space-6);
    bottom: var(--ott-space-6);
    z-index: 80;
    display: grid;
    gap: var(--ott-space-3);
    width: min(24rem, calc(100vw - 2rem));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--ott-space-3);
    padding: var(--ott-space-4);
    border: 1px solid var(--ott-border);
    border-left: 3px solid var(--ott-success);
    border-radius: var(--ott-radius-lg);
    background: var(--ott-surface);
    color: var(--ott-text);
    font-size: var(--ott-text-md);
    box-shadow: var(--ott-shadow-lg);
    animation: ott-toast var(--ott-dur) var(--ott-ease);
}

.toast > .icon {
    color: var(--ott-success);
}

.toast__text {
    flex: 1;
    padding-top: 1px;
}

.toast .icon-btn {
    width: 1.75rem;
    height: 1.75rem;
    min-height: 0;
    margin: -2px -4px 0 0;
}

@keyframes ott-toast {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@media (max-width: 599.98px) {
    .toasts {
        right: var(--ott-space-4);
        bottom: var(--ott-space-4);
        left: var(--ott-space-4);
        width: auto;
    }
}

/* Squelettes --------------------------------------------------------------- */

.skeleton {
    display: block;
    height: 0.875rem;
    border-radius: var(--ott-radius-sm);
    background: linear-gradient(90deg, var(--ott-surface-3) 25%, var(--ott-surface-2) 50%, var(--ott-surface-3) 75%);
    background-size: 200% 100%;
    animation: ott-shimmer 1.6s ease-in-out infinite;
}

@keyframes ott-shimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

/* En-tête de page et fil d'Ariane ----------------------------------------- */

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--ott-space-4) var(--ott-space-6);
    margin-bottom: var(--ott-space-8);
}

.page-header__main {
    display: grid;
    gap: var(--ott-space-2);
    min-width: 0;
}

.page-header__title {
    font-size: var(--ott-text-2xl);
    font-weight: var(--ott-weight-bold);
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.page-header__subtitle {
    max-width: var(--ott-measure);
    color: var(--ott-text-muted);
}

.page-header__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ott-space-2) var(--ott-space-3);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-md);
}

.page-header__meta .sep {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--ott-border-strong);
}

.page-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ott-space-3);
}

.page-header__actions form {
    margin: 0;
}

@media (max-width: 599.98px) {
    .page-header {
        margin-bottom: var(--ott-space-6);
    }

    .page-header__title {
        font-size: var(--ott-text-xl);
    }

    .page-header__actions {
        width: 100%;
    }
}

.breadcrumb ol {
    display: flex;
    flex-wrap: nowrap;
    min-width: 0;
    overflow: hidden;
    align-items: center;
    gap: var(--ott-space-1);
    list-style: none;
    font-size: var(--ott-text-md);
}

.breadcrumb li {
    display: inline-flex;
    align-items: center;
    gap: var(--ott-space-1);
    min-width: 0;
    white-space: nowrap;
    color: var(--ott-text-muted);
}

.breadcrumb li + li::before {
    content: "/";
    padding: 0 var(--ott-space-1);
    color: var(--ott-text-faint);
}

.breadcrumb a {
    color: var(--ott-text-muted);
    font-weight: var(--ott-weight-medium);
}

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

.breadcrumb [aria-current="page"] {
    overflow: hidden;
    color: var(--ott-text);
    font-weight: var(--ott-weight-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 599.98px) {
    .breadcrumb li:not(:last-child):not(:nth-last-child(2)) {
        display: none;
    }
}

.section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--ott-space-2) var(--ott-space-4);
    margin: var(--ott-space-10) 0 var(--ott-space-4);
}

.section-header__title {
    font-size: var(--ott-text-lg);
}

.section-header__text {
    color: var(--ott-text-muted);
    font-size: var(--ott-text-md);
}

/* Onglets (filtres par statut) -------------------------------------------- */

.tabs {
    display: flex;
    gap: var(--ott-space-1);
    margin-bottom: var(--ott-space-6);
    overflow-x: auto;
    border-bottom: 1px solid var(--ott-border);
}

.tabs a {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--ott-space-2);
    min-height: var(--ott-control-h-lg);
    padding: 0 var(--ott-space-3);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-md);
    font-weight: var(--ott-weight-medium);
    white-space: nowrap;
}

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

.tabs a[aria-current="page"] {
    color: var(--ott-text);
    font-weight: var(--ott-weight-semibold);
}

.tabs a[aria-current="page"]::after {
    content: "";
    position: absolute;
    right: var(--ott-space-2);
    bottom: -1px;
    left: var(--ott-space-2);
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--ott-rail);
}

.tabs a[aria-current="page"] .counter {
    background: var(--ott-primary-subtle);
    color: var(--ott-primary);
}

/* Pagination --------------------------------------------------------------- */

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--ott-space-3);
    padding: var(--ott-space-3) var(--ott-space-6);
    border-top: 1px solid var(--ott-border);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
}

.pagination__links {
    display: flex;
    gap: var(--ott-space-2);
}

@media (max-width: 599.98px) {
    .pagination {
        padding: var(--ott-space-3) var(--ott-space-4);
    }
}

/* États vides -------------------------------------------------------------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--ott-space-2);
    padding: var(--ott-space-10) var(--ott-space-6);
    text-align: center;
}

.empty__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: var(--ott-space-2);
    border-radius: 50%;
    background: var(--ott-surface-3);
    color: var(--ott-text-muted);
}

.empty__title {
    color: var(--ott-text);
    font-size: var(--ott-text-base);
    font-weight: var(--ott-weight-semibold);
}

.empty__text {
    max-width: 44ch;
    color: var(--ott-text-muted);
    font-size: var(--ott-text-md);
}

.empty__actions {
    margin-top: var(--ott-space-3);
}

.empty--compact {
    align-items: flex-start;
    padding: 0;
    text-align: left;
}

/* Code, commandes, secrets affichés une fois ------------------------------- */

.code-block {
    display: block;
    padding: var(--ott-space-3) var(--ott-space-4);
    border: 1px solid var(--ott-border);
    border-radius: var(--ott-radius-md);
    background: var(--ott-surface-inset);
    color: var(--ott-text);
    font-family: var(--ott-font-mono);
    font-size: var(--ott-text-md);
    line-height: 1.6;
    letter-spacing: 0.02em;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.terminal {
    overflow: hidden;
    border: 1px solid #1f3355;
    border-radius: var(--ott-radius-lg);
    background: #0a1426;
}

.terminal__bar {
    display: flex;
    align-items: center;
    gap: var(--ott-space-2);
    padding: var(--ott-space-2) var(--ott-space-4);
    border-bottom: 1px solid #1f3355;
    color: #9db3d6;
    font-size: var(--ott-text-sm);
    font-weight: var(--ott-weight-medium);
}

.terminal__bar .icon {
    color: var(--ott-brand-cyan);
}

.terminal .code-block {
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #e6edf8;
}

.secret {
    display: grid;
    gap: var(--ott-space-3);
    padding: var(--ott-space-5);
    border: 1px solid var(--ott-warning-border);
    border-radius: var(--ott-radius-lg);
    background: var(--ott-warning-subtle);
}

.secret__title {
    display: flex;
    align-items: center;
    gap: var(--ott-space-2);
    font-size: var(--ott-text-lg);
    color: var(--ott-text);
    font-weight: var(--ott-weight-semibold);
}

.secret__title .icon {
    color: var(--ott-warning);
}

.secret .code-block {
    background: var(--ott-surface);
    border-color: var(--ott-warning-border);
    font-size: var(--ott-text-base);
}

.codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: var(--ott-space-2);
    list-style: none;
}

.codes .code-block {
    text-align: center;
}

.qr {
    display: inline-block;
    padding: var(--ott-space-3);
    border: 1px solid var(--ott-border);
    border-radius: var(--ott-radius-lg);
    background: #ffffff;
    line-height: 0;
}

.qr svg {
    width: 184px;
    height: 184px;
}

.hint {
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
}

.note {
    display: flex;
    align-items: flex-start;
    gap: var(--ott-space-2);
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
}

.note .icon {
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

.steps {
    display: flex;
    gap: var(--ott-space-2);
    margin-bottom: var(--ott-space-4);
    list-style: none;
}

.steps li {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--ott-surface-3);
}

.steps li[aria-current="step"],
.steps li.is-done {
    background: var(--ott-rail);
}

.card__body--flush {
    gap: 0;
}

.stat {
    position: relative;
}

.stat__icon {
    position: absolute;
    top: var(--ott-space-4);
    right: var(--ott-space-4);
}

.skeleton-group {
    display: grid;
    gap: var(--ott-space-3);
}

.skeleton-group .skeleton:last-child {
    width: 60%;
}

/* Icône du sélecteur de thème : soleil en clair, lune en sombre. */
svg.theme-icon--dark {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) svg.theme-icon--light {
        display: none;
    }

    :root:not([data-theme="light"]) svg.theme-icon--dark {
        display: inline-block;
    }
}

:root[data-theme="dark"] svg.theme-icon--light {
    display: none;
}

:root[data-theme="dark"] svg.theme-icon--dark {
    display: inline-block;
}

.card__footer > .form {
    flex: 1;
}

/* Listes de propriétés dans une carte étroite : libellé au-dessus de la valeur. */
.card {
    container-type: inline-size;
}

@container (max-width: 28rem) {
    .dl {
        grid-template-columns: minmax(0, 1fr);
    }

    .dl dt {
        padding-bottom: 0;
        border-bottom: 0;
        font-size: var(--ott-text-sm);
    }

    .dl dd {
        padding-top: var(--ott-space-1);
    }
}

.dl dd .badge {
    max-width: 100%;
    white-space: normal;
}

.breadcrumb li:not(:last-child) {
    flex: none;
}

.breadcrumb li:last-child {
    overflow: hidden;
}

/* Configuration TOTP : QR code, clé manuelle et saisie du code (partiel totp-setup). */
.totp {
    display: grid;
    gap: var(--ott-space-5);
}

.totp__side {
    display: grid;
    align-content: start;
    gap: var(--ott-space-4);
    min-width: 0;
}

/* Installation assistée côté provider (P4-C2, lot C2-1) : liste de prérequis, étapes, journal. */

/* C2-1.2 : l'attribut « hidden » (bandeaux de reconnexion et « aucune progression », « Commande copiée »)
   doit l'emporter sur l'affichage des composants (.note est en flex) ; le script de suivi ne fait que le basculer. */
.install [hidden] {
    display: none !important;
}

/* C2-2.3 : choix root / compte avec sudo. Le champ « Compte SSH » n'est masqué que si root est coché
   (amélioration progressive : sans :has(), il reste visible et le serveur ignore sa valeur en mode root). */
.install-access {
    display: grid;
    gap: var(--ott-space-3);
}

.install-access:has(input[name="ssh_access"][value="root"]:checked) .install-access__account {
    display: none;
}

.install-access .choice:has(input:disabled) {
    color: var(--ott-text-muted);
    cursor: not-allowed;
}

.install-access .choice input:disabled {
    cursor: not-allowed;
}

.install-checklist {
    display: grid;
    gap: var(--ott-space-2);
    padding-left: var(--ott-space-4);
}

.install__fingerprint {
    font-family: var(--ott-font-mono);
    font-size: 1rem;
    word-break: break-all;
}

.install__details {
    margin-top: var(--ott-space-2);
}

.install__decisions {
    display: grid;
    gap: var(--ott-space-4);
    margin-top: var(--ott-space-3);
}

.install__risk {
    display: grid;
    gap: var(--ott-space-2);
    padding-top: var(--ott-space-3);
    border-top: 1px solid var(--ott-border);
}

.install-steps {
    display: grid;
    gap: var(--ott-space-2);
    padding: 0;
    list-style: none;
}

.install-steps li {
    display: flex;
    justify-content: space-between;
    gap: var(--ott-space-3);
    padding: var(--ott-space-2) var(--ott-space-3);
    border: 1px solid var(--ott-border);
    border-left-width: 4px;
    border-radius: var(--ott-radius-sm);
}

.install-steps li[data-state="done"] {
    border-left-color: var(--ott-success);
}

.install-steps li[data-state="current"] {
    border-left-color: var(--ott-rail);
    font-weight: 600;
}

.install-steps li[data-state="stopped"] {
    border-left-color: var(--ott-danger);
}

.install-steps__state {
    color: var(--ott-text-muted);
    font-size: var(--ott-text-sm);
}

.install-events {
    display: grid;
    gap: var(--ott-space-2);
    padding: 0;
    list-style: none;
}

.install-events__item {
    display: grid;
    grid-template-columns: 5.5rem minmax(8rem, 14rem) 1fr;
    gap: var(--ott-space-3);
    font-size: var(--ott-text-sm);
}

.install-events__item[data-state="failed"] {
    color: var(--ott-danger);
}

/* C2-1.3 : une annulation voulue est informative, jamais présentée comme un échec. */
.install-events__item[data-state="cancelled"] {
    color: var(--ott-info);
}

.install-events__time {
    color: var(--ott-text-muted);
    font-family: var(--ott-font-mono);
}

@media (max-width: 40rem) {
    .install-events__item {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* P4-C3-3 : carte « Accès au Panel » ; l'attribut hidden (lien d'activation, erreurs, « Lien copié ») l'emporte
   sur l'affichage des composants (.note et .secret) ; seul js/admin-activation.js le bascule. */
.panel-access [hidden] {
    display: none !important;
}

.panel-access [data-activation-link] {
    word-break: break-all;
    user-select: all;
}
