:root{
  --bg:#f5f6f8;--card:#fff;--text:#18212b;--muted:#66717e;--line:#e4e8ed;
  --orange:#ec9700;--orange-dark:#cc7d00;--orange-soft:#fff3dc;--navy:#123b5a;
  --green:#1d9a57;--red:#d74343;--blue:#2878b8;--shadow:0 15px 38px rgba(24,33,43,.10);
  --radius:22px;--navh:76px;
}
*{box-sizing:border-box}html{background:var(--bg)}body{margin:0;min-height:100vh;font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;color:var(--text);background:linear-gradient(180deg,#fff9ed 0,#f5f6f8 220px);padding-bottom:calc(var(--navh) + 28px)}
a{color:inherit;text-decoration:none}button,input,select,textarea{font:inherit}.site-header{position:sticky;top:0;z-index:40;background:rgba(255,255,255,.92);backdrop-filter:blur(14px);border-bottom:1px solid var(--line)}
.header-inner{max-width:1180px;margin:auto;display:flex;align-items:center;justify-content:space-between;gap:18px;padding:10px 18px}.brand{display:flex;align-items:center;gap:12px}.brand img{width:92px;height:64px;object-fit:contain}.brand span{display:flex;flex-direction:column}.brand strong{font-size:20px;color:var(--navy)}.brand small{font-size:12px;color:var(--muted)}
.user-chip{display:flex;align-items:center;gap:10px;padding:7px 10px;border:1px solid var(--line);border-radius:18px;background:#fff}.user-chip span:last-child{display:flex;flex-direction:column}.user-chip strong{font-size:13px}.user-chip small{font-size:11px;color:var(--muted)}.avatar{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;background:var(--orange-soft);color:var(--orange-dark);font-weight:900}
.top-actions{max-width:1180px;margin:auto;display:grid;grid-template-columns:1fr 1fr 1fr;align-items:center;border-top:1px solid #f2f2f2}.top-actions a{min-height:42px;display:flex;justify-content:center;align-items:center;gap:7px;font-size:12px;font-weight:800;color:var(--muted)}.top-actions a.active{color:var(--orange-dark);background:var(--orange-soft)}
.page-wrap{max-width:1180px;margin:0 auto;padding:18px}.flash{max-width:1144px;margin:14px auto 0;padding:12px 16px;border-radius:15px;font-weight:750}.flash.ok{background:#e9f8ef;border:1px solid #bce7cc}.flash.err{background:#fff0ef;border:1px solid #f1c5c1}
.page-head{position:relative;overflow:hidden;background:var(--card);border:1px solid var(--line);box-shadow:var(--shadow);border-radius:var(--radius);padding:18px 20px;margin-bottom:16px;display:flex;align-items:center;gap:14px}.page-head:before{content:"";position:absolute;left:0;top:0;bottom:0;width:7px;background:linear-gradient(var(--orange),#ffb532)}.page-head .icon{width:58px;height:58px;display:grid;place-items:center;border-radius:18px;background:var(--orange-soft);font-size:30px}.page-head h1{margin:0;font-size:24px}.page-head p{margin:4px 0 0;color:var(--muted);font-size:13px}.page-head .actions{margin-left:auto;display:flex;gap:8px;flex-wrap:wrap}
.grid{display:grid;gap:14px}.grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}.grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.grid.four{grid-template-columns:repeat(4,minmax(0,1fr))}.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:0 9px 28px rgba(24,33,43,.07)}
.stat-card{position:relative;overflow:hidden;min-height:128px}.stat-card .watermark{position:absolute;right:-8px;bottom:-16px;font-size:72px;opacity:.11;transform:rotate(-14deg)}.stat-card .label{font-size:12px;color:var(--muted);font-weight:800}.stat-card .value{font-size:30px;font-weight:950;color:var(--navy);margin-top:8px}.stat-card .hint{font-size:11px;color:var(--muted);margin-top:4px}
.btn{border:1px solid var(--line);border-radius:14px;min-height:44px;padding:10px 14px;background:#fff;font-weight:850;display:inline-flex;align-items:center;justify-content:center;gap:7px;cursor:pointer}.btn:hover{transform:translateY(-1px);box-shadow:0 8px 18px rgba(0,0,0,.06)}.btn-primary{background:var(--orange);color:#fff;border-color:var(--orange)}.btn-primary:hover{background:var(--orange-dark)}.btn-danger{background:#fff0ef;color:#a82f2f;border-color:#efc4c0}.btn-ghost{background:#f7f8fa}.btn-sm{min-height:36px;padding:7px 10px;font-size:12px}.btn-block{width:100%}
.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.field{display:flex;flex-direction:column;gap:6px}.field.full{grid-column:1/-1}.field label{font-size:12px;font-weight:850;color:#4e5964}.input,select,textarea{width:100%;border:1px solid #d7dde4;border-radius:14px;background:#fff;padding:12px 13px;outline:none;min-height:46px;color:var(--text)}textarea{min-height:110px;resize:vertical}.input:focus,select:focus,textarea:focus{border-color:#f1aa32;box-shadow:0 0 0 4px rgba(236,151,0,.12)}
.table-wrap{overflow:auto;border-radius:18px;border:1px solid var(--line)}table{width:100%;border-collapse:collapse;background:#fff}th,td{padding:12px 13px;text-align:left;border-bottom:1px solid var(--line);font-size:13px;vertical-align:middle}th{font-size:11px;text-transform:uppercase;color:var(--muted);background:#fafbfc;letter-spacing:.03em}tr:last-child td{border-bottom:0}
.badge{display:inline-flex;align-items:center;border-radius:999px;padding:5px 9px;font-size:11px;font-weight:850;background:#eef1f4}.badge.orange{background:var(--orange-soft);color:#9b6100}.badge.green{background:#e7f7ee;color:#147d47}.badge.red{background:#ffeaea;color:#a32a2a}.badge.blue{background:#e9f3ff;color:#236ca5}.badge.gray{background:#eef0f2;color:#5c6570}
.cards-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.project-card{display:block;position:relative;overflow:hidden}.project-card:after{content:"🏗️";position:absolute;right:-7px;bottom:-20px;font-size:82px;opacity:.07;transform:rotate(-12deg)}.project-card h3{margin:0 0 5px;font-size:17px}.project-card p{margin:3px 0;color:var(--muted);font-size:12px}.project-card .meta{display:flex;gap:7px;flex-wrap:wrap;margin-top:10px}
.kpi-line{display:flex;justify-content:space-between;align-items:center;padding:9px 0;border-bottom:1px dashed var(--line)}.kpi-line:last-child{border:0}.kpi-line strong{font-size:14px}.muted{color:var(--muted)}.small{font-size:12px}.section-title{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:18px 0 10px}.section-title h2{margin:0;font-size:18px}
.progress{height:9px;border-radius:999px;background:#edf0f3;overflow:hidden}.progress span{height:100%;display:block;background:linear-gradient(90deg,var(--orange),#ffb733);border-radius:999px}
.bottom-nav{position:fixed;z-index:50;left:0;right:0;bottom:0;min-height:var(--navh);display:grid;grid-template-columns:repeat(5,1fr);align-items:end;padding:8px max(8px,env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));background:rgba(255,255,255,.96);backdrop-filter:blur(16px);border-top:1px solid var(--line);box-shadow:0 -8px 28px rgba(24,33,43,.09)}.bottom-nav a,.bottom-nav button{position:relative;border:0;background:transparent;display:flex;min-height:54px;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:#69737d;font-weight:850;cursor:pointer}.bottom-nav span{font-size:22px}.bottom-nav small{font-size:10px}.bottom-nav .active{color:var(--orange-dark)}.bottom-nav .main-action{align-self:start;margin-top:-22px;width:78px;height:72px;justify-self:center;border-radius:26px;background:var(--orange);color:#fff;box-shadow:0 10px 24px rgba(236,151,0,.35);border:5px solid #fff}.bottom-nav .main-action small{font-size:9px}
.menu-scrim{position:fixed;inset:0;background:rgba(14,22,30,.35);z-index:60}.quick-menu{position:fixed;z-index:70;left:50%;transform:translateX(-50%);bottom:calc(var(--navh) + 10px);width:min(520px,calc(100% - 20px));background:#fff;border-radius:24px;border:1px solid var(--line);box-shadow:0 18px 50px rgba(0,0,0,.2);padding:12px}.quick-head{display:flex;justify-content:space-between;align-items:center;padding:4px 5px 10px}.quick-head button{width:34px;height:34px;border:0;border-radius:50%;background:#f1f3f5}.quick-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:9px}.quick-grid a{min-height:88px;border:1px solid var(--line);border-radius:18px;background:#fafbfc;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px}.quick-grid a span{font-size:28px}.quick-grid a strong{font-size:12px}
.footer{text-align:center;color:#8b939b;font-size:10px;padding:25px 0 4px}.modal{position:fixed;inset:0;z-index:100;display:grid;place-items:center;padding:18px;background:rgba(11,18,25,.48)}.modal[hidden]{display:none}.modal-card{width:min(650px,100%);max-height:90vh;overflow:auto;background:#fff;border-radius:25px;border:1px solid var(--line);box-shadow:0 25px 70px rgba(0,0,0,.25);padding:18px}.modal-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:14px}.modal-head h2{margin:0}.modal-close{border:0;background:#f0f2f4;width:36px;height:36px;border-radius:50%;cursor:pointer}
.planning-toolbar{display:flex;gap:8px;align-items:center;justify-content:space-between;flex-wrap:wrap;margin-bottom:10px}.week-grid{display:grid;grid-template-columns:repeat(7,minmax(145px,1fr));gap:8px;overflow:auto;padding-bottom:4px}.day-col{min-height:350px;border:1px solid var(--line);border-radius:18px;background:#fff;overflow:hidden}.day-col.is-today{outline:2px solid rgba(236,151,0,.3)}.day-head{position:sticky;top:0;background:#fbfbfc;padding:10px;border-bottom:1px solid var(--line);font-size:12px;font-weight:900;text-align:center}.day-body{min-height:300px;padding:7px}.plan-card{border:1px solid #f0c777;border-left:5px solid var(--orange);background:#fff9ed;border-radius:13px;padding:8px;margin-bottom:7px;cursor:grab;font-size:11px}.plan-card strong{display:block;font-size:12px}.plan-card small{color:var(--muted)}.plan-card.dragging{opacity:.45}.day-body.drop-target{background:#fff4dd}
.password-rules{display:grid;gap:7px;margin:12px 0}.password-rule{display:flex;align-items:center;gap:8px;font-size:12px;color:#7b848d}.password-rule i{width:18px;height:18px;border-radius:50%;display:grid;place-items:center;background:#eceff2;font-style:normal;font-size:11px}.password-rule.ok{color:#137744}.password-rule.ok i{background:#1fa760;color:#fff}
.line-builder{display:grid;grid-template-columns:2.2fr .8fr .7fr .9fr auto;gap:8px;align-items:end;margin-bottom:8px}.line-builder .remove-line{width:44px;height:44px;border-radius:14px;border:1px solid #efc7c3;background:#fff1ef;color:#b03933}.summary-strip{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:12px}.summary-strip>div{background:#fafbfc;border:1px solid var(--line);border-radius:16px;padding:11px}.summary-strip span{display:block;font-size:10px;color:var(--muted);font-weight:800}.summary-strip strong{font-size:18px;color:var(--navy)}
@media(max-width:900px){.grid.four{grid-template-columns:repeat(2,1fr)}.grid.three{grid-template-columns:repeat(2,1fr)}.week-grid{grid-template-columns:repeat(7,180px)}}
@media(max-width:640px){body{background:#f5f6f8}.page-wrap{padding:12px}.header-inner{padding:8px 12px}.brand img{width:78px;height:54px}.brand span{display:none}.user-chip span:last-child{display:none}.page-head{padding:14px}.page-head .icon{width:50px;height:50px;font-size:25px}.page-head h1{font-size:19px}.page-head p{font-size:11px}.page-head .actions{margin-left:0;width:100%}.page-head{flex-wrap:wrap}.grid.two,.grid.three,.grid.four,.cards-list{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.card{padding:12px;border-radius:18px}.stat-card{min-height:112px}.stat-card .value{font-size:23px}.stat-card .watermark{font-size:62px}.form-grid{grid-template-columns:1fr}.field.full{grid-column:auto}.line-builder{grid-template-columns:1fr 1fr}.line-builder .field:first-child{grid-column:1/-1}.line-builder .remove-line{align-self:end}.summary-strip{grid-template-columns:1fr}.table-wrap{border-radius:14px}.hide-mobile{display:none}.bottom-nav small{font-size:9px}.top-actions a span{display:none}.top-actions a{font-size:18px}.project-card h3{font-size:14px}.project-card p{font-size:10px}.project-card .meta{gap:4px}.badge{font-size:9px;padding:4px 6px}}
@media(max-width:390px){.grid.two,.grid.three,.grid.four,.cards-list{grid-template-columns:1fr 1fr}.stat-card .value{font-size:20px}}

/* Ajustements ergonomiques EMFB */
.user-area{margin-left:auto;display:flex;align-items:center;gap:9px;min-width:0;line-height:1.15}.user-logout-btn{padding:7px 10px;border:1px solid var(--line);border-radius:999px;background:rgba(255,255,255,.97);box-shadow:0 5px 18px rgba(15,23,42,.06);max-width:48%;transition:.16s ease}.user-logout-btn:hover{border-color:#f1b449;box-shadow:0 7px 20px rgba(236,151,0,.14);transform:translateY(-1px)}.user-avatar{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;background:var(--navy);color:#fff;font-weight:900;font-size:12px;flex:0 0 34px}.user-area-text{min-width:0;display:flex;flex-direction:column;text-align:left}.user-area strong{font-size:12px;color:var(--navy);font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.user-area small{font-size:10px;color:var(--muted);font-weight:750;margin-top:3px;white-space:nowrap}

/* Connexion : aucune barre de défilement et espacements comparables au site de référence */
.login-page{height:100dvh;min-height:100dvh;overflow:hidden;padding:0;background:#f5f6f8}.login-page .login-shell{height:100dvh;min-height:0;padding:14px 18px;overflow:hidden}.login-page .login-card{padding:22px 25px}.login-page .login-logo{height:128px;margin-bottom:2px}.login-page .login-sub{margin-bottom:20px}.login-form{display:grid;gap:17px}.login-form .field{gap:7px}.login-form .btn{margin-top:2px}.login-page .login-footer{margin-top:10px}

/* Accueil compact : garder l'essentiel dans la hauteur utile dès que l'écran le permet */
.home-dashboard{display:flex;flex-direction:column;gap:0}.home-dashboard .page-head{margin-bottom:12px;padding-top:14px;padding-bottom:14px}.home-dashboard .stat-card{min-height:108px}.home-dashboard .section-title{margin:12px 0 8px}.home-dashboard .project-card{padding-top:13px;padding-bottom:13px}

/* Changement du premier mot de passe en popup bloquant */
.password-first-modal{z-index:250;background:rgba(13,21,29,.64);backdrop-filter:blur(5px)}.password-modal-card{width:min(520px,100%);overflow:visible;padding:22px 24px}.password-modal-brand{text-align:center}.password-modal-brand img{width:190px;height:86px;object-fit:contain}.password-modal-head{display:block;text-align:center;margin:0 0 16px}.password-modal-head h2{font-size:22px;color:var(--navy)}.password-modal-head p{margin:6px 0 0;color:var(--muted);font-size:12px;line-height:1.45}.password-modal-form{display:grid;gap:15px}.password-modal-form .password-rules{margin:0}.password-modal-form .btn{margin-top:2px}

@media(min-width:901px) and (min-height:760px){.home-dashboard .cards-list{grid-template-columns:repeat(4,minmax(0,1fr))}.home-dashboard .project-card{min-height:118px}}
@media(max-width:640px){.user-logout-btn{max-width:58%;padding:6px 8px}.user-avatar{width:31px;height:31px;flex-basis:31px;font-size:10px}.user-area strong{font-size:11px}.user-area small{font-size:9px}.login-page .login-shell{padding:10px 14px}.login-page .login-card{padding:18px 20px;border-radius:24px}.login-page .login-logo{height:105px}.login-page .login-title{font-size:22px}.login-page .login-sub{margin:3px 0 16px}.login-form{gap:14px}.home-dashboard .page-head{margin-bottom:9px;padding:10px 12px}.home-dashboard .page-head .icon{width:42px;height:42px;font-size:22px}.home-dashboard .stat-card{min-height:92px}.home-dashboard .stat-card .value{margin-top:4px}.home-dashboard .section-title{margin:9px 0 7px}.home-dashboard .project-card{padding:10px}.password-modal-card{padding:18px}.password-modal-brand img{height:72px;width:165px}}
@media(max-height:700px){.login-page .login-logo{height:82px}.login-page .login-card{padding-top:14px;padding-bottom:14px}.login-page .login-title{font-size:20px}.login-page .login-sub{margin-bottom:12px}.login-form{gap:11px}.login-icon input{min-height:42px}.login-form .btn{min-height:42px}.login-page .login-footer{margin-top:6px}.home-dashboard .page-head{display:none}.home-dashboard .stat-card{min-height:84px}.home-dashboard .section-title{margin-top:8px}}

/* V3 — accueil verrouillé dans la fenêtre et création utilisateur automatisée */
.home-page{height:100dvh;min-height:100dvh;overflow:hidden;padding-bottom:0;overscroll-behavior:none}
.home-page .site-header{position:relative;top:auto}
.home-page .page-wrap{height:calc(100dvh - 129px - var(--navh));max-height:calc(100dvh - 129px - var(--navh));overflow:hidden;padding-top:12px;padding-bottom:8px}
.home-page .home-dashboard{height:100%;overflow:hidden}
.home-page .home-dashboard .page-head{flex:0 0 auto}
.home-page .home-dashboard .grid.four{flex:0 0 auto}
.home-page .home-dashboard .cards-list{min-height:0;overflow:hidden}
.generated-login{min-height:58px;border:1px dashed #efb354;border-radius:14px;background:var(--orange-soft);display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 13px}.generated-login strong{font-size:17px;color:var(--navy);letter-spacing:.04em}.generated-login span{font-size:11px;color:var(--muted);text-align:right}
@media(max-width:640px){.home-page .page-wrap{height:calc(100dvh - 113px - var(--navh));max-height:calc(100dvh - 113px - var(--navh));padding-top:8px;padding-bottom:4px}.home-page .home-dashboard .grid.four{gap:7px}.home-page .home-dashboard .stat-card{min-height:82px;padding:9px}.home-page .home-dashboard .stat-card .label{font-size:10px}.home-page .home-dashboard .stat-card .value{font-size:20px}.home-page .home-dashboard .stat-card .hint{font-size:9px}.home-page .home-dashboard .section-title{margin:7px 0 5px}.home-page .home-dashboard .section-title h2{font-size:15px}.home-page .home-dashboard .project-card{padding:8px;min-height:0}.home-page .home-dashboard .project-card .small{display:none}.home-page .home-dashboard .project-card .progress{display:none}.generated-login{align-items:flex-start;flex-direction:column}.generated-login span{text-align:left}}
@media(max-height:720px){.home-page .home-dashboard .page-head{display:none}.home-page .page-wrap{padding-top:7px}.home-page .home-dashboard .stat-card{min-height:72px}.home-page .home-dashboard .stat-card .watermark{font-size:50px}.home-page .home-dashboard .project-card{padding-top:7px;padding-bottom:7px}}

/* V4 — bandeaux de pages EMFB : orange chantier, compacts et emoji en filigrane */
.page-head{
  min-height:82px;
  background:linear-gradient(120deg,#f29a00 0%,#e48800 58%,#b96400 100%);
  border:0;
  box-shadow:0 10px 26px rgba(164,91,0,.18);
  color:#fff;
  padding:14px 18px;
  margin-bottom:14px;
}
.page-head:before{display:none}
.page-head>div:not(.icon):not(.actions){position:relative;z-index:2;min-width:0}
.page-head h1{color:#fff;text-shadow:0 1px 2px rgba(61,32,0,.16)}
.page-head p{color:rgba(255,255,255,.88)}
.page-head .icon{
  position:absolute;
  z-index:1;
  right:-7px;
  bottom:-17px;
  width:auto;
  height:auto;
  border-radius:0;
  background:transparent;
  color:inherit;
  font-size:76px;
  line-height:1;
  opacity:.17;
  transform:rotate(-13deg);
  pointer-events:none;
  filter:saturate(.9);
}
.page-head .actions{position:relative;z-index:3}
.page-head .actions .btn:not(.btn-primary){background:rgba(255,255,255,.95);border-color:rgba(255,255,255,.75)}
.page-head .actions .btn-primary{background:#fff;color:#b96800;border-color:#fff;box-shadow:0 5px 14px rgba(89,45,0,.14)}
.page-head .actions .btn-primary:hover{background:#fff7e9;color:#965500}

@media(max-width:640px){
  .page-head{
    min-height:58px;
    padding:9px 12px;
    margin-bottom:9px;
    border-radius:16px;
    gap:7px;
    flex-wrap:nowrap;
  }
  .page-head h1{font-size:17px;line-height:1.08}
  .page-head p{font-size:10px;line-height:1.2;margin-top:3px;max-width:78vw}
  .page-head .icon{right:-5px;bottom:-13px;font-size:57px;opacity:.16}
  .page-head .actions{margin-left:auto;width:auto;flex:0 0 auto}
  .page-head .actions .btn{min-height:34px;padding:7px 9px;border-radius:11px;font-size:11px}
  .home-dashboard .page-head{padding:9px 12px;min-height:56px;margin-bottom:8px}
  .home-dashboard .page-head .icon{width:auto;height:auto;font-size:55px}
}

@media(max-width:390px){
  .page-head{min-height:54px;padding:8px 10px}
  .page-head h1{font-size:16px}
  .page-head p{font-size:9px}
  .page-head .icon{font-size:52px;bottom:-12px}
}

/* Compte : cartes de synthèse + édition uniquement en popup */
.account-grid{align-items:stretch}
.account-card{display:flex;flex-direction:column;gap:18px;min-height:250px}
.account-summary{display:grid;gap:10px}
.account-summary>div{display:flex;justify-content:space-between;gap:16px;align-items:center;padding:10px 12px;border-radius:12px;background:var(--surface-soft,#f7f7f7)}
.account-summary span{font-size:.82rem;color:var(--muted,#6b7280)}
.account-summary strong{text-align:right;overflow-wrap:anywhere}
.account-password-state{display:flex;align-items:center;gap:14px;flex:1;padding:14px;border-radius:14px;background:var(--surface-soft,#f7f7f7)}
.account-lock{font-size:2rem}
.card-actions{margin-top:auto;text-align:right}
.btn-icon{min-width:42px;padding-left:10px;padding-right:10px}
@media(max-width:700px){
  .account-card{min-height:auto;gap:14px}
  .account-summary>div{padding:9px 10px}
}
