/* ═══════════════════════════════════════════════════════
   JARVIS BTP — DESIGN SYSTEM v2.0
   Référence : Linear + Vercel · Accent marine · Dark/Light
   ═══════════════════════════════════════════════════════ */

:root {
  /* ── Accent marine ── */
  --accent:          #143c78;
  --accent-2:        #1a4d9a;
  --accent-3:        #0f2d5c;
  --accent-fg:       #ffffff;
  --accent-soft:     rgba(20,60,120,0.12);
  --accent-soft-2:   rgba(20,60,120,0.20);

  /* ── Surfaces dark ── */
  --bg-base:    #0d0d0f;
  --bg-card:    #17171b;
  --bg-card-2:  #1e1e24;
  --bg-input:   #1e1e24;
  --bg-hover:   #252530;
  --bg-active:  #2d2d3a;

  /* ── Bordures dark ── */
  --border:     rgba(255,255,255,.07);
  --border-2:   rgba(255,255,255,.10);
  --border-3:   rgba(255,255,255,.14);

  /* ── Textes dark ── */
  --text-main:  #ebebef;
  --text-sub:   #8888a0;
  --text-dim:   #55556a;
  --text-link:  #5b8fe8;

  /* ── Icônes dark ── */
  --icon-col:   #9090a8;

  /* ── Sémantique ── */
  --success:    #22c55e;
  --success-bg: rgba(34,197,94,.12);
  --warning:    #f59e0b;
  --warning-bg: rgba(245,158,11,.12);
  --danger:     #ef4444;
  --danger-bg:  rgba(239,68,68,.12);
  --info:       #3b82f6;
  --info-bg:    rgba(59,130,246,.12);

  /* ── Ombres ── */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.40);
  --shadow-md:  0 4px 16px rgba(0,0,0,.50);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.60);
  --shadow-float: 0 16px 48px rgba(0,0,0,.65);

  /* ── Radius ── */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* ── Transitions ── */
  --t-fast:   100ms cubic-bezier(.4,0,.2,1);
  --t-normal: 180ms cubic-bezier(.4,0,.2,1);
  --t-slow:   300ms cubic-bezier(.4,0,.2,1);

  /* ── Typography ── */
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

/* ── Light mode tokens ── */
body.light-mode {
  --bg-base:    #f4f4f8;
  --bg-card:    #ffffff;
  --bg-card-2:  #f8f8fc;
  --bg-input:   #f0f0f5;
  --bg-hover:   #e8e8f0;
  --bg-active:  #e0e0ec;

  --border:     rgba(0,0,0,.08);
  --border-2:   rgba(0,0,0,.11);
  --border-3:   rgba(0,0,0,.15);

  --text-main:  #0d0d14;
  --text-sub:   #505068;
  --text-dim:   #9090a8;
  --text-link:  #1a4daa;

  --icon-col:   #606080;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.07);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.14);
  --shadow-float: 0 16px 48px rgba(0,0,0,.18);
}

/* ═══════════════════════════════════════════════════════
   BASE & RESET
   ═══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-slow), color var(--t-slow);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════
   SEGMENTED CONTROL — toggle propre (remplace les styles inline)
   ═══════════════════════════════════════════════════════ */
.seg {
  display: flex; gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
}
.seg-btn {
  flex: 1; padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600;
  color: var(--text-sub);
  background: transparent;
  transition: background var(--t-fast), color var(--t-fast);
}
.seg-btn:hover { color: var(--text-main); }
.seg-btn.active {
  background: var(--accent);
  color: var(--accent-fg);          /* toujours #fff -> jamais de contraste illisible */
  box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════════════════
   SYSTÈME DE BOUTONS UNIFIÉ
   ═══════════════════════════════════════════════════════ */

/* Primaire — accent plein */
.btn, .btn-primary, #login-btn, #token-login-btn,
#register-btn, #forgot-btn, #reset-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 38px; padding: 0 16px;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast), opacity var(--t-fast), transform var(--t-fast);
  letter-spacing: .01em;
}
.btn:hover, .btn-primary:hover,
#login-btn:hover, #token-login-btn:hover,
#register-btn:hover, #forgot-btn:hover { background: var(--accent-2); }
.btn:active, .btn-primary:active { transform: scale(.98); }
.btn:disabled, #login-btn:disabled, #register-btn:disabled,
#forgot-btn:disabled, #reset-btn:disabled {
  opacity: .45; cursor: not-allowed; transform: none;
}

/* Plein large (login) */
#login-btn, #token-login-btn, #register-btn, #forgot-btn, #reset-btn {
  width: 100%; height: 42px; font-size: 15px; border-radius: var(--r-lg);
}

/* Secondaire — contour */
.btn-outline {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-soft); }

/* Ghost — pas de bordure */
.btn-ghost {
  background: transparent; color: var(--text-sub);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-main); }

/* Danger */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* Petits boutons action */
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }

/* ═══════════════════════════════════════════════════════
   SYSTÈME D'INPUTS UNIFIÉ
   ═══════════════════════════════════════════════════════ */
.input, input[type="email"], input[type="password"], input[type="text"],
input[type="number"], input[type="time"], select, textarea,
.settings-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 10px 13px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none; -webkit-appearance: none;
}
.input:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="text"]:focus, input[type="number"]:focus,
input[type="time"]:focus, select:focus, textarea:focus,
.settings-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}
select { cursor: pointer; }
select option { background: var(--bg-card); color: var(--text-main); }

input, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ===== Layout ===== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════
   LOGIN SCREEN — v3.0 premium
   ═══════════════════════════════════════════════════════ */

/* Fond animé avec mesh gradient */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(900px 500px at 50% -80px, #eef2fb, transparent), #ffffff;
  overflow: hidden;
}

/* Orbes lumineux en arrière-plan */
#login-screen::before,
#login-screen::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  animation: orbFloat 8s ease-in-out infinite;
}
#login-screen::before {
  width: 500px; height: 500px;
  top: -150px; left: -100px;
  background: radial-gradient(circle, rgba(20,60,120,.10) 0%, transparent 70%);
}
#login-screen::after {
  width: 400px; height: 400px;
  bottom: -100px; right: -80px;
  background: radial-gradient(circle, rgba(74,120,255,.08) 0%, transparent 70%);
  animation-delay: -4s;
  animation-direction: reverse;
}

@keyframes orbFloat {
  0%,100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(20px,15px) scale(1.05); }
  66%      { transform: translate(-10px,20px) scale(.97); }
}

/* Carte principale */
.login-box {
  position: relative;
  z-index: 1;
  width: 100%; max-width: 380px;
  background: #ffffff;
  border: 1px solid #e7e9f0;
  border-radius: 20px;
  padding: 36px 32px 28px;
  text-align: center;
  box-shadow: 0 14px 44px rgba(20,60,120,.12);
  animation: loginCardIn 400ms cubic-bezier(.16,1,.3,1) both;
}

@keyframes loginCardIn {
  from { opacity:0; transform:translateY(24px) scale(.98); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}

/* Logo avec glow animé */
.login-logo {
  margin-bottom: 18px;
  position: relative;
  display: inline-block;
}
.login-logo::before {
  content: '';
  position: absolute;
  inset: -8px;
  background: radial-gradient(circle, rgba(20,60,180,.4) 0%, transparent 70%);
  border-radius: 50%;
  animation: logoGlow 3s ease-in-out infinite;
}
.login-logo img {
  position: relative;
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  width: 72px; height: 72px;
}
@keyframes logoGlow {
  0%,100% { opacity:.6; transform:scale(1); }
  50%      { opacity:1; transform:scale(1.08); }
}

#login-screen h1 {
  font-size: 24px; font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: 4px;
  color: #15192b;
}
.login-subtitle {
  color: #5a6076;
  font-size: 13px;
  margin-bottom: 24px;
}

/* Inputs premium */
#login-form-panel input,
#token-form-panel input,
#forgot-form-panel input,
#register-form-panel input,
#reset-form-panel input {
  margin-bottom: 10px;
  background: #f7f8fc !important;
  border: 1px solid #e7e9f0 !important;
  color: #15192b !important;
  transition: border-color var(--t-normal), background var(--t-normal), box-shadow var(--t-normal);
}
#login-form-panel input:focus,
#token-form-panel input:focus,
#forgot-form-panel input:focus,
#register-form-panel input:focus,
#reset-form-panel input:focus {
  border-color: rgba(20,60,120,.5) !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(20,60,120,.12);
  outline: none;
}

/* Boutons login premium */
#login-btn, #token-login-btn, #register-btn, #forgot-btn, #reset-btn {
  background: linear-gradient(135deg, #1a4db5 0%, #143c78 100%) !important;
  box-shadow: 0 4px 16px rgba(20,60,120,.5), inset 0 1px 0 rgba(255,255,255,.15);
  transition: transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
#login-btn:hover:not(:disabled),
#token-login-btn:hover:not(:disabled),
#register-btn:hover:not(:disabled),
#forgot-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(20,60,120,.6), inset 0 1px 0 rgba(255,255,255,.2);
  background: linear-gradient(135deg, #2058cc 0%, #1a4db5 100%) !important;
}
#login-btn:active:not(:disabled),
#register-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(20,60,120,.4);
}

/* Badge essai gratuit */
.login-trial-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(30,158,99,.10);
  border: 1px solid rgba(30,158,99,.22);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #1e9e63;
  margin-bottom: 20px;
  letter-spacing: .3px;
}
.login-trial-badge::before { content: '✦'; font-size: 9px; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-hint {
  color: #5a6076;
  font-size: 13px;
  margin-top: 18px;
  line-height: 1.6;
}

.login-hint code {
  background: #eef2fb;
  color: #143c78;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.login-hint.hidden { display: none; }

.login-error {
  color: #ef4444;
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
  min-height: 18px;
}
.login-error.hidden { display: none; }

.login-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}
.login-forgot,
.login-links a {
  color: var(--accent, #143c78);
  font-size: 13px;
  text-decoration: none;
  opacity: 0.8;
}
.login-forgot:hover,
.login-links a:hover { opacity: 1; text-decoration: underline; }

/* Afficher / masquer le mot de passe */
.pwd-wrap { position: relative; width: 100%; margin-bottom: 10px; }
.pwd-wrap input { margin-bottom: 0 !important; padding-right: 44px !important; }
.pwd-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: #8a90a2;
  padding: 0;
}
.pwd-toggle:hover { color: #143c78; }
.pwd-toggle svg { width: 20px; height: 20px; display: block; }

/* Glisser-déposer un fichier dans le chat */
#chat-screen.drag-over::after {
  content: "Dépose ton fichier ici";
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13,13,15,.7); color: #fff;
  font-size: 20px; font-weight: 700; letter-spacing: .3px;
  border: 3px dashed var(--text-link, #5b8fe8); border-radius: 14px;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════
   ANIMATIONS GLOBALES
   ═══════════════════════════════════════════════════════ */
@keyframes slideInRight { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:translateX(0); } }
@keyframes slideInUp    { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn       { from { opacity:0; } to { opacity:1; } }
@keyframes scaleIn      { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:scale(1); } }

/* Message apparaît : user depuis la droite, assistant depuis la gauche */
@keyframes msgIn {
  from { opacity:0; transform: translateY(8px) scale(.98); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}
.message.user    { animation: msgInRight 220ms cubic-bezier(.16,1,.3,1) both; }
.message.assistant { animation: msgInLeft 220ms cubic-bezier(.16,1,.3,1) both; }
@keyframes msgInRight { from { opacity:0; transform:translateX(12px) translateY(4px); } to { opacity:1; transform:translateX(0); } }
@keyframes msgInLeft  { from { opacity:0; transform:translateX(-8px) translateY(4px); } to { opacity:1; transform:translateX(0); } }

/* Bouton envoyer — pulse quand actif */
#send-btn:not(:disabled):hover { transform: scale(1.06); }
#send-btn:not(:disabled):active { transform: scale(.95); }

/* Bottom nav mobile — animation tab active */
.mobile-tab-btn {
  transition: color var(--t-normal), background var(--t-normal), transform var(--t-fast);
}
.mobile-tab-btn.active { transform: translateY(-1px); }
.mobile-tab-btn:active { transform: scale(.93); }

/* Chips contextuelles — entrée fluide */
.chips-row .chip-btn {
  animation: chipIn 200ms cubic-bezier(.16,1,.3,1) both;
}
@keyframes chipIn {
  from { opacity:0; transform:translateY(6px) scale(.95); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}

/* Card finance / devis — hover lift */
.fin-card, .devis-card, .facture-card {
  transition: transform var(--t-normal), box-shadow var(--t-normal);
}
.fin-card:hover, .devis-card:hover, .facture-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes pulse        { 0%,100% { opacity:1; } 50% { opacity:.5; } }
@keyframes spin         { to { transform: rotate(360deg); } }

/* Classe utilitaire */
.animate-fadein { animation: fadeIn var(--t-normal) both; }
.animate-up     { animation: slideInUp var(--t-normal) both; }

/* ═══════════════════════════════════════════════════════
   CARTES (surfaces élevées)
   ═══════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: border-color var(--t-fast);
}
.card:hover { border-color: var(--border-2); }

/* ═══════════════════════════════════════════════════════
   BADGES STATUT — système unifié
   ═══════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; white-space: nowrap;
}
/* Devis */
.badge-brouillon  { background: var(--bg-active);    color: var(--text-sub); }
.badge-envoye     { background: var(--info-bg);       color: var(--info); }
.badge-accepte    { background: var(--success-bg);    color: var(--success); }
.badge-refuse     { background: var(--danger-bg);     color: var(--danger); }
.badge-expire     { background: var(--bg-hover);      color: var(--text-dim); }
/* Factures */
.badge-envoyee    { background: var(--info-bg);       color: var(--info); }
.badge-payee      { background: var(--success-bg);    color: var(--success); }
.badge-en_retard  { background: var(--danger-bg);     color: var(--danger); }
/* Events */
.badge-planifie   { background: var(--accent-soft);   color: var(--accent-2); }
.badge-fait       { background: var(--success-bg);    color: var(--success); }
.badge-annule     { background: var(--bg-hover);      color: var(--text-dim); }
/* Priorité */
.badge-high       { background: var(--danger-bg);     color: var(--danger); }
.badge-normal     { background: var(--info-bg);       color: var(--info); }

/* ═══════════════════════════════════════════════════════
   TOASTS & NOTIFICATIONS
   ═══════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text-main); color: var(--bg-base);
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-float);
  z-index: 300;
  transition: opacity var(--t-normal);
  opacity: 0;
  max-width: 320px;
}
.toast.show { opacity: 1; animation: slideInRight var(--t-normal) both; }

/* ===== Topbar ===== */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  position: relative;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-left img {
  border-radius: 7px;
}

.topbar-title { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }

.topbar-status { font-size: 11px; color: var(--success); font-weight: 500; }
.topbar-status.offline { color: var(--danger); }

/* ── Icon buttons ── */
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  color: var(--icon-col);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.icon-btn:hover  { background: var(--bg-hover); color: var(--text-main); }
.icon-btn:active { background: var(--bg-active); transform: scale(.95); }

.icon-btn.send {
  background: linear-gradient(135deg, #1e50d0, #143c78);
  color: white;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  box-shadow: 0 2px 10px rgba(20,60,120,.4);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.icon-btn.send:hover {
  background: linear-gradient(135deg, #2058cc, #1a4db5);
  box-shadow: 0 4px 16px rgba(20,60,120,.5);
  transform: translateY(-1px);
}
.icon-btn.send:active { transform: scale(.93); }

.icon-btn.stop {
  background: linear-gradient(135deg, #e53e3e, #c53030);
  color: white;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  box-shadow: 0 2px 10px rgba(229,62,62,.4);
  animation: pulse-stop 1.6s ease-in-out infinite;
}
.icon-btn.stop:hover { transform: scale(1.05); }
@keyframes pulse-stop { 0%,100%{box-shadow:0 2px 10px rgba(229,62,62,.4);} 50%{box-shadow:0 4px 20px rgba(229,62,62,.6);} }

.icon-btn.recording {
  background: var(--danger); color: white;
  animation: pulse-mic 1.2s infinite;
}
@keyframes pulse-mic {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50%     { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

/* ===== TTS button ===== */
.icon-btn.tts-active {
  color: #6ad27a;
}
.icon-btn.tts-muted {
  color: var(--text-sub);
}

/* ===== Notification bell + badge ===== */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

#notif-btn {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  display: none;
}
.notif-badge.visible {
  display: flex;
}

/* Popin notifications */
.notif-popin {
  position: fixed;
  top: 56px;
  right: 8px;
  width: 300px;
  max-height: 60vh;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.15s ease-out;
}
.notif-popin-header {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notif-popin-body {
  overflow-y: auto;
  flex: 1;
}
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.notif-item-title {
  color: var(--text-main);
  font-weight: 500;
  margin-bottom: 3px;
}
.notif-item-body {
  color: var(--text-sub);
  font-size: 12px;
}
.notif-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-sub);
  font-size: 13px;
}

/* Interim transcript dans textarea */
#text-input.listening {
  border-color: #ef4444;
  color: var(--text-dim);
}

/* ===== Messages ===== */
.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.empty-state {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-sub);
  text-align: center;
  padding: 24px;
}

.empty-state img {
  border-radius: 16px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 14px;
  max-width: 280px;
  line-height: 1.6;
}

.message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  animation: msgIn 220ms cubic-bezier(.16,1,.3,1) both;
  font-size: 15px;
  line-height: 1.55;
  animation: msgIn 0.18s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1e50d0 0%, #143c78 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(20,60,200,.3);
}

.streaming-cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor .7s step-end infinite;
}
@keyframes blink-cursor { 0%,100%{opacity:1} 50%{opacity:0} }

.agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(74,158,255,0.1);
  border: 1px solid rgba(74,158,255,0.2);
  border-radius: 10px;
  padding: 2px 8px;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* Badge plan dans le header */
.plan-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 8px;
  margin-top: 1px;
  display: inline-block;
}
.plan-badge.trial    { background: rgba(74,255,128,0.15); color: #4aff80; border: 1px solid rgba(74,255,128,0.3); }
.plan-badge.starter  { background: rgba(74,158,255,0.15); color: #4a9eff; border: 1px solid rgba(74,158,255,0.3); }
.plan-badge.pro      { background: rgba(255,170,0,0.15);  color: #ffaa00; border: 1px solid rgba(255,170,0,0.3); }
.plan-badge.enterprise { background: rgba(180,74,255,0.15); color: #c070ff; border: 1px solid rgba(180,74,255,0.3); }
.plan-badge.expired  { background: rgba(229,62,62,0.15);  color: #fc8181; border: 1px solid rgba(229,62,62,0.3); }

/* Disclaimer IA — affiché sur les réponses techniques */
.ai-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(255, 170, 0, 0.08);
  border: 1px solid rgba(255, 170, 0, 0.25);
  border-radius: 6px;
  font-size: 11px;
  color: #b38600;
  line-height: 1.5;
}
body.light-mode .ai-disclaimer { color: #8a6500; background: rgba(255,170,0,0.06); }

.tool-indicator {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 6px;
  font-style: italic;
  animation: pulse-tool 1.2s ease-in-out infinite;
}
@keyframes pulse-tool { 0%,100%{opacity:.5} 50%{opacity:1} }

.message.assistant {
  align-self: flex-start;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  max-width: 92%;
}

.message.system {
  align-self: center;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  font-style: italic;
  border-radius: 8px;
  padding: 4px 12px;
}

.message.error {
  align-self: center;
  background: #2a0e0e;
  border: 1px solid #5b1c1c;
  color: #ff8a8a;
  font-size: 13px;
  max-width: 92%;
}

.message.tool {
  align-self: center;
  background: #1a2a1a;
  border: 1px solid #2a4a2a;
  color: #8de890;
  font-size: 12px;
  max-width: 92%;
  font-family: monospace;
}

/* ===== Avatar profil topbar ===== */
.avatar-profile-btn {
  display: flex; align-items: center; gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px 4px 4px;
  border-radius: 20px;
  transition: background .15s;
  flex-shrink: 0;
}
.avatar-profile-btn:hover { background: rgba(255,255,255,.1); }

.avatar-circle {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent, #143c78);
  border: 2px solid rgba(255,255,255,.3);
  color: #fff;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.avatar-label {
  display: flex; flex-direction: column; align-items: flex-start;
  line-height: 1.2;
}
#avatar-name {
  font-size: 13px; font-weight: 600;
  color: var(--text-main, #1e293b);
  max-width: 90px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.avatar-role-badge {
  font-size: 10px; font-weight: 500;
  color: var(--accent, #143c78);
  text-transform: capitalize;
}

@media (max-width: 480px) {
  .avatar-label { display: none; }
  .avatar-profile-btn { padding: 4px; }
}

.profile-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-input, #f1f5f9);
  border-radius: 10px; padding: 12px 14px;
  margin-bottom: 4px;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent, #143c78); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-edit {
  position: absolute; bottom: -2px; right: -2px;
  background: var(--accent, #143c78); color: #fff;
  border-radius: 50%; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.profile-info { flex: 1; min-width: 0; }

/* ===== Chips d'actions contextuelles ===== */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 4px 10px;
  align-self: flex-start;
  max-width: 94%;
}
.chip {
  background: transparent;
  border: 1.5px solid var(--accent, #143c78);
  color: var(--accent, #143c78);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, transform .1s;
  line-height: 1.4;
}
.chip:hover  { background: var(--accent, #143c78); color: #fff; }
.chip:active { transform: scale(0.94); }

/* ═══════════════════════════════════════════════════════
   CARTES FINANCE — Layout structuré
   ═══════════════════════════════════════════════════════ */
.fin-card {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.fin-card:last-child { border-bottom: none; }
.fin-card:hover { background: var(--bg-hover); }

/* Ligne 1 : numéro + badge */
.fin-card-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.fin-card-num {
  font-size: 13px; font-weight: 600; color: var(--text-main);
  letter-spacing: .01em;
}

/* Ligne 2 : client — TOUJOURS lisible */
.fin-card-client {
  font-size: 13.5px; color: var(--text-main); font-weight: 500;
  margin-bottom: 5px;
  white-space: normal; word-break: break-word;
}

/* Ligne 3 : méta (chantier + montants + échéance) */
.fin-card-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px;
}
.fin-card-chantier {
  font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-2);
  padding: 2px 8px; border-radius: var(--r-full);
}
.fin-card-chantier.warn {
  background: rgba(245,158,11,.12); color: var(--warning);
}
.fin-card-ht {
  font-size: 12px; color: var(--text-sub);
}
.fin-card-ttc {
  font-size: 12px; font-weight: 600; color: var(--text-main);
}
.fin-card-ech {
  font-size: 11px; color: var(--text-sub);
  background: var(--bg-active); padding: 1px 7px; border-radius: var(--r-full);
}
.fin-card-ech.late {
  background: var(--danger-bg); color: var(--danger); font-weight: 600;
}

/* Ligne 4 : boutons — wrappent proprement */
.fin-card-btns {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.fin-btn-pdf {
  font-size: 12px; font-weight: 500; color: var(--text-sub);
  padding: 4px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: transparent; text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.fin-btn-pdf:hover { background: var(--bg-hover); color: var(--text-main); text-decoration: none; }

.fin-btn-sec {
  font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: transparent; color: var(--text-sub);
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.fin-btn-sec:hover { background: var(--bg-hover); color: var(--text-main); }

.fin-btn-primary {
  font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-fg);
  border: none; cursor: pointer;
  transition: background var(--t-fast);
}
.fin-btn-primary:hover { background: var(--accent-2); }

/* ===== Boutons actions Finance (statut + lier chantier) ===== */
.fin-actions-row {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 5px 0 4px;
}
.fin-act-btn {
  padding: 3px 10px; border-radius: 6px; font-size: 11px;
  font-weight: 500; cursor: pointer; border: 1.5px solid;
  background: transparent; transition: all .12s; white-space: nowrap;
  border-color: var(--accent, #143c78); color: var(--accent, #143c78);
}
.fin-act-btn.ok   { border-color: #10b981; color: #10b981; }
.fin-act-btn.ko   { border-color: #ef4444; color: #ef4444; }
.fin-act-btn.lier { border-color: #f59e0b; color: #f59e0b; }
.fin-act-btn:hover { opacity: .8; }

/* ===== PDF Card inline ===== */
.pdf-card-msg {
  align-self: flex-start;
  max-width: 92%;
  background: none;
  padding: 2px 0 6px;
}
.pdf-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card, #1e1e1e);
  border: 1px solid var(--border, #2a2a2a);
  border-left: 3px solid var(--accent, #143c78);
  border-radius: 10px;
  padding: 12px 14px;
  max-width: 340px;
}
.pdf-card-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.pdf-card-info {
  flex: 1;
  min-width: 0;
}
.pdf-card-num {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-card-type {
  font-size: 12px;
  color: var(--text-sub, #888);
  margin-top: 2px;
}
.pdf-card-btn {
  flex-shrink: 0;
  background: var(--accent, #143c78);
  color: #fff;
  border-radius: 6px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .15s;
}
.pdf-card-btn:hover,
.pdf-card-btn:active { opacity: 0.8; }

/* Markdown styles dans les messages */
.message strong { font-weight: 600; }
.message em { font-style: italic; }
.message code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "SF Mono", Monaco, Consolas, monospace;
}
.message pre {
  background: rgba(0,0,0,0.4);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 8px 0;
  overflow-x: auto;
}
.message pre code {
  background: transparent;
  padding: 0;
}
.message h1, .message h2, .message h3 {
  margin: 12px 0 6px;
  font-weight: 600;
}
.message h1 { font-size: 18px; }
.message h2 { font-size: 16px; }
.message h3 { font-size: 15px; }
.message ul, .message ol {
  margin: 6px 0;
  padding-left: 20px;
}
.message li {
  margin: 2px 0;
}
.message p {
  margin: 6px 0;
}
.message p:first-child { margin-top: 0; }
.message p:last-child { margin-bottom: 0; }

/* ===== Loading indicator ===== */
.loading-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: var(--bg-base);
}

.loading-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6ad27a;
  animation: bounce 1s infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.15s; }
.loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== Composer (input bar) ===== */
.composer {
  flex: 0 0 auto;
  padding: 8px 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--bg-base);
  border-top: 1px solid var(--border);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: 22px;
  padding: 4px;
  transition: border-color var(--t-normal), box-shadow var(--t-normal);
}
.composer-row:focus-within {
  border-color: rgba(74,120,255,.4);
  box-shadow: 0 0 0 3px rgba(74,120,255,.08), 0 4px 20px rgba(0,0,0,.3);
}

#text-input {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 10px 8px;
  resize: none;
  outline: none;
  max-height: 140px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.4;
}

#text-input::placeholder {
  color: #6a6a6a;
}

/* ===== Menu drawer ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 20;
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80%;
  max-width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-2);
  z-index: 21;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom));
  animation: slideIn 0.22s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* Paramètres : modale CENTRÉE (au lieu du drawer latéral) */
#settings-drawer {
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: 92%;
  max-width: 500px;
  max-height: 88vh;
  border: 1px solid var(--border-2);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
  animation: settingsModalIn 0.2s ease-out;
  overflow: hidden;
}
#settings-drawer .drawer-body { overflow-y: auto; flex: 1; }

/* Groupes Paramètres repliables (accordéon) */
.settings-group { border-bottom: 1px solid var(--border); }
.settings-group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; cursor: pointer; font-weight: 700; font-size: 14px;
  user-select: none;
}
.settings-group-header:hover { background: rgba(127,127,127,0.06); }
.settings-group-chevron { transition: transform .2s ease; opacity: .55; font-size: 13px; }
.settings-group.open .settings-group-chevron { transform: rotate(90deg); }
.settings-group-body { display: none; padding: 0 2px 6px; }
.settings-group.open .settings-group-body { display: block; }
.settings-group .settings-section { border: none; }
@keyframes settingsModalIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Menu : petit dropdown compact en haut à droite (au lieu du drawer plein écran) */
#menu-drawer {
  top: 52px;
  right: 12px;
  left: auto;
  bottom: auto;
  height: auto;
  max-height: 80vh;
  width: 230px;
  max-width: 82vw;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.4);
  padding: 6px 0 8px;
  animation: menuDropIn 0.16s ease-out;
}
#menu-drawer .drawer-header { padding-bottom: 6px; }
#menu-drawer .drawer-info { margin-top: 8px; }
@keyframes menuDropIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 8px;
}

.drawer-header h2 {
  font-size: 18px;
  font-weight: 500;
}

.drawer-item {
  text-align: left;
  padding: 14px 18px;
  font-size: 14px;
  color: var(--icon-col);
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
}

.drawer-item:hover, .drawer-item:active {
  background: var(--bg-card);
  color: white;
}

.drawer-item.warning {
  color: #f0b432;
}

.drawer-item.danger {
  color: #ef4444;
}

/* Drawer : header fixe en haut, body scrollable */
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 32px;
}

.drawer-info {
  margin-top: auto;
  padding: 12px 18px;
  font-size: 11px;
  color: var(--text-sub);
  border-top: 1px solid var(--border-2);
}

/* ===== Liste docs/outputs (popin) ===== */
.list-popin {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.list-popin-content {
  background: var(--bg-card);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  width: 100%;
  max-width: 500px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}

.list-popin-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-popin-header h3 {
  font-weight: 500;
  font-size: 16px;
}

.list-popin-body {
  overflow-y: auto;
  padding: 8px 0;
  flex: 1;
}

.list-item {
  padding: 12px 16px;
  border-bottom: 1px solid #232323;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.12s;
}

.list-item:hover, .list-item:active {
  background: var(--bg-card);
}

.list-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-sub);
  font-size: 13px;
}

/* ===== Responsive ===== */
@media (min-width: 700px) {
  .message {
    max-width: 70%;
  }
}



/* ===== Premium v1 : Sidebar Conversations ===== */
#chat-screen {
  flex-direction: row;
  align-items: stretch;
}

.main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* ── Chat wrapper (enveloppe header + messages + composer) ── */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   DÉTAIL PANEL — split GAUCHE/DROITE (horizontal)
   Documents (gauche) | Jarvis (droite)
═══════════════════════════════════════════════════════════ */
.detail-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 50%;
  min-width: 0;
  min-height: 0;
  border-right: 2px solid var(--accent);   /* séparateur vertical */
  background: var(--bg-base);
  overflow: hidden;
}
.detail-panel.hidden { display: none; }

/* Mode split : main-pane devient horizontal */
.main-pane.split-mode {
  flex-direction: row !important;
}
.main-pane.split-mode .chat-wrapper {
  flex: 1;
  min-width: 0;
}

/* Mobile : repasse en vertical */
@media (max-width: 768px) {
  .main-pane.split-mode {
    flex-direction: column !important;
  }
  .main-pane.split-mode .detail-panel {
    flex: 0 0 50%;
    border-right: none;
    border-bottom: 2px solid var(--accent);
  }
}

/* En-tête panel */
.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.dp-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.dp-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.dp-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-subtitle {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 1px;
}
.dp-close {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-sub); border-radius: var(--r-sm);
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.dp-close:hover { background: var(--danger-bg); color: var(--danger); }

/* Onglets du panel */
.dp-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.dp-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.dp-tab:hover { color: var(--text-main); }
.dp-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.dp-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--border);
  color: var(--text-sub);
  font-size: 10px;
  font-weight: 700;
}
.dp-tab.active .dp-count { background: var(--accent); color: #fff; }

/* Filtres dans le panel */
.dp-filters {
  flex-shrink: 0;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

/* Liste documents dans le panel */
.dp-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px;
}

/* ═══════════════════════════════════════════════════════════
   LISTE CLIENTS — Finance sidebar
═══════════════════════════════════════════════════════════ */
.fin-clients-wrap {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.fin-clients-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 6px;
  gap: 8px;
}
.fin-clients-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.fin-client-search {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 12px;
  outline: none;
  transition: border-color var(--t-fast);
}
.fin-client-search:focus { border-color: var(--accent); }

.fin-client-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 12px;
}
.fin-client-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
  border: 1px solid transparent;
}
.fin-client-item:hover { background: var(--bg-hover); }
.fin-client-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
}
.fin-client-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
  flex-shrink: 0;
  letter-spacing: -.5px;
}
.fin-client-info {
  flex: 1;
  min-width: 0;
}
.fin-client-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fin-client-meta {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 1px;
}
.fin-client-arrow {
  color: var(--text-dim);
  font-size: 12px;
  flex-shrink: 0;
}

/* KPI cards cliquables */
.summary-card {
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.summary-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.summary-card.kpi-active {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-base);
  border-right: 1px solid #262626;
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid #1c1c1c;
}

.new-conv-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: #1f6feb;
  color: white;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  transition: background .15s;
}
.new-conv-btn:hover { background: #2778f0; }

/* Conversation Watch — épinglée en tête */
.conv-watch-pin {
  margin: 6px 0 0 0;
  padding: 6px 8px;
  background: linear-gradient(135deg, rgba(30,60,120,0.25), rgba(74,158,255,0.1));
  border: 1px solid rgba(74,158,255,0.25);
  border-radius: 10px;
}
.conv-watch-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px 4px 4px;
  opacity: 0.8;
}
.conv-watch-pin .conv-item {
  border-radius: 6px;
  border: none;
}
.conv-list-sep {
  height: 1px;
  background: var(--border-2);
  margin: 8px 4px;
  opacity: 0.5;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-item {
  position: relative;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  border-left: 3px solid transparent;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-card); border-left-color: #1f6feb; }

.conv-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 24px;
}
.conv-date {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

.conv-menu {
  position: absolute;
  top: 8px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: var(--text-sub);
  font-size: 18px;
  opacity: 0;
  transition: opacity .12s, background .12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.conv-item:hover .conv-menu { opacity: 1; }
.conv-menu:hover { background: var(--border-2); color: #eee; }

.conv-popmenu {
  position: absolute;
  top: 32px;
  right: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-3);
  border-radius: 6px;
  padding: 4px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  min-width: 140px;
}
.conv-popmenu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-main);
}
.conv-popmenu button:hover { background: var(--border-2); }
.conv-popmenu button.danger { color: #ff6b6b; }

/* Toggle burger : visible seulement en mobile */
.sidebar-toggle { display: none; position: relative; }
.sidebar-overlay { display: none; }
.conv-count-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--accent);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

/* ===== Responsive : mobile (<768px) ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    height: 100%;
    transition: left .25s cubic-bezier(.2,.8,.2,1);
    box-shadow: 4px 0 16px rgba(0,0,0,0.4);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9;
  }
  .sidebar-overlay.visible { display: block; }
  .sidebar-toggle { display: inline-flex; margin-right: 4px; }
}


/* ===== Sidebar : onglets ===== */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid #262626;
  background: var(--bg-base);
}
.tab-btn {
  flex: 1;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
}
.tab-btn:hover { color: #ccc; }
.tab-btn.active { color: #fff; border-bottom-color: #1f6feb; }

.tab-pane {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}
/* Finances mobile : scroll vertical classique */
#tab-finances.active {
  display: block !important;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
/* fin-tabs sticky mobile */
#tab-finances.active .fin-tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bg-base);
  padding-top: 4px;
  margin: 0 -4px;
  padding-left: 4px;
  padding-right: 4px;
}
/* Colonnes desktop : cachées par défaut (mobile = tabs) */
.fin-col-head { display: none; }

/* ═══════════════════════════════════════════════════════════════
   COLONNE CENTRALE FINANCE — #fin-doc-col
   Cachée par défaut, visible quand Finance tab actif sur desktop
═══════════════════════════════════════════════════════════════ */

/* Colonne cachée par défaut */
#fin-doc-col {
  display: none;
  flex-direction: column;
  width: 360px;
  flex-shrink: 0;
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  overflow: hidden;
  height: 100%;
}

/* Visible sur desktop quand Finance actif */
@media (min-width: 769px) {
  #chat-screen.fin-3col #fin-doc-col {
    display: flex;
  }

  /* Sur mobile : onglets inline cachés sur desktop */
  .fin-tabs-mobile { display: none; }
  #fin-mobile-panels { display: none; }

  /* Sidebar reste à 280px, main-pane prend le reste */
  #chat-screen.fin-3col .sidebar { width: 280px; }
  #chat-screen.fin-3col .main-pane { flex: 1; min-width: 260px; }
}

/* Header colonne centrale */
.fin-doc-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
  min-height: 40px;
}
.fin-doc-col-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.fin-doc-col-title.filtered {
  color: var(--accent);
  text-transform: none;
  font-size: 13px;
  letter-spacing: 0;
}
.fin-doc-reset {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.fin-doc-reset:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.fin-doc-reset.hidden { display: none; }

/* Onglets dans la colonne centrale */
#fin-doc-col .fin-tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-base);
  border-bottom: 2px solid var(--border);
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

/* Panels dans la colonne centrale — affichage flex colonne */
#fin-doc-col .fin-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#fin-doc-col .fin-panel.fin-panel-active {
  display: flex;
}
#fin-doc-col .dash-filter-row {
  flex-shrink: 0;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
/* Liste scrollable */
.fin-doc-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px;
}

/* Sur mobile : fin-doc-col disparaît, onglets inline dans sidebar */
@media (max-width: 768px) {
  #fin-doc-col { display: none !important; }
  .fin-tabs-mobile { display: flex; }
  #fin-mobile-panels { display: block; }
}
/* Docs : scroll vertical natif UNIQUEMENT quand actif */
#tab-documents.active {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Agenda : toolbar fixe, liste scrollable */
#tab-agenda.active {
  overflow: hidden;
  flex-direction: column;
}
#tab-agenda .dash-toolbar {
  flex-shrink: 0;
}
#tab-agenda #agenda-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Calendrier : scroll si contenu dépasse */
#tab-calendrier.active {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex-direction: column;
}

.tab-pane.active { display: flex; }

/* ===== Documents : arborescence v2 ===== */
.docs-tree { flex: 1; overflow-y: auto; padding: 6px 8px; }
.docs-empty {
  padding: 32px 16px; text-align: center;
  color: var(--text-sub); font-size: 13px; line-height: 1.6;
}

/* Nœud projet */
.proj-node { margin-bottom: 2px; }

.proj-header {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--text-main);
  transition: background var(--t-fast), box-shadow var(--t-fast);
  position: relative;
}
.proj-header:hover {
  background: var(--bg-hover);
  box-shadow: inset 0 0 0 1px var(--border-2);
}
.proj-header:active { transform: scale(.99); }

/* Chevron SVG */
.proj-header .chevron {
  flex-shrink: 0;
  color: var(--text-dim);
  transition: transform 200ms cubic-bezier(.16,1,.3,1), color var(--t-fast);
  display: flex; align-items: center;
}
.proj-node.open > .proj-header .chevron { transform: rotate(90deg); color: var(--accent); }

/* Icône projet */
.proj-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(20,60,120,.35), rgba(74,100,200,.2));
  border: 1px solid rgba(74,100,200,.25);
  display: flex; align-items: center; justify-content: center;
  color: #6a9eef;
}

/* Nom du projet */
.proj-header .proj-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Compteur badge */
.proj-badge {
  flex-shrink: 0;
  font-size: 10px; font-weight: 600;
  color: var(--text-sub);
  background: var(--bg-active);
  padding: 1px 7px; border-radius: 10px;
  opacity: 0; transition: opacity var(--t-normal);
}
.proj-header:hover .proj-badge { opacity: 1; }

/* Enfants */
.proj-children {
  display: none;
  margin: 2px 0 2px 14px;
  padding-left: 14px;
  border-left: 1px solid var(--border-2);
}
.proj-node.open > .proj-children { display: block; }

/* Sous-dossiers */
.subdir-node { margin: 1px 0; }
.subdir-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 6px;
  cursor: pointer; font-size: 12px; color: var(--text-sub);
  transition: background var(--t-fast), color var(--t-fast);
}
.subdir-header:hover { background: var(--bg-hover); color: var(--text-main); }
.subdir-header .chevron {
  flex-shrink: 0; color: var(--text-dim);
  transition: transform 180ms cubic-bezier(.16,1,.3,1);
}
.subdir-node.open > .subdir-header .chevron { transform: rotate(90deg); }
.subdir-files { display: none; }
.subdir-node.open .subdir-files { display: block !important; }
.subdir-icon { color: #e6a817; flex-shrink: 0; }  /* dossier doré */

.subdir-count {
  margin-left: auto; font-size: 10px; color: var(--text-dim);
  background: var(--bg-card); padding: 1px 5px; border-radius: 8px;
}
.subdir-files { display: none; padding-left: 22px; margin: 1px 0; }
.subdir-node.open .subdir-files { display: block; }

/* Fichiers */
.file-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 5px;
  font-size: 11.5px; color: var(--text-sub);
  cursor: pointer; text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  overflow: hidden;
}
.file-item:hover { background: var(--bg-hover); color: var(--text-main); }
.file-item .file-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Couleur icône par type */
.file-icon-pdf  { color: #fc5656; }
.file-icon-xlsx { color: #22c55e; }
.file-icon-docx { color: #4a9eff; }
.file-icon-img  { color: #f59e0b; }
.file-icon-other { color: var(--text-dim); }


/* ===== Modal preview de fichiers ===== */
.file-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-modal.hidden { display: none; }
.file-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}
.file-modal-content {
  position: relative;
  width: min(1200px, 95vw);
  height: 90vh;
  background: var(--bg-card);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  overflow: hidden;
}
.file-modal-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-2);
  gap: 12px;
  background: var(--bg-base);
}
#file-modal-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-modal-actions {
  display: flex;
  gap: 4px;
}
.file-modal-body {
  flex: 1;
  overflow: auto;
  background: var(--bg-base);
}
.file-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}
.file-modal-body img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
}
.file-modal-body .preview-text {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
  color: #d4d4d4;
  padding: 20px;
}
.file-modal-body .preview-doc {
  padding: 32px;
  max-width: 900px;
  margin: 0 auto;
  color: var(--text-main);
  background: var(--bg-card);
}
.file-modal-body .preview-doc h1 { font-size: 22px; margin: 16px 0 8px; }
.file-modal-body .preview-doc h2 { font-size: 18px; margin: 14px 0 6px; color: #ddd; }
.file-modal-body .preview-doc h3 { font-size: 15px; margin: 12px 0 4px; color: #ccc; }
.file-modal-body .preview-doc p { margin: 6px 0; line-height: 1.55; }
.preview-table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 13px;
}
.preview-table td {
  border: 1px solid var(--border-3);
  padding: 6px 10px;
  color: #d4d4d4;
  vertical-align: top;
}
.preview-table tr:first-child td { background: #222; font-weight: 600; }
.file-modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-sub);
  font-size: 14px;
}

/* ===== CSS Accent Color (custom property) ===== */
:root {
  --accent: #143c78;
  --accent-hover: #1a4e96;
  --accent-light: rgba(20, 60, 120, 0.12);
}

/* ===== Sidebar tabs (4 tabs) ===== */
.sidebar-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 7px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-sub);
  background: none;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.tab-btn.active {
  color: #fff;
  background: var(--bg-card);
  border-bottom: 2px solid var(--accent);
}
.tab-btn:hover:not(.active) { color: #ccc; background: var(--bg-card); }

/* ===== Dashboard toolbar ===== */
.dash-toolbar {
  padding: 8px 10px 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}
.dash-refresh-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-sub);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-card);
  cursor: pointer;
  transition: color .15s;
}
.dash-refresh-btn:hover { color: #ccc; }

/* ===== Summary cards ===== */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 10px 4px;
  flex-shrink: 0;
}
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 10px 10px 8px;
}
.summary-card.accent { border-color: var(--accent); background: var(--accent-light); }
.summary-card.warn   { border-color: #7c3a1a; background: rgba(124,58,26,.12); }
.summary-card-label {
  font-size: 10px;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.summary-card-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summary-card.accent .summary-card-value { color: #7eb3f0; }
.summary-card.warn   .summary-card-value { color: #f07e5e; }

/* ===== Dash section title ===== */
.dash-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 12px 4px;
  flex-shrink: 0;
}

/* ===== Dash lists ===== */
.dash-list { overflow-y: visible; }
#tab-agenda .dash-list { max-height: none; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 8px 12px; }

/* ── Carte événement ── */
.dash-item {
  display: block;
  padding: 10px 12px 10px 14px;
  margin-bottom: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-dim);
  border-radius: 8px;
  cursor: default;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  position: relative;
  animation: msgIn 180ms cubic-bezier(.16,1,.3,1) both;
}
.dash-item:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
  border-left-color: var(--accent);
}

/* Couleur barre gauche par type */
.dash-item[data-type="rdv"],
.dash-item[data-type="rdv_chantier"] { border-left-color: #4a9eff; }
.dash-item[data-type="deadline"]     { border-left-color: #ef4444; }
.dash-item[data-type="livraison"]    { border-left-color: #f97316; }
.dash-item[data-type="reunion"]      { border-left-color: #a855f7; }
.dash-item[data-type="rappel"]       { border-left-color: #14b8a6; }
.dash-item[data-type="action"]       { border-left-color: #06b6d4; }
.dash-item[data-type="rdv_client"]   { border-left-color: #22c55e; }

/* Événement fait → atténué */
.dash-item[data-status="fait"]   { opacity: .55; }
.dash-item[data-status="annule"] { opacity: .35; text-decoration-line: none; }

.dash-item-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.dash-item-sub {
  font-size: 11px; color: var(--text-sub);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

/* Heure mise en avant */
.dash-item-time {
  font-size: 11px; font-weight: 700;
  color: var(--text-main); opacity: .7;
  font-variant-numeric: tabular-nums;
  background: var(--bg-active);
  padding: 1px 6px; border-radius: 4px;
}

/* Point type */
.dash-item-type-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-dim);
}

/* Lieu */
.dash-item-location {
  font-size: 11px; color: var(--text-sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dash-item-badge {
  display: inline-flex; align-items: center;
  font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: .05em;
  flex-shrink: 0;
}
/* Badges supplémentaires (legacy override par le système unifié ci-dessus) */
.badge-brouillon { background: var(--bg-active);   color: var(--text-sub); }
.badge-envoye    { background: var(--info-bg);      color: var(--info); }
.badge-accepte   { background: var(--success-bg);   color: var(--success); }
.badge-refuse    { background: var(--danger-bg);    color: var(--danger); }
.badge-envoyee   { background: var(--info-bg);      color: var(--info); }
.badge-payee     { background: var(--success-bg);   color: var(--success); }
.badge-en_retard { background: var(--danger-bg);    color: var(--danger); }
.badge-planifie  { background: var(--accent-soft);  color: var(--accent-2); }
.badge-fait      { background: var(--success-bg);   color: var(--success); }
.badge-annule    { background: var(--bg-hover);     color: var(--text-dim); }

.dash-item-pdf-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  margin-left: 6px;
  opacity: .8;
}
.dash-item-pdf-link:hover { opacity: 1; }

/* Items devis/factures cliquables */
.dash-item-clickable {
  cursor: pointer;
  transition: background 0.12s;
}
.dash-item-clickable:hover {
  background: rgba(255,255,255,0.04);
}
.dash-item-clickable:active {
  background: rgba(255,255,255,0.07);
}
.dash-item-pdf-icon {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 5px;
  vertical-align: middle;
  letter-spacing: .05em;
  opacity: 0.9;
}
.dash-item-project {
  color: #6a9fd8;
  font-size: 10px;
  margin-left: 4px;
}

/* ===== Widget Minuterie / Chrono ===== */
.timer-widget {
  position: fixed;
  bottom: 80px; right: 16px;
  background: var(--accent, #143c78);
  color: #fff;
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  z-index: 150;
  min-width: 160px;
  text-align: center;
  user-select: none;
}
.timer-widget.hidden { display: none; }
.timer-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.timer-label  { font-size: 12px; opacity: .8; font-weight: 500; flex: 1; text-align: left; }
.timer-close  { background: rgba(255,255,255,.15); border: none; color: #fff;
                width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
                font-size: 12px; line-height: 1; }
.timer-display {
  font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: 2px; margin: 4px 0 10px;
}
.timer-widget.urgent { animation: timer-pulse .5s infinite alternate; }
@keyframes timer-pulse { from { background: var(--accent,#143c78); } to { background: #ef4444; } }
.timer-btns   { display: flex; gap: 8px; justify-content: center; }
.timer-btn    { background: rgba(255,255,255,.15); border: none; color: #fff;
                padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
.timer-btn:hover { background: rgba(255,255,255,.25); }
.timer-mode   { background: rgba(255,255,255,.1); border: 1.5px solid rgba(255,255,255,.3);
                color: #fff; padding: 4px 10px; border-radius: 6px; font-size: 10px;
                font-weight: 700; letter-spacing: 1px; cursor: pointer; }

/* ===== Agenda : bouton suppression événement ===== */
.dash-item-deletable {
  position: relative;
}
.event-del-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: transparent;
  font-size: 11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  padding: 0;
  line-height: 1;
}
.dash-item-deletable:hover .event-del-btn {
  color: #ef4444;
  background: rgba(239,68,68,0.12);
}
.event-del-btn:hover {
  background: rgba(239,68,68,0.25) !important;
}
.dash-item-title {
  position: relative;
  padding-right: 26px;
}

/* ===== Settings drawer ===== */
.settings-section {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.settings-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.settings-colors {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .1s, border-color .1s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.settings-info {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== Devis filter row ===== */
.dash-filter-row {
  display: flex;
  gap: 4px;
  padding: 4px 10px 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.dash-filter-btn {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.dash-filter-btn.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.dash-filter-btn:hover:not(.active) { color: #ccc; border-color: #444; }

/* ===== Settings inputs ===== */
.settings-input {
  display: block;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  color: var(--text-main);
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 6px;
  outline: none;
  transition: border-color .15s;
}
.settings-input:focus { border-color: var(--accent); }
.settings-input::placeholder { color: var(--text-sub); }

/* Settings helpers — inline row + small label + checkbox */
.settings-row-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}
.settings-label-sm {
    font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 110px;
}
.settings-input-sm {
  width: auto;
  flex: 0 0 auto;
}
.settings-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
}
.settings-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== Settings time input ===== */
.settings-time-input {
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  color: var(--text-main);
  padding: 6px 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.settings-time-input:focus { border-color: var(--accent); }

/* ===== Theme toggle button ===== */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.theme-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.theme-toggle-track {
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--border-2);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.theme-toggle-track.on {
  background: var(--accent);
}
.theme-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.theme-toggle-track.on .theme-toggle-knob {
  transform: translateX(18px);
}

/* ===== Light mode — overrides specifiques ===== */
body.light-mode .message.assistant {
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  color: var(--text-main);
}
body.light-mode .message.assistant pre,
body.light-mode .message.assistant code {
  background: #f0f2f5;
  color: #1a1a1a;
}
body.light-mode .topbar {
  box-shadow: 0 1px 0 var(--border);
}
body.light-mode .menu-overlay,
body.light-mode .menu-panel {
  background: #ffffff;
}
body.light-mode .menu-item {
  color: var(--text-main);
}
body.light-mode .menu-item:hover {
  background: var(--bg-hover);
}
body.light-mode .conv-item.active {
  background: #e8eef8;
  border-left-color: var(--accent);
}
body.light-mode .tab-btn.active {
  color: var(--text-main);
  background: var(--bg-hover);
}
body.light-mode .summary-card {
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
body.light-mode .badge-en_retard { background: #fde8e8; color: #c0392b; }
body.light-mode .badge-accepte   { background: #e6f9ee; color: #1a7a3c; }
body.light-mode .badge-envoye    { background: #e8f0fd; color: #1a4a8c; }
body.light-mode .badge-payee     { background: #e6f9ee; color: #1a7a3c; }
body.light-mode .badge-brouillon { background: #f0f0f0; color: #555; }
body.light-mode .badge-refuse    { background: #fde8e8; color: #c0392b; }
body.light-mode .drawer {
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
}
body.light-mode .dash-item {
  border: 1px solid var(--border);
}
body.light-mode .dash-item-clickable:hover {
  background: var(--bg-hover);
}
body.light-mode .notif-popin {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
body.light-mode .jarvis-toast {
  background: #2d4f2d;
  color: #d4f0d4;
}
body.light-mode .jarvis-toast.jarvis-toast-error {
  background: #5c1a1a;
  color: #f0d4d4;
}
body.light-mode .file-modal-content {
  background: #fff;
  border: 1px solid var(--border);
}
body.light-mode #text-input {
  background: var(--bg-card);
  box-shadow: 0 0 0 1px var(--border);
}
body.light-mode .dash-filter-btn {
  background: var(--bg-input);
  border-color: var(--border-2);
  color: var(--text-sub);
}
body.light-mode .settings-drawer,
body.light-mode .drawer {
  background: #ffffff;
}

/* ===== Calendrier ===== */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 6px;
  flex-shrink: 0;
}
.cal-month-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}
.cal-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  color: var(--text-main);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.cal-nav-btn:hover { background: var(--bg-hover); }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 8px;
  gap: 2px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  padding: 4px 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0 8px 8px;
  flex-shrink: 0;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  min-height: 36px;
  gap: 2px;
}
.cal-cell:hover { background: var(--bg-hover); }
.cal-cell-empty { cursor: default; }
.cal-cell-empty:hover { background: none; }
.cal-day-num {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1;
}
.cal-today .cal-day-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.cal-cell.selected {
  background: var(--accent-light);
  border: 1px solid var(--accent);
}
.cal-dots {
  display: flex;
  gap: 2px;
  align-items: center;
  min-height: 6px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-day-panel {
  border-top: 1px solid var(--border);
  overflow-y: auto;
  flex: 1 1 auto;
}
.cal-day-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px 6px;
}

/* ===== Dismiss notifications ===== */
.notif-item {
  position: relative;
}
.notif-dismiss-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.notif-item:hover .notif-dismiss-btn { opacity: 1; }
.notif-dismiss-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.notif-clear-all-btn {
  font-size: 11px;
  color: var(--text-sub);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.notif-clear-all-btn:hover { background: var(--bg-hover); color: var(--text-main); }

/* Light mode calendrier */
body.light-mode .cal-cell.selected { background: #e8eef8; }

/* ================================================================
   MOBILE RESPONSIVE — Bottom navigation + full-width sidebar panel
   ================================================================ */

/* Bottom nav : caché sur desktop, visible sur mobile */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {

  /* --- Bottom navigation bar --- */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-base);
    border-top: 1px solid var(--border);
    z-index: 100;
  }

  .mobile-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-sub);
    transition: color var(--t-normal), transform var(--t-fast);
    min-width: 0;
    position: relative;
  }

  .mobile-tab-btn.active {
    color: var(--accent, #143c78);
  }

  /* Indicateur actif — point sous l'icône */
  .mobile-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--accent, #143c78);
    box-shadow: 0 0 6px rgba(20,60,120,.8);
  }

  .mobile-tab-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 56px;
  }

  /* --- Sidebar : panneau plein écran sur mobile --- */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 56px !important;    /* laisse la bottom nav visible */
    width: 100% !important;
    height: auto !important;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.2,.8,.2,1) !important;
    box-shadow: none !important;
    z-index: 95 !important;     /* > topbar (90) pour ne pas qu'elle perce */
    padding-top: 0;             /* topbar cachée derrière la sidebar */
  }

  .sidebar.open {
    transform: translateX(0) !important;
    left: 0 !important;
  }

  /* Cacher les tabs internes de la sidebar (remplacés par bottom nav) */
  .sidebar > .sidebar-tabs {
    display: none !important;
  }

  /* Masquer l'overlay et le toggle burger (remplacés par bottom nav) */
  .sidebar-overlay { display: none !important; }
  .sidebar-toggle  { display: none !important; }

  /* --- Main pane : réserver l'espace pour la bottom nav --- */
  .main-pane {
    padding-bottom: 56px;
  }

  /* Topbar : padding safe area iOS */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  /* Header client mobile dans Finance */
  .fin-mobile-client-header {
    padding: 8px 12px 6px;
    background: var(--accent-soft);
    border-radius: var(--r-md);
    margin: 8px 4px 0;
    border: 1px solid var(--accent-soft-2);
  }
  .fin-mob-back-btn {
    background: none; border: none; cursor: pointer;
    font-size: 12px; color: var(--accent); font-weight: 600;
    padding: 0; margin-bottom: 4px; display: block;
  }
  .fin-mob-client-name {
    font-size: 14px; font-weight: 700; color: var(--text-main);
  }
  .fin-mob-client-meta {
    font-size: 11px; color: var(--text-sub); margin-top: 2px;
  }

  /* Composer : pas de double safe-area (gérée par main-pane) */
  .composer {
    padding-bottom: 8px !important;
  }

  /* Messages : ne pas couvrir la bottom nav */
  .messages {
    padding-bottom: 8px;
  }

  /* Drawers (menu, settings) : au-dessus de tout */
  .overlay { z-index: 110 !important; }
  .drawer  { z-index: 120 !important; }

  /* Popins notif : au-dessus de la bottom nav */
  .notif-popin {
    bottom: 60px !important;
    top: auto !important;
    max-height: 60vh;
  }

  /* Tab panes : overflow scroll pour contenu long */
  .tab-pane.active {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Light mode : bottom nav */
body.light-mode .mobile-bottom-nav {
  background: var(--bg-card);
  border-top-color: var(--border);
}
body.light-mode .mobile-tab-btn.active {
  color: var(--accent, #143c78);
}

/* ── Planning chantier ─────────────────────────────────────── */
.planning-section {
  border-top: 1px solid var(--border);
  margin-bottom: 4px;
}
.planning-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  user-select: none;
}
.planning-header:hover { background: var(--bg-hover); }
.planning-header .chevron {
  font-size: 9px;
  transition: transform .18s;
  color: var(--text-sub);
}
.planning-section.open .planning-header .chevron { transform: rotate(90deg); }

.planning-avancement {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-sub);
}
.planning-avancement.av-wip  { color: var(--accent, #143c78); }
.planning-avancement.av-done { color: #22c55e; }

.planning-body { padding: 0 12px 10px; }

.plan-summary { margin-bottom: 10px; }
.plan-bar-wrap {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 5px;
}
.plan-bar-fill {
  height: 100%;
  background: var(--accent, #143c78);
  border-radius: 3px;
  transition: width .4s;
}
.plan-totals {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-sub);
}
.plan-over  { color: #ef4444; }
.plan-under { color: #22c55e; }

.plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 8px;
}
.plan-table th {
  text-align: left;
  color: var(--text-sub);
  font-weight: 500;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.plan-table td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.plan-table tr:last-child td { border-bottom: none; }
.plan-nom   { font-weight: 500; color: var(--text-main); max-width: 110px; }
.plan-dates { color: var(--text-sub); white-space: nowrap; font-size: 11px; }
.plan-num   { text-align: right; white-space: nowrap; font-size: 11px; }
.plan-actions { text-align: right; white-space: nowrap; }

.statut-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.statut-todo { background: var(--bg-hover); color: var(--text-sub); }
.statut-wip  { background: #dbeafe; color: #1d4ed8; }
.statut-done { background: #dcfce7; color: #16a34a; }

.plan-statut-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-sub);
  margin-left: 4px;
}
.plan-btn-start:hover { border-color: var(--accent, #143c78); color: var(--accent, #143c78); }
.plan-btn-done:hover  { border-color: #16a34a; color: #16a34a; }

.plan-add-btn {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-sub);
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: border-color .15s, color .15s;
}
.plan-add-btn:hover { border-color: var(--accent, #143c78); color: var(--accent, #143c78); }

/* Modal ajout phase */
#add-phase-modal { z-index: 200; }

/* ── Graphique CA mensuel ──────────────────────────────────────────────── */
.ca-chart-wrap {
  margin: 0 0 8px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 12px 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
/* Titre lisible sur fond blanc */
.ca-chart-wrap .dash-section-title { color: #1f2937; }

.taux-transfo-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin: 0 0 6px;
}
.taux-transfo-badge.taux-good { background: #16a34a22; color: #16a34a; }
.taux-transfo-badge.taux-mid  { background: #d9770622; color: #d97706; }
.taux-transfo-badge.taux-low  { background: #dc262622; color: #dc2626; }

/* ── Bandeaux de date Agenda ───────────────────────────────────────────── */
.agenda-date-band {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 6px;
  padding: 0;
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-sub);
  position: relative;
}
/* Ligne horizontale à côté de la date */
.agenda-date-band::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-2);
}

.agenda-date-band.agenda-date-today {
  color: #4aff80;
}
.agenda-date-band.agenda-date-today::before {
  content: '● ';
  color: #4aff80;
  font-size: 8px;
}

/* ── Action buttons on dash items (Facturer / Avoir) ── */
.dash-item-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.dash-item-action-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.dash-item-action-btn:active { transform: scale(.96); }

.facturer-btn { border-color: var(--accent); color: var(--accent); }
.facturer-btn:hover { background: var(--accent); color: #fff; }

.avoir-btn { border-color: #e74c3c; color: #e74c3c; }
.avoir-btn:hover { background: #e74c3c; color: #fff; border-color: #e74c3c; }

/* ── Linked factures block under a devis card ── */
.devis-factures-linked {
  margin: 6px 0 2px;
  padding: 8px 10px;
  background: var(--bg-input, var(--bg-card));
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  font-size: 12px;
}
.dflink-header {
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dflink-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.dflink-row:last-child { border-bottom: none; }
.dflink-num  { font-weight: 700; color: var(--text-main); min-width: 100px; }
.dflink-ht   { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-main); }

/* badge variants used in dflink */
.badge-paid  { background: #2ecc71; color: #fff; }
.badge-sent  { background: var(--accent); color: #fff; }
.badge-draft { background: var(--border); color: var(--text-sub); }

/* ═══════════════════════════════════════════════
   FINANCES — sous-onglets + cartes documents
═══════════════════════════════════════════════ */

/* Sous-onglets */
.fin-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 0;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.fin-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px 9px;
  border: none;
  background: none;
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 6px 6px 0 0;
  transition: color .15s, border-color .15s;
}
.fin-tab:hover { color: var(--text-main); }
.fin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.fin-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--border);
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 700;
}
.fin-tab.active .fin-tab-count { background: var(--accent); color: #fff; }

.fin-panel { padding-top: 4px; }

/* Carte document */
.fin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px 8px;
  margin-bottom: 8px;
  transition: box-shadow .15s;
}
/* En-tête de groupe chantier (vue client groupée par chantier) */
.fin-chantier-hd {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin: 14px 0 6px;
  padding: 4px 8px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 0 6px 6px 0;
  letter-spacing: .2px;
}
.fin-chantier-hd:first-child { margin-top: 2px; }
.fin-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.fin-card-avoir { border-left: 3px solid #e74c3c; }

.fin-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}
.fin-card-num {
  font-weight: 800;
  font-size: 13px;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.fin-card-client {
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  /* nom client toujours lisible — pas de troncature */
  white-space: normal;
  word-break: break-word;
}
.fin-card-project {
  background: var(--border);
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}
.fin-card-devis-link {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.fin-card-amounts {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.fin-card-amounts strong { color: var(--text-main); }
.fin-card-sep { opacity: .35; }
.fin-card-date { font-size: 11px; }
.fin-card-ech { font-size: 11px; font-weight: 600; color: var(--text-sub); }
.fin-card-ech.ech-retard { color: #e74c3c; }
.fin-card-motif { font-size: 12px; color: var(--text-sub); font-style: italic; margin-top: 4px; }

/* Boutons d'action sur les cartes */
.fin-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.fin-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input, var(--bg-card));
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.fin-action-btn:active { transform: scale(.95); }
.fin-pdf-btn:hover     { background: var(--text-main); color: var(--bg-card); border-color: var(--text-main); }
.fin-facturer-btn      { border-color: var(--accent); color: var(--accent); }
.fin-facturer-btn:hover{ background: var(--accent); color: #fff; }
.fin-avoir-btn         { border-color: #e74c3c; color: #e74c3c; }
.fin-avoir-btn:hover   { background: #e74c3c; color: #fff; }
.fin-link-btn          { font-size: 14px; padding: 2px 8px; }

/* Badges statut */
.fin-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-brouillon { background: var(--border);     color: var(--text-sub); }
.badge-envoye    { background: #f39c12;            color: #fff; }
.badge-accepte   { background: #2ecc71;            color: #fff; }
.badge-refuse    { background: #e74c3c;            color: #fff; }
.badge-expire    { background: var(--text-sub);    color: #fff; }
.badge-envoyee   { background: #3498db;            color: #fff; }
.badge-payee     { background: #2ecc71;            color: #fff; }
.badge-retard    { background: #e74c3c;            color: #fff; }
.badge-avoir     { background: #9b59b6;            color: #fff; }

/* Bloc factures liées sous la carte devis */
.fin-linked-wrap:not(:empty) {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-input, rgba(0,0,0,.04));
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

/* ═══════════════════════════════════════════════
   VISIONNEUSE UNIVERSELLE DE FICHIERS
═══════════════════════════════════════════════ */
.file-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.file-modal-overlay.hidden { display: none; }

.file-modal-box {
  background: var(--bg-card);
  border-radius: 14px;
  width: 100%;
  max-width: 900px;
  height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.4);
}

.file-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.file-modal-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.file-modal-body {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg-main);
}
.file-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.file-modal-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: auto;
  padding: 16px;
}
.file-modal-body pre.preview-text {
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-main);
}
.file-modal-loading {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-sub);
  font-size: 13px;
}

/* Fichier item dans l'arbre docs */
.file-item {
  display: block;
  padding: 5px 12px 5px 28px;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  border-radius: 5px;
  transition: background .12s;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item:hover { background: var(--border); }

/* ═══════════════════════════════════════════════
   BOUTON ACTIONS RAPIDES JARVIS (⚡ topbar)
═══════════════════════════════════════════════ */
.jarvis-actions-wrap {
  position: relative;
}

.jarvis-actions-btn {
  color: var(--accent);
}
.jarvis-actions-btn:hover {
  background: var(--accent);
  color: #fff;
}

.jarvis-actions-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 8000;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 6px 0 8px;
  animation: jam-pop .12s ease-out;
}
.jarvis-actions-menu.hidden { display: none; }

@keyframes jam-pop {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.jam-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-sub);
  padding: 4px 14px 8px;
}

.jam-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 10px;
}

.jam-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  margin: 0 4px;
  width: calc(100% - 8px);
  transition: background .12s;
}
.jam-item:hover { background: var(--border); }
.jam-item:active { background: var(--accent); color: #fff; }

.jam-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}
.jam-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}
.jam-sub {
  font-size: 11px;
  color: var(--text-sub);
  line-height: 1.3;
}
.jam-item:hover .jam-label,
.jam-item:hover .jam-sub { color: var(--text-main); }

/* ── Mode selector (Off / Manuel / Programmé) ── */
.sched-mode-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sched-mode-btn {
  cursor: pointer;
}
.sched-mode-btn input[type="radio"] { display: none; }
.sched-mode-btn span {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-input, var(--bg-card));
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  transition: background .13s, color .13s, border-color .13s;
  user-select: none;
}
.sched-mode-btn input:checked + span {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Sélecteur de jours (L M Me J V S D) ── */
.sched-days-row {
  display: flex;
  gap: 5px;
}
.sched-day { cursor: pointer; }
.sched-day input[type="checkbox"] { display: none; }
.sched-day span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input, var(--bg-card));
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  transition: background .13s, color .13s;
  user-select: none;
}
.sched-day input:checked + span {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Notifications planifiées dans le panneau notif ── */
.notif-sched {
  border-left: 3px solid var(--accent);
  background: var(--bg-card);
}
.notif-sched .notif-item-title { font-weight: 700; color: var(--text-main); margin-bottom: 2px; }
.notif-sched .notif-item-body  { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }

.sched-notif-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sched-notif-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-input, var(--bg-card));
  color: var(--text-sub);
  transition: background .12s, color .12s;
}
.sched-launch { border-color: var(--accent); color: var(--accent); }
.sched-launch:hover { background: var(--accent); color: #fff; }
.sched-snooze:hover { background: var(--border); color: var(--text-main); }

/* ===== Sched cards (Réveil matin / Bilan journalier) ===== */
.sched-card {
  background: var(--bg-input, var(--bg-card));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.sched-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sched-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
}
.sched-card-sub {
  font-size: 12px;
  color: var(--text-sub);
}
.sched-card-opts {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Toggle switch */
.sched-toggle-wrap {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.sched-toggle-wrap input { display: none; }
.sched-toggle-track {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background .2s;
}
.sched-toggle-wrap input:checked + .sched-toggle-track {
  background: var(--accent);
}
.sched-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.sched-toggle-wrap input:checked + .sched-toggle-track .sched-toggle-knob {
  left: 23px;
}
