/* Identité Corporate (reprise de prototype/index.html) — clair par défaut, sombre au choix. */
:root{
  --bg:#EFF6F5; --surface:#FFFFFF; --surface-alt:#E3F0EE;
  --text:#0B2A4A; --text-muted:#4C6E78; --text-faint:#8AAAB0;
  --primary:#0F7A6D; --primary-strong:#0B5C52; --on-primary:#FFFFFF;
  --accent:#14A393; --on-accent:#062A22;
  --border:#D9E7E5; --border-strong:#BFDBD6;
  --brand-gradient:linear-gradient(135deg, #14A393 0%, #0B2A4A 100%);
  --status-new:#2E63A6; --status-new-bg:#E4EEFA;
  --status-progress:#B9791F; --status-progress-bg:#FBF0DC;
  --status-won:#2B8A56; --status-won-bg:#E3F5EA;
  --status-lost:#B14545; --status-lost-bg:#FBE7E7;
  --radius-sm:8px; --radius-md:12px; --radius-lg:20px;
  --shadow-card:0 1px 2px rgba(11,42,74,.06), 0 8px 20px rgba(11,42,74,.08);
  --font-display:"Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  --font-body:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --tracking-label:.09em; --weight-display:600;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#00325D; --surface:#0E4A7D; --surface-alt:#0A3F6D;
    --text:#F2F8FC; --text-muted:#A9C7DD; --text-faint:#6E93B3;
    --primary:#1A9E90; --primary-strong:#2FBFAE; --on-primary:#FFFFFF;
    --accent:#3FE0CC; --on-accent:#022A22;
    --border:#175080; --border-strong:#2A6699;
    --brand-gradient:linear-gradient(135deg, #1A9E90 0%, #00325D 100%);
    --status-new:#7FB0EA; --status-new-bg:#123A5E;
    --status-progress:#E0AC55; --status-progress-bg:#3A2C12;
    --status-won:#6FCB98; --status-won-bg:#0F3A2C;
    --status-lost:#E68080; --status-lost-bg:#3A1A1A;
    --shadow-card:0 1px 2px rgba(0,0,0,.25), 0 10px 24px rgba(0,0,0,.35);
    color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --bg:#00325D; --surface:#0E4A7D; --surface-alt:#0A3F6D;
  --text:#F2F8FC; --text-muted:#A9C7DD; --text-faint:#6E93B3;
  --primary:#1A9E90; --primary-strong:#2FBFAE; --on-primary:#FFFFFF;
  --accent:#3FE0CC; --on-accent:#022A22;
  --border:#175080; --border-strong:#2A6699;
  --brand-gradient:linear-gradient(135deg, #1A9E90 0%, #00325D 100%);
  --status-new:#7FB0EA; --status-new-bg:#123A5E;
  --status-progress:#E0AC55; --status-progress-bg:#3A2C12;
  --status-won:#6FCB98; --status-won-bg:#0F3A2C;
  --status-lost:#E68080; --status-lost-bg:#3A1A1A;
  --shadow-card:0 1px 2px rgba(0,0,0,.25), 0 10px 24px rgba(0,0,0,.35);
  color-scheme:dark;
}

/* ---------- Base ---------- */
*,*::before,*::after{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{ background:var(--bg); color:var(--text); font-family:var(--font-body); min-height:100vh; min-height:100dvh; }
button{ font:inherit; color:inherit; }
input,select,textarea{ font:inherit; }
a{ color:var(--primary); }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:2px; }
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{ animation-duration:.001ms !important; transition-duration:.001ms !important; scroll-behavior:auto !important; }
}
.boot, .boot-error{ padding:48px 20px; text-align:center; color:var(--text-muted); }

/* ---------- Mise en page mobile : colonne centrée, jamais étirée ---------- */
.m-app{ max-width:480px; margin:0 auto; min-height:100vh; min-height:100dvh; display:flex; flex-direction:column; background:var(--bg); }
@media (min-width:481px){ .m-app{ border-left:1px solid var(--border); border-right:1px solid var(--border); } }
.m-header{
  position:sticky; top:0; z-index:10; background:var(--bg);
  padding:calc(12px + env(safe-area-inset-top, 0px)) 20px 12px; display:flex; align-items:center; gap:10px; min-height:60px;
}
.m-header h1{
  font-family:var(--font-display); font-weight:var(--weight-display); font-size:1.4rem; margin:0;
  flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.m-content{ flex:1; padding:4px 20px 110px; overflow-x:hidden; }
.m-tabbar{
  position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:480px; z-index:10;
  display:flex; border-top:1px solid var(--border); background:var(--surface);
  padding:10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
}
.m-tabbar[hidden]{ display:none; }
.m-tabbar a{
  flex:1; min-width:0; display:flex; flex-direction:column; align-items:center; gap:4px; padding:6px 4px;
  color:var(--text-muted); text-decoration:none; font-size:11px; font-weight:600;
  letter-spacing:var(--tracking-label); text-transform:uppercase; text-align:center;
}
.m-tabbar a[aria-current="page"]{ color:var(--primary); }
.m-tabbar .dot{ width:6px; height:6px; border-radius:50%; background:currentColor; opacity:0; }
.m-tabbar a[aria-current="page"] .dot{ opacity:1; }
@media (max-width:400px){
  .m-tabbar{ padding-left:6px; padding-right:6px; }
  .m-tabbar a{ font-size:10px; letter-spacing:.04em; }
}
.icon-spacer{ width:34px; flex:none; }
.icon-btn{
  position:relative; width:34px; height:34px; border-radius:50%; border:1px solid var(--border); background:var(--surface);
  display:inline-flex; align-items:center; justify-content:center; cursor:pointer; flex:none; color:var(--text); text-decoration:none;
}
.icon-btn:disabled{ opacity:.35; cursor:default; }
.icon-btn svg{ width:16px; height:16px; }
.icon-badge{
  position:absolute; top:-4px; right:-4px; min-width:15px; height:15px; padding:0 4px;
  border-radius:999px; background:var(--status-lost); color:#fff; font-size:9px; font-weight:800;
  display:flex; align-items:center; justify-content:center; line-height:1;
}

/* ---------- Composants (repris du prototype) ---------- */
.eyebrow{ font-size:11px; font-weight:700; letter-spacing:var(--tracking-label); text-transform:uppercase; color:var(--text-muted); margin:0 0 6px; }
.between .eyebrow, .card .eyebrow{ margin:0; }
.card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); box-shadow:var(--shadow-card); padding:16px; }
.stack{ display:flex; flex-direction:column; gap:12px; }
.stack-tight{ gap:4px; }
.stack-tight p{ line-height:1.35; }
.row{ display:flex; align-items:center; gap:10px; }
.row.wrap{ flex-wrap:wrap; }
.gap-6{ gap:6px; }
.between{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.block{ margin-bottom:14px; }
.block-top{ margin-top:14px; }
.mail-composer{ margin-bottom:18px; border-color:var(--primary); }
.mail-composer textarea{ min-height:260px; line-height:1.45; }
.section-head{ margin-bottom:10px; }
.self-start{ align-self:flex-start; }
.muted{ color:var(--text-muted); font-size:13px; }
.small{ font-size:12.5px; }
.tiny{ font-size:11.5px; }
.faint{ color:var(--text-faint); }
.hint{ margin:0; font-size:13px; color:var(--text-muted); }
.descriptif{ font-size:13.5px; margin:4px 0 0; white-space:pre-line; }
.note{ margin:8px 0 0; white-space:pre-line; }
.count{ font-size:12px; color:var(--text-muted); font-variant-numeric:tabular-nums; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px; text-decoration:none;
  border-radius:var(--radius-sm); padding:12px 18px; font-weight:700; font-size:14px; cursor:pointer;
  border:1px solid transparent; width:100%;
}
.btn:disabled{ opacity:.6; cursor:progress; }
.btn-primary{ background:var(--brand-gradient, var(--primary)); color:var(--on-primary); }
.btn-primary:hover{ filter:brightness(.92); }
.btn-ghost{ background:var(--surface); color:var(--text); border-color:var(--border); }
.btn-ghost:hover{ border-color:var(--border-strong); }
.btn-accent{ background:var(--accent); color:var(--on-accent); }
.btn-sm{ width:auto; padding:9px 14px; font-size:13px; }
.btn-danger{ background:var(--status-lost-bg); color:var(--status-lost); border-color:var(--status-lost-bg); }

.field{ display:flex; flex-direction:column; gap:6px; }
.field[hidden]{ display:none; }
.field label{ font-size:12px; font-weight:700; color:var(--text-muted); letter-spacing:.02em; }
.field input, .field select, .field textarea, .chat-form textarea{
  border:1px solid var(--border); background:var(--surface); color:var(--text);
  border-radius:var(--radius-sm); padding:11px 12px; width:100%;
}
.field textarea{ resize:vertical; min-height:80px; }
.field .err{ font-size:12px; color:var(--status-lost); }
.field .invalid{ border-color:var(--status-lost); }
.field-sm label{ font-size:11px; }
.field-sm input, .field-sm select, .field-sm textarea{ padding:7px 9px; font-size:12.5px; }
.field-sm textarea{ min-height:52px; }
.input-group{
  display:flex; align-items:center; border:1px solid var(--border); background:var(--surface);
  border-radius:var(--radius-sm);
}
.field .input-group input{ border:0; background:none; flex:1; min-width:0; }
.input-group input:focus-visible{ outline:none; }
.input-group:focus-within{ outline:2px solid var(--accent); outline-offset:2px; }
.input-suffix{ padding-right:12px; color:var(--text-muted); white-space:nowrap; }
.password-wrap{ position:relative; }
.field .password-wrap input{ padding-right:44px; }
.password-toggle{
  position:absolute; top:50%; right:4px; transform:translateY(-50%);
  display:flex; align-items:center; justify-content:center; width:36px; height:36px;
  border:0; background:none; color:var(--text-muted); cursor:pointer; border-radius:var(--radius-sm);
}
.password-toggle:hover{ color:var(--text); }
.check{ display:flex; align-items:center; gap:8px; font-size:13px; }
/* Recherche de bien : intitulé d'un groupe de cases, communes choisies (croix), suggestions de communes. */
.field .field-label{ font-size:11px; font-weight:700; color:var(--text-muted); letter-spacing:.02em; margin:0; }
.chip-remove{ display:inline-flex; align-items:center; border:0; background:none; padding:0; margin-left:2px; color:var(--text-muted); cursor:pointer; }
.chip-remove:hover{ color:var(--text); }
.chip-remove svg{ width:12px; height:12px; }
.suggestions{ display:flex; flex-direction:column; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); overflow:hidden; }
.suggestion{ text-align:left; border:0; border-bottom:1px solid var(--border); background:none; color:var(--text); padding:9px 12px; font-size:13px; cursor:pointer; }
.suggestion:last-child{ border-bottom:none; }
.suggestion:hover, .suggestion:focus-visible{ background:var(--surface-alt); }

.pill{ display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:700; padding:5px 10px; border-radius:999px; letter-spacing:.01em; white-space:nowrap; }
/* Dans une ligne de liste, un libellé de statut long est tronqué pour laisser la place au nom du client. */
.list-item .pill{ display:inline-block; max-width:45%; overflow:hidden; text-overflow:ellipsis; flex-shrink:1; }
.pill-neutral{ background:var(--surface-alt); color:var(--text); }
.pill-clear{ color:inherit; text-decoration:none; font-weight:700; margin-left:2px; }
.tag{ font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text-muted); border:1px solid var(--border); border-radius:999px; padding:2px 7px; }
.new-dot{ width:9px; height:9px; border-radius:50%; background:var(--status-new); flex:none; }
.badge-unread{
  min-width:20px; height:20px; padding:0 6px; border-radius:999px; flex:none;
  background:var(--primary); color:var(--on-primary); font-size:11px; font-weight:700;
  display:inline-flex; align-items:center; justify-content:center; line-height:1;
}
/* Échanges d'une affaire : colonne inversée, le plus récent en bas et visible sans défiler */
.chat-scroll{ display:flex; flex-direction:column-reverse; gap:8px; max-height:340px; overflow-y:auto; padding:4px 0; }
.bubble{ max-width:82%; padding:9px 12px; border-radius:14px; font-size:14px; }
.bubble p{ margin:0; white-space:pre-wrap; overflow-wrap:anywhere; }
.bubble-left{ align-self:flex-start; background:var(--surface-alt); color:var(--text); border-bottom-left-radius:4px; }
.bubble-right{ align-self:flex-end; background:var(--primary); color:var(--on-primary); border-bottom-right-radius:4px; }
.bubble-meta{ display:block; margin-top:4px; font-size:11px; opacity:.75; }
.bubble-right .bubble-meta{ text-align:right; }
.chat-form{ display:flex; gap:8px; align-items:flex-end; margin-top:8px; }
.chat-form textarea{ flex:1; min-height:44px; resize:vertical; }
.tab-icon{ position:relative; display:inline-flex; }
.tab-icon svg{ width:18px; height:18px; }
.badge-tab{
  position:absolute; top:-6px; right:-9px; min-width:16px; height:16px; padding:0 4px;
  border-radius:999px; background:var(--status-lost); color:#fff; font-size:9.5px; font-weight:700;
  display:flex; align-items:center; justify-content:center; line-height:1;
}
.avatar{
  width:40px; height:40px; border-radius:50%; background:var(--surface-alt); color:var(--primary);
  display:flex; align-items:center; justify-content:center; font-weight:700; font-family:var(--font-display); flex:none;
  border:1px solid var(--border);
}
.avatar-ref{ font-family:var(--font-body); }
.avatar-date{ font-family:var(--font-body); font-size:11px; text-align:center; line-height:1.1; }
.avatar-date.is-overdue{ color:var(--status-lost); border-color:var(--status-lost); }
.list-item{
  display:flex; align-items:center; gap:12px; padding:14px 4px; border-bottom:1px solid var(--border);
  color:inherit; text-decoration:none; cursor:pointer;
}
.list-item.is-static{ cursor:default; }
.list-item:last-child{ border-bottom:none; }
a.list-item:hover{ background:var(--surface-alt); border-radius:var(--radius-sm); }
.list-item .meta{ flex:1; min-width:0; }
.list-item .meta strong{ display:block; font-size:14.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.list-item .meta span{ display:block; font-size:12.5px; color:var(--text-muted); overflow:hidden; text-overflow:ellipsis; }
/* État d'avancement d'une affaire : ligne dédiée, en couleur principale pour ressortir du détail gris. */
.list-item .meta .row-etape{ display:flex; align-items:center; gap:5px; margin-top:3px; color:var(--primary); font-weight:700; white-space:nowrap; }
.row-etape svg{ width:14px; height:14px; flex:none; }
.chevron{ color:var(--text-faint); flex:none; display:inline-flex; }
.filter-select{
  border:1px solid var(--border); background:var(--surface); color:var(--text); font-size:12.5px; font-weight:700;
  padding:7px 10px; border-radius:var(--radius-sm); cursor:pointer; max-width:60%;
}
.empty{ text-align:center; padding:40px 12px; color:var(--text-muted); }
.empty svg{ margin-bottom:10px; opacity:.5; }
.empty .btn{ margin-top:12px; }
.loading{ text-align:center; padding:48px 12px; color:var(--text-muted); }
.toast{
  position:fixed; left:50%; bottom:96px; transform:translateX(-50%) translateY(8px); max-width:calc(100% - 32px);
  background:var(--text); color:var(--bg); padding:10px 18px; border-radius:999px; font-size:13px; font-weight:600; text-align:center;
  opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; z-index:50;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.link-box{
  display:flex; align-items:center; gap:10px; border:1px dashed var(--border-strong); background:var(--surface-alt);
  border-radius:var(--radius-sm); padding:10px 12px; min-width:0;
}
.link-box code{ flex:1; min-width:0; font-size:12.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.qr-box{ width:148px; padding:6px; background:#fff; border-radius:var(--radius-sm); border:1px solid var(--border); }
.qr-box svg{ display:block; width:100%; height:auto; }
.statut-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 4px; border-bottom:1px solid var(--border); }
.statut-row:last-child, .statut-edit:last-child{ border-bottom:none; }
.statut-edit{ padding:12px 4px; border-bottom:1px solid var(--border); }
.history .between{ align-items:flex-start; }

/* ---------- Connexion ---------- */
.login-wrap{ padding-top:24px; }
.login-logo-wrap{
  display:flex; align-items:center; justify-content:center; background:var(--brand-gradient);
  border-radius:var(--radius-lg); padding:26px 20px; margin:8px auto 26px; width:min(260px,82%);
}
.login-logo{ display:block; width:100%; height:auto; }
.login-appname{ text-align:center; font-family:var(--font-display); font-weight:var(--weight-display); font-size:1.35rem; margin:0 0 4px; }
.login-wrap .sub{ text-align:center; color:var(--text-muted); font-size:13.5px; margin:0 0 24px; }
.login-hint{ text-align:center; color:var(--text-muted); font-size:12.5px; margin:20px 0 0; }
.app-version{ text-align:center; color:var(--text-faint); font-size:11.5px; margin:28px 0 0; font-variant-numeric:tabular-nums; }

/* ---------- Installation sur l'écran d'accueil, nouvelle version ---------- */
.install-banner{
  display:flex; align-items:center; gap:10px; margin:8px 20px 4px; padding:10px 8px 10px 14px;
  background:var(--surface); border:1px solid var(--border-strong); border-radius:var(--radius-md); box-shadow:var(--shadow-card);
  font-size:13px; line-height:1.4;
}
.install-banner > span{ flex:1; min-width:0; }
.install-banner svg{ vertical-align:-2px; }
.install-banner .btn{ flex-shrink:0; }
.update-banner{
  position:fixed; left:16px; right:16px; top:calc(10px + env(safe-area-inset-top, 0px)); z-index:60; margin:0 auto; max-width:420px;
  display:flex; align-items:center; gap:12px; padding:8px 8px 8px 18px;
  background:var(--text); color:var(--bg); border-radius:999px; box-shadow:var(--shadow-card); font-size:13px; font-weight:600;
}
.update-banner span{ flex:1; min-width:0; }
.update-banner .btn{ flex-shrink:0; border-radius:999px; }

/* ---------- Mise en page desktop (admin, courtier ≥ 1024 px) — reprise de prototype-desktop ---------- */
:root{ --chrome-bg:#0B2A4A; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){ --chrome-bg:#00213F; } }
:root[data-theme="dark"]{ --chrome-bg:#00213F; }

.d-app{ display:grid; grid-template-columns:238px minmax(0,1fr); min-height:100vh; min-height:100dvh; }
.d-sidebar{
  position:sticky; top:0; height:100vh; height:100dvh; overflow-y:auto;
  background:var(--chrome-bg); display:flex; flex-direction:column; padding:20px 14px 16px;
}
.sidebar-brand{ display:flex; align-items:center; gap:10px; padding:0 8px 22px; }
.sidebar-brand img{ width:30px; height:30px; object-fit:contain; }
.sidebar-brand strong{ display:block; font-family:var(--font-display); font-weight:var(--weight-display); font-size:15px; color:#FFFFFF; }
.sidebar-brand span{ display:block; font-size:10.5px; color:rgba(255,255,255,.6); letter-spacing:.06em; text-transform:uppercase; }
.nav-list{ display:flex; flex-direction:column; gap:2px; }
.nav-item{
  display:flex; align-items:center; gap:12px; padding:10px 12px; border-radius:var(--radius-sm);
  color:rgba(255,255,255,.65); font-size:13.5px; font-weight:700; text-decoration:none;
}
.nav-item svg{ flex:none; width:18px; height:18px; }
.nav-item:hover{ background:rgba(255,255,255,.08); color:#FFFFFF; }
.nav-item[aria-current="page"]{ background:rgba(255,255,255,.12); color:var(--accent); }
.nav-badge{
  margin-left:auto; min-width:18px; height:18px; padding:0 5px; border-radius:999px;
  background:var(--status-lost); color:#fff; font-size:10px; font-weight:800;
  display:flex; align-items:center; justify-content:center; line-height:1;
}
.nav-count{
  margin-left:auto; min-width:22px; padding:2px 7px; border-radius:999px; background:rgba(255,255,255,.18);
  color:#FFFFFF; font-size:11.5px; font-weight:700; text-align:center; font-variant-numeric:tabular-nums;
}
.nav-item[aria-current="page"] .nav-count{ background:var(--accent); color:var(--on-accent); }
.sidebar-footer{ margin-top:auto; padding-top:14px; border-top:1px solid rgba(255,255,255,.16); display:flex; align-items:center; gap:10px; }
.sidebar-footer .meta{ flex:1; min-width:0; }
.sidebar-footer strong{ display:block; font-size:13px; color:#FFFFFF; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar-footer span{ display:block; font-size:11px; color:rgba(255,255,255,.6); }

.d-main{ display:flex; flex-direction:column; min-width:0; }
.d-topbar{
  position:sticky; top:0; z-index:10; display:flex; align-items:center; gap:14px;
  min-height:66px; padding:14px 28px; background:var(--chrome-bg);
}
.d-topbar h1{
  font-family:var(--font-display); font-weight:var(--weight-display); font-size:1.35rem; margin:0;
  flex:1; min-width:0; color:#FFFFFF; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.d-topbar .icon-btn{ background:rgba(255,255,255,.14); border-color:rgba(255,255,255,.28); color:#FFFFFF; }
.d-content{ flex:1; width:100%; max-width:1320px; padding:22px 28px 48px; }
/* Écrans communs (formulaires, statuts, rappels) : colonne de lecture confortable. */
.d-content.d-narrow{ max-width:816px; }
[data-layout="desktop"] .toast{ bottom:26px; }
.avatar-sm{ width:30px; height:30px; font-size:10.5px; }
.sr-only{ position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ---------- Tableau de bord ---------- */
.kpi-grid{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; margin-bottom:22px; }
.kpi-card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); padding:16px 18px; box-shadow:var(--shadow-card); }
.kpi-label{ font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--text-muted); margin:0 0 8px; }
.kpi-value{ font-family:var(--font-display); font-weight:var(--weight-display); font-size:1.85rem; margin:0; }
.widget-grid{ display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; align-items:start; margin-bottom:22px; }
.widget-grid.widget-grid-2{ grid-template-columns:repeat(2,minmax(0,1fr)); }
.widget-card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); box-shadow:var(--shadow-card); padding:16px; display:flex; flex-direction:column; gap:10px; min-width:0; }
.widget-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.widget-head strong{ font-size:13.5px; }
.widget-more{ font-size:12px; font-weight:700; color:var(--primary); text-decoration:none; }
.widget-more:hover{ text-decoration:underline; }
.widget-list{ display:flex; flex-direction:column; }
.widget-scroll{ max-height:360px; overflow-y:auto; }
.widget-sub{ margin:10px 4px 2px; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--text-muted); }
.widget-row{ display:flex; align-items:center; gap:10px; padding:9px 4px; border-bottom:1px solid var(--border); color:inherit; text-decoration:none; border-radius:6px; min-width:0; }
.widget-row:last-child{ border-bottom:none; }
a.widget-row:hover{ background:var(--surface-alt); }
.widget-row .meta{ flex:1; min-width:0; }
.widget-row .meta strong{ display:block; font-size:12.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.widget-row .meta span{ display:block; font-size:11.5px; color:var(--text-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.widget-row .pill{ max-width:40%; overflow:hidden; text-overflow:ellipsis; }
.export-card{ display:flex; align-items:flex-end; justify-content:space-between; gap:20px; flex-wrap:wrap; }
.export-card + .export-card{ margin-top:16px; }
.export-fields{ display:flex; align-items:flex-end; gap:12px; flex-wrap:wrap; }
.export-fields .field{ width:170px; }
@media (max-width:1180px){
  .kpi-grid{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .widget-grid, .widget-grid.widget-grid-2{ grid-template-columns:minmax(0,1fr); }
}

/* ---------- Fenêtres modales (routes) ---------- */
.modal{ position:fixed; inset:0; z-index:40; display:flex; align-items:center; justify-content:center; padding:24px; }
.modal-backdrop{ position:absolute; inset:0; background:rgba(0,50,93,.38); }
.modal-panel{
  position:relative; width:min(480px,100%); max-height:calc(100vh - 48px); max-height:calc(100dvh - 48px); overflow-y:auto;
  background:var(--bg); border-radius:var(--radius-lg); box-shadow:0 24px 48px rgba(0,0,0,.28); padding:22px; border:1px solid var(--border);
}
.modal-panel-lg{ width:min(720px,100%); }
.pdf-frame{ display:block; width:100%; height:calc(100vh - 200px); height:calc(100dvh - 200px); min-height:320px; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--surface-alt); }
.modal-panel:has(.pdf-frame){ width:min(1400px,100%); }
.modal:has(.pdf-frame){ padding:16px; }
.modal-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:14px; }
.modal-head h2{ font-family:var(--font-display); font-weight:var(--weight-display); font-size:1.15rem; margin:0; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
html:has(.modal){ overflow:hidden; }

/* ---------- Affaires : liste + panneau de détail (desktop) ---------- */
.split{ display:flex; gap:20px; align-items:flex-start; }
.split-list{ flex:1.15; min-width:0; display:flex; flex-direction:column; gap:12px; }
.split-list-scroll{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); box-shadow:var(--shadow-card); padding:4px 10px; }
.split-detail{
  flex:1; min-width:340px; max-width:480px; position:sticky; top:86px;
  max-height:calc(100vh - 106px); max-height:calc(100dvh - 106px); overflow-y:auto; padding-bottom:8px;
}
.toolbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.toolbar .field{ flex:1; min-width:200px; }
.toolbar .filter-select{ max-width:220px; }
.detail-placeholder{ background:var(--surface); border:1px dashed var(--border-strong); border-radius:var(--radius-md); padding:40px 20px; text-align:center; color:var(--text-muted); }
.detail-placeholder p{ margin:10px 0 0; }
.list-item[aria-current="true"]{ background:var(--surface-alt); box-shadow:inset 3px 0 0 var(--primary); border-radius:var(--radius-sm); }
.modal-panel .card{ box-shadow:none; }

/* ---------- Tableaux (apporteurs, classement, utilisateurs) ---------- */
.data-table{
  width:100%; border-collapse:separate; border-spacing:0; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-md); overflow:hidden; box-shadow:var(--shadow-card);
}
.data-table th{
  text-align:left; font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text-muted);
  padding:11px 14px; border-bottom:1px solid var(--border); background:var(--surface-alt);
}
.data-table td{ padding:11px 14px; border-bottom:1px solid var(--border); font-size:13px; vertical-align:middle; }
.data-table tbody tr:last-child td{ border-bottom:none; }
.data-table tbody tr:hover{ background:var(--surface-alt); }
.data-table a{ color:inherit; text-decoration:none; }
.data-table a:hover strong{ text-decoration:underline; }
.table-name{ display:flex; align-items:center; gap:10px; min-width:0; }
.table-name .meta{ min-width:0; display:flex; flex-direction:column; align-items:flex-start; gap:2px; }
.table-name .meta > span:not(.pill){ font-size:11.5px; color:var(--text-muted); }
.table-name .meta > span:empty{ display:none; }
.cell-sub{ display:block; font-size:11.5px; color:var(--text-muted); }
.cell-actions{ text-align:right; white-space:nowrap; }
.cell-actions .icon-btn + .icon-btn{ margin-left:6px; }
.rank{ width:36px; font-family:var(--font-display); color:var(--text-muted); }
.rate-bar{ position:relative; width:90px; height:6px; border-radius:999px; background:var(--surface-alt); overflow:hidden; flex:none; }
.rate-bar span{ position:absolute; inset:0; width:var(--pct,0%); background:var(--primary); border-radius:999px; }
.summary-row{ display:flex; gap:14px; margin-bottom:16px; }
.summary-row .card{ flex:1; text-align:center; }
.summary-row .card strong{ display:block; font-family:var(--font-display); font-size:1.4rem; }
.summary-row .card span{ display:block; font-size:11px; color:var(--text-muted); text-transform:uppercase; letter-spacing:.06em; margin-top:4px; }
.toolbar .btn{ width:auto; }
.toolbar-spacer{ flex:1; }

/* Statistiques d'utilisation (admin de maintenance) : histogramme CSS des affaires par mois */
.stats-chart{ display:grid; grid-template-columns:repeat(12,minmax(0,1fr)); gap:8px; align-items:end; height:150px; }
.stats-col{ display:flex; flex-direction:column; justify-content:flex-end; height:100%; gap:4px; text-align:center; font-size:11px; }
.stats-bars{ flex:1; display:flex; align-items:flex-end; justify-content:center; gap:3px; }
.stats-bar{ display:block; width:40%; max-width:14px; min-height:2px; background:var(--primary); border-radius:3px 3px 0 0; }
.stats-bar.is-won{ background:var(--status-won); }
.stats-key{ display:inline-block; width:9px; height:9px; border-radius:2px; background:var(--primary); margin:0 2px 0 8px; }
.stats-key.is-won{ background:var(--status-won); }

/* Diffusion du PDF des recherches (admin) : destinataires groupés par courtier */
.recipient-groups{ border:1px solid var(--border); border-radius:var(--radius-md); max-height:360px; overflow:auto; }
.recipient-group{ border-bottom:1px solid var(--border); }
.recipient-group:last-child{ border-bottom:0; }
.recipient-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:9px 12px; background:var(--surface-alt); }
.recipient-list{ display:grid; gap:6px; padding:8px 12px 10px 34px; border-left:3px solid var(--border); margin-left:12px; }
.recipient-all{ padding:2px 0; }
.recipient-dropdown summary{ display:flex; align-items:center; justify-content:space-between; gap:10px; list-style:none; cursor:pointer; width:100%; }
.recipient-dropdown summary::-webkit-details-marker{ display:none; }
.recipient-dropdown[open] .recipient-caret{ transform:rotate(180deg); }
.recipient-panel{ display:grid; gap:10px; margin-top:8px; padding:12px; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--surface); }

/* Logs (journal des évolutions) : entrées compactes */
.journal-entry{ padding:8px 12px; margin-bottom:6px; }
.journal-entry .row{ gap:8px; }
.journal-entry .pill{ padding:2px 8px; font-size:11.5px; }
.journal-entry p{ margin:4px 0 0; font-size:13.5px; line-height:1.35; }
.journal-month{ margin:12px 0 4px; }

/* ---------- Statut à communiquer à l'apporteur (envoi validé par le courtier) ---------- */
.notice{ margin-top:4px; padding:10px 12px; border-radius:var(--radius-md); background:var(--status-progress-bg); color:var(--text); border:1px solid var(--status-progress); }
.notice svg{ vertical-align:-2px; }

/* ---------- Journal d'erreurs (Maintenance) ---------- */
.log-list{ display:flex; flex-direction:column; gap:6px; max-height:60vh; overflow:auto; }
.log-entry{ position:relative; padding:8px 10px; border-radius:var(--radius-md); border-left:3px solid var(--border-strong); background:var(--bg); }
.log-entry pre{ margin:0; font-family:ui-monospace, SFMono-Regular, Consolas, monospace; font-size:11.5px; line-height:1.45; white-space:pre-wrap; word-break:break-word; }
.log-error{ border-left-color:var(--status-lost); }
.log-warning{ border-left-color:var(--status-progress); }
.log-count{ float:right; margin-left:8px; font-size:11px; font-weight:700; padding:1px 6px; border-radius:999px; background:var(--status-progress-bg); color:var(--status-progress); }
