:root {
  --fond: #f5f6f8; --carte: #ffffff; --texte: #14181f; --doux: #4a5362;
  --ligne: #d5d9e0; --accent: #183a70; --accent-texte: #ffffff;
  --argent: #0b6b3a; --danger: #b3261e; --alerte-fond: #fff3cd; --alerte-texte: #5c4300;
  --barre: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1319; --carte: #1a2029; --texte: #f1f3f6; --doux: #aab3c2;
    --ligne: #343c49; --accent: #7fb0ff; --accent-texte: #0b1220;
    --argent: #5fd493; --danger: #ff8a80; --alerte-fond: #3d3210; --alerte-texte: #ffe08a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 18px; }
body {
  margin: 0; background: var(--fond); color: var(--texte); line-height: 1.4;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
main {
  max-width: 640px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(var(--barre) + env(safe-area-inset-bottom) + 96px);
}
h1 { font-size: 1.6rem; margin: 4px 0 16px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Barre d'onglets */
#onglets {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--carte); border-top: 1px solid var(--ligne);
  padding-bottom: env(safe-area-inset-bottom);
}
#onglets[hidden] { display: none; }
#onglets a, #onglets button {
  flex: 1; height: var(--barre); display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 0.85rem; font-weight: 600; color: var(--doux);
  text-decoration: none; background: none; border: 0; padding: 0 2px; line-height: 1.2;
}
#onglets .actif { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* Cartes, boutons */
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; margin-bottom: 14px; overflow: hidden; }
.bouton {
  min-height: 52px; padding: 0 20px; border-radius: 12px; border: 2px solid var(--accent);
  background: var(--accent); color: var(--accent-texte); font-weight: 700;
}
.bouton.second { background: transparent; color: var(--accent); }
.bouton.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.bouton.large { width: 100%; }
.rangee { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.rangee > * { flex: 1; }
.vide { color: var(--doux); text-align: center; padding: 40px 12px; font-size: 1.1rem; }
.erreur { color: var(--danger); font-weight: 600; margin: 8px 0; }

/* To-do */
.groupe > summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 60px; padding: 8px 16px; font-weight: 700; font-size: 1.1rem; cursor: pointer;
}
.groupe > summary::-webkit-details-marker { display: none; }
.groupe > summary::after { content: "▾"; color: var(--doux); margin-left: auto; padding-left: 8px; }
.groupe:not([open]) > summary::after { content: "▸"; }
.groupe .total { color: var(--argent); font-weight: 800; }
.groupe .nb { color: var(--doux); font-weight: 600; }
.tache { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-top: 1px solid var(--ligne); }
.case { width: 32px; height: 32px; margin: 0; accent-color: var(--accent); }
.zone-case { flex: none; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; margin: -6px 0 -6px -8px; }
.tache .corps { flex: 1; min-width: 0; }
.tache .titre { font-size: 1rem; word-wrap: break-word; }
.tache .note { color: var(--doux); font-size: 0.85rem; }
.montant {
  background: none; border: 0; padding: 6px 0; min-height: 48px; text-align: left;
  color: var(--argent); font-weight: 800; font-size: 1rem;
}
.montant.vide-m { color: var(--doux); font-weight: 600; text-decoration: underline; }
.montant .est { font-weight: 600; color: var(--doux); }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--barre) + env(safe-area-inset-bottom) + 16px);
  min-height: 56px; border-radius: 28px; padding: 0 22px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

/* Agenda */
.bascule { display: flex; border: 2px solid var(--accent); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.bascule button { flex: 1; min-height: 48px; border: 0; background: transparent; color: var(--accent); font-weight: 700; }
.bascule .actif { background: var(--accent); color: var(--accent-texte); }
.nav-jour { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.nav-jour .bouton { min-height: 48px; padding: 0 16px; flex: none; }
.nav-jour .libelle { flex: 1; text-align: center; font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
.rdv { display: block; width: 100%; text-align: left; background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; padding: 12px 16px; margin-bottom: 10px; }
.rdv .quand { color: var(--accent); font-weight: 700; font-size: 0.9rem; }
.rdv .quoi { font-weight: 700; font-size: 1.05rem; }
.rdv .ou { color: var(--doux); font-size: 0.9rem; }
.encart { background: var(--alerte-fond); color: var(--alerte-texte); border-radius: 14px; padding: 16px; margin-bottom: 14px; font-weight: 600; }
.encart .bouton { margin-top: 10px; }

/* Connexion */
.connexion { padding-top: 12vh; }
.connexion label { display: block; font-weight: 700; margin: 16px 0 6px; }
.connexion input { width: 100%; min-height: 52px; padding: 0 14px; border: 2px solid var(--ligne); border-radius: 12px; background: var(--carte); }

/* Feuille modale dans la page */
#feuille { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 10; }
#feuille[hidden] { display: none; }
.feuille-corps {
  background: var(--carte); width: 100%; max-width: 640px; margin: 0 auto; max-height: 92vh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.feuille-corps h2 { margin: 0 0 12px; font-size: 1.3rem; }
.feuille-corps label { display: block; font-weight: 700; margin: 12px 0 6px; font-size: 0.9rem; }
.feuille-corps input, .feuille-corps select {
  width: 100%; min-height: 52px; padding: 0 12px; border: 2px solid var(--ligne); border-radius: 12px; background: var(--fond);
}
