/* =========================================================================
   Gestion appartement familial — Feuille de style
   Design sobre et professionnel : bleu ardoise + accents, cartes claires.
   ========================================================================= */
:root {
  --bleu: #1e3a5f;
  --bleu-clair: #2f5480;
  --bleu-pale: #eef3f9;
  --or: #c8992e;
  --vert: #1f9d55;
  --vert-pale: #e8f6ee;
  --rouge: #c0392b;
  --rouge-pale: #fdecea;
  --orange: #d98014;
  --orange-pale: #fdf2e2;
  --gris-txt: #1f2937;
  --gris-doux: #6b7280;
  --gris-bord: #e5e7eb;
  --fond: #f4f6fb;
  --blanc: #ffffff;
  --ombre: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --ombre-forte: 0 8px 24px rgba(16,24,40,.12);
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--gris-txt);
  background: var(--fond);
  line-height: 1.55;
}
a { color: var(--bleu-clair); }
h1, h2, h3 { color: var(--bleu); line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 0 0 .3em; }
small { color: var(--gris-doux); }

/* ---------- Barre supérieure ---------- */
.topbar { background: var(--bleu); color: #fff; box-shadow: var(--ombre); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1180px; margin: auto; display: flex; align-items: center; gap: 1rem; padding: .55rem 1.1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 700; }
.brand-logo { font-size: 1.6rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { color: #b9c7da; font-weight: 400; font-size: .72rem; }
.mainnav { display: flex; gap: .2rem; margin-left: auto; flex-wrap: wrap; }
.mainnav a { color: #d7e1ee; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font-size: .92rem; font-weight: 500; white-space: nowrap; }
.mainnav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.mainnav a.actif { background: #fff; color: var(--bleu); }
.mainnav a.aide-link { border: 1px solid rgba(255,255,255,.3); }
.user-chip { display: flex; align-items: center; gap: .5rem; padding-left: .8rem; border-left: 1px solid rgba(255,255,255,.2); }
.user-name { font-weight: 600; }
.user-role { font-size: .68rem; padding: .12rem .5rem; border-radius: 999px; background: rgba(255,255,255,.16); text-transform: uppercase; letter-spacing: .03em; }
.role-superadmin { background: var(--or); color: #26200a; }
.role-admin { background: #5aa9e6; color: #06263f; }
.btn-logout { color: #d7e1ee; text-decoration: none; font-size: .85rem; padding: .3rem .6rem; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; }
.btn-logout:hover { background: rgba(255,255,255,.12); color:#fff; }
.menu-toggle { display: none; background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; font-size: 1.2rem; border-radius: 8px; padding: .2rem .5rem; cursor: pointer; }

/* ---------- Zone principale ---------- */
.page { max-width: 1180px; margin: 1.4rem auto 3rem; padding: 0 1.1rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head .lead { color: var(--gris-doux); max-width: 60ch; margin: .2rem 0 0; }

/* ---------- Messages flash ---------- */
.flash { padding: .8rem 1.1rem; border-radius: 10px; margin-bottom: 1.1rem; font-weight: 500; border: 1px solid transparent; }
.flash-succes { background: var(--vert-pale); color: #0f6b39; border-color: #bfe6cf; }
.flash-erreur { background: var(--rouge-pale); color: #9b2318; border-color: #f3c2bc; }
.flash-info { background: var(--bleu-pale); color: var(--bleu); border-color: #cdddef; }

/* ---------- Encadré pédagogique ---------- */
.info-box { background: var(--bleu-pale); border: 1px solid #d5e2f0; border-left: 4px solid var(--bleu-clair); border-radius: 10px; padding: .9rem 1.1rem; margin-bottom: 1.2rem; }
.info-box h3 { margin: 0 0 .35rem; font-size: 1rem; display: flex; align-items: center; gap: .4rem; }
.info-box p { margin: .3rem 0; }
.info-box.astuce { background: var(--orange-pale); border-color: #f2d9b3; border-left-color: var(--orange); }
.info-box.astuce h3 { color: var(--orange); }

/* ---------- Cartes ---------- */
.card { background: var(--blanc); border: 1px solid var(--gris-bord); border-radius: var(--radius); box-shadow: var(--ombre); padding: 1.2rem 1.3rem; margin-bottom: 1.2rem; }
.card h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card-title-row h2 { margin: 0; }

/* ---------- Grille de statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: var(--blanc); border: 1px solid var(--gris-bord); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--ombre); }
.stat .label { color: var(--gris-doux); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; gap: .4rem; }
.stat .val { font-size: 1.7rem; font-weight: 700; color: var(--bleu); margin-top: .25rem; }
.stat .sub { font-size: .82rem; color: var(--gris-doux); margin-top: .2rem; }
.stat.accent-vert .val { color: var(--vert); }
.stat.accent-rouge .val { color: var(--rouge); }
.stat.accent-or { border-top: 3px solid var(--or); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.grid th, table.grid td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--gris-bord); }
table.grid th { background: var(--bleu-pale); color: var(--bleu); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
table.grid tbody tr:hover, table.grid tr:hover { background: #fafbfe; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.total-row td { font-weight: 700; background: var(--bleu-pale); border-top: 2px solid var(--bleu-clair); }
.montant-pos { color: var(--vert); font-weight: 600; }
.montant-neg { color: var(--rouge); font-weight: 600; }

/* ---------- Badges de statut ---------- */
.badge { display: inline-block; padding: .18rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge-paye { background: var(--vert-pale); color: #0f6b39; }
.badge-attente { background: var(--bleu-pale); color: var(--bleu); }
.badge-retard { background: var(--rouge-pale); color: #9b2318; }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem 1.1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .88rem; }
label .hint { font-weight: 400; color: var(--gris-doux); font-size: .8rem; }
input, select, textarea { font: inherit; padding: .55rem .65rem; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--gris-txt); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--bleu-clair); box-shadow: 0 0 0 3px rgba(47,84,128,.15); }
textarea { min-height: 70px; resize: vertical; }

/* ---------- Champ mot de passe avec bouton "œil" ---------- */
.champ-mdp { position: relative; display: flex; }
.champ-mdp input { flex: 1; padding-right: 2.4rem; }
.btn-oeil { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1rem; padding: .3rem .4rem; line-height: 1; border-radius: 6px; }
.btn-oeil:hover { background: var(--gris-bord); }
.form-actions { margin-top: 1rem; display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 600; padding: .6rem 1.1rem; border-radius: 9px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--bleu); color: #fff; }
.btn-primary:hover { background: var(--bleu-clair); }
.btn-or { background: var(--or); color: #26200a; }
.btn-or:hover { filter: brightness(1.05); }
.btn-ghost { background: #fff; border-color: #cbd5e1; color: var(--bleu); }
.btn-ghost:hover { background: var(--bleu-pale); }
.btn-danger { background: #fff; border-color: #e7b7b1; color: var(--rouge); }
.btn-danger:hover { background: var(--rouge-pale); }
.btn-sm { padding: .32rem .6rem; font-size: .82rem; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--gris-doux); font-size: .95rem; padding: .2rem .4rem; border-radius: 6px; }
.btn-icon:hover { background: var(--gris-bord); color: var(--rouge); }

/* ---------- Connexion ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #1e3a5f, #2f5480); padding: 1.2rem; }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--ombre-forte); padding: 2.2rem 2rem; width: 100%; max-width: 400px; }
.auth-card .brand-logo { font-size: 2.4rem; }
.auth-head { text-align: center; margin-bottom: 1.4rem; }
.auth-head h1 { font-size: 1.35rem; margin: .4rem 0 .2rem; }
.auth-head p { color: var(--gris-doux); margin: 0; font-size: .9rem; }
.auth-card .field { margin-bottom: .9rem; }
.auth-card .btn { width: 100%; justify-content: center; }

/* ---------- Divers ---------- */
.muted { color: var(--gris-doux); }
.pill-cats { display: flex; flex-wrap: wrap; gap: .3rem; }
.mini { font-size: .82rem; }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.2rem; align-items: start; }
.progress { height: 10px; background: var(--gris-bord); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--vert); }
.list-clean { list-style: none; padding: 0; margin: 0; }
.list-clean li { padding: .5rem 0; border-bottom: 1px solid var(--gris-bord); display: flex; justify-content: space-between; gap: .6rem; }
.list-clean li:last-child { border-bottom: none; }
details.faq { border: 1px solid var(--gris-bord); border-radius: 10px; padding: .3rem .9rem; margin-bottom: .6rem; background: #fff; }
details.faq summary { cursor: pointer; font-weight: 600; padding: .5rem 0; color: var(--bleu); }
details.faq[open] summary { border-bottom: 1px solid var(--gris-bord); margin-bottom: .5rem; }

/* ---------- Pied de page ---------- */
.footer { text-align: center; color: var(--gris-doux); font-size: .84rem; padding: 1.5rem 1rem 2.5rem; }
.footer-note { margin-top: .3rem; color: var(--orange); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .menu-toggle { display: block; order: 3; margin-left: auto; }
  .mainnav { display: none; width: 100%; flex-direction: column; order: 4; }
  body.nav-open .mainnav { display: flex; }
  .user-chip { order: 5; width: 100%; border-left: none; padding-left: 0; }
  .two-col { grid-template-columns: 1fr; }
}
