/* =====================================================================
   Orvalys UGC — styles (mobile d'abord)
   ===================================================================== */
:root {
  --fond: #FBF7F4;
  --carte: #FFFFFF;
  --encre: #2A1F2D;
  --doux: #75677A;
  --ligne: #EDE4E6;
  --accent: #B8336A;
  --accent-clair: #F8E6EE;
  --prune: #5B3B63;
  --bleu: #3D7DD8;
  --bleu-clair: #E7F0FC;
  --vert: #2F8A57;
  --vert-clair: #E3F4EA;
  --orange: #B86B12;
  --orange-clair: #FCF0DF;
  --rouge: #C23B3B;
  --rouge-clair: #FBE7E7;
  --rayon: 16px;
  --ombre: 0 1px 2px rgba(42,31,45,.06), 0 4px 16px rgba(42,31,45,.06);
  --nav-h: 64px;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fond); color: var(--encre); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; letter-spacing: -.02em; }
h2 { font-size: 18px; letter-spacing: -.01em; }
h3 { font-size: 15px; }
p { margin: 0; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--encre); }
.cache { display: none !important; }

/* ---------- Écrans de base ---------- */
.ecran-chargement { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--doux); }
.logo-rond {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 26px;
  box-shadow: 0 6px 20px rgba(184,51,106,.3);
}
.logo-rond.petit { width: 32px; height: 32px; font-size: 15px; box-shadow: none; }

/* ---------- Mise en page ---------- */
.coque { min-height: 100vh; padding-top: var(--haut); padding-bottom: calc(var(--nav-h) + var(--bas) + 16px); }
.entete {
  position: sticky; top: 0; z-index: 20; background: rgba(251,247,244,.92); backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: calc(10px + var(--haut));
  border-bottom: 1px solid var(--ligne);
}
.entete .titre-appli { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contenu { padding: 16px; max-width: 980px; margin: 0 auto; display: grid; gap: 16px; }
.bandeau-lecture {
  background: var(--prune); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.bandeau-lecture span { flex: 1; }

.nav-bas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--carte);
  border-top: 1px solid var(--ligne); display: flex; padding-bottom: var(--bas); height: calc(var(--nav-h) + var(--bas));
}
.nav-bas a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--doux); font-size: 11px; font-weight: 600;
}
.nav-bas a svg { width: 22px; height: 22px; }
.nav-bas a.actif { color: var(--accent); }

@media (min-width: 900px) {
  .coque { padding-bottom: 24px; padding-left: 232px; }
  .nav-bas {
    top: 0; bottom: 0; right: auto; width: 216px; height: auto; flex-direction: column; justify-content: flex-start;
    padding: 76px 12px 12px; border-top: 0; border-right: 1px solid var(--ligne); gap: 4px;
  }
  .nav-bas a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
  .nav-bas a.actif { background: var(--accent-clair); }
  .entete { padding-left: 24px; }
  .contenu { padding: 24px; }
}

/* ---------- Éléments ---------- */
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; }
.carte.plate { box-shadow: none; border: 1px solid var(--ligne); }
.carte h2 + *, .carte h3 + * { margin-top: 10px; }
.ligne-titre { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ligne-titre .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sous { color: var(--doux); font-size: 13px; }
.grille { display: grid; gap: 12px; }
.grille-2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .grille-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grille-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.grille-4, .grille-3 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.tuile { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 14px; display: grid; gap: 4px; }
.tuile .etiquette { color: var(--doux); font-size: 12px; font-weight: 600; }
.tuile .valeur { font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.tuile .detail { color: var(--doux); font-size: 12px; }
.tuile.accent { background: var(--accent); color: #fff; }
.tuile.accent .etiquette, .tuile.accent .detail { color: rgba(255,255,255,.85); }

.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 650; cursor: pointer;
  background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; text-align: center;
}
.btn:disabled { opacity: .55; cursor: wait; }
.btn.secondaire { background: var(--accent-clair); color: var(--accent); }
.btn.neutre { background: var(--carte); color: var(--encre); border: 1px solid var(--ligne); }
.btn.danger { background: var(--rouge-clair); color: var(--rouge); }
.btn.petit { padding: 7px 12px; min-height: 36px; font-size: 13px; border-radius: 10px; }
.btn.plein { width: 100%; }
.btn-vue {
  border: 1px solid var(--accent); color: var(--accent); background: var(--carte); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn-vue.actif { background: var(--accent); color: #fff; }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + var(--bas) + 18px); z-index: 25;
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  font-size: 28px; box-shadow: 0 8px 24px rgba(184,51,106,.35); cursor: pointer;
}
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }

.liste { display: grid; gap: 8px; }
.element {
  background: var(--carte); border-radius: 14px; padding: 12px 14px; box-shadow: var(--ombre);
  display: flex; align-items: center; gap: 12px; cursor: pointer; border: 0; width: 100%; text-align: left;
}
.element .corps { flex: 1; min-width: 0; display: grid; gap: 2px; }
.element .principal { font-weight: 650; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.element .droite { text-align: right; display: grid; gap: 4px; justify-items: end; }
.element.plat { box-shadow: none; border: 1px solid var(--ligne); }
.vide { text-align: center; color: var(--doux); padding: 28px 12px; display: grid; gap: 12px; justify-items: center; }

.pastille {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: var(--ligne); color: var(--encre); white-space: nowrap;
}
.pastille.rose { background: var(--accent-clair); color: var(--accent); }
.pastille.bleu { background: var(--bleu-clair); color: #2a5fa8; }
.pastille.vert { background: var(--vert-clair); color: var(--vert); }
.pastille.orange { background: var(--orange-clair); color: var(--orange); }
.pastille.rouge { background: var(--rouge-clair); color: var(--rouge); }
.pastille.prune { background: #EEE6F0; color: var(--prune); }

.case {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--ligne); background: #fff;
  display: grid; place-items: center; flex: none; cursor: pointer; color: #fff;
}
.case.cochee { background: var(--vert); border-color: var(--vert); }
.barre-progression { height: 8px; background: var(--ligne); border-radius: 99px; overflow: hidden; }
.barre-progression > div { height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- Onglets / filtres ---------- */
.onglets { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.onglets::-webkit-scrollbar { display: none; }
.onglet {
  border: 1px solid var(--ligne); background: var(--carte); border-radius: 999px; padding: 7px 14px;
  font-size: 13px; font-weight: 650; white-space: nowrap; cursor: pointer; color: var(--doux);
}
.onglet.actif { background: var(--encre); border-color: var(--encre); color: #fff; }

/* ---------- Formulaires ---------- */
.champ { display: grid; gap: 6px; }
.champ label { font-size: 13px; font-weight: 650; color: var(--doux); }
.champ input, .champ select, .champ textarea {
  width: 100%; border: 1px solid var(--ligne); background: #fff; border-radius: 12px; padding: 11px 12px; min-height: 44px;
  outline: none;
}
.champ textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.champ input:focus, .champ select:focus, .champ textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-clair); }
.champ.coche { display: flex; align-items: center; gap: 10px; }
.champ.coche input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); }
.formulaire { display: grid; gap: 14px; }
.formulaire .duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.erreur-form { color: var(--rouge); font-size: 13px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; padding-top: calc(24px + var(--haut)); }
.auth .boite { width: 100%; max-width: 400px; display: grid; gap: 18px; }
.auth .marque-auth { display: grid; justify-items: center; gap: 10px; text-align: center; }
.auth .lien-bas { text-align: center; font-size: 14px; color: var(--doux); }

/* ---------- Modale ---------- */
.voile {
  position: fixed; inset: 0; background: rgba(42,31,45,.45); z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  animation: apparait .15s ease;
}
.modale {
  background: var(--fond); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + var(--bas)); display: grid; gap: 14px; animation: monte .2s ease;
}
@media (min-width: 700px) { .voile { align-items: center; } .modale { border-radius: 22px; } }
.modale .poignee { width: 40px; height: 4px; border-radius: 4px; background: var(--ligne); margin: -6px auto 2px; }
.modale .pied { display: flex; gap: 10px; position: sticky; bottom: calc(-18px - var(--bas)); background: var(--fond); padding: 10px 0 0; }
.modale .pied .btn { flex: 1; }
@keyframes apparait { from { opacity: 0; } }
@keyframes monte { from { transform: translateY(30px); opacity: .6; } }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); bottom: calc(var(--nav-h) + var(--bas) + 20px);
  background: var(--encre); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; z-index: 200;
  opacity: 0; pointer-events: none; transition: all .2s ease; max-width: 90vw; text-align: center;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.erreur { background: var(--rouge); }

/* ---------- Graphique ---------- */
.graphique { display: grid; gap: 8px; }
.legende { display: flex; gap: 14px; font-size: 12px; color: var(--doux); flex-wrap: wrap; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.barres { display: flex; align-items: flex-end; gap: 6px; height: 150px; border-bottom: 1px solid var(--ligne); padding-top: 8px; }
.barres .colonne { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; position: relative; cursor: default; }
.barres .seg { border-radius: 4px 4px 0 0; min-height: 0; }
.barres .seg + .seg { border-radius: 0; }
.barres .seg.argent { background: #B8336A; }
.barres .seg.gifting { background: #3D7DD8; }
.barres .colonne:hover .seg, .barres .colonne:focus .seg { filter: brightness(.9); }
.axe-x { display: flex; gap: 6px; font-size: 11px; color: var(--doux); }
.axe-x span { flex: 1; text-align: center; }
.bulle {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--encre); color: #fff;
  font-size: 12px; padding: 6px 8px; border-radius: 8px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 5;
}
.barres .colonne:hover .bulle, .barres .colonne:focus .bulle { opacity: 1; }

/* ---------- Tableau ---------- */
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau th { text-align: left; color: var(--doux); font-size: 12px; font-weight: 650; padding: 8px 6px; border-bottom: 1px solid var(--ligne); }
.tableau td { padding: 10px 6px; border-bottom: 1px solid var(--ligne); }
.tableau td.nombre, .tableau th.nombre { text-align: right; font-variant-numeric: tabular-nums; }
.defile { overflow-x: auto; }

/* ---------- Contrat / texte ---------- */
.texte-long { white-space: pre-wrap; font-size: 14px; line-height: 1.6; background: #fff; border: 1px solid var(--ligne); border-radius: 12px; padding: 14px; max-height: 50vh; overflow: auto; }

/* ---------- Formules ---------- */
.grille-formules { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grille-formules { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.formule { border: 2px solid var(--ligne); border-radius: var(--rayon); padding: 16px; background: var(--carte); display: grid; gap: 10px; cursor: pointer; }
.formule.choisie { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-clair); }
.formule .prix { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.formule .prix small { font-size: 14px; font-weight: 600; color: var(--doux); }
.formule .barre { text-decoration: line-through; color: var(--doux); font-size: 14px; }
.formule ul { margin: 0; padding-left: 18px; color: var(--doux); font-size: 14px; display: grid; gap: 4px; }
.bascule { display: inline-flex; background: var(--ligne); border-radius: 999px; padding: 4px; }
.bascule button { border: 0; background: transparent; padding: 8px 14px; border-radius: 999px; font-weight: 650; cursor: pointer; font-size: 13px; }
.bascule button.actif { background: var(--carte); box-shadow: var(--ombre); }

@media print {
  .nav-bas, .entete, .fab, .bandeau-lecture { display: none !important; }
}
