/* =============================================================================
   École MCF Francilienne — interface
   Identité : marine #003554 + ciel #82D0F6 du logo, coupe diagonale à 45°
   (reprise du panneau ciel/marine de l'emblème), Poppins auto-hébergée.
   ============================================================================= */
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url(../fonts/poppins-regular.woff) format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url(../fonts/poppins-medium.woff) format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-display: swap; src: url(../fonts/poppins-bold.woff) format("woff"); }

:root {
  --navy: #003554; --navy-deep: #002539; --sky: #82d0f6; --sky-soft: #e4f4fd;
  --bg: #f2f6f9; --surface: #fff; --line: #dce6ed; --text: #0b2233; --muted: #5b7486;
  --primary: var(--navy); --on-primary: #fff;
  --ok: #2f7d4f; --ok-soft: #e3f3e9; --warn: #a96612; --warn-soft: #fcf0dc;
  --danger: #b4232f; --danger-soft: #fbe6e7;
  --r-lg: 20px; --r-md: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 37, 57, .06), 0 6px 20px -12px rgba(0, 37, 57, .25);
  --tab-h: calc(64px + env(safe-area-inset-bottom));
  --bar-h: calc(56px + env(safe-area-inset-top));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #001a2b; --surface: #042a42; --line: #0f3d5a; --text: #eaf4fb; --muted: #8fb3c9;
    --sky-soft: #0a3a57; --primary: var(--sky); --on-primary: #00253a;
    --ok: #6fd39a; --ok-soft: #0d3a2c; --warn: #f2b65c; --warn-soft: #3a2c12;
    --danger: #ff8a93; --danger-soft: #3d1820;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 400 15.5px/1.5 "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.err { color: var(--danger); }
.warn { background: var(--warn-soft); color: var(--warn); padding: .7rem .9rem; border-radius: var(--r-sm); font-size: .9rem; margin: 0 0 1rem; }
.loading { color: var(--muted); padding: 3rem 0; text-align: center; }
.empty { color: var(--muted); padding: .4rem 0; margin: 0; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* --- Barre de marque (haut) ------------------------------------------------ */
.appbar { position: sticky; top: 0; z-index: 20; height: var(--bar-h); padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; gap: 12px; background: var(--navy); color: #fff; }
.appbar .emblem { width: 38px; height: 38px; object-fit: contain; flex: none; }
.appbar .brand { flex: 1; min-width: 0; line-height: 1.1; }
.appbar .brand b { display: block; font-size: 1rem; }
.appbar .brand span { font-size: .72rem; color: var(--sky); font-weight: 500; }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: #fff; text-decoration: none; border: 2px solid rgba(255,255,255,.85); }

.view { padding: 18px 16px calc(var(--tab-h) + 96px); max-width: 720px; margin: 0 auto; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.bar h1 { flex: 1; }
.back { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -8px; border-radius: 50%;
  text-decoration: none; font-size: 1.7rem; line-height: 1; color: var(--text); }

/* --- Accueil : bandeau à coupe diagonale -------------------------------------- */
.hero { position: relative; margin: -18px -16px 1.2rem; padding: 22px 20px 26px; color: #fff;
  background: var(--navy); overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background: var(--sky);
  clip-path: polygon(80% 0, 100% 0, 100% 100%, 56% 100%); }
.hero > * { position: relative; }
.hero .hello { font-size: 1.55rem; font-weight: 700; max-width: 14ch; }
.hero .date { color: var(--sky); font-weight: 500; margin-top: .15rem; text-transform: capitalize; }
.hero .stats { display: flex; gap: .6rem; margin-top: 1.1rem; flex-wrap: wrap; }
.hero .stat { background: rgba(0, 37, 57, .78); backdrop-filter: blur(6px); border-radius: var(--r-md);
  padding: .55rem .85rem; text-decoration: none; color: #fff; min-width: 7.5rem; }
.hero .stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.hero .stat span { font-size: .78rem; color: #cfe9f8; }
.hero .stat.neg b { color: #ffb4ba; }

/* --- Sections / panneaux ------------------------------------------------------ */
.section { margin-bottom: 1.4rem; }
.section > h2 { margin: 0 2px .55rem; display: flex; justify-content: space-between; align-items: baseline; }
.section > h2 a { font-size: .85rem; font-weight: 500; color: var(--muted); }
.card { background: var(--surface); border-radius: var(--r-lg); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card > h2 { margin-bottom: .6rem; }
.stack { display: flex; flex-direction: column; gap: .85rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .55rem; align-items: end; }
@media (max-width: 440px) { .grid2 { grid-template-columns: 1fr; } .grid3 { grid-template-columns: 1fr 1fr; } }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* Listes : panneau unique, lignes séparées (pas une carte par ligne) */
.list { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .8rem 1rem;
  color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); min-height: 60px; }
.list > .item:last-child, .card .item:last-child { border-bottom: 0; }
.card .item { padding: .7rem 0; }
a.item:active { background: var(--sky-soft); }
.item .main { flex: 1; min-width: 0; }
.item .main b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { display: block; font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list .empty, .list > p { padding: 1rem; }

/* --- Formulaires ------------------------------------------------------------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 500; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .7rem; color: var(--text); font-size: .95rem; font-weight: 400; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1.5px solid transparent; border-radius: var(--r-sm); padding: .65rem .8rem; width: 100%; min-height: 48px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky); background: var(--surface); }
input[type=checkbox] { width: 22px; min-height: 22px; accent-color: var(--navy); }
input[type=color] { padding: 4px; }
textarea { resize: vertical; }
details > summary { cursor: pointer; font-weight: 500; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 48px;
  padding: .6rem 1.15rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 38px; padding: .35rem .9rem; font-size: .88rem; }
.btn:disabled { opacity: .5; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--muted); font: inherit; padding: .5rem; cursor: pointer; text-decoration: underline; }

/* --- Pastilles, statuts ------------------------------------------------------ */
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .4rem; vertical-align: .05em; flex: none; }
.pill, .st { display: inline-block; font-size: .74rem; font-weight: 500; padding: .12rem .6rem; border-radius: 999px; white-space: nowrap; }
.pill { background: var(--sky-soft); color: var(--navy); }
@media (prefers-color-scheme: dark) { .pill { color: var(--sky); } }
.pill.perdu { background: var(--line); color: var(--muted); }
.st.prevue { background: var(--line); color: var(--muted); }
.st.realisee { background: var(--sky-soft); color: var(--navy); }
.st.facturee { background: var(--warn-soft); color: var(--warn); }
.st.payee { background: var(--ok-soft); color: var(--ok); }
.st.annulee { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; }
@media (prefers-color-scheme: dark) { .st.realisee { color: var(--sky); } }

.filters { display: flex; gap: .5rem; margin-bottom: .9rem; }
.filters > * { flex: 1; }
.filters input, .filters select { background: var(--surface); box-shadow: var(--shadow); }
.seg { display: flex; background: var(--surface); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.seg button { flex: 1; border: 0; background: none; font: inherit; font-size: .9rem; color: var(--muted); border-radius: 999px; min-height: 40px; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; font-weight: 500; }
.chips { display: flex; gap: .45rem; overflow-x: auto; padding: 2px 2px .6rem; margin: 0 -16px .3rem; padding-left: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .35rem .85rem; font: inherit; font-size: .88rem; cursor: pointer; }
.chips button.on { border-color: var(--navy); background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button.on, .chips button.on { background: var(--sky); border-color: var(--sky); color: var(--navy-deep); } }

/* --- Agenda : bande de jours + journée ------------------------------------------ */
.weekhead { display: flex; align-items: center; gap: .4rem; margin-bottom: .7rem; }
.weekhead strong { flex: 1; font-size: 1.05rem; text-transform: capitalize; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); font-size: 1.3rem; display: grid; place-items: center; text-decoration: none; cursor: pointer; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 1rem; }
.days a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem 0 .5rem;
  border-radius: var(--r-md); text-decoration: none; color: var(--muted); }
.days a .n { font-size: 1.15rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.days a .w { font-size: .72rem; text-transform: capitalize; }
.days a .marks { display: flex; gap: 2px; height: 6px; }
.days a .marks i { width: 6px; height: 6px; border-radius: 50%; }
.days a.today .n { color: var(--navy); text-decoration: underline 3px var(--sky); text-underline-offset: 4px; }
@media (prefers-color-scheme: dark) { .days a.today .n { color: var(--sky); } }
.days a.on { background: var(--navy); }
.days a.on .n, .days a.on .w { color: #fff; }
@media (prefers-color-scheme: dark) { .days a.on { background: var(--sky); } .days a.on .n, .days a.on .w { color: var(--navy-deep); } }

.timeline { display: flex; flex-direction: column; gap: .5rem; }
.ev { display: grid; grid-template-columns: 3.6rem 1fr; gap: .8rem; align-items: start; text-decoration: none; color: inherit; }
.ev .t { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; padding-top: .7rem; font-size: .9rem; line-height: 1.25; }
.ev .t small { display: block; color: var(--muted); font-weight: 400; }
.ev .body { background: var(--surface); border-radius: var(--r-md); padding: .7rem .9rem; box-shadow: var(--shadow);
  border-left: 5px solid var(--c); min-width: 0; }
.ev .body b { display: block; font-weight: 500; }
.ev .who { font-size: .82rem; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: .2rem .7rem; margin-top: .2rem; }
.ev.busy .body { background: transparent; box-shadow: none; border: 1.5px dashed var(--line); border-left: 5px solid var(--c); color: var(--muted); padding: .45rem .9rem; }
.ev.busy .t { padding-top: .45rem; color: var(--muted); }
.ev.book .body { background: var(--sky-soft); }
details.ev { display: block; }
details.ev > summary { display: grid; grid-template-columns: 3.6rem 1fr; gap: .8rem; list-style: none; cursor: pointer; }
details.ev > summary::-webkit-details-marker { display: none; }
.evbody { margin: .5rem 0 0 4.4rem; display: flex; flex-direction: column; gap: .5rem; }
.dayempty { text-align: center; padding: 2rem 1rem; color: var(--muted); background: var(--surface); border-radius: var(--r-lg); }

/* --- Prestation : répartition --------------------------------------------------- */
.split { border-radius: var(--r-md); overflow: hidden; border: 1.5px solid var(--line); }
.split .bars { display: flex; height: 10px; }
.split .bars i { display: block; }
.split div.l { display: flex; justify-content: space-between; align-items: center; padding: .45rem .8rem; border-top: 1px solid var(--line); font-size: .92rem; }
.split div.l b { font-variant-numeric: tabular-nums; }

/* --- Comptes ----------------------------------------------------------------- */
.balance { background: var(--navy); color: #fff; border-radius: var(--r-lg); padding: 1.1rem 1.2rem; margin-bottom: 1rem; position: relative; overflow: hidden; }
.balance::after { content: ""; position: absolute; right: -70px; top: 0; bottom: 0; width: 110px; background: var(--sky); transform: skewX(-45deg); }
.balance > small { display: block; max-width: 78%; }
.balance > * { position: relative; z-index: 1; }
.balance strong { display: block; font-size: 2.2rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.balance.neg strong { color: #ffb4ba; }
.balance small { color: #cfe9f8; }
.table { display: flex; flex-direction: column; font-size: .9rem; }
.th, .tr { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: .4rem; padding: .55rem 0; border-bottom: 1px solid var(--line); align-items: center; }
.th { color: var(--muted); font-size: .78rem; font-weight: 500; }
.tr:last-child { border-bottom: 0; }
.tr > :not(:first-child), .th > :not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); } .neg { color: var(--danger); }

.member { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.member.off { opacity: .5; }

/* --- À faire (accueil) -------------------------------------------------------- */
.todo { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1.4rem; }
.todo a { background: var(--surface); border-radius: var(--r-md); padding: .75rem .8rem; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.todo a b { display: block; font-size: 1.5rem; line-height: 1.1; }
.todo a span { font-size: .78rem; color: var(--muted); }
.todo a.hot b { color: var(--warn); }

/* --- Navigation basse + bouton d'action ------------------------------------------ */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: var(--tab-h); padding: 0 4px env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 500; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--navy); }
.tabbar a.active svg { stroke-width: 2.3; }
@media (prefers-color-scheme: dark) { .tabbar a.active { color: var(--sky); } }
.fab { position: fixed; right: 18px; bottom: calc(var(--tab-h) + 16px); z-index: 21; width: 60px; height: 60px;
  border-radius: 18px; background: var(--sky); color: var(--navy-deep); display: grid; place-items: center;
  text-decoration: none; box-shadow: 0 10px 24px -8px rgba(0, 53, 84, .55); transform: rotate(0); }
.fab svg { width: 28px; height: 28px; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.fab[hidden] { display: none; }
@media (min-width: 760px) { .fab { right: calc(50% - 360px + 8px); } }

/* --- Connexion ----------------------------------------------------------------- */
.auth-wrap { min-height: 100dvh; display: flex; flex-direction: column; background: var(--navy); color: #fff; position: relative; overflow: hidden; }
.auth-wrap::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 46%; background: var(--sky);
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 100%); }
.auth-logo { position: relative; width: min(78%, 360px); margin: calc(env(safe-area-inset-top) + 48px) auto 24px; display: block; }
.auth { position: relative; background: var(--surface); color: var(--text); border-radius: 26px 26px 0 0; margin-top: auto;
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 1rem; max-width: 480px; width: 100%; align-self: center; }
@media (min-width: 520px) { .auth { border-radius: 26px; margin: auto auto 48px; } }
.auth h1 { font-size: 1.4rem; }
.auth .lead { margin: -.5rem 0 0; color: var(--muted); }
.qr { width: 200px; height: 200px; margin: 0 auto; background: #fff; padding: 8px; border-radius: 12px; }
.secret { word-break: break-all; font-size: .9rem; }
.steps { padding-left: 1.2rem; margin: 0; }
.code { font-size: 1.7rem; letter-spacing: .4em; text-align: center; font-weight: 500; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 90px); z-index: 50;
  background: var(--navy); color: #fff; padding: .75rem 1.1rem; border-radius: 999px; max-width: calc(100% - 32px);
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); animation: pop .2s ease-out; font-size: .92rem; }
.toast.err { background: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Agenda : le titre du mois ouvre un sélecteur de date (aller à n'importe quel jour, passé compris) */
.jump { position: relative; flex: 1; flex-direction: row; align-items: center; gap: .35rem; color: var(--text); font-size: inherit; cursor: pointer; }
.jump strong { white-space: nowrap; }
.jump strong::after { content: " ▾"; color: var(--muted); font-size: .8em; }
.jump input { position: absolute; inset: 0; opacity: 0; width: 100%; min-height: 0; padding: 0; cursor: pointer; }
.jump input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
/* Date + heure côte à côte, même sur téléphone */
@media (max-width: 440px) { .grid2.dt { grid-template-columns: 1.25fr 1fr; } }
.grid2.dt input { padding-left: .6rem; padding-right: .4rem; }
