/* Socle : couleurs, typographie, éléments de formulaire, structure de l'application. */
:root {
  --papier: #f4f5f6;
  --feuille: #ffffff;
  --creux: #eceef0;
  --encre: #16181c;
  --gris: #5f6670;
  --pale: #959ba4;
  --trait: #dfe2e6;
  --trait-fort: #c5cad1;
  --prune: #2b2f36;
  --prune-fonce: #14171c;
  --prune-pale: #eceef1;
  --sarcelle: #0f6b73;
  --sarcelle-pale: #dff1f2;
  --stylo: #1f3fa6;
  --stylo-pale: #e8edfb;
  --ambre: #a8690a;
  --ambre-pale: #fbf0d9;
  --vert: #24754a;
  --vert-pale: #e0f2e8;
  --rouge: #b3261e;
  --rouge-pale: #fbe6e3;
  --ardoise: #5b6472;
  --ardoise-pale: #e9ecf0;
  --rayon: 10px;
  --rayon-petit: 6px;
  --ombre: 0 1px 2px rgba(20, 24, 30, .06), 0 6px 20px rgba(20, 24, 30, .06);
  --police: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --titre: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --barre: 58px;
  --bas: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--papier); color: var(--encre);
  font: 15px/1.45 var(--police); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--titre); margin: 0; letter-spacing: -.015em; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.12rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--stylo); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.chiffre { font-variant-numeric: tabular-nums; }
.discret { color: var(--gris); }
.petit { font-size: .85rem; }
.droite { text-align: right; }
.centre { text-align: center; }
.pousse { margin-left: auto; }
.nowrap { white-space: nowrap; }

/* ---------- Boutons ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
.b {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 40px; padding: 0 14px; border-radius: var(--rayon-petit);
  border: 1px solid var(--trait-fort); background: var(--feuille); font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none; color: var(--encre);
}
.b:hover { background: var(--creux); text-decoration: none; }
.b:active { transform: translateY(1px); }
.b svg { width: 18px; height: 18px; flex: none; }
.b.plein { background: var(--prune); border-color: var(--prune); color: #fff; }
.b.plein:hover { background: var(--prune-fonce); }
.b.calme { border-color: transparent; background: transparent; }
.b.calme:hover { background: var(--creux); }
.b.danger { color: var(--rouge); }
.b.grand { min-height: 50px; padding: 0 20px; font-size: 1.02rem; }
.b.menu { min-height: 34px; padding: 0 10px; font-size: .88rem; }
.b.carre { padding: 0; width: 40px; }
.b.menu.carre { width: 34px; }
.b[disabled] { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--stylo); outline-offset: 2px; }

/* ---------- Champs ---------- */
.champ { display: grid; gap: 4px; min-width: 0; }
.champ > span { font-size: .82rem; font-weight: 600; color: var(--gris); }
input[type=text], input[type=search], input[type=email], input[type=tel], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid var(--trait-fort); border-radius: var(--rayon-petit);
  background: var(--feuille); color: var(--stylo); font-weight: 500;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--pale); font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--stylo); outline-offset: 0; border-color: var(--stylo); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--prune); }
.grille { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grille.serree { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.rangee { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rangee.fin { justify-content: flex-end; }
.pile { display: grid; gap: 14px; }
.pile.serree { gap: 8px; }
.case { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

/* ---------- Structure : barre haute sur ordinateur, barre basse sur téléphone ---------- */
.haut {
  position: sticky; top: 0; z-index: 30; height: var(--barre); display: flex; align-items: center; gap: 6px;
  padding: 0 18px; background: var(--feuille); border-bottom: 1px solid var(--trait);
}
.marque { display: flex; align-items: center; gap: 9px; font: 700 1.02rem var(--titre); color: var(--encre); margin-right: 14px; }
.marque svg { width: 30px; height: 30px; }
.marque:hover { text-decoration: none; }
.onglets { display: flex; gap: 2px; align-self: stretch; overflow-x: auto; scrollbar-width: none; }
.onglets a {
  display: flex; align-items: center; padding: 0 12px; color: var(--gris); font-weight: 600; border-bottom: 3px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.onglets a:hover { color: var(--encre); text-decoration: none; }
.onglets a[aria-current] { color: var(--prune); border-bottom-color: var(--prune); }
.cloche { position: relative; }
.cloche i { position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--rouge); color: #fff; font: 700 11px/17px var(--police); text-align: center; font-style: normal; }
.pastille-nom { width: 34px; height: 34px; border-radius: 50%; background: var(--prune-pale); color: var(--prune); font-weight: 700; border: 0; cursor: pointer; }
main { max-width: 1240px; margin: 0 auto; padding: 22px 18px 60px; }
main.large { max-width: none; }
.entete { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.entete .sous { color: var(--gris); margin-top: 3px; }
.bas { display: none; }

@media (max-width: 860px) {
  body { font-size: 16px; }
  .haut { padding: 0 12px; }
  .haut .onglets, .haut .nouvelle span { display: none; }
  .haut .nouvelle { display: none; }
  .marque { margin-right: auto; }
  main { padding: 14px 12px calc(92px + var(--bas)); }
  .bas {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--feuille); border-top: 1px solid var(--trait); padding-bottom: var(--bas);
  }
  .bas a, .bas button {
    display: grid; justify-items: center; gap: 2px; padding: 8px 0 7px; font-size: .7rem; font-weight: 600; color: var(--gris);
    border: 0; background: none; cursor: pointer;
  }
  .bas svg { width: 23px; height: 23px; }
  .bas [aria-current] { color: var(--prune); }
  .bas .plus-fiche span { width: 46px; height: 46px; margin-top: -20px; border-radius: 50%; background: var(--prune); color: #fff; display: grid; place-items: center; box-shadow: var(--ombre); }
  .bas a:hover { text-decoration: none; }
  h1 { font-size: 1.35rem; }
}

/* ---------- Surfaces ---------- */
.feuille { background: var(--feuille); border: 1px solid var(--trait); border-radius: var(--rayon); }
.feuille.marge { padding: 16px; }
.bloc { padding: 16px; border-bottom: 1px solid var(--trait); }
.bloc:last-child { border-bottom: 0; }
.bloc > h2, .bloc > .titre-bloc { margin-bottom: 12px; }
.titre-bloc { display: flex; align-items: center; gap: 8px; }
.vide { padding: 34px 16px; text-align: center; color: var(--gris); }
.vide strong { display: block; color: var(--encre); margin-bottom: 4px; font-size: 1.02rem; }
.vide .b { margin-top: 14px; }

/* Numéro de fiche : écrit comme au stylo sur la fiche papier. */
.numero { font: 700 .92rem var(--titre); color: var(--stylo); font-variant-numeric: tabular-nums; letter-spacing: .01em; white-space: nowrap; }
.numero.grand { font-size: 1.5rem; padding: 4px 12px; border: 1.5px solid var(--stylo); border-radius: 8px; background: var(--feuille); }

.etat { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 20px; font-size: .78rem; font-weight: 650; white-space: nowrap; background: var(--ardoise-pale); color: var(--ardoise); }
.etat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.t-prune { background: var(--sarcelle-pale); color: var(--sarcelle); }
.t-stylo { background: var(--stylo-pale); color: var(--stylo); }
.t-ambre { background: var(--ambre-pale); color: var(--ambre); }
.t-vert { background: var(--vert-pale); color: var(--vert); }
.t-rouge { background: var(--rouge-pale); color: var(--rouge); }
.t-ardoise { background: var(--ardoise-pale); color: var(--ardoise); }

/* Filtres en segments avec compteur. */
.segments { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.segments button {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px; border: 1px solid var(--trait-fort);
  border-radius: 20px; background: var(--feuille); font-weight: 600; color: var(--gris); cursor: pointer; white-space: nowrap;
}
.segments button b { font-variant-numeric: tabular-nums; color: var(--pale); font-weight: 650; }
.segments button[aria-pressed=true] { background: var(--encre); border-color: var(--encre); color: #fff; }
.segments button[aria-pressed=true] b { color: #c9cdd3; }

/* ---------- Tableaux ---------- */
.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; font-weight: 650; color: var(--gris); padding: 9px 12px; border-bottom: 1px solid var(--trait); white-space: nowrap; background: var(--feuille); }
td { padding: 10px 12px; border-bottom: 1px solid var(--trait); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.cliquable { cursor: pointer; }
tr.cliquable:hover td { background: #f7f8f9; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--trait-fort); border-bottom: 0; }
td input, td select { min-height: 36px; padding: 5px 8px; }

/* ---------- Calques : dialogues et tiroirs ---------- */
.voile { position: fixed; inset: 0; z-index: 60; background: rgba(22, 24, 28, .42); display: grid; place-items: center; padding: 16px; }
.dialogue {
  width: min(100%, var(--largeur, 560px)); max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--feuille); border-radius: 14px; box-shadow: 0 20px 60px rgba(22, 24, 28, .3); overflow: hidden;
}
.dialogue > header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--trait); }
.dialogue > .corps { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dialogue > footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--trait); background: #fafafb; flex-wrap: wrap; }
@media (max-width: 860px) {
  .voile { padding: 0; place-items: end stretch; }
  .dialogue { width: 100%; max-height: 94dvh; border-radius: 16px 16px 0 0; padding-bottom: var(--bas); }
  .dialogue > footer .b { flex: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .dialogue { animation: monte .16s ease-out; }
  @keyframes monte { from { transform: translateY(12px); opacity: 0; } }
}

#annonces { position: fixed; z-index: 90; left: 50%; bottom: calc(84px + var(--bas)); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.annonce { padding: 11px 14px; border-radius: 9px; background: var(--encre); color: #fff; font-weight: 550; box-shadow: var(--ombre); }
.annonce.erreur { background: var(--rouge); }

.menu-flottant { position: absolute; z-index: 70; min-width: 220px; padding: 6px; background: var(--feuille); border: 1px solid var(--trait); border-radius: 10px; box-shadow: var(--ombre); }
.menu-flottant button, .menu-flottant a { display: flex; width: 100%; gap: 9px; align-items: center; padding: 9px 10px; border: 0; background: none; border-radius: 6px; text-align: left; cursor: pointer; color: var(--encre); font-weight: 550; }
.menu-flottant button:hover, .menu-flottant a:hover { background: var(--creux); text-decoration: none; }
.menu-flottant svg { width: 18px; height: 18px; color: var(--gris); }
.menu-flottant hr { border: 0; border-top: 1px solid var(--trait); margin: 5px 0; }

/* ---------- Connexion ---------- */
.porte { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.porte .cote { background: var(--prune); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.porte .cote h1 { font-size: clamp(2rem, 4vw, 3.1rem); font-weight: 700; line-height: 1.05; max-width: 9em; }
.porte .cote svg { width: 56px; height: 56px; }
.porte .cote p { opacity: .82; max-width: 30em; }
.porte form { align-self: center; justify-self: center; width: min(100%, 380px); padding: 28px; display: grid; gap: 14px; }
@media (max-width: 860px) {
  .porte { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .porte .cote { padding: 28px 22px; gap: 26px; }
  .porte .cote p { display: none; }
  .porte form { align-self: start; padding: 26px 22px; }
}
@media print {
  .haut, .bas, #annonces, .sans-impression { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .feuille { border: 0; }
}
