/* Interface de One (lot 4i, revue de la décision 038) : le téléphone d'abord, lisible sur ordinateur ; sombre si
   l'appareil l'est. Aucune ressource d'ailleurs (politique de sécurité : tout vient de ce site). */
:root {
  color-scheme: light dark;
  --fond: #f4f6f7;
  --carte: #ffffff;
  --encre: #17212b;
  --doux: #56626d;
  --filet: #e3e7ea;
  --bord: #7d8a96;
  --accent: #0f6e64;
  --sur-accent: #ffffff;
  --accent-clair: #e3f2ef;
  --rouge: #b42318;
  --rouge-clair: #fdecea;
  --orange: #b54708;
  --rayon: 12px;
  --pied: calc(60px + env(safe-area-inset-bottom));
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #11161b;
    --carte: #1a2128;
    --encre: #e7ecef;
    --doux: #9aa6b1;
    --filet: #2a333c;
    --bord: #6b7884;
    --accent: #46b3a5;
    --sur-accent: #0b1f1c;
    --accent-clair: #17322f;
    --rouge: #f97066;
    --rouge-clair: #3a1d1b;
    --orange: #f5a35c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--fond);
  color: var(--encre);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--pied) + 16px);
  caret-color: var(--accent);
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accent-clair); color: var(--encre); }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; }

/* En-tête : la marque et le titre de la page ; un filet qui court pendant un chargement */
.entete {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: baseline; gap: 12px;
  padding: 12px 16px; background: var(--carte); border-bottom: 1px solid var(--filet);
}
.marque { font-weight: 700; color: var(--accent); }
.titre { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.titre:focus { outline: none; }
.entete::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 30%;
  background: var(--accent); opacity: 0; transform: translateX(-100%);
}
body.charge .entete::after { opacity: 1; animation: course 1.1s cubic-bezier(.16, 1, .3, 1) infinite; }
@keyframes course { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.page { max-width: 760px; margin: 0 auto; padding: 16px; }
.page[aria-busy="true"] button { opacity: .6; pointer-events: none; }

/* Onglets : en bas, sous le pouce */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; justify-content: center; gap: 4px;
  background: var(--carte); border-top: 1px solid var(--filet);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.onglets a {
  flex: 1; max-width: 150px; display: flex; align-items: center; justify-content: center; min-height: 44px;
  border-radius: 10px; color: var(--doux); text-decoration: none; font-size: 14px;
}
.onglets a.actif { color: var(--accent); background: var(--accent-clair); font-weight: 600; }

/* Cartes et textes */
.carte { background: var(--carte); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 16px; margin: 0 0 16px; }
.carte h2 { font-size: 17px; font-weight: 650; margin: 0 0 10px; }
.carte h2.intertitre { margin-top: 18px; }
.carte h3 { font-size: 14px; font-weight: 600; margin: 18px 0 2px; color: var(--doux); }
.carte h3:first-of-type { margin-top: 4px; }
.carte h3.retard { color: var(--rouge); }
.carte > p:last-child { margin-bottom: 0; }
.doux { color: var(--doux); }
.petit { font-size: 14px; }
.negatif { color: var(--rouge); }
.note { margin: 10px 0 0; font-size: 14px; color: var(--doux); }

/* Le relevé : le mois en lignes, montants alignés à droite comme sur un relevé de compte */
.releve { margin: 0; }
.releve-ligne {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--filet);
}
.releve-ligne:first-child { padding-top: 2px; }
.releve-ligne:last-child { border-bottom: 0; padding-bottom: 0; }
.releve dt { min-width: 0; }
.releve dt .sous { display: block; font-size: 13px; color: var(--doux); margin-top: 1px; }
.releve dt .sous .negatif { color: var(--rouge); }
.releve dd { margin: 0; white-space: nowrap; font-weight: 600; }
.releve dd .cents { font-weight: 600; color: var(--doux); }
.releve.grand dd .cents { font-size: .62em; }
.releve dd.negatif .cents { color: inherit; }
.releve-ligne.total { border-top: 1px solid var(--encre); border-bottom: 0; margin-top: 2px; }
.releve-ligne.total dt { font-weight: 600; }
.releve.grand .releve-ligne { padding: 12px 0; }
.releve.grand dt { font-size: 15px; }
.releve.grand dd { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.compte { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--filet); font-size: 14px; color: var(--doux); }
.compte b { color: var(--encre); font-weight: 600; }

/* Listes : sur un téléphone, les boutons passent sous le texte au lieu de l'écraser */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li {
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; row-gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--filet);
}
.liste li:last-child { border-bottom: 0; }
.liste .quoi { flex: 1 1 9rem; min-width: 0; overflow-wrap: anywhere; }
.liste .quoi .sous { display: block; font-size: 14px; color: var(--doux); margin-top: 1px; }
.liste .combien { white-space: nowrap; margin-left: auto; }
.liste .actions { margin-left: auto; }
.liste a.suite { display: flex; align-items: center; justify-content: space-between; min-height: 44px; flex: 1; text-decoration: none; color: var(--encre); }
.liste a.suite::after {
  content: ""; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid var(--doux); border-bottom: 2px solid var(--doux); transform: rotate(-45deg);
}

/* La semaine : rendez-vous à leur heure, tâches avec leur case */
.semaine li { flex-wrap: wrap; }
.semaine .heure { flex: 0 0 4.6em; color: var(--accent); font-weight: 600; font-size: 14px; }
.semaine .tache .heure { color: var(--doux); font-weight: 400; }
.semaine .tache .quoi { display: flex; gap: 10px; align-items: baseline; }
.semaine .tache .quoi::before {
  content: ""; flex: 0 0 auto; width: 13px; height: 13px; border: 2px solid var(--bord); border-radius: 50%;
  transform: translateY(2px);
}
.semaine .tache.haute .quoi::before { border-color: var(--rouge); }

/* Le graphique des mois */
.barres { display: grid; gap: 8px; }
.barre { display: grid; grid-template-columns: 5.6em 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.barre .piste { height: 10px; background: var(--fond); border-radius: 5px; overflow: hidden; }
.barre .plein { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.barre .plein.rouge { background: var(--rouge); }
.barre .montant { text-align: right; min-width: 6.5em; }

/* Boutons et champs */
button, .bouton {
  font: inherit; font-size: 14px; min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--bord); background: var(--carte); color: var(--encre);
  border-radius: 8px; cursor: pointer;
}
button:hover { border-color: var(--encre); }
button.principal { background: var(--accent); color: var(--sur-accent); border-color: var(--accent); font-weight: 600; }
button.principal:hover { filter: brightness(1.08); }
button.danger { color: var(--rouge); }
button.lien { border-color: transparent; background: none; color: var(--accent); font-weight: 600; padding-inline: 8px; }
button.lien:hover { border-color: var(--bord); }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
form.ligne { display: grid; gap: 10px; }
input, select {
  font: inherit; padding: 8px 10px; min-height: 40px; width: 100%;
  border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--encre);
  accent-color: var(--accent);
}
input::placeholder { color: var(--doux); opacity: 1; }
label.champ { display: grid; gap: 4px; font-size: 14px; color: var(--doux); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.case { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 40px; }
label.case input { width: 20px; height: 20px; min-height: 0; margin: 0; }
.actions input[type="date"] { width: auto; }
@media (pointer: coarse), (max-width: 600px) {
  button, .bouton, input, select { min-height: 44px; }
  button { padding-inline: 10px; }
  .actions { gap: 6px; }
}

/* Avis : en bas de l'écran, au-dessus des onglets */
.avis {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--pied) + 12px); z-index: 3;
  max-width: 560px; margin: 0 auto; padding: 12px 14px; border-radius: 10px;
  background: var(--encre); color: var(--carte); font-size: 15px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  transition: transform .35s cubic-bezier(.16, 1, .3, 1), opacity .35s cubic-bezier(.16, 1, .3, 1);
}
.avis.erreur { background: var(--rouge); color: #fff; }
.avis[hidden] { display: block !important; opacity: 0; transform: translateY(16px); pointer-events: none; visibility: hidden; }
.alerte { background: var(--rouge-clair); color: var(--rouge); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }

.etiquette {
  display: inline-block; font-size: 12px; line-height: 1.3; padding: 3px 8px; border-radius: 10px;
  background: var(--fond); color: var(--doux); margin-left: 6px; white-space: nowrap; vertical-align: 1px;
}
.etiquette.alerte-douce { background: var(--rouge-clair); color: var(--rouge); }
.etiquette.ok { background: var(--accent-clair); color: var(--accent); }
.navmois { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.navmois b { font-size: 17px; }
.preuve { font-size: 13px; color: var(--doux); margin: 4px 0 0; }
.recherche { margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--filet); }
th { font-weight: 600; color: var(--doux); }
th.n, td.n { text-align: right; white-space: nowrap; }
tfoot td { border-bottom: 0; }
tfoot th { color: var(--encre); border-bottom: 0; border-top: 1px solid var(--encre); }
td .sous { display: block; font-size: 13px; color: var(--doux); margin-top: 1px; }
/* Mémoire par thèmes (décision 041) : un raccourci par thème */
.raccourcis { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.raccourcis button { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; }
.compte-theme { font-size: 12px; color: var(--doux); }
.carte[id] { scroll-margin-top: 72px; }
.liste a.suite .sous { display: block; font-size: 14px; color: var(--doux); margin-top: 1px; overflow-wrap: anywhere; }
.defile { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-color: var(--bord) transparent; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  body.charge .entete::after { animation: none; transform: none; width: 100%; opacity: .5; }
  .avis { transition: none; }
}
