/*
 * Charte Champ Libre (vert sapin #1D4145, Montserrat) sur une base sobre façon iOS.
 * Thème clair et sombre suivis automatiquement ; tailles en rem pour respecter
 * la taille de texte choisie sur l'appareil.
 */

@font-face {
    font-family: 'Montserrat';
    src: url("../fonts/montserrat-regular-CQBBhOQ.woff2") format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'Montserrat';
    src: url("../fonts/montserrat-medium--JXSJN8.woff2") format('woff2');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'Montserrat';
    src: url("../fonts/montserrat-semibold-gsz9ESR.woff2") format('woff2');
    font-weight: 600;
    font-display: swap;
}

:root {
    color-scheme: light dark;

    --brand: #1d4145;
    --background: #f6f4ef;
    --surface: #ffffff;
    --text: #1c1c1e;
    --text-secondary: #5f6466;
    --separator: rgb(60 60 67 / 0.18);
    --danger: #c0392b;
    --danger-surface: #fbeceb;
    --on-brand: #ffffff;
    --logo-filter: none;

    /* Zone tactile minimale (Apple : 44 pt). */
    --touch-target: 2.75rem;
    --radius: 0.875rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Le vert sapin sur fond sombre manque de contraste : version éclaircie. */
        --brand: #8fc1bc;
        --background: #0e1a1b;
        --surface: #172628;
        --text: #f2f2f0;
        --text-secondary: #a3acad;
        --separator: rgb(235 235 245 / 0.16);
        --danger: #ff8a7a;
        --danger-surface: #3a1f1c;
        --on-brand: #0e1a1b;
        /* Logo au trait noir sur fond transparent : inversé en blanc. */
        --logo-filter: invert(1);
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--background);
    color: var(--text);
    font: 400 1rem/1.5 'Montserrat', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* --- Accueil ------------------------------------------------------------ */

.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 100dvh;
    padding: max(2rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));
    text-align: center;
}

.welcome__logo {
    width: min(14rem, 60vw);
    height: auto;
    filter: var(--logo-filter);
}

.welcome__title {
    margin: 0.5rem 0 0;
    color: var(--brand);
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: 600;
    line-height: 1.05;
    /* Grand titre : interlettrage resserré. */
    letter-spacing: -0.02em;
}

.welcome__lead {
    max-width: 28rem;
    margin: 0;
    font-size: 1.125rem;
    line-height: 1.45;
}

.welcome__status {
    margin: 1rem 0 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    /* Petit texte : interlettrage légèrement ouvert pour la lisibilité. */
    letter-spacing: 0.01em;
}

/* --- Connexion ---------------------------------------------------------- */

.login {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-height: 100dvh;
    padding: max(2.5rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
    text-align: center;
}

.login__logo {
    width: min(9rem, 40vw);
    height: auto;
    filter: var(--logo-filter);
}

.login__title {
    margin: 0.25rem 0 0;
    color: var(--brand);
    font-size: 2.25rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.login__lead {
    margin: 0 0 1rem;
    color: var(--text-secondary);
}

.login__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(100%, 24rem);
    text-align: start;
}

/* --- Écrans ------------------------------------------------------------- */

.screen {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: min(100%, 40rem);
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
}

.screen--wide {
    width: min(100%, 64rem);
}

.screen--centered {
    align-items: center;
    text-align: center;
}

.screen__title {
    margin: 0;
    color: var(--brand);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.screen__lead {
    margin: -0.5rem 0 0;
    color: var(--text-secondary);
}

.back-link {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    min-height: var(--touch-target);
    color: var(--brand);
    font-weight: 500;
    text-decoration: none;
}

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

.welcome__action {
    width: auto;
    margin-top: 1.5rem;
    text-decoration: none;
}

/* --- Bandeau du vendeur ------------------------------------------------- */

.seller-banner {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: max(0.25rem, env(safe-area-inset-top)) 1.25rem 0.25rem;
    /* Matériau translucide : le contenu défile dessous. */
    background: color-mix(in srgb, var(--background) 80%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--separator);
}

.seller-banner p {
    margin: 0;
}

.seller-banner__who {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.seller-banner__name {
    overflow: hidden;
    font-size: 1.125rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seller-banner__change {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target);
    color: var(--brand);
    font-weight: 500;
    text-decoration: none;
}

.seller-banner__countdown {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.seller-banner__end {
    margin: 0;
}

@media (prefers-reduced-transparency: reduce) {
    .seller-banner {
        background: var(--background);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

.notice--flash {
    width: min(calc(100% - 2.5rem), 40rem);
    margin: 1rem auto 0;
}

/* Confirmation « Déclaré par Prénom », avec « Annuler » à portée de pouce. */
.confirmation {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.confirmation__text {
    flex: 1;
    margin: 0;
}

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

/* Même fond que la notice : le contour dessine le bouton. */
.confirmation__button {
    box-shadow: inset 0 0 0 1px var(--separator);
}

/* Le temps qui reste pour annuler, en barre qui se vide. */
.confirmation__timer {
    height: 0.1875rem;
    border-radius: 999px;
    background: var(--brand);
    transform-origin: left;
    animation: confirmation-timer var(--undo-seconds, 10s) linear forwards;
}

@keyframes confirmation-timer {
    to {
        transform: scaleX(0);
    }
}

/* Sans mouvement : pas de barre ; le bouton disparaît quand même à l'échéance. */
@media (prefers-reduced-motion: reduce) {
    .confirmation__timer {
        display: none;
    }
}

/* Retour à l'écran précédent, au-dessus du titre. */
.screen__back {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    min-height: var(--touch-target);
    color: var(--brand);
    text-decoration: none;
}

.screen__back::before {
    content: "‹";
    margin-right: 0.375rem;
    font-size: 1.5rem;
    line-height: 1;
}

/* --- Suppression d'une déclaration ------------------------------------- */

.archive-confirm__summary {
    margin: 0;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    font-variant-numeric: tabular-nums;
}

.archive-confirm__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.archive-confirm__actions .button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-decoration: none;
}

/* --- Mes déclarations des 15 dernières minutes ----------------------- */

.recent-reports {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.recent-reports__title {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* Liste groupée : une surface, des lignes séparées par un filet. */
.recent-reports__list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-radius: var(--radius);
    background: var(--surface);
}

.recent-reports__item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 0.75rem;
    align-items: baseline;
    min-height: var(--touch-target);
    padding: 0.625rem 1rem;
}

.recent-reports__item + .recent-reports__item {
    border-top: 1px solid var(--separator);
}

.recent-reports__time {
    grid-column: 1;
    grid-row: 1 / span 2;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.recent-reports__label {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.recent-reports__label,
.recent-reports__detail {
    grid-column: 2;
}

/* Zone tactile pleine hauteur, à droite de la ligne. */
.recent-reports__actions {
    display: flex;
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: stretch;
    gap: 0.5rem;
}

.recent-reports__action {
    display: flex;
    align-items: center;
    min-height: var(--touch-target);
    padding: 0 0.25rem;
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
}

.recent-reports__action--destructive {
    color: var(--danger);
}

/* Icône seulement sur téléphone (ci-dessous). */
.recent-reports__action svg {
    display: none;
    width: 1.375rem;
    height: 1.375rem;
    fill: none;
    stroke: currentcolor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Téléphone : la place manque, les actions deviennent des icônes de 44 px. */
@media (max-width: 30rem) {
    .recent-reports__actions {
        gap: 0;
    }

    .recent-reports__action {
        justify-content: center;
        width: var(--touch-target);
        padding: 0;
    }

    .recent-reports__action svg {
        display: block;
    }

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

.recent-reports__detail {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-variant-numeric: tabular-nums;
}

/* --- Formulaire de déclaration ----------------------------------------- */

.report-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.report-form__section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.report-form__row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1.25rem;
}

.report-form__label {
    padding: 0;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.report-form__input {
    width: 100%;
    min-height: var(--touch-target);
    padding: 0.625rem 0.875rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    /* 1 rem au moins : en dessous, Safari iOS zoome au focus. */
    font-size: max(1rem, 17px);
}

.report-form__input:focus-visible {
    border-color: var(--brand);
    outline: none;
}

textarea.report-form__input {
    resize: vertical;
}

.money {
    position: relative;
}

.money .report-form__input {
    padding-right: 2.25rem;
}

.money__currency {
    position: absolute;
    top: 50%;
    right: 0.875rem;
    color: var(--text-secondary);
    transform: translateY(-50%);
    pointer-events: none;
}

/* Photo : le champ fichier reste accessible au clavier, le bouton le remplace à l'écran. */
.photo-field__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.photo-field__input:focus-visible + .photo-field__take {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

.photo-field__take {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
}

.photo-field__take[hidden] {
    display: none;
}

/* Aperçu avec ses outils posés dans le coin, sur un matériau translucide. */
.photo-field__preview {
    position: relative;
    align-self: flex-start;
    margin: 0;
}

.photo-field__preview[hidden] {
    display: none;
}

.photo-field__preview img {
    display: block;
    max-width: min(100%, 16rem);
    max-height: 16rem;
    border-radius: var(--radius);
    object-fit: cover;
}

.photo-field__tools {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

/* Photo obligatoire (« Arrivé abîmé ») : on la remplace, on ne la supprime pas. */
.report-form:has(.switch-field__input:checked) .photo-field__remove {
    display: none;
}

/* Bouton rond à icône : 44 px de zone tactile. */
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(0 0 0 / 0.45);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    color: #ffffff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 100ms ease-out;
}

.icon-button:active {
    transform: scale(0.92);
}

.icon-button:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

.icon-button svg {
    width: 1.375rem;
    height: 1.375rem;
    fill: none;
    stroke: currentcolor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (prefers-reduced-transparency: reduce) {
    .icon-button {
        background: rgb(0 0 0 / 0.75);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

.photo-field__status {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.photo-field__required {
    display: none;
    color: var(--danger);
    font-weight: 400;
}

.report-form:has(.switch-field__input:checked) .photo-field__required {
    display: inline;
}

/* Envoi impossible faute de réseau : message et « Réessayer ». */
.submission-error {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.submission-error[hidden] {
    display: none;
}

.submission-error__text {
    margin: 0;
}

.button:disabled {
    opacity: 0.6;
    cursor: progress;
}

/* « Arrivé abîmé » : interrupteur à bascule, toute la ligne est touchable. */
.switch-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: var(--touch-target);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.switch-field__text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.switch-field__label {
    font-weight: 600;
}

.switch-field__hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.3;
}

.switch-field__input {
    flex: none;
    position: relative;
    width: 3.25rem;
    height: 2rem;
    margin: 0;
    border-radius: 1rem;
    background: var(--separator);
    appearance: none;
    cursor: pointer;
    transition: background-color 200ms ease-out;
}

.switch-field__input::before {
    content: '';
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
    transition: transform 200ms ease-out;
}

.switch-field__input:checked {
    background: var(--danger);
}

.switch-field__input:checked::before {
    transform: translateX(1.25rem);
}

.switch-field__input:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

/* Suggestions d'articles : des pastilles à toucher sous le champ. */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.suggestions[hidden] {
    display: none;
}

.suggestions__item {
    min-height: var(--touch-target);
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--separator);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 100ms ease-out;
}

.suggestions__item:active {
    transform: scale(0.97);
}

.suggestions__item:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

.report-form__total {
    margin: 0;
    color: var(--text-secondary);
}

.report-form__total strong {
    color: var(--text);
    font-size: 1.125rem;
    font-variant-numeric: tabular-nums;
}

.form-error {
    margin: 0;
    color: var(--danger);
    font-size: 0.875rem;
}

/* Tuiles des familles : de grosses cibles, choisies d'un coup d'œil. */
.family-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.625rem;
}

.family-tiles__input,
.segmented__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.family-tiles__tile {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 4rem;
    padding: 0.5rem 0.75rem;
    border: 2px solid transparent;
    border-radius: var(--radius);
    background: var(--surface);
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 100ms ease-out, background-color 100ms ease-out, border-color 100ms ease-out;
}

.family-tiles__tile:active {
    transform: scale(0.97);
}

.family-tiles__input:checked + .family-tiles__tile {
    border-color: var(--brand);
    background: color-mix(in srgb, var(--brand) 12%, var(--surface));
    color: var(--brand);
}

.family-tiles__input:focus-visible + .family-tiles__tile,
.segmented__input:focus-visible + .segmented__option {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

/* Quantité : − / + de part et d'autre du champ. */
.stepper {
    display: grid;
    grid-template-columns: var(--touch-target) 1fr var(--touch-target);
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface);
}

.stepper__button {
    min-height: var(--touch-target);
    border: 0;
    background: transparent;
    color: var(--brand);
    font: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.stepper__button:active {
    background: var(--separator);
}

.stepper__input {
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.stepper__input::-webkit-inner-spin-button,
.stepper__input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Unité : contrôle segmenté façon iOS. */
.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: var(--radius);
    background: var(--separator);
}

.segmented__option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(var(--touch-target) - 0.5rem);
    border-radius: calc(var(--radius) - 0.25rem);
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 150ms ease-out;
}

.segmented__input:checked + .segmented__option {
    background: var(--surface);
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

/* --- Choix du prénom ----------------------------------------------------- */

.seller-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 0.75rem;
}

.seller-grid__item {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Grandes cibles : on choisit debout, souvent d'une main. */
    min-height: 4.5rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.125rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 100ms ease-out, background-color 100ms ease-out;
}

.seller-grid__item:active {
    transform: scale(0.97);
    background: var(--separator);
}

.seller-grid__item:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

/* --- PIN ----------------------------------------------------------------- */

.pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    width: min(100%, 20rem);
}

.pin__field {
    width: 100%;
}

.pin__input {
    width: 100%;
    min-height: var(--touch-target);
    border: 0;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    text-align: center;
}

/* Avec le pavé, les points remplacent le champ. */
.pin:has(.pin__pad:not([hidden])) .pin__field {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.pin__dots {
    display: flex;
    gap: 1.25rem;
}

.pin:not(:has(.pin__pad:not([hidden]))) .pin__dots {
    display: none;
}

.pin__dot {
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid var(--brand);
    border-radius: 50%;
    transition: background-color 100ms ease-out;
}

.pin__dot--filled {
    background: var(--brand);
}

.pin__pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.875rem 1.25rem;
}

.pin__pad[hidden] {
    display: none;
}

.pin__key {
    width: 4.75rem;
    height: 4.75rem;
    border: 0;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1.75rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 100ms ease-out, background-color 100ms ease-out;
}

/* Retour à l'appui, comme le pavé de l'iPhone. */
.pin__key:active {
    transform: scale(0.94);
    background: var(--separator);
}

.pin__key:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

.pin__key--erase {
    background: transparent;
    font-size: 1.5rem;
}

/* --- Champs groupés (liste groupée iOS) ---------------------------------- */

.field-group {
    overflow: hidden;
    background: var(--surface);
    border-radius: var(--radius);
}

.field {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 1rem;
}

.field + .field {
    /* Séparateur en retrait à gauche, comme les listes iOS. */
    margin-left: 1rem;
    padding-left: 0;
    border-top: 1px solid var(--separator);
}

.field__label {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    letter-spacing: 0.01em;
}

.field__input {
    min-height: var(--touch-target);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    /* 1 rem au moins : en dessous, Safari iOS zoome au focus. */
    font: inherit;
    font-size: max(1rem, 17px);
    outline: none;
}

.field:focus-within .field__label {
    color: var(--brand);
}

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

.button {
    min-height: var(--touch-target);
    padding: 0.75rem 1.25rem;
    border: 0;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 100ms ease-out, opacity 100ms ease-out;
}

/* Retour immédiat à l'appui, pas au relâchement. */
.button:active {
    transform: scale(0.97);
    opacity: 0.85;
}

.button:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

.button--primary {
    width: 100%;
    background: var(--brand);
    color: var(--on-brand);
}

.button--secondary {
    background: var(--surface);
    color: var(--brand);
}

/* Geste destructeur proposé à côté d'autres : la couleur d'alerte sur le texte seul. */
.button--danger-text {
    color: var(--danger);
}

/* Geste qu'on ne défait pas soi-même : la couleur d'alerte le signale. */
.button--destructive {
    background: var(--danger);
    color: var(--on-brand);
}

.button--plain {
    margin-top: 0.5rem;
    background: transparent;
    color: var(--brand);
}

/* --- Messages ------------------------------------------------------------ */

.notice {
    margin: 0;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    line-height: 1.4;
}

.notice:not(.notice--error) {
    background: var(--surface);
    color: var(--text);
}

.notice--error {
    background: var(--danger-surface);
    color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Tableau de bord des gérants --------------------------------------- */

/* Titre à gauche, déconnexion à droite ; l'un sous l'autre si la place manque. */
.dashboard__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

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

.dashboard__who {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* « Se déconnecter » aligné sur le prénom, sans la marge des écrans centrés. */
.dashboard__account .button--plain {
    margin-top: 0;
}

/*
 * Contrôle segmenté en liens (découpage, comparaison) : la base `.segmented`
 * de l'unité, mais à la largeur de son contenu et sur plusieurs lignes au besoin.
 * Une variante, pour ne pas changer la grille pleine largeur de pièce/botte.
 */
.segmented--links {
    display: inline-flex;
    align-self: flex-start;
    flex-wrap: wrap;
}

.segmented__item {
    display: inline-flex;
    align-items: center;
    min-height: calc(var(--touch-target) - 0.5rem);
    padding: 0 1rem;
    border-radius: calc(var(--radius) - 0.25rem);
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.segmented__item[aria-current="page"] {
    background: var(--surface);
    color: var(--brand);
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

/* --- Période du tableau de bord ---------------------------------------- */

.period {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.segmented__item:focus-visible,
.period__step:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

/* Précédente · libellé · suivante ; la place vide garde le libellé centré. */
.period__bar {
    display: grid;
    grid-template-columns: var(--touch-target) 1fr var(--touch-target);
    align-items: center;
    gap: 0.5rem;
}

.period__label {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-align: center;
}

.period__step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    border-radius: 50%;
    color: var(--brand);
    -webkit-tap-highlight-color: transparent;
    transition: transform 100ms ease-out;
}

a.period__step {
    background: var(--surface);
}

a.period__step:active {
    transform: scale(0.94);
}

.period__step svg {
    width: 1.375rem;
    height: 1.375rem;
    fill: none;
    stroke: currentcolor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Dates choisies : sur une ligne quand la place le permet. */
.period__custom {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
}

.period__field {
    display: flex;
    flex: 1 1 10rem;
    flex-direction: column;
    gap: 0.25rem;
}

.period__field-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

@media (prefers-reduced-motion: reduce) {
    a.period__step:active {
        transform: none;
    }
}

/* --- Chiffres clés ------------------------------------------------------ */

/* Deux tuiles côte à côte, la comparaison dessous sur toute la largeur. */
.key-figures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.key-figures__item {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--surface);
}

.key-figures__label {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
}

.key-figures__value {
    margin: 0.25rem 0 0;
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.key-figures__comparison {
    display: flex;
    flex-direction: column;
    grid-column: 1 / -1;
    gap: 0.5rem;
}

.key-figures__change {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.key-figures__against {
    margin: -0.25rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.key-figures__note {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* --- Répartitions -------------------------------------------------------- */

.section-title {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Liste classée : une surface, des lignes séparées par un filet. */
.ranking {
    margin: 0;
    padding: 0;
    border-radius: var(--radius);
    background: var(--surface);
    list-style: none;
}

.ranking__item {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
}

.ranking__item + .ranking__item {
    border-top: 1px solid var(--separator);
}

.ranking__line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.ranking__name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.ranking__losses {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ranking__detail,
.ranking__empty {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.ranking__empty {
    margin: 0;
}

/* Côte à côte sur ordinateur et iPad paysage, l'une sous l'autre sinon. */
.dashboard__rankings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    align-items: start;
    gap: 1.5rem;
}

/* Barre proportionnelle : longueur donnée par --share (0 à 100 %). */
.bar {
    display: block;
    height: 0.5rem;
    border-radius: 0.25rem;
    background: linear-gradient(var(--brand), var(--brand)) no-repeat 0 0 / var(--share, 0%) 100%, var(--separator);
}

/* --- Liste détaillée ----------------------------------------------------- */

.reports__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}

.reports__header .section-title {
    margin: 0;
}

/* Le bouton à droite, le nombre reste collé au titre. */
.reports__export {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    text-decoration: none;
}

.reports__count {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.reports__list {
    margin: 0;
    padding: 0;
    border-radius: var(--radius);
    background: var(--surface);
    list-style: none;
}

/* Vignette · article et détails · montant et date. */
.reports__item {
    display: grid;
    grid-template-columns: 3.5rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.reports__item + .reports__item {
    border-top: 1px solid var(--separator);
}

.reports__photo {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: calc(var(--radius) - 0.25rem);
    object-fit: cover;
    background: var(--separator);
}

.reports__photo--none {
    display: block;
    opacity: 0.4;
}

.reports__title,
.reports__meta {
    margin: 0;
}

.reports__title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
}

.reports__label {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.reports__badge {
    padding: 0.0625rem 0.5rem;
    border-radius: 999px;
    background: var(--danger-surface);
    color: var(--danger);
    font-size: 0.75rem;
    font-weight: 600;
}

.reports__meta,
.reports__date {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.reports__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.125rem;
}

.reports__total {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.reports__date {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.75rem;
}

.pagination__previous,
.pagination__next {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.pagination__status {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Toute la ligne ouvre la fiche : le lien du libellé s'étend sur la ligne. */
.reports__item {
    position: relative;
    transition: background-color 150ms ease-out;
}

.reports__item:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.reports__item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.reports__item:only-child {
    border-radius: var(--radius);
}

a.reports__label {
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

a.reports__label::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.reports__item:hover,
.reports__item:active {
    background: var(--separator);
}

.reports__item:has(a.reports__label:focus-visible) {
    outline: 3px solid var(--brand);
    outline-offset: -3px;
}

a.reports__label:focus-visible {
    outline: none;
}

/* --- Fiche d'une déclaration --------------------------------------------- */

.report-sheet__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.report-sheet__header .screen__title {
    margin: 0;
    overflow-wrap: anywhere;
}

/* Actions sur la déclaration : Modifier, Supprimer, Restaurer. */
.report-sheet__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.report-sheet__action {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

/* Photo à côté du détail sur ordinateur et iPad paysage, au-dessus sinon. */
.report-sheet__body {
    display: grid;
    gap: 1rem;
    align-items: start;
}

@media (min-width: 48rem) {
    .report-sheet__body {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

.report-sheet__photo {
    width: 100%;
    max-height: 32rem;
    border-radius: var(--radius);
    object-fit: contain;
    background: var(--surface);
}

.report-sheet__details {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.625rem 1rem;
    margin: 0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: var(--surface);
}

.report-sheet__details dt {
    color: var(--text-secondary);
}

.report-sheet__details dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* Le commentaire garde ses retours à la ligne. */
.report-sheet__comment {
    white-space: pre-line;
}

/* Historique : une ligne par événement, du plus ancien au plus récent. */
.history__list {
    margin: 0;
    padding: 0.25rem 1.25rem;
    border-radius: var(--radius);
    background: var(--surface);
    list-style: none;
}

.history__entry {
    padding: 0.75rem 0;
}

.history__entry + .history__entry {
    border-top: 1px solid var(--separator);
}

.history__event {
    margin: 0;
}

.history__event time {
    font-variant-numeric: tabular-nums;
}

.history__changes {
    margin: 0.375rem 0 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    overflow-wrap: anywhere;
}

/* --- Filtres de la liste ------------------------------------------------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
    margin: 0.5rem 0 0.75rem;
    /* Arrivée par l'ancre (filtres, pages) : un peu d'air au-dessus des filtres. */
    scroll-margin-top: 1rem;
}

.filters__field {
    display: flex;
    flex: 1 1 10rem;
    flex-direction: column;
    gap: 0.25rem;
}

.filters__label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Case et libellé : toute la ligne est touchable, 44 px de haut. */
.filters__check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--touch-target);
    cursor: pointer;
}

.filters__check input {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--brand);
}

.filters__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filters__clear {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target);
    color: var(--brand);
    font-weight: 600;
}

/* Supprimée : total barré et mention en rouge, sans baisser le contraste du reste. */
.reports__item--deleted .reports__total {
    text-decoration: line-through;
}

.reports__deleted {
    margin: 0;
    color: var(--danger);
    font-size: 0.8125rem;
    font-weight: 600;
}
