/* ============ Jetons ============ */
:root {
  --fond: #F2F5F4;
  --surface: #FFFFFF;
  --encre: #16323A;
  --doux: #5B6F75;
  --trait: #D8E1DF;
  --trait-fort: #B9C7C4;
  --eucalyptus: #1F6F63;
  --eucalyptus-fonce: #175449;
  --eucalyptus-clair: #E3EFEC;
  --ambre: #F4C95D;
  --ambre-clair: #FBEBC0;
  --brique: #B5473A;
  --brique-clair: #F7E3E0;
  --vert: #2E7D4F;
  --vert-clair: #E1F1E7;
  --orange: #9A5B0F;
  --orange-clair: #FBEEDB;
  --slot: 18px;
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --ombre: 0 1px 2px rgba(22, 50, 58, .06), 0 8px 24px rgba(22, 50, 58, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font: 16px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
body.noscroll { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
a { color: var(--eucalyptus); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ambre); outline-offset: 2px; border-radius: 4px; }
.boot { padding: 3rem; text-align: center; color: var(--doux); }
.muted { color: var(--doux); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: .75rem; }
.hidden { display: none !important; }

/* ============ Boutons & champs ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1rem; border-radius: var(--r-s);
  border: 1px solid var(--trait-fort); background: var(--surface); cursor: pointer;
  font-weight: 600; text-decoration: none; color: var(--encre); white-space: nowrap;
}
.btn:hover { border-color: var(--eucalyptus); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--eucalyptus); border-color: var(--eucalyptus); color: #fff; }
.btn.primary:hover { background: var(--eucalyptus-fonce); }
.btn.danger { color: var(--brique); border-color: #E3B7B1; }
.btn.danger.plein { background: var(--brique); color: #fff; border-color: var(--brique); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: .35rem .7rem; font-size: .9rem; }
.btn.block { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: var(--r-s);
  border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--eucalyptus-clair); }
.lien { background: none; border: 0; padding: 0; color: var(--eucalyptus); text-decoration: underline; cursor: pointer; font-weight: 600; }

label.champ { display: block; font-weight: 600; font-size: .9rem; }
label.champ > span.aide { display: block; font-weight: 400; color: var(--doux); font-size: .82rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: .3rem; min-height: 44px; padding: .55rem .7rem;
  border: 1px solid var(--trait-fort); border-radius: var(--r-s); background: var(--surface);
  font-weight: 400; font-size: 16px;
}
textarea { min-height: 88px; resize: vertical; }
select:disabled, input:disabled { background: #EEF2F1; color: var(--doux); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--eucalyptus); box-shadow: 0 0 0 3px var(--eucalyptus-clair); }
.case { display: flex; gap: .6rem; align-items: center; min-height: 40px; font-weight: 500; cursor: pointer; }
.case input { width: 20px; height: 20px; accent-color: var(--eucalyptus); margin: 0; }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grille3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.1rem; }
fieldset { border: 1px solid var(--trait); border-radius: var(--r-m); padding: .9rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .35rem; }

/* ============ Badges ============ */
.badge {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--eucalyptus-clair); color: var(--eucalyptus-fonce); white-space: nowrap;
}
.badge.ok { background: var(--vert-clair); color: var(--vert); }
.badge.warn { background: var(--orange-clair); color: var(--orange); }
.badge.err { background: var(--brique-clair); color: var(--brique); }
.badge.neutre { background: #E8ECEB; color: var(--doux); }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--eucalyptus)); flex: none; }

/* ============ Écran de connexion ============ */
body.auth { background: var(--eucalyptus); }
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; padding-top: calc(1.25rem + var(--safe-t)); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--r-l); padding: 1.75rem 1.4rem; box-shadow: var(--ombre); }
.marque { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.marque img { width: 44px; height: 44px; border-radius: 11px; }
.marque strong { display: block; font-size: 1.2rem; }
.marque span { color: var(--doux); font-size: .9rem; }
.auth-card form > * + * { margin-top: .9rem; }
.auth-bas { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--trait); font-size: .92rem; }
.encadre { background: var(--eucalyptus-clair); border-radius: var(--r-m); padding: .8rem .9rem; font-size: .92rem; }
.encadre.ambre { background: var(--ambre-clair); }
.encadre.rouge { background: var(--brique-clair); color: #7A2E25; }

/* ============ Structure ============ */
.shell { min-height: 100dvh; }
.side { display: none; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: calc(.7rem + var(--safe-t)) 1rem .7rem; background: rgba(242, 245, 244, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--trait);
}
#main { padding: 1rem 1rem calc(88px + var(--safe-b)); max-width: 1200px; outline: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--trait); padding-bottom: var(--safe-b);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem .2rem .45rem;
  font-size: .72rem; font-weight: 600; color: var(--doux); text-decoration: none; position: relative;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a.actif { color: var(--eucalyptus); }
.tabs a .pastille-compteur { position: absolute; top: 4px; left: calc(50% + 6px); }
.pastille-compteur { background: var(--brique); color: #fff; border-radius: 999px; font-size: .7rem; min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px; font-weight: 700; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 250px 1fr; }
  .side {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 1.25rem .9rem;
    background: var(--surface); border-right: 1px solid var(--trait);
  }
  .side nav { display: flex; flex-direction: column; gap: 2px; margin-top: .5rem; }
  .side nav a {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: var(--r-s);
    color: var(--encre); text-decoration: none; font-weight: 500;
  }
  .side nav a svg { width: 20px; height: 20px; color: var(--doux); }
  .side nav a:hover { background: var(--fond); }
  .side nav a.actif { background: var(--eucalyptus-clair); color: var(--eucalyptus-fonce); font-weight: 700; }
  .side nav a.actif svg { color: var(--eucalyptus); }
  .side nav .sep { height: 1px; background: var(--trait); margin: .6rem .4rem; }
  .side .qui { margin-top: auto; font-size: .88rem; color: var(--doux); padding: .6rem; }
  .tabs { display: none; }
  #main { padding: 1.4rem 1.75rem 3rem; }
  .top { padding: 1rem 1.75rem; }
}

/* ============ Listes & cartes ============ */
.bloc { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--r-m); }
.bloc + .bloc, .bloc + h2, h2 + .bloc { margin-top: 1rem; }
.bloc-pad { padding: 1rem; }
.section-titre { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 1.4rem 0 .6rem; }
.section-titre:first-child { margin-top: 0; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li + li { border-top: 1px solid var(--trait); }
.ligne {
  display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer;
}
.ligne:hover { background: #F7FAF9; }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .titre { font-weight: 600; }
.ligne .sous { color: var(--doux); font-size: .88rem; }
.barre-couleur { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c, var(--eucalyptus)); flex: none; }
.vide { text-align: center; padding: 2.5rem 1rem; color: var(--doux); }
.vide .btn { margin-top: 1rem; }
.filtres { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filtres > * { flex: 1 1 160px; }
.seg { display: inline-flex; border: 1px solid var(--trait-fort); border-radius: var(--r-s); overflow: hidden; background: var(--surface); flex: none !important; }
.seg button { border: 0; background: none; padding: .5rem .85rem; min-height: 40px; cursor: pointer; font-weight: 600; color: var(--doux); }
.seg button + button { border-left: 1px solid var(--trait-fort); }
.seg button.on { background: var(--eucalyptus); color: #fff; }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.chiffre { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--r-m); padding: .8rem 1rem; }
.chiffre b { display: block; font-size: 1.35rem; }
.chiffre span { color: var(--doux); font-size: .85rem; }
.detail { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; margin: 0; }
.detail dt { color: var(--doux); }
.detail dd { margin: 0; text-align: right; font-weight: 600; }
.detail .total { border-top: 1px solid var(--trait); padding-top: .45rem; font-size: 1.05rem; color: var(--encre); font-weight: 700; }
.tableau { width: 100%; border-collapse: collapse; }
.tableau th, .tableau td { padding: .6rem .8rem; border-bottom: 1px solid var(--trait); text-align: left; vertical-align: middle; }
.tableau th { font-size: .82rem; color: var(--doux); font-weight: 600; }
.tableau td.right, .tableau th.right { text-align: right; }
.defile-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mois-nav { display: flex; align-items: center; gap: .4rem; }
.mois-nav strong { min-width: 150px; text-align: center; }
.jauge { height: 10px; background: #E8ECEB; border-radius: 999px; overflow: hidden; }
.jauge > i { display: block; height: 100%; background: var(--c, var(--eucalyptus)); border-radius: 999px; }
.code-activation { font-size: 1.6rem; font-weight: 700; letter-spacing: .12em; text-align: center; padding: .7rem; background: var(--ambre-clair); border-radius: var(--r-m); user-select: all; }

/* Facturation : cartes sur mobile, grille sur grand écran */
.fact-ligne { padding: .9rem 1rem; display: grid; gap: .5rem; grid-template-columns: 1fr auto; align-items: center; }
.fact-ligne + .fact-ligne { border-top: 1px solid var(--trait); }
.fact-montants { display: flex; gap: 1rem; font-size: .9rem; color: var(--doux); flex-wrap: wrap; }
.fact-montants b { color: var(--encre); }
.fact-actions { grid-column: 1 / -1; display: flex; gap: .4rem; flex-wrap: wrap; }
@media (min-width: 900px) {
  .fact-ligne { grid-template-columns: minmax(180px, 1.4fr) 2fr auto; }
  .fact-actions { grid-column: auto; justify-content: flex-end; }
}

/* ============ Calendrier ============ */
.cal-barre { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.cal-barre .nav { display: inline-flex; gap: .3rem; }
.cal-titre { flex: 1 1 100%; order: -1; display: flex; align-items: center; gap: .5rem; }
.cal-titre h2 { font-size: 1.1rem; }
.cal-titre input[type=date] { width: auto; min-height: 36px; margin: 0; padding: .2rem .4rem; font-size: 14px; }
.cal-barre .btn.primary { margin-left: auto; }
@media (min-width: 700px) { .cal-titre { flex: 1 1 auto; order: 0; } }
.puces { display: flex; gap: .45rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: .5rem; scrollbar-width: none; }
.puce {
  display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .75rem; min-height: 36px; border-radius: 999px;
  border: 1px solid var(--trait-fort); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; font-size: .9rem;
}
.puce.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); }
.aide-cal { font-size: .82rem; color: var(--doux); margin: 0 0 .5rem; }

.cal-cadre {
  position: relative; overflow: auto; max-height: calc(100dvh - 250px - var(--safe-b)); min-height: 320px;
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--r-m); -webkit-overflow-scrolling: touch;
}
@media (min-width: 900px) { .cal-cadre { max-height: calc(100dvh - 210px); } }
.cal-cadre.charge::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.5); z-index: 8; }
.cal { display: grid; min-width: 100%; }
.cal .tete {
  position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--trait);
  padding: .45rem .3rem; text-align: center; font-size: .82rem; font-weight: 600; line-height: 1.25;
}
.cal .tete.coin { left: 0; z-index: 7; }
.cal .tete .jour-num { display: block; font-size: 1.05rem; }
.cal .tete.aujourdhui .jour-num { color: #fff; background: var(--eucalyptus); border-radius: 999px; width: 30px; margin: 0 auto; }
.cal .tete .cab-nom { display: inline-flex; align-items: center; gap: .35rem; }
.cal .heures { position: sticky; left: 0; z-index: 5; background: var(--surface); border-right: 1px solid var(--trait); }
.cal .heures div { height: calc(var(--slot) * 4); font-size: .72rem; color: var(--doux); text-align: right; padding-right: 6px; transform: translateY(-.55em); }
.cal .heures div:first-child { transform: none; }
.col {
  position: relative; border-right: 1px solid var(--trait);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: pan-x pan-y;
}
.col:last-child { border-right: 0; }
.col .s { height: var(--slot); border-bottom: 1px dotted #E6ECEA; }
.col .s.h { border-bottom: 1px solid var(--trait); }
.col .s.libre { cursor: pointer; }
@media (hover: hover) { .col .s.libre:hover { background: var(--ambre-clair); } }
.col .s.ferme { background: repeating-linear-gradient(-45deg, #F0F3F2, #F0F3F2 4px, #E7ECEA 4px, #E7ECEA 8px); }
.col .s.passe:not(.ferme) { background: #F6F8F7; }
.bk {
  position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 2px 6px; overflow: hidden; z-index: 2;
  font-size: .76rem; line-height: 1.25; text-align: left; border: 0; font-weight: 600;
}
.bk.moi { background: var(--c); color: #fff; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.bk.moi.demande { background: repeating-linear-gradient(-45deg, var(--c), var(--c) 6px, color-mix(in srgb, var(--c) 75%, white) 6px, color-mix(in srgb, var(--c) 75%, white) 12px); }
.bk.autre {
  background: repeating-linear-gradient(-45deg, #DCE3E1, #DCE3E1 5px, #CFD8D6 5px, #CFD8D6 10px);
  color: #3F5358; border: 1px solid #C2CDCA;
}
.bk.admin { cursor: pointer; }
.bk.admin.autre { background: color-mix(in srgb, var(--c) 18%, white); border: 1px solid color-mix(in srgb, var(--c) 45%, white); border-left: 4px solid var(--c); color: var(--encre); }
.bk.admin.demande { outline: 2px dashed var(--brique); outline-offset: -2px; }
.bk small { display: block; font-weight: 500; opacity: .9; }
.sel {
  position: absolute; left: 2px; right: 2px; z-index: 4; border-radius: 6px; pointer-events: none;
  background: color-mix(in srgb, var(--ambre) 55%, transparent); border: 2px solid #D9A92E;
  font-size: .76rem; font-weight: 700; padding: 2px 6px; color: #4A3608;
}
.maintenant { position: absolute; left: 0; right: 0; height: 2px; background: var(--brique); z-index: 3; pointer-events: none; }
.maintenant::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brique); }

/* ============ Fenêtres (bas d'écran sur mobile) ============ */
.ov { position: fixed; inset: 0; z-index: 50; background: rgba(22, 50, 58, .38); display: flex; align-items: flex-end; justify-content: center; animation: fondu .15s ease-out; }
.sheet {
  width: 100%; max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: var(--r-l) var(--r-l) 0 0;
  padding-bottom: calc(1rem + var(--safe-b)); animation: monte .2s ease-out;
}
.sheet-h { position: sticky; top: 0; z-index: 2; background: var(--surface); display: flex; align-items: center; justify-content: space-between; padding: .9rem .6rem .6rem 1.1rem; border-bottom: 1px solid var(--trait); }
.sheet-b { padding: 1rem 1.1rem 0; }
.sheet-b > * + * { margin-top: .85rem; }
@media (min-width: 700px) {
  .ov { align-items: center; padding: 1.5rem; }
  .sheet { max-width: 520px; border-radius: var(--r-l); padding-bottom: 1.1rem; }
  .sheet.large { max-width: 760px; }
}
.recap-resa { background: var(--ambre-clair); border-radius: var(--r-m); padding: .8rem .9rem; }
.recap-resa .quand { font-size: 1.1rem; font-weight: 700; }
@keyframes monte { from { transform: translateY(24px); opacity: .6; } }
@keyframes fondu { from { opacity: 0; } }

/* ============ Notifications ============ */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b)); z-index: 90; display: grid; gap: .5rem; width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 900px) { #toasts { bottom: 1.5rem; } }
.toast { background: var(--encre); color: #fff; padding: .75rem 1rem; border-radius: var(--r-m); box-shadow: var(--ombre); font-weight: 500; transition: opacity .4s, transform .4s; }
.toast.err { background: var(--brique); }
.toast.out { opacity: 0; transform: translateY(8px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
