/* =====================================================================
   STYLE NEUTRE DU SOCLE — à habiller projet par projet.
   Pour changer l'allure d'une appli : modifier les variables ci-dessous (couleurs, arrondis, police),
   puis ajouter une feuille propre au client après celle-ci. Ne rien retirer : la coque s'appuie sur ces classes.
   ===================================================================== */
:root {
  --fond: #f4f6f8;            /* fond de page */
  --surface: #ffffff;         /* cartes, barre, fenêtres */
  --encre: #1c2733;           /* texte */
  --encre-douce: #5d6b7a;     /* texte secondaire */
  --trait: #dfe5eb;           /* bordures */
  --marque: #16324f;          /* couleur du client : barre, boutons principaux */
  --marque-encre: #ffffff;    /* texte sur la couleur du client */
  --accent: #1d6fb8;          /* liens, sélection */
  --alerte: #b3261e;
  --ok: #1e7a46;
  --attente: #a15c00;
  --rayon: 12px;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 var(--police); color: var(--encre); background: var(--fond); padding-bottom: env(safe-area-inset-bottom, 0); }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; }
a { color: var(--accent); }
.discret { color: var(--encre-douce); font-size: .9rem; }
.erreur { color: var(--alerte); font-size: .92rem; margin: .4rem 0; }
.erreur:empty { display: none; }
.vide { color: var(--encre-douce); text-align: center; padding: 2rem 1rem; margin: 0; }
.avis { background: #fff4de; color: var(--attente); border-radius: var(--rayon); padding: .7rem .9rem; margin: 0 0 .8rem; font-size: .92rem; }

/* ---------- boutons et champs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: 0 1rem; border: 1px solid var(--trait); border-radius: var(--rayon);
  background: var(--surface); color: var(--encre); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.principal { background: var(--marque); border-color: var(--marque); color: var(--marque-encre); }
.btn.danger { color: var(--alerte); }
.btn.lien { border-color: transparent; background: none; color: var(--accent); padding: 0 .3rem; }
.btn.mini { min-height: 36px; padding: 0 .7rem; font-size: .9rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: default; pointer-events: none; }
.btn.occupe::after { content: ""; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: tourne .7s linear infinite; }
.rond { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--trait); background: var(--surface);
  color: var(--encre); font: inherit; font-size: 1.2rem; font-weight: 700; text-decoration: none; cursor: pointer; flex: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
label { display: block; font-size: .9rem; font-weight: 600; color: var(--encre-douce); margin: 0 0 .9rem; }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; min-height: 44px; padding: .55rem .7rem; border: 1px solid var(--trait); border-radius: 10px; background: var(--surface);
  color: var(--encre); font: inherit; font-weight: 400; }
textarea { resize: vertical; }
label.case { display: flex; align-items: center; gap: .6rem; color: var(--encre); font-weight: 400; }
label.case input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: none; }
.actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.actions.colonne { flex-direction: column; align-items: stretch; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

/* ---------- connexion ---------- */
.connexion { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; background: var(--marque); }
.carte-connexion { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 1.6rem 1.4rem; text-align: center; }
.carte-connexion img { border-radius: 14px; }
.carte-connexion h1 { margin: .7rem 0 .2rem; }
.carte-connexion form { text-align: left; margin-top: 1rem; }
.carte-connexion .btn.principal { width: 100%; }
.carte-connexion .btn.lien { width: 100%; margin-top: .3rem; }
.google { display: flex; justify-content: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--trait); min-height: 44px; }

/* ---------- barre et navigation ---------- */
.barre { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .7rem; padding: .5rem .9rem; padding-top: calc(.5rem + env(safe-area-inset-top, 0px));
  background: var(--marque); color: var(--marque-encre); }
.marque { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; min-width: 0; }
.marque img { border-radius: 7px; flex: none; }
.marque span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.marque b, .marque small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marque small { opacity: .75; font-size: .72rem; }
#nav { display: flex; gap: .2rem; margin-left: .6rem; flex: 1; min-width: 0; overflow-x: auto; }
#nav a { color: inherit; text-decoration: none; padding: .45rem .8rem; border-radius: 999px; opacity: .8; white-space: nowrap; font-weight: 600; font-size: .95rem; }
#nav a.actif { background: rgba(255, 255, 255, .18); opacity: 1; }
.barre .rond { background: rgba(255, 255, 255, .16); border-color: transparent; color: inherit; font-size: 1rem; }
.etat { font-size: .78rem; padding: .2rem .6rem; border-radius: 999px; background: rgba(255, 255, 255, .14); white-space: nowrap; }
.etat.sync { background: rgba(255, 255, 255, .28); }
.etat.hors, .etat.attente { background: #ffd58a; color: #4a2c00; }
.etat.refus { background: #ffb4a8; color: #5a0d00; }
.etat.cliquable { cursor: pointer; }
.carte.refusee { border-left: 4px solid #c62828; }
.carte .actions { display: flex; gap: .5rem; margin-top: .4rem; }
.bandeau { display: flex; align-items: center; justify-content: center; gap: .8rem; padding: .5rem .9rem; background: #fff4de; color: #4a2c00; font-size: .92rem; }
main { max-width: 860px; margin: 0 auto; padding: 1rem .9rem 5rem; outline: none; }
.tete-page { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tete-page h2 { margin: 0; }
.choix-mois { display: flex; align-items: center; gap: .7rem; }
.choix-mois h1 { min-width: 9.5rem; text-align: center; text-transform: capitalize; }
.resume { color: var(--encre-douce); margin: 0 0 .8rem; min-height: 1.4em; }

/* ---------- listes ---------- */
.cartes { display: grid; gap: .55rem; }
.carte { display: grid; grid-template-columns: 1fr auto; gap: .1rem .8rem; align-items: center; width: 100%; padding: .75rem .9rem; border: 1px solid var(--trait); border-radius: var(--rayon);
  background: var(--surface); color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.carte b { grid-column: 1; overflow: hidden; text-overflow: ellipsis; }
.carte span { grid-column: 1; color: var(--encre-douce); font-size: .88rem; }
.carte .montant, .carte .pastille { grid-column: 2; grid-row: 1 / span 2; color: var(--encre); font-weight: 600; white-space: nowrap; }
.carte .pastille { font-size: .8rem; font-weight: 600; color: var(--encre-douce); }
.carte.fait b { text-decoration: line-through; color: var(--encre-douce); }
.carte.inactif { opacity: .55; }
.carte:disabled { cursor: default; }
.fiche, .pieces { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1rem; margin-bottom: 1rem; }
.journal { font-size: .86rem; }
.ligne-journal { display: grid; grid-template-columns: 9.5rem 8rem 1fr; gap: .1rem .7rem; padding: .45rem 0; border-bottom: 1px solid var(--trait); }
.ligne-journal .discret { grid-column: 1 / -1; font-size: .84rem; }

/* ---------- messages et fenêtres ---------- */
.toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 1rem); max-width: min(92vw, 480px); padding: .7rem 1rem; border-radius: 999px;
  background: var(--encre); color: #fff; font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 40; text-align: center; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.erreur { background: var(--alerte); border-radius: var(--rayon); }
.modale-fond { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(16, 24, 32, .45); padding: 0; }
.modale { width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 18px 18px 0 0; padding: 1.2rem 1.1rem calc(1.2rem + env(safe-area-inset-bottom, 0px)); }
.modale h2 { margin: 0 0 .6rem; }

/* ---------- visionneuse de documents ---------- */
.visio { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #20262d; color: #fff; }
.visio-tete, .visio-pied { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; background: #161b21; }
.visio-tete { padding-top: calc(.5rem + env(safe-area-inset-top, 0px)); }
.visio-pied { justify-content: space-between; padding-bottom: calc(.5rem + env(safe-area-inset-bottom, 0px)); }
.visio-pied .discret { color: #b9c2cc; }
.visio-titre { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.visio-titre b, .visio-titre span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visio-titre span { font-size: .78rem; color: #b9c2cc; }
.visio-outils { display: flex; align-items: center; gap: .35rem; }
.visio .rond, .visio .btn { background: #2c343d; border-color: #3b4651; color: #fff; }
.visio-corps { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; outline: none; }
.visio-attente { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7rem; padding: 2rem; text-align: center; color: #d5dce3; }
.visio-attente.erreur { color: #ffb4ab; }
.visio-image { padding: .6rem; }
.visio-image img { display: block; width: calc(100% * var(--zoom, 1)); max-width: none; margin: 0 auto; background: #fff; }
.visio-pages { width: calc(100% * var(--zoom, 1)); max-width: calc(900px * var(--zoom, 1)); margin: 0 auto; padding: .6rem; display: grid; gap: .6rem; }
.visio-page { aspect-ratio: 1 / var(--ratio, 1.414); background: #fff; }
.visio-page canvas { display: block; width: 100%; height: auto; }
.roue { width: 34px; height: 34px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* ---------- écrans larges ---------- */
@media (min-width: 720px) {
  .modale-fond { align-items: center; padding: 1rem; }
  .modale { border-radius: 18px; padding: 1.4rem; }
  .cartes { gap: .5rem; }
}
/* ---------- téléphones : navigation en bas, sous le pouce ---------- */
@media (max-width: 719px) {
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; margin: 0; justify-content: space-around; padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface); color: var(--encre); border-top: 1px solid var(--trait); }
  #nav a { flex: 1; text-align: center; opacity: .7; }
  #nav a.actif { background: color-mix(in srgb, var(--marque) 12%, transparent); color: var(--marque); opacity: 1; }
  .marque { flex: 1; }
  .ligne-journal { grid-template-columns: 1fr 1fr; }
  .toast { bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px)); }
  .visio-outils .btn[data-visio="ajuster"] { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition: none !important; } }
.attente { color: #8a5a00; font-style: normal; font-weight: 600; }
