/* Téléphone : liste dense + onglets en bas. Ordinateur : filtres toujours visibles à gauche, grille au centre, fiche à droite.
   Bleu des panneaux d'autoroute pour les actions ; vert, ambre, rouge réservés au statut (affaire, délai Maroc). */
:root {
  --fond: oklch(97% 0.005 250);
  --surface: oklch(99.5% 0.002 250);
  --surface-2: oklch(94.5% 0.007 250);
  --encre: oklch(21% 0.015 255);
  --encre-2: oklch(42% 0.015 255);
  --trait: oklch(89% 0.008 250);
  --bleu: oklch(45% 0.14 257);
  --sur-bleu: oklch(98.5% 0.01 257);
  --bleu-fond: oklch(93% 0.035 257);
  --affaire: oklch(43% 0.12 150);
  --affaire-fond: oklch(93% 0.06 150);
  --proche: oklch(47% 0.11 60);
  --proche-fond: oklch(94% 0.06 80);
  --vieux: oklch(48% 0.15 27);
  --vieux-fond: oklch(94% 0.035 27);
  --voile: oklch(18% 0.02 255 / 0.5);
  --ombre: oklch(20% 0.02 255 / 0.12);
  --titre: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --texte: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sortie: cubic-bezier(0.23, 1, 0.32, 1);
  --r: 10px;
  --gouttiere-g: max(16px, env(safe-area-inset-left, 0px));
  --gouttiere-d: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: oklch(16.5% 0.01 255); --surface: oklch(20.5% 0.012 255); --surface-2: oklch(25% 0.012 255);
    --encre: oklch(95% 0.006 250); --encre-2: oklch(75% 0.012 250); --trait: oklch(30% 0.012 255);
    --bleu: oklch(74% 0.12 255); --sur-bleu: oklch(17% 0.03 257); --bleu-fond: oklch(30% 0.06 257);
    --affaire: oklch(80% 0.14 150); --affaire-fond: oklch(29% 0.06 150);
    --proche: oklch(84% 0.12 80); --proche-fond: oklch(31% 0.06 70);
    --vieux: oklch(79% 0.12 27); --vieux-fond: oklch(30% 0.06 27);
    --voile: oklch(5% 0.01 255 / 0.6); --ombre: oklch(0% 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--encre); font: 16px/1.45 var(--texte); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--fond); }

/* Champs */
label, .etiquette-champ { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--encre-2); margin-top: 10px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--trait); border-radius: 8px; }
textarea { resize: vertical; }
.bouton { min-height: 50px; padding: 0 16px; border-radius: var(--r); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; text-decoration: none; border: 1px solid var(--trait); background: var(--surface); color: var(--encre); transition: transform 120ms var(--sortie); }
.bouton.plein { background: var(--bleu); border-color: var(--bleu); color: var(--sur-bleu); }
.bouton.petit { min-height: 40px; padding: 0 12px; }
.bouton:active, .rond:active { transform: scale(0.97); }
.lien { min-height: 44px; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border: 0; background: none; color: var(--bleu); font-weight: 600; text-decoration: none; }
.rond { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--trait); background: var(--surface); position: relative; }
.rond.petit { width: 36px; height: 36px; border: 0; background: transparent; }
.rond .nb:not(:empty) { position: absolute; top: 0; right: -2px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bleu); color: var(--sur-bleu); font-size: 0.6875rem; font-weight: 600; display: grid; place-items: center; padding: 0 4px; }
.erreur { color: var(--vieux); min-height: 1.5em; margin: 4px 0 0; font-size: 0.875rem; }

/* Connexion */
.connexion { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gouttiere-d) 24px var(--gouttiere-g); }
.connexion form { width: min(100%, 360px); display: grid; gap: 6px; }
.connexion img { border-radius: 12px; }
.connexion h1 { font: 700 1.75rem/1.1 var(--titre); margin: 8px 0 12px; }
.connexion .bouton { margin-top: 12px; }

/* Structure */
.coque { display: block; }
.cote { display: contents; }
.cote .marque, .nav-cote { display: none; }

.haut { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--fond); border-bottom: 1px solid var(--trait);
  display: grid; gap: 10px; padding-block: 10px 0; padding-left: var(--gouttiere-g); padding-right: var(--gouttiere-d); }
.ligne-titre { display: flex; align-items: center; gap: 10px; }
.ligne-titre h1 { font: 700 1.5rem/1.1 var(--titre); letter-spacing: -0.005em; }
.compte { color: var(--encre-2); font-size: 0.875rem; white-space: nowrap; }
.espace { flex: 1; }

.types { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.types button { min-height: 40px; border: 0; border-radius: 8px; background: transparent; font: 600 0.875rem/1.1 var(--titre); color: var(--encre-2); padding: 2px; }
.types button[aria-pressed="true"] { background: var(--surface); color: var(--encre); box-shadow: 0 1px 2px var(--ombre); }
.types small { display: block; font: 500 0.6875rem/1.2 var(--texte); color: var(--encre-2); }

.puces { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 10px;
  margin-left: calc(-1 * var(--gouttiere-g)); margin-right: calc(-1 * var(--gouttiere-d)); padding-left: var(--gouttiere-g); padding-right: var(--gouttiere-d); }
.puces::-webkit-scrollbar { display: none; }
.puce { flex: none; min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--trait); background: var(--surface); font-size: 0.875rem; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.puce[aria-pressed="true"] { background: var(--bleu); border-color: var(--bleu); color: var(--sur-bleu); }
.puce svg.i { width: 16px; height: 16px; }

.tri { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-block: 10px 6px; padding-left: var(--gouttiere-g); padding-right: var(--gouttiere-d); }
.tri p { margin: 0; font-size: 0.8125rem; line-height: 1.3; color: var(--encre-2); min-width: 0; }
.tri select { width: auto; flex: none; min-height: 36px; padding: 0 8px; font-size: 0.875rem; font-weight: 500; }

.installer { display: flex; gap: 12px; align-items: center; padding: 10px 6px 10px 12px; border-radius: var(--r); background: var(--bleu-fond); font-size: 0.875rem;
  margin: 4px var(--gouttiere-d) 8px var(--gouttiere-g); }
.installer img { border-radius: 9px; flex: none; }
.installer div { flex: 1; min-width: 0; }
.installer b { display: block; }

/* Liste */
.liste { list-style: none; margin: 0; display: grid; gap: 8px; padding-block: 4px calc(84px + env(safe-area-inset-bottom, 0px)); padding-left: var(--gouttiere-g); padding-right: var(--gouttiere-d); }
.carte { width: 100%; display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 12px; padding: 10px; text-align: left; color: inherit;
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--r); transition: transform 120ms var(--sortie), border-color 150ms var(--sortie); }
.carte:active { transform: scale(0.985); }
.carte[aria-current="true"] { border-color: var(--bleu); box-shadow: 0 0 0 1px var(--bleu); }
.vignette { width: 116px; height: 96px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.corps { min-width: 0; display: grid; gap: 3px; align-content: start; }
.nom { font: 600 1.0625rem/1.2 var(--titre); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nom span { color: var(--encre-2); font-weight: 500; }
.specs { font-size: 0.8125rem; color: var(--encre-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prix-ligne { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.prix { font: 700 1.25rem/1 var(--titre); letter-spacing: -0.01em; }
.prix small { font: 500 0.75rem var(--texte); color: var(--encre-2); margin-left: 3px; }
.prix.demande { font-size: 1rem; color: var(--encre-2); }
.ecart { font: 700 0.875rem/1 var(--titre); padding: 4px 7px; border-radius: 6px; background: var(--affaire-fond); color: var(--affaire); }
.ecart.moyen { background: var(--surface-2); color: var(--encre-2); }
.ecart.suspect { background: var(--vieux-fond); color: var(--vieux); }
.bas { display: flex; gap: 4px 8px; align-items: center; flex-wrap: wrap; font-size: 0.75rem; color: var(--encre-2); margin-top: 2px; }
.delai { font-weight: 600; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.s-importable, .s-neuf { background: var(--affaire-fond); color: var(--affaire); }
.s-limite_proche { background: var(--proche-fond); color: var(--proche); }
.s-trop_vieux { background: var(--vieux-fond); color: var(--vieux); }
.s-mois_inconnu, .s-a_verifier { background: var(--surface-2); color: var(--encre-2); }
.marque-suivi { font-weight: 600; color: var(--bleu); }
.vide { text-align: center; color: var(--encre-2); padding: 48px 16px; }

/* Onglets du bas */
.onglets { position: fixed; inset: auto 0 0; z-index: 25; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--trait);
  padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.onglets button { min-height: 58px; border: 0; background: none; display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 0.75rem; font-weight: 600; color: var(--encre-2); position: relative; }
.onglets button[aria-current="page"] { color: var(--bleu); }
.onglets button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--bleu); }
.onglets .nb:not(:empty) { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--bleu); color: var(--sur-bleu); font-size: 0.6875rem; display: grid; place-items: center; padding: 0 4px; }

/* Feuilles */
dialog { border: 0; padding: 0; color: var(--encre); background: var(--surface); }
dialog::backdrop { background: var(--voile); }
.filtres { width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 16px 16px 0 0; max-height: 92dvh;
  padding-block: 8px calc(16px + env(safe-area-inset-bottom, 0px)); padding-left: var(--gouttiere-g); padding-right: var(--gouttiere-d); }
.filtres[open] { animation: monte 240ms var(--sortie); }
.filtres-entete { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; }
.filtres-entete h2 { font: 700 1.375rem var(--titre); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.options-filtre { border: 0; padding: 0; margin: 14px 0 0; }
.options-filtre legend { font-size: 0.8125rem; font-weight: 600; color: var(--encre-2); padding: 0; }
.cases { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cases label { margin: 0; font-weight: 500; color: var(--encre); }
.cases input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cases span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--trait); font-size: 0.8125rem; }
.cases span small { margin-left: 6px; color: var(--encre-2); }
.cases input:checked + span { background: var(--bleu); color: var(--sur-bleu); border-color: var(--bleu); }
.cases input:checked + span small { color: inherit; }
.cases input:focus-visible + span { outline: 2px solid var(--bleu); outline-offset: 2px; }
.info-passage { font-size: 0.75rem; color: var(--encre-2); margin: 16px 0 0; }
.filtres .voir { width: 100%; margin-top: 14px; position: sticky; bottom: 0; }

/* Fiche */
.fiche { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; }
.fiche[open] { animation: entre 240ms var(--sortie); }
.fiche-defile { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
.fiche-barre { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface); border-bottom: 1px solid var(--trait);
  padding-block: calc(4px + env(safe-area-inset-top, 0px)) 4px; padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.galerie { position: relative; background: var(--surface-2); }
.photos { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.photos::-webkit-scrollbar { display: none; }
.photos img { flex: none; width: 100%; max-width: 100%; aspect-ratio: 4 / 3; object-fit: cover; scroll-snap-align: start; display: block; }
.compteur-photos:not(:empty) { position: absolute; right: 12px; bottom: 12px; font-size: 0.75rem; font-weight: 600; background: oklch(15% 0.01 255 / 0.7); color: oklch(98% 0 0); padding: 3px 8px; border-radius: 10px; }
.fiche-corps { display: grid; gap: 18px; padding-block: 16px; padding-left: var(--gouttiere-g); padding-right: var(--gouttiere-d); min-width: 0; }
.fiche-corps h2 { font: 700 1.375rem/1.15 var(--titre); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fiche-corps h3 { font: 600 0.75rem var(--texte); letter-spacing: 0.06em; text-transform: uppercase; color: var(--encre-2); margin: 0 0 8px; }
.fiche-corps p { margin: 0; }
.bloc-prix { display: grid; gap: 6px; padding: 14px; border-radius: var(--r); background: var(--surface-2); }
.bloc-prix.affaire { background: var(--affaire-fond); }
.bloc-prix .grand { font: 700 2rem/1 var(--titre); letter-spacing: -0.015em; }
.bloc-prix .grand small { font: 500 0.875rem var(--texte); color: var(--encre-2); margin-left: 4px; }
.bloc-prix p { font-size: 0.875rem; }
.bloc-prix.affaire strong { color: var(--affaire); }
.jauge { position: relative; height: 8px; border-radius: 4px; margin-top: 4px; background: linear-gradient(90deg, var(--affaire) 0 33%, var(--trait) 33% 66%, var(--vieux-fond) 66%); }
.jauge i { position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px; background: var(--encre); transform: translateX(-2px); }
.statut { padding: 12px 14px; border-radius: var(--r); font-weight: 600; }
.statut small { display: block; font-weight: 400; color: var(--encre-2); margin-top: 2px; }
.faits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--trait); border: 1px solid var(--trait); border-radius: var(--r); overflow: hidden; margin: 0; }
.faits div { background: var(--surface); padding: 10px 12px; min-width: 0; }
.faits dt { font-size: 0.75rem; color: var(--encre-2); }
.faits dd { margin: 0; font: 600 1.0625rem/1.25 var(--titre); overflow-wrap: anywhere; }
.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; }
.etiquettes span { font-size: 0.8125rem; font-weight: 500; padding: 4px 10px; border-radius: 14px; background: var(--surface-2); }
.etiquettes span.cle { background: var(--bleu-fond); color: var(--bleu); font-weight: 600; }
.vendeur b { display: block; font: 600 1.125rem var(--titre); }
.vendeur a { color: var(--bleu); font-weight: 600; overflow-wrap: anywhere; }
.vendeur p { font-size: 0.9375rem; }
.suivi { display: flex; flex-wrap: wrap; gap: 6px; }
.suivi button { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--trait); background: var(--surface); font-size: 0.875rem; font-weight: 500; }
.suivi button[aria-pressed="true"] { background: var(--bleu); border-color: var(--bleu); color: var(--sur-bleu); }
.enregistre { font-size: 0.8125rem; color: var(--encre-2); min-height: 1.5em; margin-top: 4px !important; }
.tout summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--bleu); }
.details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 16px; margin: 0 0 12px; }
.details dt, .details dd { padding: 8px 0; border-bottom: 1px solid var(--trait); margin: 0; font-size: 0.9375rem; overflow-wrap: anywhere; }
.details dt { color: var(--encre-2); }
.description { white-space: pre-line; font-size: 0.9375rem; color: var(--encre-2); max-width: 70ch; overflow-wrap: anywhere; }
.actions { position: absolute; inset: auto 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--surface); border-top: 1px solid var(--trait);
  padding-block: 10px calc(10px + env(safe-area-inset-bottom, 0px)); padding-left: var(--gouttiere-g); padding-right: var(--gouttiere-d); }

@keyframes monte { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes entre { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .filtres[open], .fiche[open] { animation: none; }
  .carte:active, .bouton:active, .rond:active { transform: none; }
}

/* Tablette : cartes sur plusieurs colonnes */
@media (min-width: 700px) {
  .liste { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  .fiche { max-width: 720px; margin: 0 auto; }
}

/* Ordinateur : filtres toujours visibles à gauche, fiche en panneau à droite */
@media (min-width: 1080px) {
  .coque { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100dvh; }
  .cote { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: 18px 16px 24px max(16px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--trait); background: var(--surface); }
  .cote .marque { display: flex; align-items: center; gap: 10px; font: 700 1.375rem/1 var(--titre); }
  .cote .marque img { border-radius: 7px; }
  .nav-cote { display: grid; gap: 2px; }
  .nav-cote button { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 8px; background: none; font-weight: 600; color: var(--encre-2); text-align: left; }
  .nav-cote button .nb { margin-left: auto; font-weight: 500; font-size: 0.8125rem; }
  .nav-cote button[aria-current="page"] { background: var(--bleu-fond); color: var(--bleu); }
  .filtres, .filtres:not([open]) { display: block; position: static; width: auto; max-width: none; max-height: none; margin: 0; padding: 0; border-radius: 0; background: transparent; animation: none; }
  .filtres-entete { border-top: 1px solid var(--trait); padding-top: 12px; }
  .filtres-entete h2 { font-size: 1.125rem; }
  .filtres input, .filtres select { min-height: 38px; background: var(--fond); }
  .filtres .voir, #ouvrir-filtres, .onglets { display: none; }
  .haut .puces { margin: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; }
  .liste { padding-bottom: 32px; }
  .coque.fiche-ouverte .principal { margin-right: min(480px, 38vw); }
  .fiche { position: fixed; inset: 0 0 0 auto; z-index: 22; width: min(480px, 38vw); height: 100dvh; max-height: 100dvh; max-width: none; margin: 0;
    border-left: 1px solid var(--trait); box-shadow: -8px 0 24px var(--ombre); }
  .fiche::backdrop { display: none; }
}
