/* ==========================================================================
   Système de design commun (site public, espaces des comptes et gestion).
   Formes et composants repris de la v3 d'Adarka Fueling ; AUCUNE couleur ici : toutes viennent de theme.css,
   calculé depuis la couleur de la marque (API : classes/Theme.php), en clair et en sombre.
   Une page n'a ni <style> ni couleur écrite en dur ; un composant qui manque s'ajoute ici.

   Règles : tout aligné à gauche, montants compris ; libellé sur les boutons d'action ; sur téléphone, les tableaux
   gardent toutes leurs colonnes et défilent dans leur cadre.
   ========================================================================== */

/* ---------- Police (DM Sans, hébergée ici ; licence OFL) ---------- */
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 100 1000; font-display: swap;
  src: url(../polices/dm-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 100 1000; font-display: swap;
  src: url(../polices/dm-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- Jetons hors couleur ---------- */
:root {
  --gouttiere: 24px;   /* marge gauche et droite des pages (au moins 20 px sur téléphone) */
  --r-champ: 16px; --r-carte: 22px; --r-feuille: 28px; --r-complet: 999px;
  --ombre-carte: 0 6px 18px rgba(23, 32, 51, .05);
  --ombre-flottant: 0 18px 44px rgba(23, 32, 51, .22);
  --d-appui: 90ms; --d-court: 180ms; --d-moyen: 260ms;
  --c-sortie: cubic-bezier(.33, 1, .68, 1);
  --voile-fond: rgba(15, 21, 34, .45); --voile-flou: saturate(1.15) blur(8px);
  /* Valeurs de secours si theme.css ne charge pas (API injoignable) */
  --police: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
html.dark { --ombre-carte: 0 3px 12px rgba(0, 0, 0, .18); --ombre-flottant: 0 14px 36px rgba(0, 0, 0, .38); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--police); font-size: 15px; line-height: 1.5; color: var(--encre, #18202F); background: var(--fond, #F5F6F8); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; font-weight: 700; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent-texte); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
code { font-size: .92em; }
:focus-visible { outline: none; box-shadow: var(--anneau); }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; margin: -1px !important; padding: 0 !important; border: 0 !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.attenue { color: var(--attenue); }
.discret { color: var(--discret); }
.chiffres { font-variant-numeric: tabular-nums; }
.en-ligne { display: inline; margin: 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
/* Pas de zoom automatique sur iOS : tout champ fait au moins 16 px sur écran tactile. */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]), select, textarea { font-size: max(16px, 1em) !important; }
}
.aller-contenu { position: absolute; left: 12px; top: -60px; z-index: 2000; padding: 10px 16px; border-radius: var(--r-complet); background: var(--accent); color: var(--sur-accent); font-weight: 700; }
.aller-contenu:focus { top: 12px; }

/* Thème : la bonne icône et le bon logo pour le mode affiché */
html.dark .theme-sombre, html:not(.dark) .theme-clair { display: none; }
html.dark .logo-clair, html:not(.dark) .logo-sombre { display: none; }

/* ---------- Icônes (sprite Lucide) ---------- */
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic.petite { width: 16px; height: 16px; }
.ic.grande { width: 28px; height: 28px; }

/* Retour au toucher : l'élément se resserre */
.appui { transition: transform var(--d-appui) var(--c-sortie), background-color var(--d-court), border-color var(--d-court), box-shadow var(--d-court), color var(--d-court); }
.appui:active { transform: scale(.97); }

/* ---------- Boutons (pilule, 52 / compact 42 / mini 34) ---------- */
.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 24px; border: 1.5px solid transparent; border-radius: var(--r-complet); background: var(--accent); color: var(--sur-accent); font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.bouton:hover { background: var(--accent-survol); }
.bouton.plein-largeur { width: 100%; }
.bouton.compact { min-height: 42px; padding: 0 18px; font-size: 14px; }
.bouton.mini { min-height: 34px; padding: 0 14px; font-size: 13px; }
.bouton.doux { background: var(--accent-doux); color: var(--accent-texte); }
.bouton.doux:hover { background: var(--accent-doux-survol); }
.bouton.contour { background: transparent; border-color: var(--accent-trait); color: var(--accent-texte); }
.bouton.contour:hover { background: var(--accent-doux); }
.bouton.texte { background: transparent; color: var(--accent-texte); padding: 0 12px; }
.bouton.texte:hover { background: var(--accent-doux); }
.bouton.texte.neutre { color: var(--attenue); }
.bouton.texte.danger-texte { color: var(--danger); }
.bouton.texte.danger-texte:hover { background: var(--danger-doux); }
.bouton.danger { background: var(--danger); color: #fff; }
.bouton[disabled], fieldset[disabled] .bouton { opacity: .45; pointer-events: none; }
.bouton.en-cours { pointer-events: none; color: transparent !important; position: relative; }
.bouton.en-cours::after { content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--sur-accent) 40%, transparent); border-top-color: var(--sur-accent); animation: tourne .7s linear infinite; }
.bouton.doux.en-cours::after, .bouton.texte.en-cours::after { border-color: var(--accent-trait); border-top-color: var(--accent-texte); }
@keyframes tourne { to { transform: rotate(360deg); } }
.bouton-rond { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--attenue); cursor: pointer; flex: none; padding: 0; }
.bouton-rond:hover { background: var(--accent-doux); color: var(--accent-texte); }

/* ---------- Cartes ---------- */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r-carte); box-shadow: var(--ombre-carte); }
.carte-corps { padding: 24px; }
.carte-titre { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.carte-titre h2 { font-size: 17px; }
@media (max-width: 640px) { .carte-corps { padding: 22px 20px; } }

/* ---------- Pastilles (icône dans un rond teinté) ---------- */
.pastille { --t: 40px; display: inline-grid; place-items: center; width: var(--t); height: var(--t); border-radius: 50%; background: var(--accent-doux); color: var(--accent-texte); flex: none; }
.pastille .ic { width: calc(var(--t) * .5); height: calc(var(--t) * .5); }
.pastille.grande { --t: 56px; }

/* ---------- Champs : libellé qui flotte sur le bord ---------- */
.champ { position: relative; display: block; min-width: 0; }
.champ > input, .champ > select, .champ > textarea {
  display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 56px; padding: 22px 16px 8px; border: 1.5px solid var(--trait-fort); border-radius: var(--r-champ);
  background: var(--champ); font-size: 15px; line-height: 1.4; transition: border-color var(--d-court), box-shadow var(--d-court); appearance: none; -webkit-appearance: none;
}
.champ > textarea { resize: vertical; min-height: 96px; }
.champ > label { position: absolute; left: 17px; right: 16px; top: 8px; font-size: 12px; font-weight: 600; color: var(--attenue); pointer-events: none; transition: color var(--d-court); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.champ > input::placeholder, .champ > textarea::placeholder { color: var(--discret); }
.champ > input:hover, .champ > select:hover, .champ > textarea:hover { border-color: var(--discret); }
.champ > input:focus, .champ > select:focus, .champ > textarea:focus { outline: none; border-color: var(--focus); box-shadow: var(--anneau); }
.champ:focus-within > label { color: var(--accent-texte); }
.champ .fin { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.champ.avec-fin > input { padding-right: 56px; } .champ.avec-fin > label { right: 56px; }
.champ.en-erreur > input, .champ.en-erreur > select, .champ.en-erreur > textarea { border-color: var(--danger); }
/* Formulaires guidés (socle.js) : un champ amené à l'écran ne passe pas sous l'en-tête collant. */
form h2, form h3, form legend, form .reglage, form .champ, form .case, form [role="radiogroup"], form .actions-formulaire { scroll-margin-top: 88px; }
.champ > input[readonly] { background: var(--fond); }
fieldset[disabled] .champ > input, fieldset[disabled] .champ > select, fieldset[disabled] .champ > textarea { background: var(--fond); color: var(--attenue); }
.champ > select { padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237A8599' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; background-size: 18px; }
.aide { margin-top: 6px; padding: 0 4px; font-size: 13px; color: var(--attenue); }
.erreur-champ { margin-top: 6px; padding: 0 4px; font-size: 13px; font-weight: 600; color: var(--danger); }
/* Champ obligatoire : un « * » après le libellé, déduit de l'attribut required. */
.champ:has(> :is(input, select, textarea)[required]) > label::after, .obligatoire::after { content: '\00a0*'; color: var(--danger); font-weight: 700; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; font-weight: 700; font-size: 15px; margin-bottom: 12px; }

/* Cases à cocher : rondes partout ; boutons radio assortis */
input[type="checkbox"], input[type="radio"] { -webkit-appearance: none; appearance: none; flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; margin: 0;
  border: 2px solid var(--discret); border-radius: 50%; background: var(--carte) center / 12px 12px no-repeat; cursor: pointer; transition: background-color var(--d-court), border-color var(--d-court); }
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--accent); }
input[type="checkbox"]:checked { border-color: var(--accent); background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }
input[type="radio"]:checked { border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--carte); background-color: var(--accent); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .45; cursor: not-allowed; }
.case { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 600; font-size: 14.5px; }

/* Choix exclusif en tuiles (radios) */
.choix-radios { display: flex; flex-wrap: wrap; gap: 10px; }
.choix-radio { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 16px; border: 1.5px solid var(--trait-fort); border-radius: var(--r-champ); background: var(--champ); cursor: pointer; font-weight: 600; font-size: 14.5px; }
.choix-radio:has(input:checked) { border-color: var(--accent); background: var(--accent-doux); color: var(--accent-texte); }

/* ---------- Bandeaux ---------- */
.bandeau { --c: var(--info); --f: var(--info-doux); display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-champ); background: var(--f); color: var(--c); font-size: 14px; line-height: 1.5; }
.bandeau .ic { margin-top: 1px; }
.bandeau.alerte { --c: var(--alerte); --f: var(--alerte-doux); }
.bandeau.erreur { --c: var(--danger); --f: var(--danger-doux); }
.bandeau.succes { --c: var(--succes); --f: var(--succes-doux); }

/* ---------- Puces (étiquettes d'état, compteurs) ---------- */
.puce { --c: var(--attenue); display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 12px; border-radius: var(--r-complet); background: color-mix(in srgb, var(--c) 12%, var(--carte)); color: var(--c); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.puce.succes { --c: var(--succes); } .puce.alerte { --c: var(--alerte); } .puce.danger { --c: var(--danger); } .puce.marque { --c: var(--accent-texte); }
.puce.mini { min-height: 22px; padding: 0 9px; font-size: 11.5px; gap: 4px; }

/* ---------- Segments (choix exclusif compact) ---------- */
.segments { display: inline-flex; padding: 3px; border-radius: var(--r-complet); background: var(--fond); border: 1px solid var(--trait); gap: 2px; }
.segments button, .segments a { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; min-width: 40px; padding: 0 14px; border: 0; border-radius: var(--r-complet); background: none; color: var(--attenue); font-weight: 700; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.segments button[aria-pressed="true"], .segments a[aria-current="page"] { background: var(--carte); color: var(--accent-texte); box-shadow: var(--ombre-carte); }

/* ---------- Listes en rangées ---------- */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li + li { border-top: 1px solid var(--trait); }
.rangee { display: flex; align-items: center; gap: 14px; padding: 12px 20px; color: var(--encre); text-decoration: none !important; }
.rangee.sans-marge { padding-left: 0; padding-right: 0; }
a.rangee:hover { background: var(--survol); }
.rangee-texte { flex: 1; min-width: 0; }
.rangee-titre { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 14.5px; }
.rangee-sous { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: 13px; color: var(--attenue); }

/* ---------- Tableaux : tout à gauche ; sur téléphone, défilement dans le cadre ---------- */
.tableau-cadre { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau th, .tableau td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--trait); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tableau th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--attenue); background: var(--fond); }
.tableau tbody tr:hover { background: var(--survol); }

.vide { padding: 24px 8px; text-align: center; color: var(--attenue); font-size: 14px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-carte); background: #172033; color: #fff; box-shadow: var(--ombre-flottant); font-size: 14px; pointer-events: auto; animation: monte var(--d-moyen) var(--c-sortie); }
html.dark .toast { background: #2A3550; }

/* ---------- Voile et dialogue ---------- */
.voile { position: fixed; inset: 0; z-index: 900; background: var(--voile-fond); -webkit-backdrop-filter: var(--voile-flou); backdrop-filter: var(--voile-flou); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; animation: fondu var(--d-court); }
.voile > * { min-width: 0; max-width: 100%; }
.dialogue { width: min(420px, 100%); padding: 28px 24px 20px; border-radius: var(--r-feuille); background: var(--carte); text-align: center; box-shadow: var(--ombre-flottant); animation: monte var(--d-moyen) var(--c-sortie); }
.dialogue .pastille { margin: 0 auto 14px; }
.dialogue h2 { font-size: 19px; margin-bottom: 8px; }
.dialogue p { color: var(--attenue); font-size: 14.5px; }
.dialogue .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
@keyframes fondu { from { opacity: 0; } }
@keyframes monte { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* ---------- Champ piège (formulaires publics) : invisible pour une personne ---------- */
.piege { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Téléphone avec pays : drapeau + indicatif, puis le numéro (formulaires.php, socle.js) ---------- */
.champ-telephone { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: stretch; }
.champ-telephone.sans-pays { grid-template-columns: minmax(0, 1fr); }
.champ-telephone.sans-pays .choix-pays { display: none; }
.choix-pays > select { width: auto; max-width: 190px; }
.champ > select.pays-natif, select.pays-natif { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.choix-pays:has(.pays-bouton) > label { display: none; }
.pays-bouton { display: inline-flex; align-items: center; gap: 8px; height: 100%; min-height: 56px; padding: 0 12px 0 14px; border: 1.5px solid var(--trait-fort);
  border-radius: var(--r-champ); background: var(--champ); color: var(--encre); font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap; }
.pays-bouton:hover { border-color: var(--discret); }
.pays-bouton:focus-visible { border-color: var(--focus); box-shadow: var(--anneau); }
.pays-bouton .ic { color: var(--attenue); }
/* Pays seul dans un champ à libellé (Réglages › Région) : le bouton prend toute la largeur, sous le libellé. */
.champ.pays-plein > .pays-bouton { display: flex; width: 100%; padding: 18px 14px 0 16px; font-weight: 500; font-size: 15px; }
.champ.pays-plein > .pays-bouton .ic { margin-left: auto; }
fieldset[disabled] .pays-bouton { background: var(--fond); color: var(--attenue); pointer-events: none; }
.drapeau { width: 24px; height: 18px; flex: none; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); }
.pays-panneau { position: fixed; z-index: 1000; width: 320px; max-height: 340px; display: flex; flex-direction: column; overflow: hidden;
  background: var(--carte); border: 1px solid var(--trait); border-radius: 18px; box-shadow: var(--ombre-flottant); animation: fondu var(--d-court); }
@media (max-width: 640px) {
  .pays-panneau { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; max-height: 70dvh; animation: monte var(--d-moyen) var(--c-sortie); }
}
.pays-recherche { display: flex; align-items: center; gap: 8px; margin: 8px; padding: 0 12px; border-radius: var(--r-complet); background: var(--fond); color: var(--attenue); }
.pays-recherche input { flex: 1; min-width: 0; height: 42px; border: 0; background: none; outline: none; color: var(--encre); }
.pays-recherche:focus-within { box-shadow: var(--anneau); }
.pays-panneau ul { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; overscroll-behavior: contain; }
.pays-panneau li { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; cursor: pointer; font-size: 15px; }
.pays-panneau li:hover, .pays-panneau li:focus { background: var(--accent-doux); color: var(--accent-texte); outline: none; }
.pays-panneau li[aria-selected="true"] { font-weight: 700; }
.pays-nom { flex: 1; min-width: 0; }
.pays-indicatif { color: var(--attenue); font-variant-numeric: tabular-nums; }
/* Plusieurs pays : une tuile par pays (réglage « Pays ouverts à l'inscription ») */
.tuiles-pays { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tuile-pays { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; border: 1.5px solid var(--trait-fort);
  border-radius: var(--r-champ); background: var(--champ); cursor: pointer; font-size: 14.5px; }
.tuile-pays:has(input:checked) { border-color: var(--accent); background: var(--accent-doux); }
.tuile-pays .pays-nom { font-weight: 600; }
.tuile-pays:has(input:disabled) { cursor: default; }

/* ---------- Cloche (notifications non lues) ---------- */
.cloche { position: relative; }
.cloche-nombre { position: absolute; top: 2px; right: -1px; display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-complet); background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; box-shadow: 0 0 0 2px var(--carte); }
@media (max-width: 520px) { .masque-telephone { display: none; } }

/* ---------- Logo ---------- */
.logo { display: block; height: 36px; width: auto; max-width: 220px; object-fit: contain; }
.logo-texte { display: inline-block; height: auto; font-weight: 800; font-size: 19px; letter-spacing: -.02em; color: var(--encre); white-space: nowrap; }
.marque-lien { display: inline-flex; align-items: center; text-decoration: none !important; min-width: 0; }
