/* ─────────────────────────────────────────────────────────────
   TODOS-G2O — style INSTITUTIONNEL PREMIUM (paipartners inspired)
   3 couleurs strictes : noir / blanc / accent orange G2O #FF4614
   Angles droits, aucune ombre, aucun gradient.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Couleurs */
  --color-bg:             #ffffff;
  --color-bg-subtle:      #ffffff;
  --color-bg-muted:       #000000;
  --color-border:         #000000;
  --color-border-soft:    #E5E7EB;
  --color-text-primary:   #000000;
  --color-text-secondary: #8A8A8D;
  --color-text-muted:     #8A8A8D;
  --color-accent:         #FF4614;   /* orange G2O */
  --color-accent-hover:   #E63E10;
  --color-accent-subtle:  #FFF3EE;
  --color-accent-tint:    #FFE4DC;
  --color-urgent:         #FF4614;
  --color-high:           #EA580C;
  --color-medium:         #737373;
  --color-low:            #a3a3a3;

  /* Sémantique — succès / erreur / avertissement */
  --color-success:         #16a34a;
  --color-success-subtle:  #f0fdf4;
  --color-error:           #dc2626;
  --color-error-subtle:    #fef2f2;
  --color-warning:         #d97706;
  --color-warning-subtle:  #fffbeb;

  /* Fonctionnel — distingue Perso (bleu-cyan) de Pro (orange accent).
     Défini par la note de marque Ellma. Ne fait PAS partie du logo. */
  --color-perso:           #2E9BF0;
  --color-perso-hover:     #1E88E5;
  --color-perso-subtle:    #E8F4FE;
  --color-perso-alpha:     rgba(46, 155, 240, 0.12);

  /* Geometrie — ZERO arrondi (mode institutionnel) */
  --radius: 0px;

  /* Spacing */
  --space-section: 5rem;
  --space-card: 1.75rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
html { background: #000; }  /* évite la bande blanche si un élément déborde brièvement */
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--color-text-primary);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}
@media (min-width: 640px)  { .container { padding: 0 24px; } }
@media (min-width: 1024px) { .container { padding: 0 32px; } }

/* ─── Navbar noire opaque ─────────────────────────────────────── */
.navbar {
  position: sticky;
  top: var(--safe-top);
  z-index: 100;
  background: #000000;
  height: 64px;
  display: flex;
  align-items: center;
  border-bottom: none;
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.brand {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  color: var(--color-accent);
  font-size: 20px;
  line-height: 1;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}
.nav-link {
  color: var(--color-bg);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Icône SVG dans un onglet nav — hérite de currentColor (donc de l'état du lien) */
.nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.nav-link:hover {
  border-bottom-color: var(--color-accent);
}
.nav-link.active {
  border-bottom-color: var(--color-accent);
}
/* ─── Bouton hamburger (mobile only) ─── */
.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 44px;
  height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #ffffff;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border-radius: 1px;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── Mobile : navbar bottom FIXED (toujours visible) + drawer bottom-sheet ─── */
@media (max-width: 640px) {
  .navbar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    background: #000000;
    border-bottom: none;
    border-top: 1px solid rgba(255,255,255,0.12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 100;
  }
  .navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    padding: 0 16px;
    width: 100%;
    height: 60px;
  }
  .brand { flex-shrink: 0; }
  .brand-text { display: none; }
  .brand-mark { font-size: 22px; }

  /* Hamburger visible + centré */
  .nav-toggle {
    display: flex;
    margin: 0;
  }

  /* nav-links devient un bottom-sheet qui monte depuis le bas */
  .nav-links {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    background: #000000;
    border-top: 1px solid rgba(255,255,255,0.12);
    border-bottom: 1px solid rgba(255,255,255,0.12);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-height: 70vh;
    overflow-y: auto;
    padding: 8px 0;
    transform: translateY(8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
    z-index: 99;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
  }
  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
    border-bottom: none;
    border-left: 3px solid transparent;
    min-height: 52px;
  }
  .nav-link:hover { background: rgba(255,255,255,0.05); border-bottom-color: transparent; }
  .nav-link.active {
    background: var(--color-accent);
    color: #ffffff;
    border-left-color: #ffffff;
    border-bottom-color: transparent;
  }
  .nav-link.nav-finance,
  .nav-link.nav-planning,
  .nav-link.nav-kanban,
  .nav-link.nav-perso,
  .nav-link.nav-ignored { padding: 16px 24px; }

  /* Menu user à droite du hamburger */
  .nav-user { margin-left: 8px; }
  .nav-user .btn-mine { display: none; }
  /* Le dropdown user monte vers le haut (au-dessus de la bottom bar) */
  .user-dropdown {
    top: auto;
    bottom: calc(100% + 8px);
    right: 0;
  }

  /* Le body doit laisser de la place pour la bottom bar */
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  /* La barre de filtres colle SOUS le viewport top */
  .filters-bar { top: var(--safe-top); }
}

/* ─── Hero ─────────────────────────────────────────────────────── */
.hero {
  background: #000000;
  color: #ffffff;
  padding: 4rem 0 3rem;
}
.hero-title {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}
.hero-title em {
  color: var(--color-accent);
  font-style: normal;
  font-weight: 400;
}
.hero-sub {
  font-size: 1.0625rem;
  color: #a1a1aa;
  max-width: 640px;
  margin: 0 0 3rem;
  line-height: 1.5;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: #1f1f1f;
  border: 1px solid #1f1f1f;
  margin-top: 2rem;
}
@media (min-width: 640px)  { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(6, 1fr); } }

.stat-card {
  background: #000000;
  padding: 1.5rem 1.25rem;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
}
.stat-card:hover { background: #0a0a0a; }
.stat-card.active {
  background: var(--color-accent);
  color: #000000;
}
.stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  letter-spacing: -0.02em;
}
.stat-card.active .stat-value { color: #000000; }
.stat-card.accent .stat-value { color: var(--color-accent); }
.stat-card.active.accent .stat-value { color: #000000; }
.stat-label {
  font-size: 0.75rem;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.stat-card.active .stat-label { color: #000000; }

/* ─── Filtres ─────────────────────────────────────────────────── */
.filters-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  padding: 1.25rem 0;
  position: sticky;
  top: calc(var(--safe-top) + 64px);
  z-index: 50;
}
.filters-inner {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.filter-group.filter-search {
  flex: 1 1 240px;
  min-width: 180px;
}
.filter-group label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.filter-group select,
.filter-group input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: #ffffff;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  min-width: 0;
  width: 100%;
}
.filter-group select:focus,
.filter-group input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.btn-refresh {
  height: 40px;
  padding: 0 24px;
  background: #000000;
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 0;
}
.btn-refresh:hover { background: var(--color-accent); }
.btn-refresh.has-updates {
  background: var(--color-accent);
  animation: pulse-updates 1.4s ease-in-out infinite;
}
@keyframes pulse-updates {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

@media (max-width: 640px) {
  .filters-inner { gap: 8px; }
  .filter-group { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }
  .filter-group.filter-search { flex-basis: 100%; }
  .btn-refresh { width: 100%; }
}

/* ─── Liste todos ─────────────────────────────────────────────── */
.main {
  padding-top: 3rem;
  padding-bottom: 4rem;
  min-height: 60vh;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 2px solid #000000;
  padding-bottom: 8px;
  margin: 2.5rem 0 1.5rem;
}
.section-header:first-child { margin-top: 0; }
.section-header h2 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
}
.section-header.urgent h2 { color: var(--color-accent); }
.section-count {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.todos-list { display: grid; gap: 0; }

.todo-card {
  padding: var(--space-card);
  border-bottom: 1px solid var(--color-border-soft);
  background: #ffffff;
  cursor: pointer;
  transition: background 0.1s ease;
  border-left: 3px solid transparent;
}
.todo-card:hover {
  background: #FAFAFA;
  border-left-color: var(--color-accent);
}
.todo-card.urgent { border-left-color: var(--color-accent); background: #FFFAF7; }
.todo-card.high   { border-left-color: var(--color-high); }
.todo-card.done   { opacity: 0.5; text-decoration: line-through; }
.todo-card.dragging { opacity: 0.4; }
.nav-link.drop-target {
  background: var(--color-accent);
  color: #ffffff;
  outline: 2px dashed rgba(255,255,255,0.6);
  outline-offset: -4px;
}
.todo-card.ignored { opacity: 0.35; }

.todo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 0.75rem;
}
.todo-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
  color: var(--color-text-primary);
  flex: 1;
  word-break: break-word;
}

.todo-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Mobile : titre pleine largeur, tags sur une ligne dédiée dessous.
   Sinon 4-5 tags écrasent le titre à ~40% de la largeur (illisible). */
@media (max-width: 640px) {
  .todo-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .todo-title {
    flex: none;
    width: 100%;
  }
  .todo-badges {
    width: 100%;
    flex-shrink: 1;
  }
}
.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 0;
  border: 1px solid var(--color-border);
  background: #ffffff;
  color: var(--color-text-primary);
}
.badge.badge-accent {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}
.badge.badge-entity {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
}
.badge.badge-chantier {
  background: #ffffff;
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.todo-summary {
  font-size: 0.9375rem;
  color: #374151;
  line-height: 1.55;
  margin: 0 0 1rem;
}

.todo-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta-item.deadline {
  font-weight: 600;
  color: var(--color-text-primary);
}
.meta-item.deadline.overdue { color: var(--color-accent); }
.meta-item.deadline.soon { color: var(--color-high); }
.meta-item.amount {
  font-weight: 700;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.loading, .empty {
  padding: 6rem 20px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
}
.empty-icon {
  display: block;
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ─── Footer institutionnel ──────────────────────────────────── */
.footer {
  background: #000000;
  color: #ffffff;
  padding: var(--space-section) 0 3rem;
  margin-top: 4rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-brand {
  font-weight: 800;
  letter-spacing: 0.05em;
  font-size: 0.875rem;
}
.footer-meta {
  font-size: 0.75rem;
  color: #a1a1aa;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ─── Modal detail ────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;               /* > chat-panel (950) — modal passe TOUJOURS au 1er plan */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal-panel {
  background: #ffffff;
  border: 1px solid #000000;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  border-radius: 0;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--color-border-soft);
  font-size: 22px;
  cursor: pointer;
  border-radius: 0;
  line-height: 1;
}
.modal-close:hover { background: var(--color-accent); color: #ffffff; border-color: var(--color-accent); }
.modal-content { padding: 2.5rem; }
.modal-content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 1rem;
  padding-right: 40px;
}
.modal-section {
  margin-bottom: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border-soft);
}
.modal-section:first-of-type { border-top: none; padding-top: 0; }
.modal-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin: 0 0 0.5rem;
}
.action-item {
  padding: 12px 16px;
  background: #FAFAFA;
  border-left: 3px solid var(--color-accent);
  margin-bottom: 8px;
}
.action-item strong { font-weight: 700; }
.action-item .action-meta {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* ── Bandeau paiement / encaissement (modal détail) ─────────────────
   Bien distinct des actions de statut : c'est une action financière,
   pas administrative. Visible uniquement pour facture/prélèvement/avoir. */
.payment-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  margin-top: 1rem;
  background: var(--color-accent-subtle);
  border: 1px solid var(--color-accent);
  border-radius: 8px;
}
.payment-btn {
  flex: 1 1 auto;
  min-height: 52px;
  min-width: 220px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-accent);
  color: var(--color-bg);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9375rem;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.payment-btn:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 70, 20, 0.28);
}
.payment-btn:focus-visible {
  outline: 3px solid var(--color-accent-hover);
  outline-offset: 2px;
}
.payment-btn-icon { font-size: 1.25rem; }
.payment-btn-hint {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.88;
}
.payment-status {
  flex: 1 1 auto;
  min-height: 52px;
  min-width: 220px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-success);
  color: var(--color-bg);
  border-radius: 6px;
  font-weight: 700;
}
.payment-status-label { font-size: 0.9375rem; }
.payment-status-date {
  font-size: 0.8125rem;
  font-weight: 500;
  opacity: 0.9;
}
.payment-btn-undo {
  margin-left: auto;
  min-height: 44px;
  padding: 6px 14px;
  background: transparent;
  color: var(--color-bg);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8125rem;
  transition: background 0.15s;
}
.payment-btn-undo:hover {
  background: rgba(255,255,255,0.15);
}
.payment-btn-undo:focus-visible {
  outline: 2px solid var(--color-bg);
  outline-offset: 2px;
}

/* Badge payé / encaissé sur les cards liste */
.badge-paid {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--color-success);
  color: var(--color-bg);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-paid.credited {
  background: var(--color-accent);
}

@media (max-width: 640px) {
  .payment-btn, .payment-status {
    min-width: 0;
    flex: 1 1 100%;
  }
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border-soft);
}
.modal-actions button, .modal-actions a {
  height: 44px;
  padding: 0 20px;
  background: #ffffff;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  border-radius: 0;
  transition: background 0.1s;
}
.modal-actions button:hover, .modal-actions a:hover {
  background: #000000;
  color: #ffffff;
}
.modal-actions button.primary {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}
.modal-actions button.primary:hover {
  background: var(--color-accent-hover);
}

@media (max-width: 640px) {
  .modal-content { padding: 1.5rem; }
  .modal-actions button, .modal-actions a { flex: 1 1 100%; justify-content: center; }
}

/* ─── AUTH SCREENS (setup + login) ──────────────────────────── */
.auth-screen {
  min-height: 100vh;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-panel {
  background: #ffffff;
  padding: 3rem;
  max-width: 460px;
  width: 100%;
  border: 1px solid #ffffff;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #000000;
  margin-bottom: 2rem;
}
.auth-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0 0 0.5rem;
}
.auth-sub {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  margin: 0 0 2rem;
  line-height: 1.5;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}
.auth-form input {
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: #ffffff;
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text-primary);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}
.auth-form input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.btn-primary {
  height: 48px;
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  margin-top: 0.5rem;
  border-radius: 0;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--color-accent-hover); }
.auth-error {
  color: var(--color-accent);
  font-size: 0.875rem;
  margin: 0.5rem 0 0;
  min-height: 20px;
}

/* ─── NAV : Mes docs + user avatar ──────────────────────────── */
.nav-user {
  display: flex;
  align-items: center;
  gap: 16px;
}
.btn-mine {
  background: transparent;
  color: #ffffff;
  border: 1px solid #ffffff;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: 0;
  transition: all 0.15s;
}
.btn-mine:hover, .btn-mine.active {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}
.user-menu { position: relative; }
.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: 0;
}
.user-avatar:hover { background: var(--color-accent-hover); }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #000000;
  border: 1px solid var(--color-accent);
  min-width: 260px;
  z-index: 150;
  padding-bottom: 8px;
}
/* Mobile (navbar bottom-fixed) : dropdown monte vers le haut */
@media (max-width: 640px) {
  .user-dropdown {
    top: auto;
    bottom: calc(100% + 8px);
    right: 8px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}
.user-info {
  padding: 14px 16px;
  border-bottom: 1px solid #262626;
  color: #ffffff;
  font-size: 13px;
}
.user-info .info-name { font-weight: 700; }
.user-info .info-role {
  color: #a1a1aa;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}
.user-dropdown button {
  width: 100%;
  background: transparent;
  color: #ffffff;
  border: none;
  padding: 12px 16px;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
}
.user-dropdown button:hover { background: var(--color-accent); }

/* Boutons d'action encadrés — tous les items du dropdown */
.user-dropdown #btn-admin-users,
.user-dropdown #btn-reconcile,
.user-dropdown #btn-logs,
.user-dropdown #btn-guide,
.user-dropdown button[data-action="logout"] {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 12px 0 12px;
  padding: 14px 16px;
  width: calc(100% - 24px);
  background: #111111;
  border: 1.5px solid var(--color-accent);
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  min-height: 48px;
  transition: background 0.15s, transform 0.1s;
}
.user-dropdown #btn-admin-users:hover,
.user-dropdown #btn-reconcile:hover,
.user-dropdown #btn-logs:hover,
.user-dropdown #btn-guide:hover {
  background: var(--color-accent);
  color: #ffffff;
  transform: translateY(-1px);
}
.user-dropdown #btn-admin-users:focus-visible,
.user-dropdown #btn-reconcile:focus-visible,
.user-dropdown #btn-logs:focus-visible,
.user-dropdown #btn-guide:focus-visible,
.user-dropdown button[data-action="logout"]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Deconnexion — bordure rouge pour la distinguer (action de sortie) */
.user-dropdown button[data-action="logout"] {
  border-color: #DC2626;
  color: #FCA5A5;
  margin-top: 14px;
}
.user-dropdown button[data-action="logout"]:hover {
  background: #DC2626;
  color: #ffffff;
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .btn-mine { display: none; }
  .user-dropdown { min-width: 240px; }
  .user-dropdown #btn-admin-users,
  .user-dropdown #btn-reconcile,
  .user-dropdown #btn-logs,
  .user-dropdown #btn-guide,
  .user-dropdown button[data-action="logout"] {
    font-size: 16px;
    padding: 16px;
    min-height: 52px;
  }
}

/* ─── ADMIN USERS ────────────────────────────────────────────── */
.users-list {
  border-top: 1px solid var(--color-border);
  margin-bottom: 2rem;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-soft);
}
.user-row-avatar {
  width: 36px; height: 36px;
  background: #000000;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}
.user-row-info {
  flex: 1;
  min-width: 0;
}
.user-row-name { font-weight: 600; font-size: 0.9375rem; }
.user-row-meta {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.user-row-actions {
  display: flex;
  gap: 6px;
}
.user-row-actions button {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  background: #ffffff;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  border-radius: 0;
}
.user-row-actions button:hover { background: #000000; color: #ffffff; }
.user-row-actions button.danger { color: var(--color-accent); }
.user-row-actions button.danger:hover { background: var(--color-accent); color: #ffffff; border-color: var(--color-accent); }

.badge-admin {
  background: var(--color-accent);
  color: #ffffff;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-left: 6px;
}
.badge-inactive {
  background: #E5E7EB;
  color: #6B7280;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-left: 6px;
}

/* ─── Card avatar assigne ──────────────────────────────────── */
.assigned-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #000000;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 0;
  margin-right: 6px;
}
.assigned-avatar.suggested {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px dashed var(--color-border-soft);
}

/* ─── Badge STATUT (visible sur cards + modal) ──────────────── */
.badge-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  border-radius: 0; border: 1px solid;
}
.badge-status-pending     { background: #FFF3EE; color: var(--color-accent); border-color: var(--color-accent); }
.badge-status-in_progress { background: #FFF7ED; color: #B45309; border-color: #B45309; }
.badge-status-done        { background: #F0FDF4; color: #16A34A; border-color: #16A34A; }
.badge-status-ignored     { background: #F5F5F5; color: #737373; border-color: #737373; }

/* ─── Actions type paiement auto (rappels tresorerie) ──────── */
.action-item.reminder {
  border-left-color: #1E40AF;
  background: #EFF6FF;
}
.action-item .action-type-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 8px;
  background: #000;
  color: #fff;
}
.action-item.reminder .action-type-tag { background: #1E40AF; }
.action-item.lcr .action-type-tag { background: #7C3AED; }

/* ─── Modal — bouton Fermer + statut header ──────────────── */
.modal-actions .btn-close {
  background: #f5f5f5;
  color: #000;
  border: 1px solid var(--color-border);
}
.modal-actions .btn-close:hover { background: #000; color: #fff; }
.modal-status-line {
  padding: 12px 16px;
  background: #FAFAFA;
  border-left: 3px solid var(--color-text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ─── Nav : style uniforme pour tous les onglets ─────────────
   Chaque onglet est visuellement égal : texte blanc + soulignement discret
   au hover. L'onglet ACTIF est encadré (fond + texte contrasté) dans la
   couleur thématique de son onglet — comme un vrai bouton "enfoncé". */
.navbar .nav-link {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.navbar .nav-link:hover {
  border-bottom-color: rgba(255, 255, 255, 0.4);
}
/* Onglet Trésorerie — orange */
.nav-link.nav-finance { margin-left: 8px; }
.nav-link.nav-finance.active {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}
/* Onglet Planning — bleu ciel */
.nav-link.nav-planning.active {
  background: #38BDF8;
  color: #000000;
  border-color: #38BDF8;
  border-bottom-color: #38BDF8;
}
/* Onglets standards (A traiter, En cours, Fait, Tous) — accent orange */
.nav-link:not(.nav-finance):not(.nav-planning):not(.nav-perso).active {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* ─── Hero PERSO — même look mais accent bleu-cyan au lieu d'orange ─── */
.hero.hero-perso .hero-title em { color: var(--color-perso); }

.finance-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  margin-bottom: 3rem;
}
@media (min-width: 640px)  { .finance-summary-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .finance-summary-grid { grid-template-columns: repeat(4, 1fr); } }

.finance-card {
  background: #ffffff;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.finance-card.accent { background: #000000; color: #ffffff; }
.finance-card.credit {
  background: #ECFDF5;
  border-left: 4px solid #16A34A;
}
.finance-card.credit .finance-card-label { color: #166534; }
.finance-net {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 20px;
  margin: 12px 0 24px;
  background: #F3F4F6;
  border-left: 4px solid #000;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.finance-net-label { font-size: 0.875rem; color: var(--color-text-secondary); font-weight: 600; }
.finance-net-value { font-size: 1.25rem; font-weight: 700; }
.action-item.avoir .action-type-tag { background: #16A34A; }
.action-item.avoir { border-left: 3px solid #16A34A; padding-left: 12px; }
.finance-card-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--color-text-secondary);
}
.finance-card.accent .finance-card-label { color: #a1a1aa; }
.finance-card-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.finance-card.accent .finance-card-value { color: var(--color-accent); }
.finance-card-note { font-size: 0.75rem; color: var(--color-text-secondary); }
.finance-card.accent .finance-card-note { color: #a1a1aa; }

.finance-section { margin-bottom: 3rem; }
.finance-section h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 0 0 1.5rem;
  padding-bottom: 8px;
  border-bottom: 2px solid #000;
}

.finance-months { display: grid; gap: 0; border: 1px solid var(--color-border-soft); }
.finance-month-row {
  display: grid;
  grid-template-columns: 100px 1fr 130px 130px 130px 90px;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-soft);
  align-items: center;
  font-size: 0.9375rem;
}
/* Colonne supplementaire "Avoirs" quand des credits existent */
.finance-months.with-credits .finance-month-row {
  grid-template-columns: 100px 1fr 130px 130px 130px 130px 90px;
}
.finance-month-row:last-child { border-bottom: none; }
.finance-month-row.header {
  background: #FAFAFA;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}
.finance-month-name { font-weight: 700; }
.finance-month-bar {
  height: 24px;
  background: var(--color-border-soft);
  position: relative;
  overflow: hidden;
  display: flex;
}
.finance-month-bar-fill {
  height: 100%;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  padding-left: 6px;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
.finance-month-bar-fill.auto { background: #1E40AF; }
.finance-month-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}
.finance-month-count { text-align: right; color: var(--color-text-secondary); font-size: 0.8125rem; }

@media (max-width: 767px) {
  .finance-month-row { grid-template-columns: 80px 1fr 100px; }
  .finance-month-row > *:nth-child(4),
  .finance-month-row > *:nth-child(5) { display: none; }
}

/* Liste upcoming */
.upcoming-list { display: grid; gap: 0; border-top: 1px solid var(--color-border-soft); }
.upcoming-row {
  display: grid;
  grid-template-columns: 100px 1fr 140px 100px;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border-soft);
  align-items: center;
  cursor: pointer;
  transition: background 0.1s;
}
.upcoming-row:hover { background: #FAFAFA; }
.upcoming-date { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.875rem; }
.upcoming-date-soon { color: var(--color-accent); }
.upcoming-title {
  font-size: 0.9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upcoming-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  font-size: 0.9375rem;
}
.upcoming-type {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 3px 6px;
  border: 1px solid #000;
  color: #000;
}
.upcoming-type.auto  { border-color: #1E40AF; color: #1E40AF; background: #EFF6FF; }
.upcoming-type.lcr   { border-color: #7C3AED; color: #7C3AED; background: #F5F3FF; }
.upcoming-type.avoir { border-color: #16A34A; color: #16A34A; background: #ECFDF5; }
.upcoming-row.is-avoir { background: #F6FDF9; }
.upcoming-row.is-avoir .upcoming-amount { color: #16A34A; font-weight: 700; }

@media (max-width: 767px) {
  .upcoming-row { grid-template-columns: 80px 1fr 100px; }
  .upcoming-row > .upcoming-type { display: none; }
}

/* ─── Corriger l'analyse (auto-apprentissage) ────────────── */
.btn-correct {
  margin-top: 12px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid #000;
  color: #000;
  border-radius: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
}
.btn-correct:hover { background: #000; color: #fff; }
.correct-form {
  margin-top: 14px;
  padding: 16px;
  background: #FAFAFA;
  border: 1px solid var(--color-border);
}
.correct-form label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-text-primary);
}
.correct-form input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  font-family: inherit;
  font-size: 16px;
  min-height: 40px;
  background: #fff;
}
.correct-form input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.correct-form .primary {
  width: 100%;
  padding: 10px 16px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 0;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.correct-form .primary:hover { background: var(--color-accent-hover); }

/* ─── Notes de suivi (modal) ────────────────────────────── */
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.notes-date-btn {
  padding: 6px 14px;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}
.notes-date-btn:hover { background: var(--color-accent); }
.notes-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
}
#notes-input {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: #fff;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  resize: vertical;
}
#notes-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  border-color: var(--color-accent);
}

/* ─── PWA : version badge + update toast ─────────────────── */
.version-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  opacity: 0.7;
}
.pwa-update-toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 16px;
  right: 16px;
  background: #000;
  color: #fff;
  border-radius: 0;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  z-index: 9999;
  animation: fadeInUp 0.3s ease;
}
.pwa-update-toast > span {
  flex: 1 1 auto;
  font-size: 14px;
  font-weight: 500;
}
.pwa-update-toast button {
  min-height: 40px;
  padding: 8px 14px;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8125rem;
}
.pwa-update-toast button.primary {
  background: var(--color-accent);
  color: #fff;
}
.pwa-update-toast button.primary:hover { background: var(--color-accent-hover); }
.pwa-update-toast button:not(.primary) {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (min-width: 640px) {
  .pwa-update-toast {
    left: auto;
    right: 24px;
    max-width: 420px;
  }
}

/* ─── Bouton PDF + split-view desktop + overlay mobile ────── */
.btn-pdf {
  background: transparent;
  border: 1px solid #000;
  color: #000;
  padding: 8px 14px;
  border-radius: 0;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 40px;
}
.btn-pdf:hover { background: #000; color: #fff; }

/* Desktop : split-view — le modal panel s'élargit et un iframe s'attache à droite */
@media (min-width: 769px) {
  #modal-backdrop.with-pdf .modal-panel {
    max-width: min(1400px, 92vw);
    display: flex;
    align-items: stretch;
    padding: 0;
  }
  #modal-backdrop.with-pdf .modal-content {
    flex: 0 0 42%;
    max-width: 42%;
    overflow-y: auto;
    padding: 32px;
  }
  #modal-pdf-pane {
    flex: 1 1 auto;
    background: #f5f5f5;
    border-left: 1px solid var(--color-border);
    display: flex;
  }
  #modal-pdf-pane iframe,
  #modal-pdf-pane embed {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    border: none;
    background: #f5f5f5;
  }
}

/* Overlay PDF plein écran (mobile OU force plein écran) */
.pdf-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.pdf-overlay-bar {
  flex: 0 0 auto;
  height: 52px;
  background: #000;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  font-size: 0.875rem;
}
.pdf-overlay-bar button,
.pdf-overlay-bar a {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 8px 12px;
  border-radius: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.pdf-overlay-bar button:hover,
.pdf-overlay-bar a:hover { background: rgba(255,255,255,0.1); }
.pdf-title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
}
#pdf-frame {
  flex: 1 1 auto;
  width: 100%;
  border: none;
  background: #f5f5f5;
}

/* ─── Onglet Perso (compartiment personnel) ──────────────
   Bleu-cyan `--color-perso` = compartiment perso, distinct de l'orange
   accent qui est réservé au Pro. Cf. note de marque Ellma. */
.nav-link.nav-perso {
  background: transparent;
  color: var(--color-perso);
  border-bottom-color: transparent;
}
.nav-link.nav-perso:hover {
  background: var(--color-perso-alpha);
  border-bottom-color: var(--color-perso);
}
.nav-link.nav-perso.active {
  background: var(--color-perso);
  color: var(--color-bg);
  border-bottom-color: var(--color-perso);
}
@media (max-width: 640px) {
  .nav-link.nav-perso {
    background: transparent;
    color: var(--color-perso);
  }
  .nav-link.nav-perso.active {
    background: transparent;
    color: var(--color-perso);
    border-top-color: var(--color-perso);
  }
}

/* ─── Vue PLANNING (3 sous-vues) — la nav est gérée bloc "Nav uniforme" ── */

.planning-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 0; border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
}
.planning-tabs { display: inline-flex; gap: 0; border: 1px solid #000; }
.planning-tabs button {
  padding: 10px 18px; background: #fff; color: #000; border: none;
  border-right: 1px solid var(--color-border); border-radius: 0;
  font-weight: 600; font-size: 0.875rem; cursor: pointer; min-height: 44px;
}
.planning-tabs button:last-child { border-right: none; }
.planning-tabs button.active { background: #000; color: #fff; }
.planning-tabs button:hover:not(.active) { background: #f5f5f5; }
.planning-toggles { display: inline-flex; gap: 12px; }
.datefield-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.875rem; cursor: pointer;
}
.datefield-toggle input { cursor: pointer; }

.planning-nav {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 16px;
}
.planning-nav button {
  padding: 8px 20px; background: #fff; border: 1px solid #000; color: #000;
  border-radius: 0; font-weight: 600; cursor: pointer; min-height: 44px; font-size: 18px;
}
.planning-nav button:hover { background: #000; color: #fff; }
.planning-label {
  font-size: 1.125rem; font-weight: 700; text-transform: capitalize;
  flex: 1 1 auto; text-align: center;
}

/* ── Sous-vue : Cette semaine ── */
.planning-week-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 8px; min-height: 500px;
}
.planning-day {
  border: 1px solid var(--color-border); padding: 8px;
  background: #fff; display: flex; flex-direction: column;
}
.planning-day.today { border-color: var(--color-accent); border-width: 2px; }
.planning-day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 8px; border-bottom: 1px solid var(--color-border); margin-bottom: 8px;
}
.planning-day-name { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: var(--color-text-secondary); }
.planning-day-num { font-size: 1.25rem; font-weight: 700; }
.planning-day.today .planning-day-num { color: var(--color-accent); }
.planning-day-tasks { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; }
.planning-empty { font-size: 0.75rem; color: var(--color-text-muted); text-align: center; padding: 12px 0; }

/* ── Sous-vue : Ce mois ── */
.planning-month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: var(--color-border);
  border: 1px solid var(--color-border);
}
.planning-month-head {
  background: #000; color: #fff; padding: 8px 4px; text-align: center;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
}
.planning-month-cell {
  background: #fff; padding: 6px 4px; min-height: 100px;
  display: flex; flex-direction: column; gap: 3px;
}
.planning-month-cell.out { background: #FAFAFA; opacity: 0.5; }
.planning-month-cell.today { background: #FFF7ED; border: 2px solid var(--color-accent); }
.planning-month-num { font-size: 0.8125rem; font-weight: 700; margin-bottom: 4px; }
.planning-more { font-size: 0.6875rem; color: var(--color-accent); font-weight: 700; text-align: center; margin-top: 2px; }

/* ── Sous-vue : Timeline 90j ── */
.planning-timeline { display: flex; flex-direction: column; gap: 20px; }
.planning-tl-bucket {
  border: 1px solid var(--color-border); background: #fff;
}
.planning-tl-head {
  background: #000; color: #fff; padding: 10px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.planning-tl-label { font-weight: 700; font-size: 0.9375rem; }
.planning-tl-count { font-size: 0.75rem; opacity: 0.8; padding: 2px 8px; background: rgba(255,255,255,0.15); }
.planning-tl-items { padding: 8px; display: flex; flex-direction: column; gap: 4px; }

/* ── Section "En retard" en tête des vues Semaine et Mois ─────
   Le bucket "en retard" existait déjà dans Timeline 90j mais pas dans les
   vues semaine/mois : quand tout est en retard, la grille semblait vide. */
.planning-overdue {
  border: 1px solid var(--color-error);
  background: var(--color-error-subtle, #fef2f2);
  margin-bottom: 16px;
}
.planning-overdue-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  background: var(--color-error);
  color: var(--color-bg);
  font-weight: 700;
  min-height: 44px;
  user-select: none;
}
.planning-overdue-head::-webkit-details-marker { display: none; }
.planning-overdue-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-bg);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25);
  flex-shrink: 0;
}
.planning-overdue-label { font-size: 0.9375rem; letter-spacing: 0.02em; }
.planning-overdue-count {
  font-size: 0.8125rem;
  padding: 3px 10px;
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
  font-weight: 700;
}
.planning-overdue-hint {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.75;
  text-transform: none;
}
.planning-overdue[open] .planning-overdue-hint::before { content: '▾ '; }
.planning-overdue:not([open]) .planning-overdue-hint::before { content: '▸ '; }
.planning-overdue-items {
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 5px;
  max-height: 320px;
  overflow-y: auto;
}
@media (max-width: 639px) {
  .planning-overdue-hint { display: none; }
  .planning-overdue-items { max-height: 260px; padding: 8px; }
}

/* ── Task card (compacte pour week/month, large pour timeline) ── */
.planning-task {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; background: #fff; border-left: 3px solid #999;
  font-size: 0.75rem; cursor: pointer; user-select: none;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  transition: background 0.15s;
}
.planning-task:hover { background: #f5f5f5; }
.planning-task.wide {
  font-size: 0.875rem; padding: 8px 12px; gap: 10px;
  white-space: normal;
}
.planning-task.urg-urgent { border-left-color: #DC2626; }
.planning-task.urg-high, .planning-task.urg-elevee { border-left-color: #F97316; }
.planning-task.urg-medium, .planning-task.urg-moyenne { border-left-color: #6B7280; }
.planning-task.urg-low, .planning-task.urg-basse { border-left-color: #D1D5DB; }
.planning-task-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.planning-task-money { font-weight: 700; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.75rem; }
.planning-task-date { color: var(--color-text-secondary); font-size: 0.75rem; }
.urg-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #999; flex-shrink: 0; }
.urg-dot.urg-urgent { background: #DC2626; }
.urg-dot.urg-high, .urg-dot.urg-elevee { background: #F97316; }
.urg-dot.urg-medium, .urg-dot.urg-moyenne { background: #6B7280; }
.urg-dot.urg-low, .urg-dot.urg-basse { background: #D1D5DB; }

/* ── Mobile : week + month passent en scroll horizontal ── */
@media (max-width: 767px) {
  .planning-week-grid, .planning-month-grid {
    display: block;
  }
  .planning-week-grid .planning-day {
    margin-bottom: 8px; min-height: 80px;
  }
  .planning-month-grid { grid-template-columns: repeat(7, minmax(60px, 1fr)); display: grid; overflow-x: auto; }
  .planning-month-cell { min-height: 80px; font-size: 0.6875rem; padding: 4px 3px; }
  .planning-toolbar { justify-content: flex-start; }
  .planning-tabs button { padding: 8px 12px; font-size: 0.75rem; }
}

/* ─── Badge ID doc Paperless ────────────────────────────── */
.doc-id-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #f5f5f5;
  border: 1px solid var(--color-border);
  border-radius: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  user-select: all;
  transition: background 0.15s, color 0.15s;
}
.doc-id-badge:hover {
  background: var(--color-accent);
  color: #fff;
}
.meta-item.doc-id-card {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: 0.7;
  font-size: 0.75rem;
}

/* ─── 3 boutons secondaires (Corriger / Resync / Réanalyse) ── */
.modal-actions-secondary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.modal-actions-secondary button {
  width: 100%;
  padding: 10px 14px;
  background: #fff;
  color: #000;
  border: 1px solid var(--color-border);
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.modal-actions-secondary button:hover:not(:disabled) {
  background: #000; color: #fff; border-color: #000;
}
.modal-actions-secondary button:disabled {
  opacity: 0.5; cursor: wait;
}
@media (min-width: 640px) {
  .modal-actions-secondary { flex-direction: row; flex-wrap: wrap; }
  .modal-actions-secondary button { width: auto; text-align: center; }
}

/* ─── Toggle OCR à côté de la recherche ─────────────────── */
.filter-search {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 100%;
}
.filter-search input[type="search"] {
  flex: 1 1 auto;
}
.search-ocr-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  background: #fff;
  color: var(--color-text-primary);
  user-select: none;
  min-height: 40px;
  white-space: nowrap;
}
.search-ocr-toggle input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}
.search-ocr-toggle:has(input:checked) {
  background: #000;
  color: #fff;
  border-color: #000;
}
.search-ocr-toggle:hover {
  border-color: var(--color-border-strong);
}

/* ─── Journal système ────────────────────────────────────── */
.log-filters {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 8px 0; margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.log-filters button {
  padding: 4px 10px; background: #fff; border: 1px solid var(--color-border);
  border-radius: 0; font-size: 0.75rem; font-weight: 600; cursor: pointer;
  color: #000; min-height: 32px;
}
.log-filters button.active { background: #000; color: #fff; border-color: #000; }
.log-filters button:hover:not(.active) { background: #f5f5f5; }
.log-toggle-error { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; }
.log-list { max-height: 60vh; overflow-y: auto; }
.log-row {
  padding: 8px 12px; border-bottom: 1px solid var(--color-border);
  font-size: 0.8125rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  border-left: 3px solid #999;
}
.log-row.log-info  { border-left-color: #6B7280; }
.log-row.log-warn  { border-left-color: #F97316; }
.log-row.log-error { border-left-color: #DC2626; background: #FEF2F2; }
.log-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; font-size: 0.75rem; }
.log-ts    { color: var(--color-text-secondary); }
.log-cat   { background: #000; color: #fff; padding: 1px 6px; font-weight: 600; }
.log-level { padding: 1px 6px; font-weight: 600; text-transform: uppercase; font-size: 0.6875rem; }
.log-lv-info  { background: #E5E7EB; color: #000; }
.log-lv-warn  { background: #FED7AA; color: #7C2D12; }
.log-lv-error { background: #FCA5A5; color: #7F1D1D; }
.log-user  { opacity: 0.7; font-size: 0.75rem; }
.log-msg   { font-family: 'Plus Jakarta Sans', sans-serif; line-height: 1.4; }
.log-data  { margin: 6px 0 0; padding: 6px; background: #F5F5F5; font-size: 0.75rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* ─── KANBAN VIEW ────────────────────────────────────────────
   Kanban filtre par personne : 3 colonnes + drag & drop.
   Mobile first : scroll horizontal des colonnes (snap) sous 900px. */
/* ─── Bandeau Kanban unifié — bordure, dividers, tout aligné ─── */
.kanban-toolbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 16px 0 20px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border-strong);
  border-radius: 12px;
  overflow: hidden;
  flex-wrap: wrap;
}
/* Chaque bloc du bandeau — padding uniforme + divider vertical à droite */
.kanban-toolbar > * {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-right: 1px solid var(--color-border);
  min-height: 56px;
}
.kanban-toolbar > *:last-child { border-right: none; }
.kanban-toolbar .kanban-count { margin-left: auto; }
@media (max-width: 899px) {
  .kanban-toolbar > * { border-right: none; border-bottom: 1px solid var(--color-border); flex: 1 1 100%; }
  .kanban-toolbar > *:last-child { border-bottom: none; }
  .kanban-toolbar .kanban-count { margin-left: 0; }
}

.kanban-user-picker {
  font-size: 0.9375rem;
  color: var(--color-text-primary);
}
.kanban-user-picker > span {
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.kanban-user-picker select {
  background: transparent;
  border: none;
  padding: 6px 8px;
  font-size: 0.9375rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--color-text-primary);
  min-height: 32px;
  cursor: pointer;
  min-width: 180px;
}
.kanban-user-picker select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.kanban-count {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

/* Segmentation Tous / Pro / Perso — pas de border ni padding externe (déjà dans bandeau) */
.kanban-scope-pills {
  display: inline-flex;
  gap: 2px;
  padding: 0;
  border: none;
}
.kanban-scope-pills button {
  background: var(--color-bg-subtle, #f5f5f5);
  color: var(--color-text-secondary);
  border: none;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.kanban-scope-pills button:hover {
  background: var(--color-border);
}
.kanban-scope-pills button.active {
  background: var(--color-accent);
  color: #fff;
}

/* Toggle Fait ⇄ En litige — pilule rouge, très visible */
.kanban-toggle-litige {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FEF2F2;
  color: #DC2626;
  border: 1.5px solid #FCA5A5;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.kanban-toggle-litige:hover {
  background: #FEE2E2;
  border-color: #DC2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}
.kanban-toggle-litige.active {
  background: #DC2626;
  color: #fff;
  border-color: #DC2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}
.kanban-toggle-litige.active:hover {
  background: #B91C1C;
}

/* Nav "En litige" — badge rouge distinctif */
.nav-link.nav-on-hold {
  color: #DC2626;
}
.nav-link.nav-on-hold.active {
  background: #DC2626;
  color: #fff;
  border-left-color: #fff;
}

/* Bouton modal "Mettre en litige" — rouge */
.modal-actions .btn-on-hold {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FCA5A5;
}
.modal-actions .btn-on-hold:hover {
  background: #DC2626;
  color: #fff;
  border-color: #DC2626;
}

/* Cartes en litige : bordure gauche rouge, opacité légère */
.todo-card.on_hold,
.kanban-card.on_hold {
  border-left-color: #DC2626 !important;
  background: #FEF2F2;
}

.kanban-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 900px) {
  .kanban-board {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

.kanban-col {
  background: var(--color-bg-subtle, #f9fafb);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--col-accent, #FF4614);
  display: flex;
  flex-direction: column;
  min-height: 320px;
}
.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.kanban-col-label {
  font-weight: 700;
  font-size: 0.9375rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kanban-col-count {
  background: var(--col-accent, #FF4614);
  color: #fff;
  font-weight: 700;
  font-size: 0.8125rem;
  padding: 2px 10px;
  min-width: 28px;
  text-align: center;
}
.kanban-col-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 200px;
  transition: background 0.15s;
}
.kanban-col-body.drag-over {
  background: rgba(255, 70, 20, 0.08);
  outline: 2px dashed var(--col-accent, #FF4614);
  outline-offset: -8px;
}

.kanban-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-left: 4px solid #999;
  padding: 12px;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.15s, transform 0.15s;
}
.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging {
  opacity: 0.4;
  transform: rotate(-1deg);
}
.kanban-card.urg-urgent { border-left-color: #DC2626; }
.kanban-card.urg-high, .kanban-card.urg-elevee   { border-left-color: #F97316; }
.kanban-card.urg-medium, .kanban-card.urg-moyenne { border-left-color: #6B7280; }
.kanban-card.urg-low, .kanban-card.urg-basse     { border-left-color: #D1D5DB; }

.kanban-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kanban-card-supplier {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}
.kanban-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--color-text-primary);
  margin-bottom: 8px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.kanban-card-meta {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}
.kanban-card-date {
  color: var(--color-text-secondary);
}
.kanban-card-money {
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--color-text-primary);
}
.kanban-empty {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  padding: 24px 12px;
  font-style: italic;
}

/* Onglet Kanban dans la nav — même traitement que Planning/Perso */
.nav-link.nav-kanban.active {
  background: var(--color-accent);
  color: #fff;
}

/* Mobile : drag & drop moins pratique — les colonnes s'empilent (grid 1fr par defaut) */
@media (max-width: 640px) {
  .kanban-user-picker select { flex: 1; min-width: 0; width: 100%; }
  .kanban-card { cursor: pointer; }
}

/* ─── FOLLOW-UP (rappel perso "a revoir le") ───────────────────── */
.follow-up-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.follow-up-row input[type="date"] {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--color-border-strong);
  font-family: inherit;
  font-size: 1rem;
  background: #fff;
}
.follow-up-row input[type="date"]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-color: var(--color-accent);
}
.follow-up-row .btn-secondary {
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.875rem;
}
.kanban-card-follow {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  padding: 2px 8px;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: 3px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
/* Rappel echu : rouge — signale "a traiter aujourd'hui, tu l'avais planifie" */
.kanban-card-follow.due {
  background: #FEE2E2;
  color: #991B1B;
  border-color: #FCA5A5;
}

/* ═══════════════ Chat IA — refonte premium ═══════════════ */

/* ── Bulle flottante avec ombre orange + badge "IA" ── */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 16px;                   /* tuile Ellma, pas rond */
  background: var(--color-bg-muted);     /* noir de la marque */
  color: var(--color-bg);                /* currentColor = blanc */
  border: none;
  cursor: pointer;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.28),
    0 4px 12px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.chat-fab:hover, .chat-fab:focus-visible {
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.32),
    0 6px 16px rgba(0, 0, 0, 0.20);
  outline: none;
}
.chat-fab:active { transform: translateY(0) scale(0.96); }
.chat-fab svg { width: 32px; height: 32px; }
.chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--color-accent);
  color: var(--color-bg);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 3px 7px;
  border-radius: 999px;
  border: 2px solid var(--color-bg-muted);
  line-height: 1;
}
@media (max-width: 640px) {
  .chat-fab {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 54px;
    height: 54px;
  }
  .chat-fab svg { width: 22px; height: 22px; }
}

/* ── Panneau chat ── */
.chat-panel {
  position: fixed;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 20px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.18),
    0 6px 16px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 950;
  animation: chatSlideUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  transition: width 0.2s ease, height 0.2s ease, right 0.2s ease, bottom 0.2s ease;
}

/* ── Taille NORMALE (par défaut, comportement historique) ── */
.chat-panel.chat-size-normal {
  bottom: 100px;
  right: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 140px);
}

/* ── Taille DEMI-ECRAN (desktop uniquement — cachée sur mobile) ── */
.chat-panel.chat-size-half {
  bottom: 24px;
  right: 24px;
  width: 55vw;
  min-width: 520px;
  max-width: calc(100vw - 48px);
  height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
}

/* ── Taille PLEIN ECRAN ── */
.chat-panel.chat-size-full {
  bottom: 24px;
  right: 24px;
  width: calc(100vw - 48px);
  max-width: calc(100vw - 48px);
  height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
  border-radius: 16px;
}

@keyframes chatSlideUp {
  from { transform: translateY(24px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* ── Mobile : override — half n'existe pas, normal et full plein largeur ── */
@media (max-width: 640px) {
  .chat-panel.chat-size-normal,
  .chat-panel.chat-size-half {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
    min-width: 0;
    height: calc(100vh - 100px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100vh - 100px - env(safe-area-inset-bottom, 0px));
    border-radius: 16px;
  }
  .chat-panel.chat-size-full {
    bottom: env(safe-area-inset-bottom, 0px);
    top: env(safe-area-inset-top, 0px);
    right: 0;
    left: 0;
    width: auto;
    max-width: none;
    min-width: 0;
    height: auto;
    max-height: none;
    border-radius: 0;
  }
}

/* ── Header : sobre, blanc, avec avatar + subtitle ── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 14px 18px;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

/* Bouton "Fermer" en bas du chat — surtout utile sur mobile plein écran où
   la croix du header peut être sous la Dynamic Island / status bar. */
.chat-close-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--color-bg-muted);
  color: var(--color-bg);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.chat-close-bottom svg { width: 18px; height: 18px; }
.chat-close-bottom:hover { background: var(--color-accent); }
.chat-close-bottom:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* ── Historique des conversations (Phase 3) ─────────────────────── */
.chat-history-panel {
  position: absolute;
  top: 68px;             /* juste sous le header */
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  z-index: 10;
  display: flex;
  flex-direction: column;
  animation: chatSlideDown 0.2s ease-out;
}
@keyframes chatSlideDown {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.chat-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  min-height: 44px;
}
.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-history-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
  background: var(--color-bg);
}
.chat-history-item:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}
.chat-history-item.is-current {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}
.chat-history-open {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-history-open:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  border-radius: 8px;
}
.chat-history-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-history-meta {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  display: flex;
  gap: 6px;
}
.chat-history-del {
  min-width: 44px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.chat-history-del:hover {
  color: var(--color-error);
  background: var(--color-error-subtle);
}
.chat-history-del:focus-visible {
  outline: 2px solid var(--color-error);
  outline-offset: -2px;
}
.chat-history-loading,
.chat-history-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.chat-avatar {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 10px;             /* tuile noire de la marque Ellma */
  background: var(--color-bg-muted);
  color: var(--color-bg);          /* currentColor = blanc pour la 1re barre du "LL" */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-avatar svg { width: 28px; height: 28px; }
.chat-avatar-status {
  position: absolute;
  bottom: 0; right: 0;
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: chatPulse 2s ease-in-out infinite;
}
@keyframes chatPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50%      { opacity: 1; box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}
.chat-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text-primary);
  line-height: 1.2;
}
.chat-subtitle {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-actions {
  display: inline-flex;
  gap: 4px;
}
.chat-icon-btn {
  background: transparent;
  color: var(--color-text-secondary);
  border: none;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.chat-icon-btn:hover {
  background: var(--color-bg-subtle, #f5f5f5);
  color: var(--color-text-primary);
}
.chat-icon-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.chat-icon-btn svg { width: 18px; height: 18px; }

/* ── Zone messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.25); }

/* Empty state / accueil */
.chat-welcome {
  padding: 12px 8px 8px;
  text-align: center;
  animation: chatFadeIn 0.4s ease;
}
.chat-welcome-icon {
  width: 56px; height: 56px;
  border-radius: 14px;                 /* tuile Ellma */
  background: var(--color-bg-muted);   /* noir — cohérent avec l'app-icon */
  color: var(--color-bg);              /* currentColor = blanc pour la 1re barre */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.chat-welcome-icon svg { width: 36px; height: 36px; }
.chat-welcome-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.chat-welcome-text {
  font-size: 13.5px;
  color: var(--color-text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.chat-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-strong);
  padding: 10px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  line-height: 1.35;
}
.chat-chip-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--color-accent);
  transition: transform 0.2s;
}
.chat-chip:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
  transform: translateX(2px);
}
.chat-chip:hover .chat-chip-icon { transform: scale(1.15); }
.chat-chip:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Bulles messages ── */
.chat-msg {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  max-width: 92%;
  word-wrap: break-word;
  animation: chatFadeIn 0.24s ease;
}
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg-ai {
  background: #fff;
  border: 1px solid var(--color-border);
  align-self: flex-start;
  color: var(--color-text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.chat-msg-user {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover));
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(255, 70, 20, 0.22);
}
.chat-msg-ai strong { color: var(--color-accent); font-weight: 700; }
.chat-msg-ai em { color: var(--color-text-primary); font-style: italic; }
.chat-msg-ai p { margin: 6px 0; }
.chat-msg-ai p:first-child { margin-top: 0; }
.chat-msg-ai p:last-child  { margin-bottom: 0; }

/* Titres markdown */
.chat-msg-ai h1,
.chat-msg-ai h2,
.chat-msg-ai h3,
.chat-msg-ai h4 {
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.chat-msg-ai h1 { font-size: 17px; margin: 12px 0 6px; }
.chat-msg-ai h2 { font-size: 15.5px; margin: 10px 0 5px; }
.chat-msg-ai h3 { font-size: 14.5px; margin: 8px 0 4px; }
.chat-msg-ai h4 { font-size: 13.5px; margin: 6px 0 3px; color: var(--color-text-secondary); }
.chat-msg-ai h1:first-child,
.chat-msg-ai h2:first-child,
.chat-msg-ai h3:first-child { margin-top: 0; }

/* Listes markdown */
.chat-msg-ai ul,
.chat-msg-ai ol {
  margin: 8px 0;
  padding-left: 22px;
}
.chat-msg-ai ul { list-style: none; padding-left: 4px; }
.chat-msg-ai ul li {
  position: relative;
  padding-left: 16px;
  margin: 4px 0;
}
.chat-msg-ai ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-accent);
}
.chat-msg-ai ol li { margin: 4px 0; padding-left: 4px; }
.chat-msg-ai ol li::marker { color: var(--color-accent); font-weight: 700; }

/* Code inline */
.chat-msg-ai code {
  background: rgba(255, 70, 20, 0.08);
  color: #b91c1c;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
/* Bloc de code */
.chat-msg-ai pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12.5px;
  line-height: 1.5;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.chat-msg-ai pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* Citations */
.chat-msg-ai blockquote {
  border-left: 3px solid var(--color-accent);
  background: rgba(255, 70, 20, 0.05);
  margin: 8px 0;
  padding: 6px 12px;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* Tableaux */
.chat-msg-ai table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}
.chat-msg-ai th,
.chat-msg-ai td {
  border: 1px solid var(--color-border);
  padding: 6px 10px;
  text-align: left;
}
.chat-msg-ai th {
  background: var(--color-bg-subtle, #f5f5f5);
  font-weight: 700;
  color: var(--color-text-primary);
}

/* Séparateur horizontal */
.chat-msg-ai hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 12px 0;
}

/* Liens */
.chat-msg-ai a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-msg-ai a:hover { color: var(--color-accent-hover); }

/* Indicateur de chargement — 3 dots */
.chat-msg-loading {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  animation: chatFadeIn 0.24s ease;
}
.chat-msg-loading span {
  width: 7px; height: 7px;
  background: var(--color-accent);
  border-radius: 50%;
  animation: chatBounce 1.4s ease-in-out infinite;
}
.chat-msg-loading span:nth-child(2) { animation-delay: 0.16s; }
.chat-msg-loading span:nth-child(3) { animation-delay: 0.32s; }
@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ID de fiche cliquable dans la réponse (#123) */
.chat-msg-ai .chat-todo-link {
  color: var(--color-accent);
  font-weight: 700;
  cursor: pointer;
  padding: 1px 5px;
  border-radius: 4px;
  background: #fff5f2;
  transition: background 0.12s;
}
.chat-msg-ai .chat-todo-link:hover {
  background: #ffe4dc;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Cartes de confirmation (Phase 2) — actions proposées par Claude ── */
.chat-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 2px;
}
.chat-action-card {
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-areas:
    "icon body"
    "buttons buttons";
  gap: 10px;
  padding: 14px;
  background: linear-gradient(180deg, #fff8f5 0%, #ffffff 100%);
  border: 1px solid var(--color-accent);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(255, 70, 20, 0.08);
  transition: opacity 0.25s, filter 0.25s;
}
.chat-action-icon {
  grid-area: icon;
  color: var(--color-accent);
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}
.chat-action-body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-action-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
}
.chat-action-desc {
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text-primary);
  font-weight: 500;
}
.chat-action-buttons {
  grid-area: buttons;
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.chat-action-confirm,
.chat-action-cancel {
  flex: 1;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.chat-action-confirm {
  background: var(--color-accent);
  color: var(--color-bg);
}
.chat-action-confirm:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
}
.chat-action-confirm:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.chat-action-cancel {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.chat-action-cancel:hover {
  background: var(--color-bg-muted);
  color: var(--color-text-primary);
}
.chat-action-cancel:focus-visible {
  outline: 2px solid var(--color-border-strong);
  outline-offset: 2px;
}
.chat-action-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 8px 0;
}
.chat-action-status.chat-action-ok  { color: var(--color-success); }
.chat-action-status.chat-action-err { color: var(--color-error); }
.chat-action-card.chat-action-done {
  border-color: var(--color-success);
  background: var(--color-success-subtle, var(--color-bg-subtle));
}
.chat-action-card.chat-action-cancelled {
  opacity: 0.55;
  filter: grayscale(60%);
  background: var(--color-bg-subtle);
}
.chat-action-card.chat-action-error {
  border-color: var(--color-error);
  background: var(--color-error-subtle, var(--color-bg-subtle));
}
@media (min-width: 640px) {
  .chat-action-card {
    grid-template-columns: 32px 1fr auto;
    grid-template-areas: "icon body buttons";
    align-items: center;
  }
  .chat-action-buttons { margin-top: 0; }
  .chat-action-confirm,
  .chat-action-cancel { flex: 0 0 auto; }
}

/* ── Zone input ── */
.chat-form {
  padding: 12px 16px 14px;
  background: #fff;
  border-top: 1px solid var(--color-border);
}
.chat-input-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  background: var(--color-bg-subtle, #f8fafc);
  border: 1.5px solid var(--color-border);
  border-radius: 14px;
  padding: 4px 4px 4px 12px;
  transition: border-color 0.15s, background 0.15s;
}
.chat-input-wrap:focus-within {
  border-color: var(--color-accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 70, 20, 0.12);
}
.chat-form textarea {
  flex: 1;
  resize: none;
  border: none;
  padding: 8px 6px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  max-height: 140px;
  min-height: 28px;
  background: transparent;
  color: var(--color-text-primary);
}
.chat-form textarea:focus-visible { outline: none; }
.chat-form textarea::placeholder { color: var(--color-text-secondary); opacity: 0.7; }
.chat-send {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, transform 0.1s;
}
.chat-send:hover  { background: var(--color-accent-hover); }
.chat-send:active { transform: scale(0.94); }
.chat-send:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.chat-send:disabled {
  background: var(--color-border-strong);
  cursor: not-allowed;
}
.chat-send svg { width: 16px; height: 16px; }
.chat-form-hint {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 8px;
  text-align: center;
}
.chat-form-hint kbd {
  background: var(--color-bg-subtle, #f5f5f5);
  border: 1px solid var(--color-border);
  border-bottom-width: 1.5px;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10.5px;
  font-family: ui-monospace, monospace;
  color: var(--color-text-secondary);
}

/* ─── Utilitaires ────────────────────────────────────────────── */
.hidden { display: none !important; }
