/* Paiements ATM — couleurs de la marque (site ATM : orange #f98410, ink #121212, paper #f6f4f0). */
:root {
  --bg: #f6f4f0; --surface: #fff; --surface-2: #f4f3f1; --border: #e6e4e0; --border-strong: #d5d2cc;
  --text: #121212; --muted: #5b5750; --subtle: #74716c;
  --brand: #f98410; --brand-hover: #ff9d33; --brand-strong: #d96d00; --brand-text: #a34e00; --brand-soft: #fff1e2;
  --ok: #166534; --ok-soft: #e8f6ec; --warn: #92400e; --warn-soft: #fff6e0;
  --danger: #b91c1c; --danger-soft: #fdecec; --info: #1e4e8c; --info-soft: #e9f1fb;
  --radius: 12px; --shadow: 0 1px 2px rgb(18 18 18 / .05), 0 4px 16px rgb(18 18 18 / .04);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; }
a { color: var(--brand-text); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-line; }
:focus-visible { outline: 3px solid var(--brand-strong); outline-offset: 2px; }

/* Logo */
.logo { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: var(--text); font-weight: 800; font-size: .78rem; letter-spacing: .02em; flex: none; }

/* Barre du haut */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1.25rem; background: var(--text); color: #fff; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 700; }
.nav { display: flex; align-items: center; gap: .25rem; }
.nav a, .linkbtn { color: #d9d6d0; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font: inherit; font-size: .92rem; }
.nav a:hover, .linkbtn:hover { color: #fff; background: rgb(255 255 255 / .08); }
.nav a[aria-current] { color: #fff; background: rgb(255 255 255 / .12); }
.linkbtn { background: none; border: 0; cursor: pointer; }
.banner { padding: .55rem 1.25rem; font-size: .9rem; text-align: center; }
.banner-test { background: var(--brand-soft); color: var(--brand-text); }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner-danger { background: var(--danger); color: #fff; }
.banner a { color: inherit; font-weight: 600; }

.page { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.pagehead h1 { margin: 0; }
.eyebrow { margin: 0 0 .2rem; color: var(--muted); font-size: .82rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: .75rem; font-size: .92rem; }
.back:hover { color: var(--text); }

/* Cartes et formulaires */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 1rem; }
.form-narrow { max-width: 640px; }
fieldset { border: 0; padding: 0; margin: 0; }
fieldset + fieldset { border-top: 1px solid var(--border); padding-top: 1.25rem; margin-top: 1.25rem; }
legend { font-weight: 700; margin-bottom: .75rem; padding: 0; }
fieldset > .field + .field, fieldset > .field + .grid2, fieldset > .grid2 + .field { margin-top: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span:first-child { font-weight: 600; font-size: .9rem; }
.field em { font-style: normal; font-weight: 400; color: var(--subtle); font-size: .82rem; }
.field small { color: var(--muted); font-size: .82rem; }
.field small.error { color: var(--danger); font-weight: 600; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], input:not([type]) {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 9px; padding: .62rem .75rem; min-height: 44px;
}
input:focus { outline: none; border-color: var(--brand-strong); box-shadow: 0 0 0 3px rgb(249 132 16 / .22); }
input[readonly] { background: var(--surface-2); }
.has-error input { border-color: var(--danger); }
.amount-input { position: relative; display: block; }
.amount-input input { padding-right: 2.2rem; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.amount-input b { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-strong); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem 1rem; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.btn-primary { background: var(--brand); color: var(--text); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: .35rem .75rem; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[aria-busy=true] { opacity: .7; cursor: progress; }

/* Messages */
.flash, .alert { border-radius: 10px; padding: .75rem 1rem; margin: 0 0 1rem; background: var(--info-soft); color: var(--info); }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error, .alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert p { margin: .35rem 0 .6rem; }
.note { background: var(--surface-2); border-radius: 10px; padding: .75rem 1rem; color: var(--muted); }

/* Liste */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); gap: .75rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: .85rem; font-weight: 600; }
.kpi strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--subtle); }
.kpi-ok strong { color: var(--ok); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .45rem .8rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; }
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a[aria-current] { background: var(--text); color: #fff; }
.count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: rgb(18 18 18 / .08); font-size: .78rem; text-align: center; }
.tabs a[aria-current] .count { background: rgb(255 255 255 / .2); }
.count-alert { background: var(--danger); color: #fff; }
.search { flex: 0 1 280px; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 100px 130px 140px; gap: 1rem; align-items: center; padding: .85rem 1.1rem; color: inherit; text-decoration: none; }
.row + .row { border-top: 1px solid var(--border); }
.row:hover { background: #fbfaf8; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-main > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-date { font-size: .88rem; }
.row-amount { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.row .badge { justify-self: end; }
.empty { text-align: center; padding: 2.5rem 1rem; }
.empty p { color: var(--muted); margin-top: 0; }

/* Statuts */
.badge { display: inline-block; padding: .22rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge-lg { font-size: .9rem; padding: .35rem .85rem; }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-processing { background: var(--info-soft); color: var(--info); }
.badge-paid { background: var(--ok-soft); color: var(--ok); }
.badge-review { background: var(--danger-soft); color: var(--danger); }
.badge-cancelled { background: var(--surface-2); color: var(--subtle); }

/* Fiche */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.sum { display: flex; flex-direction: column; gap: .1rem; }
.sum-amount { font-size: 2.1rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.copy { display: flex; gap: .5rem; }
.copy input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; }
.copy-status { min-height: 1.2em; margin: .35rem 0 0; color: var(--ok); font-size: .85rem; }
.share-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.message { border-top: 1px solid var(--border); padding-top: .75rem; }
.message summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: .9rem; }
.message p { background: var(--surface-2); border-radius: 10px; padding: .75rem 1rem; font-size: .92rem; }
.side h2 { font-size: .95rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; display: flex; flex-direction: column; color: var(--subtle); }
.timeline li::before { content: ""; position: absolute; left: 0; top: .4em; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 1.2em; bottom: .1em; width: 2px; background: var(--border); }
.timeline li.done { color: var(--text); }
.timeline li.done::before { background: var(--text); border-color: var(--text); }
.timeline li.ok::before { background: var(--ok); border-color: var(--ok); }
.timeline li.ko::before { background: var(--subtle); border-color: var(--subtle); }
.timeline small { color: var(--subtle); }
.facts { margin: 0; border-top: 1px solid var(--border); padding-top: .75rem; }
.facts div { display: flex; flex-direction: column; margin-bottom: .5rem; }
.facts dt { color: var(--subtle); font-size: .8rem; }
.facts dd { margin: 0; word-break: break-word; }
.side-actions { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.steps { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.steps li + li { margin-top: .4rem; }
.test-form { margin-top: .5rem; }

/* Connexion */
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; margin-bottom: 1rem; justify-content: center; }

/* Pages client */
.public-head { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 1.5rem 1rem .5rem; font-weight: 700; font-size: 1.1rem; }
.public-main { max-width: 460px; margin: 0 auto; padding: 1rem 16px 2rem; }
.paycard { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.75rem 1.5rem; box-shadow: var(--shadow); }
.paycard .eyebrow { text-transform: none; letter-spacing: 0; font-size: .92rem; font-weight: 500; }
.pay-amount { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; margin: .15rem 0 1.25rem; font-variant-numeric: tabular-nums; }
.pay-facts { margin: 0 0 1.5rem; border-top: 1px solid var(--border); }
.pay-facts div { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.pay-facts dt { color: var(--muted); flex: none; }
.pay-facts dd { margin: 0; text-align: right; font-weight: 600; word-break: break-word; }
.btn-pay { min-height: 54px; font-size: 1.08rem; }
.secure { display: flex; align-items: center; justify-content: center; gap: .4rem; color: var(--muted); font-size: .85rem; margin: .9rem 0 0; text-align: center; }
.secure svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; }
.state { text-align: center; padding: .5rem 0; }
.state h1 { margin: .75rem 0 .5rem; font-size: 1.4rem; }
.state p { color: var(--muted); margin: 0 0 1rem; }
.state-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); font-size: 1.6rem; font-weight: 800; color: var(--muted); }
.state-ok .state-icon { background: var(--ok-soft); color: var(--ok); }
.public-foot { text-align: center; color: var(--muted); font-size: .88rem; padding: 0 16px 2rem; }

@media (max-width: 760px) {
  .page { padding: 1rem 16px 3rem; }
  .topbar { padding: .5rem 16px; }
  .brand-name { display: none; }
  .grid2, .detail { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi strong { font-size: 1.2rem; }
  .search { flex-basis: 100%; }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main amount" "date badge"; row-gap: .3rem; }
  .row-main { grid-area: main; } .row-amount { grid-area: amount; } .row-date { grid-area: date; } .row .badge { grid-area: badge; }
  .pagehead { flex-wrap: wrap; }
  .copy { flex-direction: column; }
  .share-buttons .btn { flex: 1 1 calc(50% - .5rem); }
}

/* Montant HT + TVA */
.field > label:first-child { font-weight: 600; font-size: .9rem; }
.vat { margin-top: 1rem; align-items: start; }
.rate-input { max-width: 140px; }
.rate-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { font: inherit; font-size: .85rem; font-weight: 600; min-height: 32px; padding: .2rem .7rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed=true] { background: var(--text); border-color: var(--text); color: #fff; }
.vat-total { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; background: var(--brand-soft); border-radius: 10px; padding: .75rem 1rem; color: var(--muted); }
.vat-total b { color: var(--text); font-weight: 600; }
.vat-ttc strong { color: var(--text); font-size: 1.25rem; margin-left: .35rem; font-variant-numeric: tabular-nums; }
.breakdown { margin: 0; font-size: .92rem; }
.breakdown div { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; color: var(--muted); }
.breakdown dd { margin: 0; font-variant-numeric: tabular-nums; color: var(--text); }
.breakdown .total { border-top: 1px solid var(--border); margin-top: .2rem; padding-top: .5rem; font-weight: 700; }
.breakdown .total dt { color: var(--text); }
.sum-amount small, .pay-amount small { font-size: .45em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.pay-amount { margin-bottom: .5rem; }
.pay-breakdown { margin-bottom: 1rem; }

/* Accueil */
.mobile-only { display: none; }
.home-head { align-items: center; }
.review-alert { display: flex; align-items: center; gap: .85rem; background: var(--danger-soft); color: var(--danger); border: 1px solid #f6c9c9; border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; text-decoration: none; }
.review-alert strong { display: block; }
.review-alert small { color: #8f2a2a; }
.review-dot { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--danger); color: #fff; font-weight: 800; }
.chev { margin-left: auto; font-size: 1.5rem; line-height: 1; }
a.kpi { color: inherit; text-decoration: none; transition: border-color .15s; }
a.kpi:hover { border-color: var(--border-strong); }
a.kpi.is-current { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.row { grid-template-columns: minmax(0, 1fr) 170px 120px 110px; }
.row-when { font-size: .85rem; color: var(--subtle); }
.row-when.is-late { color: var(--warn); font-weight: 600; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.share-native svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 760px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex; }
  .page:has(.fab) { padding-bottom: 6.5rem; }
  .home-head h1 { font-size: 1.4rem; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; width: calc(100% + 32px); }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: none; background: var(--surface); border: 1px solid var(--border); }
  .tabs a[aria-current] { border-color: var(--text); }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main amount" "when badge"; padding: .9rem 1rem; }
  .row-when { grid-area: when; align-self: center; }
  .fab { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 6; justify-content: center; align-items: center; min-height: 54px; border-radius: 14px; background: var(--brand); color: var(--text); font-weight: 700; font-size: 1.02rem; text-decoration: none; box-shadow: 0 8px 24px rgb(18 18 18 / .18); }
  .fab:active { background: var(--brand-strong); }
}
