/* ============================================================
   CRM - Design system (autonome, sans CDN)
   ============================================================ */
:root{
  --bg:#f6f7fb; --surface:#ffffff; --input-bg:#ffffff; --sidebar:#0f172a; --sidebar-2:#1e293b;
  --ink:#0f172a; --muted:#64748b; --line:#e6e8ef;
  --primary:#4f46e5; --primary-600:#4338ca; --primary-50:#eef2ff;
  --green:#22c55e; --amber:#f59e0b; --red:#ef4444; --sky:#0ea5e9; --violet:#8b5cf6; --slate:#94a3b8;
  --radius:14px; --shadow:0 1px 2px rgba(16,24,40,.06),0 8px 24px rgba(16,24,40,.06);
  --shadow-sm:0 1px 2px rgba(16,24,40,.08);
  --topbar-bg:rgba(255,255,255,.8);
}
:root[data-theme="dark"]{
  --bg:#0b1120; --surface:#151d2e; --input-bg:#0f1729; --sidebar:#0a0f1a; --sidebar-2:#1b2436;
  --ink:#e6eaf2; --muted:#93a1b8; --line:#26314c;
  --primary:#6366f1; --primary-600:#4f46e5; --primary-50:#1e2a4a;
  --shadow:0 1px 2px rgba(0,0,0,.45),0 10px 28px rgba(0,0,0,.4);
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --topbar-bg:rgba(17,24,39,.82);
}
:root[data-theme="dark"] .badge{background:#1e293b;color:#cbd5e1}
:root[data-theme="dark"] .kcol{background:#0f1729}
:root[data-theme="dark"] .kcard,:root[data-theme="dark"] .kpi .ic{background:var(--surface)}
:root[data-theme="dark"] .av-sm,:root[data-theme="dark"] .list-item .av-sm{background:var(--primary-50);color:#c7d2fe}
:root[data-theme="dark"] .topbar .search input,:root[data-theme="dark"] .field input{background:var(--input-bg);color:var(--ink)}
:root[data-theme="dark"] .login-wrap{background:linear-gradient(135deg,#0b1120,#131a2b)}
:root[data-theme="dark"] .login{background:var(--surface)}
:root[data-theme="dark"] .flash{background:#3b1113;color:#fecaca;border-color:#7f1d1d}
:root[data-theme="dark"] tbody tr:hover{background:#0f1729}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
html{overflow-x:hidden}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg);color:var(--ink);font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;overflow-x:hidden;max-width:100vw}
a{color:inherit;text-decoration:none}
h1,h2,h3{margin:0;font-weight:650;letter-spacing:-.01em}

/* ---------- Shell ---------- */
.shell{display:flex;min-height:100vh}
.sidebar{width:248px;background:var(--sidebar);color:#cbd5e1;display:flex;flex-direction:column;position:fixed;inset:0 auto 0 0;z-index:30}
.sidebar .brand{display:flex;align-items:center;gap:10px;padding:20px 18px;color:#fff;font-weight:700;font-size:16px;letter-spacing:-.02em}
.sidebar .brand .logo{width:30px;height:30px;border-radius:8px;background:linear-gradient(135deg,var(--primary),#7c3aed);display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800}
.nav{padding:8px 12px;display:flex;flex-direction:column;gap:2px;overflow-y:auto}
.nav .section{font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:#64748b;padding:14px 12px 6px}
.nav a{display:flex;align-items:center;gap:11px;padding:9px 12px;border-radius:9px;color:#cbd5e1;font-weight:500;transition:.15s}
.nav a svg{width:18px;height:18px;opacity:.85;flex:none}
.nav a:hover{background:var(--sidebar-2);color:#fff}
.nav a.active{background:var(--primary);color:#fff}
.nav a.active svg{opacity:1}
.sidebar .foot{margin-top:auto;padding:14px;border-top:1px solid #1e293b}
.pwa-install-btn{width:100%;display:flex;align-items:center;justify-content:center;gap:8px;margin-bottom:12px;padding:9px 12px;border:1px solid var(--primary);background:transparent;color:#c7d2fe;border-radius:10px;font-size:13px;font-weight:600;cursor:pointer;transition:background .15s}
.pwa-install-btn:hover{background:var(--primary);color:#fff}

/* ============ Experience mobile / PWA (vraie appli) ============ */
/* Safe-area (encoche iPhone) + comportement app en mode installe */
:root{--safe-b:env(safe-area-inset-bottom,0px);--safe-t:env(safe-area-inset-top,0px)}
html{-webkit-tap-highlight-color:transparent}
body{overscroll-behavior-y:none}

/* Barre d'onglets basse facon appli native */
.mobnav{display:none}
/* Visible sur mobile ET des que l'app est installee (mode standalone), quelle que soit la largeur */
@media(max-width:860px){
  .mobnav{display:flex}
  .topbar .search{display:none}
  /* barre haute fixe sur mobile aussi : compacte + padding bas (comme monitoring) */
  .topbar{position:fixed;left:0;right:0;top:0;z-index:50;height:auto;min-height:30px;padding-top:calc(2px + var(--safe-t));padding-bottom:6px}
  .main .content{padding-top:calc(54px + var(--safe-t));padding-bottom:calc(48px + var(--safe-b))}
}
html.standalone .mobnav{display:flex}
html.standalone .main .content{padding-bottom:calc(48px + var(--safe-b))}

.mobnav{
  position:fixed;left:0;right:0;bottom:0;z-index:60;
  background:var(--surface);border-top:1px solid var(--line);
  padding:6px 6px max(13px, calc(var(--safe-b) - 11px));
  box-shadow:0 -8px 24px rgba(15,23,42,.08)
}
:root[data-theme="dark"] .mobnav{box-shadow:0 -8px 24px rgba(0,0,0,.5)}
.mobnav a,.mobnav button{
  position:relative;flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  background:none;border:0;cursor:pointer;padding:2px;border-radius:12px;
  color:var(--muted);font:600 10px/1 system-ui,-apple-system,sans-serif;text-decoration:none;
  -webkit-tap-highlight-color:transparent;transition:color .16s
}
.mobnav .ico{position:relative;display:flex;align-items:center;justify-content:center;width:44px;height:22px;border-radius:12px;transition:background .2s,transform .2s}
.mobnav a svg,.mobnav button svg{width:23px;height:23px;transition:stroke .16s}
.mobnav a:active .ico,.mobnav button:active .ico{transform:scale(.9)}
.mobnav a.active{color:var(--primary)}
.mobnav a.active svg{stroke:var(--primary)}
.mobnav a.active .ico{background:rgba(124,58,237,.14)}
:root[data-theme="dark"] .mobnav a.active .ico{background:rgba(139,92,246,.22)}
/* petite pastille de notif reutilisable dans la barre */
.mobnav .mn-dot{position:absolute;top:-3px;right:1px;min-width:15px;height:15px;padding:0 3px;border-radius:9px;background:var(--red,#ef4444);color:#fff;font-size:9px;font-weight:800;display:flex;align-items:center;justify-content:center;border:2px solid var(--surface)}

/* Header facon appli en mode installe : sans champ de recherche (le positionnement fixe est gere plus bas) */
html.standalone .topbar .search{display:none}
/* Bandeau d'installation (mobile, tant que pas installe) */
.inst-banner{display:none}
@media(max-width:860px){
  .inst-banner{
    display:flex;align-items:center;gap:12px;margin:0 0 14px;padding:12px 14px;
    background:linear-gradient(135deg,var(--primary),#7c3aed);color:#fff;border-radius:14px
  }
  .inst-banner .ib-ic{width:34px;height:34px;flex:none;background:rgba(255,255,255,.18);border-radius:9px;display:flex;align-items:center;justify-content:center}
  .inst-banner b{display:block;font-size:13.5px}
  .inst-banner small{opacity:.85;font-size:11.5px}
  .inst-banner .ib-btn{margin-left:auto;background:#fff;color:var(--primary);border:0;border-radius:9px;padding:8px 13px;font-weight:700;font-size:12.5px;cursor:pointer;white-space:nowrap}
  .inst-banner .ib-x{background:transparent;border:0;color:#fff;opacity:.8;font-size:17px;cursor:pointer;padding:0 2px;line-height:1}
}

/* Bottom-sheet instructions iOS (injecte par pwa.js) */
.pwa-sheet-back{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:9998;display:flex;align-items:flex-end;justify-content:center}
.pwa-sheet{background:var(--surface,#fff);color:var(--ink,#0f172a);width:100%;max-width:460px;border-radius:20px 20px 0 0;padding:22px 20px calc(22px + env(safe-area-inset-bottom,0px));box-shadow:0 -10px 40px rgba(0,0,0,.3);animation:pwaUp .25s ease}
@keyframes pwaUp{from{transform:translateY(100%)}to{transform:translateY(0)}}
.pwa-sheet h3{margin:0 0 6px;font-size:17px}
.pwa-sheet p{margin:0 0 14px;color:var(--muted,#64748b);font-size:13.5px;line-height:1.5}
.pwa-sheet .step{display:flex;align-items:center;gap:12px;padding:11px 12px;border:1px solid var(--line,#e2e8f0);border-radius:12px;margin-bottom:9px;font-size:13.5px}
.pwa-sheet .step .n{width:24px;height:24px;flex:none;background:var(--primary);color:#fff;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:12px}
.pwa-sheet .close{margin-top:8px;width:100%;padding:11px;border:0;border-radius:11px;background:var(--primary);color:#fff;font-weight:700;font-size:14px;cursor:pointer}

/* Reglages d'app en mode installe (standalone) */
@media all and (display-mode:standalone){
  .topbar .search{display:none}
}
.user-chip{display:flex;align-items:center;gap:10px;color:#e2e8f0}
.user-chip .av{width:34px;height:34px;border-radius:50%;background:var(--primary);display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:13px;flex:none}
.user-chip small{color:#94a3b8;display:block}

.main{flex:1;margin-left:248px;display:flex;flex-direction:column;min-width:0;max-width:100%}
.content{min-width:0}
.topbar{height:40px;background:var(--topbar-bg);backdrop-filter:blur(8px);border-bottom:1px solid var(--line);
  display:flex;align-items:center;gap:16px;padding:0 26px;position:sticky;top:0;z-index:20}
.theme-btn{width:38px;height:38px;border-radius:9px;border:1px solid var(--line);background:var(--surface);color:var(--muted);display:inline-flex;align-items:center;justify-content:center;cursor:pointer}
.theme-btn:hover{color:var(--ink)}
.notif-dot{position:absolute;top:-5px;right:-5px;background:var(--red);color:#fff;font-size:10px;font-weight:800;min-width:17px;height:17px;border-radius:9px;display:flex;align-items:center;justify-content:center;padding:0 4px;border:2px solid var(--surface)}
.flash-ok{background:var(--primary-50);color:var(--primary);border:1px solid var(--primary);border-radius:10px;padding:11px 14px;margin-bottom:16px;font-weight:600}
code{background:var(--primary-50);color:var(--primary);padding:1px 6px;border-radius:6px;font-size:12.5px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
pre.code{background:#0f172a;color:#e2e8f0;padding:14px 16px;border-radius:10px;overflow-x:auto;font-size:12.5px;line-height:1.55;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;margin:10px 0}
pre.code b{color:#93c5fd;font-weight:600}
.doc h2{font-size:17px;margin:26px 0 12px}
.doc p{color:var(--muted)}
.doc .method{display:inline-block;font-weight:800;font-size:11px;padding:2px 7px;border-radius:6px;margin-right:8px}
.doc .get{background:#dbeafe;color:#1e40af}.doc .post{background:#dcfce7;color:#166534}
.theme-btn .i-sun{display:none}
:root[data-theme="dark"] .theme-btn .i-moon{display:none}
:root[data-theme="dark"] .theme-btn .i-sun{display:block}
.topbar h1{font-size:18px}
.topbar .search{flex:1;max-width:420px}
.topbar .search input{width:100%;border:1px solid var(--line);background:var(--input-bg);color:var(--ink);border-radius:10px;padding:9px 13px;font-size:13px}
.topbar .spacer{flex:1}
.content{padding:26px;width:100%}

/* ---------- Cards / grid ---------- */
.grid{display:grid;gap:18px}
.g-4{grid-template-columns:repeat(4,1fr)}
.g-3{grid-template-columns:repeat(3,1fr)}
.g-2{grid-template-columns:repeat(2,1fr)}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);overflow:hidden}
.card .hd{padding:16px 18px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between}
.card .hd h3{font-size:15px}
.card .bd{padding:18px}
.card.pad{padding:18px}

/* KPI */
.kpi{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow-sm);position:relative;overflow:hidden}
.kpi .lbl{color:var(--muted);font-size:12.5px;font-weight:600;text-transform:uppercase;letter-spacing:.03em}
.kpi .val{font-size:27px;font-weight:750;margin-top:8px;letter-spacing:-.02em}
.kpi .sub{font-size:12.5px;color:var(--muted);margin-top:4px}
.kpi .ic{position:absolute;top:16px;right:16px;width:38px;height:38px;border-radius:10px;display:flex;align-items:center;justify-content:center;background:var(--primary-50);color:var(--primary)}
.kpi .ic svg{width:20px;height:20px}

/* ---------- Progress ---------- */
.bar{height:8px;border-radius:99px;background:var(--line);overflow:hidden}
.bar > span{display:block;height:100%;background:var(--primary);border-radius:99px}

/* ---------- Badges ---------- */
.badge{display:inline-flex;align-items:center;gap:6px;padding:3px 9px;border-radius:99px;font-size:12px;font-weight:600;background:#f1f5f9;color:#475569}
.badge.dot::before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor}
.badge.green{background:#ecfdf3;color:#15803d}.badge.amber{background:#fffbeb;color:#b45309}
.badge.red{background:#fef2f2;color:#b91c1c}.badge.sky{background:#eff6ff;color:#0369a1}
.badge.violet{background:#f5f3ff;color:#6d28d9}.badge.slate{background:#f1f5f9;color:#475569}

/* ---------- Tables ---------- */
.tscroll{overflow-x:auto;-webkit-overflow-scrolling:touch}
table.tbl{width:100%;border-collapse:collapse;font-size:13.5px}
table.tbl.wide{min-width:680px}
table.tbl th{text-align:left;color:var(--muted);font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.03em;padding:11px 14px;border-bottom:1px solid var(--line)}
table.tbl.wide th{cursor:pointer;user-select:none;white-space:nowrap;transition:.1s}
table.tbl.wide th:hover{color:var(--ink)}
table.tbl.wide th[data-sort=asc]::after{content:" ↑";color:var(--primary);font-weight:800}
table.tbl.wide th[data-sort=desc]::after{content:" ↓";color:var(--primary);font-weight:800}
table.tbl td{padding:12px 14px;border-bottom:1px solid var(--line)}
table.tbl tr:last-child td{border-bottom:none}
table.tbl tbody tr:hover{background:#fafbfe}
.tbl .who{display:flex;align-items:center;gap:9px}
.av-sm{width:28px;height:28px;border-radius:50%;background:var(--primary-50);color:var(--primary);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:11px;flex:none}

/* ---------- Kanban ---------- */
.kanban{display:flex;gap:14px;overflow-x:auto;padding-bottom:6px}
.kcol{min-width:270px;width:270px;flex:none;background:#f1f3f9;border-radius:var(--radius);padding:10px}
.kcol .kh{display:flex;align-items:center;justify-content:space-between;padding:6px 8px 10px;font-weight:650;font-size:13px}
.kcol .kh .cnt{font-size:12px;color:var(--muted);font-weight:600}
.kcard{background:#fff;border:1px solid var(--line);border-radius:11px;padding:12px;margin-bottom:9px;box-shadow:var(--shadow-sm);cursor:pointer;transition:.15s}
.kcard:hover{transform:translateY(-1px);box-shadow:var(--shadow)}
.kcard .t{font-weight:600;font-size:13.5px;margin-bottom:5px}
.kcard .co{color:var(--muted);font-size:12.5px}
.kcard .m{font-weight:700;margin-top:8px;font-size:14px}
.kcol .sum{padding:4px 8px;font-size:12px;color:var(--muted)}

/* ---------- Buttons / misc ---------- */
.btn{display:inline-flex;align-items:center;gap:7px;background:var(--primary);color:#fff;border:none;border-radius:10px;padding:9px 15px;font-weight:600;font-size:13.5px;cursor:pointer;transition:.15s}
.btn:hover{background:var(--primary-600)}
.btn.ghost{background:var(--surface);color:var(--ink);border:1px solid var(--line)}
.btn.ghost:hover{background:var(--bg)}
.btn svg{width:16px;height:16px}
/* champs de formulaire : s'adaptent au thème (les styles inline transparents restent prioritaires) */
select,textarea,input[type=text],input[type=email],input[type=search],input[type=date],input[type=password],input[type=number]{background:var(--input-bg);color:var(--ink)}
select option{background:var(--surface);color:var(--ink)}
.pagetitle{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:20px}
.pagetitle p{margin:4px 0 0;color:var(--muted)}
.stack{display:flex;flex-direction:column;gap:18px}
.muted{color:var(--muted)}
.empty{padding:30px;text-align:center;color:var(--muted)}
.list-item{display:flex;align-items:center;gap:12px;padding:11px 4px;border-bottom:1px solid var(--line)}
.list-item:last-child{border-bottom:none}
.list-item .grow{flex:1;min-width:0}
.list-item .grow b{font-weight:600}
.dueflag{font-size:12px;font-weight:600}
.dueflag.late{color:var(--red)}

/* ---------- Login ---------- */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#eef2ff,#f6f7fb)}
.login{background:#fff;border-radius:18px;box-shadow:var(--shadow);width:400px;max-width:92vw;padding:34px}
.login .logo{width:46px;height:46px;border-radius:12px;background:linear-gradient(135deg,var(--primary),#7c3aed);display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:20px;margin-bottom:18px}
.login h2{font-size:20px}.login p{color:var(--muted);margin:4px 0 22px}
.field{margin-bottom:14px}
.field label{display:block;font-weight:600;font-size:12.5px;margin-bottom:6px}
.field input{width:100%;border:1px solid var(--line);border-radius:10px;padding:11px 13px;font-size:14px}
.field input:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-50)}
.demo-accounts{margin-top:20px;font-size:12.5px;color:var(--muted);background:var(--bg);border:1px solid var(--line);border-radius:10px;padding:12px}
.demo-accounts b{color:var(--ink)}
.flash{background:#fef2f2;color:#b91c1c;border:1px solid #fecaca;border-radius:10px;padding:10px 12px;font-size:13px;margin-bottom:14px}

/* ---------- Responsive ---------- */
@media(max-width:1100px){.g-4{grid-template-columns:repeat(2,1fr)}.g-3{grid-template-columns:1fr}}
@media(max-width:860px){
  .sidebar{transform:translateX(-100%);transition:.2s;z-index:50;box-shadow:0 0 40px rgba(0,0,0,.3)}
  .sidebar.open{transform:none}
  .main{margin-left:0}
  .g-2,.g-3{grid-template-columns:1fr}
  .g-4{grid-template-columns:repeat(2,1fr)}
  .menu-btn{display:inline-flex!important}
  .content{padding:16px}
  .topbar{padding:0 14px;gap:10px}
  .topbar .search{display:none}
  .topbar h1{display:none}
  .pagetitle h1{font-size:19px!important}
  .kpi .val{font-size:23px}
}
@media(max-width:560px){ .g-4,.g-3,.g-2{grid-template-columns:1fr} }
.menu-btn{display:none;align-items:center;justify-content:center;width:38px;height:38px;border-radius:9px;border:1px solid var(--line);background:var(--surface);color:var(--ink)}

/* ---------- Autocomplétion SIRENE ---------- */
.sirene-box{position:absolute;top:100%;left:0;right:0;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:10px;box-shadow:var(--shadow);margin-top:4px;max-height:300px;overflow-y:auto}
.sirene-box:empty{display:none}
.sirene-item{padding:9px 12px;cursor:pointer;border-bottom:1px solid var(--line);display:flex;flex-direction:column;gap:2px}
.sirene-item:last-child{border-bottom:none}
.sirene-item:hover{background:var(--bg)}
.sirene-item b{font-size:13.5px}
.sirene-item span{font-size:12px;color:var(--muted)}

/* ---------- Rapprochement annuaire (SIRENE) ---------- */
.reco-box:empty{display:none}
.reco-box{margin:8px 0 4px;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--bg)}
.reco-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:8px}
.reco-card{display:flex;align-items:center;gap:12px;justify-content:space-between;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:var(--surface);margin-top:8px}
.reco-card.primary{border-color:var(--primary);box-shadow:0 0 0 1px var(--primary) inset}
.reco-card-main{font-size:13px;line-height:1.5;min-width:0}
.reco-card-main .muted{font-size:12px}
.reco-card-act{flex:none}
.reco-more{margin-top:8px}
.reco-more summary{cursor:pointer;font-size:12.5px;color:var(--primary);font-weight:600;user-select:none}
.reco-list{margin-top:2px}

/* ---------- Grille de formulaire large (entreprise) ---------- */
.form-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0 18px}
.form-grid .span-all{grid-column:1/-1}
@media(max-width:820px){.form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:540px){.form-grid{grid-template-columns:1fr}}

/* ---------- Console super-admin (plateforme) ---------- */
.admin-shell{min-height:100vh;display:flex;flex-direction:column;background:var(--bg)}
.admin-top{display:flex;align-items:center;gap:10px;padding:12px 22px;background:var(--surface);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20}
.admin-brand{display:flex;align-items:center;gap:9px;font-size:15px}
.admin-brand .logo{width:28px;height:28px;border-radius:8px;background:linear-gradient(135deg,var(--primary),#7c3aed);display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800}
.admin-main{padding:26px;width:100%;max-width:1200px;margin:0 auto;flex:1}
@media(max-width:720px){
  .admin-top{flex-wrap:wrap;padding:10px 14px;gap:8px 10px;row-gap:8px}
  .admin-top .admin-brand{flex:1 1 auto}
  .admin-top>div[style*="flex:1"]{display:none}        /* le spacer forcerait un retour a la ligne inutile */
  .admin-top .user-chip small{display:none}            /* masque l'email pour gagner de la place */
  .admin-main{padding:16px}
}
@media(max-width:420px){
  .admin-top .user-chip>div{display:none}              /* garde juste l'avatar */
}
.imp-banner{background:#fef3c7;color:#92400e;border:1px solid #f59e0b;border-radius:10px;padding:9px 14px;margin-bottom:16px;font-size:13px}
.imp-banner a{font-weight:700;text-decoration:underline}
:root[data-theme="dark"] .imp-banner{background:#3a2c08;color:#fde68a;border-color:#a16207}

/* ---------- Logo client (marque blanche) dans la sidebar sombre ---------- */
.brand-logo{display:inline-flex;align-items:center;justify-content:center;background:#fff;border-radius:8px;padding:6px 10px;max-width:184px}
.brand-logo img{max-height:30px;max-width:160px;object-fit:contain;display:block}

/* ---------- Marque CRMia (sidebar) ---------- */
.brand-ic{width:32px;height:32px;object-fit:contain;flex:none;filter:drop-shadow(0 2px 6px rgba(0,0,0,.35))}
.brand-name{font-weight:800;font-size:18px;letter-spacing:-.02em;color:#fff}
.brand-name span{color:#a78bfa}

/* ---------- Écran de connexion (punchy) ---------- */
.auth-body{margin:0;background:var(--bg)}
.auth{display:grid;grid-template-columns:1.05fr .95fr;min-height:100vh}
.auth-hero{position:relative;overflow:hidden;display:flex;align-items:center;padding:60px;color:#fff;
  background:linear-gradient(135deg,#4338ca 0%,#6d28d9 52%,#7c3aed 100%)}
.auth-hero::before{content:"";position:absolute;inset:0;
  background:radial-gradient(620px 320px at 82% 15%,rgba(255,255,255,.20),transparent),
             radial-gradient(520px 420px at 8% 92%,rgba(255,255,255,.12),transparent)}
.auth-hero::after{content:"";position:absolute;right:-120px;bottom:-120px;width:360px;height:360px;border-radius:50%;
  border:1px solid rgba(255,255,255,.18)}
.auth-hero-in{position:relative;max-width:460px}
.hero-brand{display:flex;align-items:center;gap:13px;margin-bottom:34px;font-size:27px;font-weight:800;letter-spacing:-.02em}
.hero-brand > span span{color:#e9d5ff}
.hero-ic{width:46px;height:46px;object-fit:contain;filter:drop-shadow(0 6px 16px rgba(0,0,0,.3))}
.hero-logo-chip{display:inline-flex;background:#fff;border-radius:14px;padding:14px 18px;margin-bottom:26px}
.hero-logo-chip img{max-height:52px;max-width:230px;object-fit:contain;display:block}
.auth-hero h1{font-size:36px;line-height:1.12;letter-spacing:-.025em;margin:0 0 16px;font-weight:750}
.auth-hero p{font-size:15.5px;opacity:.92;line-height:1.6;margin:0}
.hero-powered{margin-top:22px;font-size:13px;opacity:.8}
.hero-feats{list-style:none;padding:0;margin:30px 0 0;display:flex;flex-direction:column;gap:13px}
.hero-feats li{position:relative;padding-left:30px;font-size:14.5px;opacity:.96}
.hero-feats li::before{content:"✓";position:absolute;left:0;top:0;width:21px;height:21px;background:rgba(255,255,255,.22);
  border-radius:50%;text-align:center;line-height:21px;font-size:12px;font-weight:800}
.auth-form{display:flex;align-items:center;justify-content:center;padding:40px}
.auth-card{width:100%;max-width:390px;background:var(--surface);border:1px solid var(--line);border-radius:20px;
  padding:36px 32px;box-shadow:var(--shadow)}
.auth-card-brand{text-align:center;margin-bottom:22px}
.auth-card h2{font-size:22px;margin:0 0 4px}
.auth-sub{color:var(--muted);font-size:13.5px;margin:0 0 18px}
.auth-card .field{margin-bottom:14px}
.auth-card .field label{display:block;font-size:12.5px;font-weight:600;color:var(--muted);margin-bottom:6px}
.auth-card .field input{width:100%;border:1px solid var(--line);background:var(--input-bg);color:var(--ink);
  border-radius:11px;padding:11px 13px;font-size:14px}
.auth-card .field textarea{width:100%;border:1px solid var(--line);background:var(--input-bg);color:var(--ink);
  border-radius:11px;padding:11px 13px;font-size:14px;font-family:inherit;resize:vertical;min-height:96px}
.auth-card .field input:focus,.auth-card .field textarea:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-50)}
.auth-btn{width:100%;justify-content:center;gap:8px;padding:12px;font-size:14.5px;margin-top:4px}
.auth-card .flash{background:#fef2f2;color:#b91c1c;border:1px solid #fecaca;border-radius:11px;padding:10px 13px;margin-bottom:14px;font-size:13px}
:root[data-theme="dark"] .auth-card .flash{background:#3b1113;color:#fecaca;border-color:#7f1d1d}
.demo-accounts{margin-top:18px;border-top:1px solid var(--line);padding-top:14px;font-size:12.5px;color:var(--muted)}
.demo-accounts summary{cursor:pointer;font-weight:600;user-select:none}
.demo-accounts div{padding:3px 0}
@media(max-width:880px){
  .auth{display:block}
  .auth-hero{display:none}
  .auth-form{display:block;min-height:100vh;padding:22px 16px;width:100%}
  .auth-card{width:100%;max-width:440px;margin:0 auto}
}

/* ---------- Marque dans la topbar (visible sur mobile, sidebar masquée) ---------- */
.topbar-brand{display:none;align-items:center;gap:8px;color:var(--ink)}
.topbar-brand .tb-ic{width:26px;height:26px;object-fit:contain;flex:none}
.topbar-brand b{font-weight:800;font-size:15px;letter-spacing:-.02em}
.topbar-brand b span{color:var(--primary)}
.topbar-brand .tb-logo{background:#fff;border-radius:7px;padding:4px 8px;display:inline-flex}
.topbar-brand .tb-logo img{max-height:22px;max-width:130px;object-fit:contain;display:block}
@media(max-width:860px){ .topbar-brand{display:inline-flex} }

/* ===== iOS/PWA plein ecran : contenu jamais sous l'heure (status bar) ===== */
/* Marche sans JS (media display-mode) -> s'applique aussi sur /login, /admin, etc. */
@media all and (display-mode:standalone){
  /* topbar VRAIMENT fixe (sticky casse par overflow-x:hidden) + hauteur auto (sinon le safe-area ecrase le contenu) */
  .topbar{position:fixed;left:0;right:0;top:0;z-index:50;height:auto;min-height:30px;
          padding-top:calc(2px + env(safe-area-inset-top,0px)) !important;padding-bottom:6px}
  .main .content{padding-top:calc(54px + env(safe-area-inset-top,0px))}
  .admin-top{height:auto;padding-top:calc(4px + env(safe-area-inset-top,0px)) !important}
  .auth{padding-top:env(safe-area-inset-top,0px);box-sizing:border-box}
  .off-wrap{padding-top:calc(24px + env(safe-area-inset-top,0px))}
  .mobnav{display:flex}
}
