/* Adaptation de binome.css (design « Compte commun ») à l'app réelle :
   plein écran, zones de sécurité Android, champs natifs, éléments propres
   à l'app. binome.css reste tel que livré par le design. */

html { background: var(--bg, #F3F5F9); }
body.app { margin: 0; min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
body.app.sans-onglets { padding-bottom: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }

/* --- Structure --- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding-top: calc(var(--sp-2) + env(safe-area-inset-top));
}
.topbar .title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .title-lg { flex: 1 1 auto; }
.content { max-width: 560px; width: 100%; margin: 0 auto; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding-bottom: calc(var(--sp-2) + env(safe-area-inset-bottom));
}
.card > h2, .card .card-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.card.vstack, .card .vstack { gap: var(--sp-3); }
.stack-3 { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-4 { display: flex; flex-direction: column; gap: var(--sp-4); }

/* --- Montants --- */
.money .dec, .amount-hero .dec, .amount-xl .dec, .amount-lg .dec, .kpi-value .dec { color: var(--muted); }
.kpi-value { font-family: var(--font); }

/* --- Champs natifs --- */
.input select { appearance: none; -webkit-appearance: none; cursor: pointer; min-height: 44px; }
.input.select { position: relative; }
.input.select::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none;
}
.input:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.input input[type="date"] { min-height: 44px; }
.input input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; }
.app.dark .input input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }
@media (prefers-color-scheme: dark) { .app:not(.light) .input input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); } }
textarea.input { width: 100%; font-family: var(--font); }
textarea.input:focus { box-shadow: var(--focus); }
.form { display: flex; flex-direction: column; gap: var(--sp-4); }
.form-inline { display: flex; gap: var(--sp-2); align-items: flex-end; flex-wrap: wrap; }
.form-inline > .field { flex: 1 1 140px; }
.check { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); font-size: var(--fs-md); }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

/* Envoi de fichiers : l'input est caché dans la zone de dépôt */
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone { position: relative; }
.dropzone .dz-files { color: var(--text); font-weight: var(--fw-medium); }
.dropzone.has-files { border-style: solid; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.envoi { display: flex; flex-direction: column; gap: 6px; }
.envoi .envoi-texte { font-size: var(--fs-xs); color: var(--muted); }

/* Choix du prix : radios en cartes */
.choice input[type="radio"]:checked { accent-color: var(--accent); }
.choice:has(input[type="radio"]:checked) { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); padding: 11px; }
.choice .choice-value .unit { font-size: var(--fs-md); color: var(--muted); }
.seg label { min-height: var(--tap); border-radius: 10px; color: var(--muted); font-size: var(--fs-md); font-weight: var(--fw-medium); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); font-weight: var(--fw-semibold); box-shadow: var(--shadow-1); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

/* Dépliants (details) en ligne de liste */
details.plier > summary {
  list-style: none; display: flex; align-items: center; gap: var(--sp-2); min-height: var(--tap);
  color: var(--accent); font-weight: var(--fw-medium); cursor: pointer;
}
details.plier > summary::-webkit-details-marker { display: none; }
details.plier > summary .i { transition: transform var(--dur) var(--ease); }
details.plier[open] > summary .i.rot { transform: rotate(180deg); }
details.plier > .form, details.plier > form { padding-top: var(--sp-2); }

/* --- Listes --- */
.row .thumb img, .thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.thumb { overflow: hidden; }
.row-end .money { font-weight: var(--fw-semibold); }
.list .empty { padding: var(--sp-6) var(--sp-4); }
.list-label { padding-left: var(--sp-1); }
a.row:active { background: var(--surface-2); }
.row .badge { align-self: flex-start; }

/* --- Médias --- */
.carousel-main img, .carousel-main video { width: 100%; height: 100%; object-fit: cover; }
.carousel-rail { display: flex; gap: var(--sp-2); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.carousel-rail > a { flex: 0 0 100%; scroll-snap-align: center; }
.carousel-thumbs a { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--ph-2); display: block; }
.carousel-thumbs a img { width: 100%; height: 100%; object-fit: cover; }
.proof-media { overflow: hidden; }
.proof-media img { width: 100%; height: 100%; object-fit: cover; }
.proof-media .i.xl { opacity: .7; }
.gallery-rail { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; }
.gallery-rail .proof { width: 112px; flex-shrink: 0; }

/* --- Chat --- */
body.page-chat { padding-bottom: calc(var(--tabbar-h) + 132px + env(safe-area-inset-bottom)); }
.page-chat .content { padding-left: 0; padding-right: 0; }
.thread { padding-top: 0; }
.composer {
  position: fixed; left: 0; right: 0; z-index: 19; border-top: 1px solid var(--line);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.composer > * { max-width: 560px; width: 100%; margin: 0 auto; }
.composer textarea.composer-input { padding: 11px 16px; resize: none; max-height: 140px; line-height: 1.4; font-family: var(--font); }
.composer .input { min-height: 40px; }
.composer .input select { min-height: 36px; font-size: var(--fs-sm); }
.bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.media-box img, .media-box video { width: 100%; display: block; }
.media-box.doc { min-height: 72px; gap: var(--sp-2); padding: var(--sp-3); }
.msg-group { display: flex; flex-direction: column; gap: 4px; }
.msg-group.me { align-items: flex-end; }
.msg-group.them { align-items: flex-start; }
.msg-group .quote-card { max-width: 76%; }
.associer { width: 240px; }
.associer > summary { color: var(--accent); font-size: var(--fs-sm); font-weight: var(--fw-medium); min-height: 32px; display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; }
.associer > summary::-webkit-details-marker { display: none; }
.associer .form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3); gap: var(--sp-2); }
.range { font-size: var(--fs-2xs); color: var(--pos); display: inline-flex; gap: 4px; align-items: center; }

/* --- Données --- */
.hist { height: 150px; }
.hist .bar { position: relative; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: 0 calc(var(--sp-4) * -1); padding: 0 var(--sp-4); }
.table td:first-child { padding-right: var(--sp-2); }
.table th.num + th, .table td.num + td { padding-left: var(--sp-3); }
.table th:not(:first-child), .table td:not(:first-child) { padding-left: var(--sp-3); }

/* --- Divers --- */
.hero-card { display: flex; flex-direction: column; gap: var(--sp-4); }
.hero-who { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); }
.avs { display: inline-flex; }
.avs .av + .av { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.quick a { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.activity { display: flex; flex-direction: column; }
.activity .row { min-height: 52px; }
.danger-zone { margin-top: var(--sp-2); }
.danger-zone > summary { color: var(--neg); }
.flash-stack { display: flex; flex-direction: column; gap: var(--sp-2); }
.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: var(--sp-6); padding: var(--sp-8) var(--gutter); max-width: 420px; margin: 0 auto; }
.auth-logo { width: 72px; height: 72px; border-radius: 20px; }
.auth h1 { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }
.menu-list .row { min-height: 56px; }
.lien-discret { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; min-height: var(--tap); display: inline-flex; align-items: center; }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.btn-row > .btn, .btn-row > form { flex: 1 1 auto; }
.btn-row > form > .btn { width: 100%; }
.fun-grid .kpi-value { font-size: 20px; }
.row.row-bloc { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; }
.row.row-bloc > .hstack { gap: var(--sp-3); }
.titre-article { align-items: flex-start; }
.titre-article .vstack { gap: 2px; }
.titre-article h2 { font-family: var(--font); }
.kv-row .v.fin { justify-content: flex-end; }
.note-carte { margin-top: var(--sp-3); }
.row-title.multiligne { white-space: normal; }
.fichier-input { cursor: pointer; position: relative; }
.fichier-input input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.hist.hist-24 { grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; height: 80px; }
.flush-list { border: none; background: transparent; margin: 0 calc(var(--sp-4) * -1); border-radius: 0; }
a.kv-row { color: inherit; }
.kv-row .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.is-disabled { opacity: .55; }
p .link, .alert .link, .help .link { min-height: 0; display: inline; }
.hero-who { flex-wrap: wrap; row-gap: 4px; } .hero-who > span, .hero-who > b { white-space: nowrap; }

/* --- Correctifs de spécificité ---
   binome.css déclare `.app button, .app a { color: inherit }` (spécificité
   0,1,1), qui l'emporte sur `.btn-primary`, `.link`… (0,1,0) : texte noir sur
   les boutons bleus, liens sans couleur. On rétablit les couleurs prévues. */
.app .btn-primary { color: var(--on-accent); }
.app .btn-secondary, .app .btn-outline { color: var(--text); }
.app .btn-danger { color: var(--neg); }
.app .btn-danger.solid { color: #fff; }
.app .btn-ghost, .app .link { color: var(--accent); }
.app .icon-btn.accent { color: var(--on-accent); }
.app .chip.on { color: var(--bg); }

/* Champs posés directement sur le fond de page (hors carte) : même gris que
   le fond, donc invisibles. On les passe en surface blanche avec un contour. */
.app .input:not(.card .input):not(.sheet .input) {
  background: var(--surface);
  border-color: var(--line);
}
.app .input:not(.card .input):focus-within { border-color: var(--accent); }
/* Même chose pour les boutons secondaires hors carte. */
.app .btn-secondary:not(.card .btn-secondary) { background: var(--surface); border: 1px solid var(--line); }
