/* Écran : facturation — factures (liste, détail, avoir), livre des recettes, facturation électronique,
   Réglages › Facturation et Connexions (SumUp), page publique /payer/{jeton}.
   Réutiliser les tokens et composants de app.css / admin.css (ne jamais redéfinir de token).
   Liée par layouts/admin.php ; la page publique /payer la charge elle-même (<link> dans la vue). */

/* ---------- Commun ---------- */
.billing .billing-seg { display: flex; width: 100%; margin: 0 0 16px; }
.billing .list-search { margin: 0; }
.billing .inv-total .item__title,
.billing .inv-total .item__value { font-weight: 600; color: var(--label); }
.billing .item__value { max-width: 60%; }

/* ---------- Liste des factures ---------- */
.inv-row { gap: 10px; }
.inv-row__client { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-row__sub { -webkit-line-clamp: 1; line-clamp: 1; }
.inv-row__end { display: flex; flex-direction: column; align-items: flex-end; flex: none; text-align: right; }
.inv-row__amount { font: var(--t-body); color: var(--label); white-space: nowrap; }
.inv-row__status { font: var(--t-sub); color: var(--label-2); white-space: nowrap; margin-top: 1px; }
.inv-row__status.is-due, .inv-status.is-due { color: var(--orange); }
.inv-row__status.is-muted, .inv-status.is-muted { color: var(--label-2); }
.inv-list__foot { margin-top: calc(-1 * var(--section-gap) + var(--header-gap)); }
.inv-list .inv-month:last-of-type { margin-bottom: var(--section-gap); }

/* ---------- Détail d'une facture ---------- */
.inv-head { margin: 4px 0 20px; }
.inv-head__client { font: var(--t-headline); color: var(--label); margin: 0; overflow-wrap: anywhere; }
.inv-head__amount { font: var(--t-large); margin: 2px 0 0; color: var(--label); }
.inv-head__amount small { font: var(--t-title3); color: var(--label-2); }
.inv-head__sub { font: var(--t-sub); color: var(--label-2); margin: 4px 0 0; }
.inv-status { font-weight: 600; color: var(--label-2); }
.inv-status.is-paid { color: var(--green); }
.inv-status.is-muted { font-weight: 400; }
.inv-actions { margin-bottom: var(--section-gap); }
.inv-actions .is-disabled { color: var(--label-3); cursor: default; pointer-events: none; }
.inv-line__detail { -webkit-line-clamp: 2; line-clamp: 2; }
.inv-integrity.is-bad { color: var(--red); font-weight: 600; }
.inv-hash { margin: 8px 0 0; }
details.more.inv-hash > summary { color: var(--label-2); font: var(--t-foot); min-height: var(--hit); padding: 0 16px; }
.inv-hash__code { margin: 0 16px; font: var(--t-foot); color: var(--label-2); overflow-wrap: anywhere; }
.inv-hash__code code { font-family: var(--font-mono); }
.btn--plain.inv-danger { color: var(--red); }
/* Facture électronique : anomalies du contrôle EN 16931 (repliées) */
details.more.inv-fx-errors > summary { color: var(--red); }
.inv-fx-errors__list { margin: 0; padding: 4px 16px 12px 36px; font: var(--t-foot); color: var(--label-2); }
.inv-fx-errors__list li { overflow-wrap: anywhere; margin: 0 0 4px; }

/* ---------- Facturation électronique (exports Factur-X / e-reporting) ---------- */
.einv .item__value { white-space: nowrap; }
.einv .item__sub { -webkit-line-clamp: 2; line-clamp: 2; }

/* ---------- Livre des recettes ---------- */
.rec-hero { text-align: center; margin: 8px 0 var(--section-gap); }
.rec-hero__label { font: var(--t-sub); color: var(--label-2); margin: 0; }
.rec-hero__value { font: var(--t-large); color: var(--label); margin: 2px 0 0; }
.rec-hero__sub { font: var(--t-foot); color: var(--label-2); margin: 4px 0 0; }
.rec-vat { padding-top: 11px; padding-bottom: 11px; }
.rec-vat__head { display: flex; align-items: baseline; gap: 12px; }
.rec-vat__head .item__title { flex: 1; min-width: 0; }
.rec-vat__bar { margin: 8px 0 6px; }
.rec-vat.is-warn .progress__bar { background: var(--orange); }
.rec-vat.is-over .progress__bar { background: var(--red); }
.rec-vat.is-over .rec-vat__msg { color: var(--red); }
.rec-vat__msg { -webkit-line-clamp: 3; line-clamp: 3; }
.rec-list__sub { -webkit-line-clamp: 2; line-clamp: 2; }
.rec-list .item__value { color: var(--label); }
.rec-list .rec-refund { color: var(--red); }

/* ---------- Livre des recettes › Déclaration URSSAF (lib/urssaf.php) ---------- */
/* Carte « Prochaine déclaration » : période, grand montant, cotisations estimées, date limite (rouge à 3 jours ou moins) */
.urssaf-card__main { padding-top: 14px; padding-bottom: 14px; }
.urssaf-card__period { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font: var(--t-headline); color: var(--label); margin: 0; }
.urssaf-card__amount { font: var(--t-title1); color: var(--label); margin: 4px 0 0; }
.urssaf-card__sub { font: var(--t-sub); color: var(--label-2); margin: 2px 0 0; }
.urssaf-deadline .item__value { color: var(--label); }
.urssaf-deadline.is-urgent .item__value, .urssaf-deadline.is-urgent .item__sub { color: var(--red); font-weight: 600; }
.urssaf-card__actions { flex-wrap: wrap; gap: 8px 12px; justify-content: space-between; }
.urssaf-card__actions form { margin: 0; }
.urssaf-card__ext { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; margin-left: auto; }
.urssaf-card__ext .icon { flex: none; }
/* Choix du rythme : contrôle segmenté pleine largeur (zone de toucher 44 px par la règle ::after de .seg) */
.urssaf-choose__seg .seg { width: 100%; }
/* Déclarations enregistrées : « Annuler » discret, aligné à droite */
.urssaf-decl { gap: 8px; }
.urssaf-decl .item__sub { -webkit-line-clamp: 2; line-clamp: 2; }
.urssaf-decl .item__value { color: var(--label); }
.urssaf-decl form { margin: 0; flex: none; }
.urssaf-decl__undo { color: var(--red); }

/* ---------- Réglages › Connexions › Paiements ---------- */
.billing-settings .frow .input[type=password] { letter-spacing: normal; }
.billing-settings__notice { margin: 0 0 var(--section-gap); }
.billing-settings__notice a { font-weight: 600; position: relative; }
.billing-settings__notice a::after { content: ""; position: absolute; inset: -13px -6px; }
.billing-settings__help code { overflow-wrap: anywhere; font-family: var(--font-mono); }

/* ---------- Page publique /payer/{jeton} et appel aux arrhes ---------- */
/* Page transactionnelle : un seul bouton plein, pas de « Réserver » dans l'en-tête */
body:has(.pay-page) .site-header .btn--brand { display: none; }
.pay-page .done-hero__check--due { background: var(--brand-tinted); color: var(--brand-text); }
.pay-page .done-hero__check--failed { background: var(--red-bg); color: var(--red); }
.pay-page .done-hero .pay-page__amount { font: var(--t-large); color: var(--label); margin-top: 4px; }
.pay-page .item__value.pay-page__due { color: var(--label); font-weight: 600; }
.pay-page__notice { margin: 0 0 var(--section-gap); }
.pay-page__actions { display: grid; gap: 12px; margin: 0 0 var(--section-gap); }
.pay-page__secure { text-align: center; margin: 0; }
/* Formulaire de carte SumUp intégré (assets/js/pay.js). Ses champs sont des cadres SumUp, toujours clairs : le formulaire
   reste une carte claire dans les deux apparences (comme un terminal de paiement), aux arrondis et à la typographie du
   site ; titre de SumUp masqué (le héros dit déjà ce qu'on paie), bouton « Payer » du site sous la carte. */
/* Apple Pay / Google Pay (boutons natifs du SDK Swift Checkout) en haut du bloc de paiement (carte blanche) */
.pay-card__wallets { display: grid; gap: 10px; padding: 16px 16px 0; }
.pay-card__wallets[hidden], .pay-wallets[hidden] { display: none; }
.pay-wallets { display: grid; gap: 10px; min-height: 48px; }
.pay-card__or { display: flex; align-items: center; gap: 12px; margin: 6px 0 0; font: var(--t-sub); color: #6e6e73; }
.pay-card__or::before, .pay-card__or::after { content: ""; flex: 1; height: 1px; background: rgba(60, 60, 67, .18); }
.pay-card__loading { margin: 0; padding: 28px 16px; text-align: center; font: var(--t-sub); color: #6e6e73; }
.pay-card__loading[hidden] { display: none; }
.pay-card { display: grid; gap: 12px; margin: 0 0 var(--section-gap); }
.pay-card[hidden] { display: none; }
.pay-card__form { color-scheme: light; background: #fff; border-radius: var(--radius); min-height: 120px; overflow: hidden; box-shadow: 0 0 0 1px rgba(60, 60, 67, .12); }
.pay-card__form [data-sumup-id="widget__container"] { font-family: var(--font); padding: 16px 16px 4px; box-shadow: none; border-radius: 0; }
.pay-card__form [data-sumup-id="widget_header__title"] { display: none; }
.pay-card__status { margin: -4px 0 var(--section-gap); text-align: center; font: var(--t-sub); color: var(--label-2); }
.pay-card__status[hidden] { display: none; }
.pay-card__status--error { color: var(--red); }
.pay-card:focus:not(:focus-visible) { outline: none; }
.pay-card .pay-page__secure svg { vertical-align: -2px; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.deposit-cta .item__value { color: var(--label); font-weight: 600; }

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    .billing .billing-seg { max-width: 360px; }
    .rec-hero { text-align: left; }
}

/* Rangées dans « Plus d'options » : séparateurs inset comme le reste du groupe */
:is(.billing, .billing-settings) .group > details.more[open] > :not(summary) { position: relative; }
:is(.billing, .billing-settings) .group > details.more[open] > :not(summary)::before {
    content: ""; position: absolute; z-index: 1; top: 0; left: var(--sep-inset); right: 0;
    border-top: var(--hairline) solid var(--separator); pointer-events: none;
}
.billing .frow .appt-money .input { text-align: right; }

/* Références de pièce (FAC-…, AV-…) : jamais coupées au tiret */
.inv-no { white-space: nowrap; }
.deposit-cta__action { margin-top: 16px; }
/* « Preuve d'intégrité » : détail d'archivage, inutile sur iPhone (le pied « Copie archivée conforme » suffit) */
@media (max-width: 599px) { .inv-hash { display: none; } }
.billing-settings .frow__label.billing-settings__nowrap { white-space: nowrap; flex: none; }

/* Payer à l'avance en ligne (partials/prepay_cta.php) : facultatif, bouton teinté (le bouton plein de la page reste
   « Voir le devis »), ligne d'action dans la carte du RDV de l'espace client */
.prepay-cta .item__value { color: var(--label); font-weight: 600; }
.prepay-cta__action { margin-top: 16px; }
.prepay-cta__action .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button.item.item--action { color: var(--brand-text); }

/* ---------- Carte sur place : terminal SumUp (lib/sumup_terminal.php, views/admin/terminal_*.php, sumup_pending.php) ---------- */
/* Rangées-boutons à deux lignes (titre + sous-titre en <span>) : chaque ligne sur la sienne, texte à gauche */
:is(.terminal-cta, .appt-billing, .sumup-tx, .terminal-match) button.item { width: 100%; text-align: left; }
:is(.terminal-cta, .appt-billing, .sumup-tx, .terminal-match) button.item .item__body > span { display: block; }
:is(.terminal-cta, .appt-billing) button.item--action .item__title { color: var(--brand-text); font-weight: 600; }
.terminal-hint { margin: 0 0 16px; }
.terminal-card-note { display: flex; gap: 6px; align-items: flex-start; margin-top: 8px; }
.terminal-card-note .icon { flex: none; margin-top: 2px; color: var(--blue); }

/* Écran d'attente : une carte centrée, le montant en grand, l'état juste dessous (annoncé : role=status) */
.terminal-card { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 20px 22px; gap: 6px; }
.group.terminal-card > *::before { display: none; } /* carte d'état : pas de séparateurs de liste entre ses lignes */
.terminal-card__glyph { width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: 6px; }
.terminal-card__glyph > [hidden] { display: none; }
.terminal-card__spin { width: 36px; height: 36px; border-width: 3px; }
.terminal-card__mark { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; }
.terminal-card__mark .icon { width: 28px; height: 28px; stroke-width: 2.6; }
.terminal-card__mark--ok { background: var(--green-bg); color: var(--green); }
.terminal-card__mark--ko { background: var(--red-bg); color: var(--red); }
.terminal-card__amount { margin: 0; font: 700 40px/46px var(--font); letter-spacing: -.02em; color: var(--label); font-variant-numeric: tabular-nums; }
.terminal-card__status { min-height: 64px; }
.terminal-card__title { margin: 2px 0 0; font: var(--t-headline); color: var(--label); }
.terminal-card__detail { margin: 4px auto 0; max-width: 34ch; font: var(--t-sub); color: var(--label-2); }
.terminal-card__meta { margin: 6px 0 0; font: var(--t-foot); color: var(--label-2); } /* information utile (délai) : contraste du texte secondaire, pas décoratif */
.terminal[data-status="paid"] .terminal-card__title { color: var(--green); }
.terminal:is([data-status="failed"], [data-status="error"]) .terminal-card__title { color: var(--red); }
.terminal__done { margin-top: 8px; }
@media (min-width: 600px) { .terminal__done .btn--block { width: auto; min-width: 280px; } .terminal__done { display: flex; justify-content: center; } }
@media (prefers-reduced-motion: reduce) { .terminal-card__spin { animation-duration: 2.4s; } }

/* Paiements SumUp à rattacher */
.sumup-tx__amount { font-weight: 600; color: var(--label); }
.sumup-tx__badge { flex: none; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--green-bg); color: var(--green); font: 600 12px/16px var(--font); white-space: nowrap; }
.sumup-tx__ref { flex-wrap: wrap; }
.sumup-tx__ref .frow__label { flex: none; }
.sumup-tx__ref .input { flex: 1 1 160px; min-width: 0; }
.sumup-reader form { flex: none; }
.sumup-tx .sumup-tx__why { white-space: normal; }
/* Appairage (Réglages › SumUp) : rangées d'un formulaire dans le groupe, séparées comme les autres */
.sumup-pair > :is(.frow, .item) + :is(.frow, .item) { position: relative; }
.sumup-pair > :is(.frow, .item) + :is(.frow, .item)::before {
    content: ""; position: absolute; top: 0; left: var(--sep-inset); right: 0; border-top: var(--hairline) solid var(--separator); pointer-events: none;
}
