:root {
  --bg: #0f1115;
  --bg-elevated: #171922;
  --bg-elevated-2: #1c1f2a;
  --border: #262838;
  --text: #e8e8ec;
  --text-muted: #9a9ab0;
  --text-faint: #63667a;
  --accent-1: #5b6dff;
  --accent-2: #7d4dff;
  --tag-bg: #1c1f2a;
  --tag-text: #a9b4ff;
  --danger: #ff6b81;
}

:root[data-theme="light"] {
  --bg: #f6f1e6;
  --bg-elevated: #fffdf7;
  --bg-elevated-2: #efe6d3;
  --border: #e2d8c0;
  --text: #2c2718;
  --text-muted: #6e6551;
  --text-faint: #9c927a;
  --accent-1: #5b6dff;
  --accent-2: #7d4dff;
  --tag-bg: #efe4c8;
  --tag-text: #4c3fc4;
  --danger: #c93b52;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease;
}

a { color: inherit; }

/* Login */

.login-box {
  max-width: 360px;
  margin: 20vh auto 0;
  text-align: center;
  padding: 0 24px;
  position: relative;
}

.login-box h1 {
  font-size: 2.5rem;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.tagline {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #1f1f1f;
  text-decoration: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 500;
}

.google-btn img {
  width: 18px;
  height: 18px;
}

/* Topbar / nav */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}

.topbar-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.topbar-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 8px;
}

.topbar-nav a:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.topbar-nav a.active {
  background: var(--bg-elevated-2);
  color: var(--text);
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.user a {
  color: var(--accent-1);
  text-decoration: none;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }

main {
  padding: 48px 32px;
}

/* Dashboard */

.metier-tag {
  display: inline-block;
  margin: 8px 0 16px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary {
  color: var(--text-muted);
  max-width: 560px;
  margin-bottom: 32px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  max-width: 800px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

.card h2 {
  font-size: 0.95rem;
  margin: 0 0 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card ul, .card ol {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.8;
}

/* Lists / tables (contacts, taches, documents) */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: 800px;
  margin-bottom: 24px;
}

.section-header h1 { margin: 0; }

.data-table {
  width: 100%;
  max-width: 800px;
  border-collapse: collapse;
  margin-bottom: 40px;
}

.data-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tr:last-child td { border-bottom: none; }

.empty-state {
  color: var(--text-faint);
  font-style: italic;
  padding: 16px 12px;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  max-width: 800px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 32px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}

.field label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input, .field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.9rem;
}

.field textarea { resize: vertical; min-height: 80px; }

.btn {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }

.checkbox-form { display: inline; }

.task-done { text-decoration: line-through; color: var(--text-faint); }

.error-banner {
  max-width: 800px;
  background: var(--bg-elevated);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.doc-link {
  color: var(--accent-1);
  text-decoration: none;
  font-size: 0.85rem;
}

/* Onboarding chat */

.onboarding-body {
  position: relative;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
  animation: float 16s ease-in-out infinite alternate;
}

.orb-a {
  width: 420px;
  height: 420px;
  top: -120px;
  left: -100px;
  background: radial-gradient(circle, #5b6dff, transparent 70%);
}

.orb-b {
  width: 380px;
  height: 380px;
  bottom: -140px;
  right: -80px;
  background: radial-gradient(circle, #ff6fb0, transparent 70%);
  animation-delay: -8s;
}

@keyframes float {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, 30px) scale(1.08); }
}

.onboarding-header {
  position: relative;
  z-index: 1;
  padding: 24px 32px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-shell {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 20px;
  min-height: 0;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 4px 16px;
}

.msg {
  display: flex;
  animation: rise 0.25s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-assistant { justify-content: flex-start; }
.msg-user { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.msg-assistant .bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg-user .bubble {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 18px;
}

.bubble.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7d84a8;
  animation: bounce 1.2s infinite ease-in-out;
}

.bubble.typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 10px 10px 18px;
}

.chat-input-bar textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  max-height: 160px;
  line-height: 1.4;
  padding: 6px 0;
}

.chat-input-bar textarea::placeholder {
  color: var(--text-faint);
}

.chat-input-bar button {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.chat-input-bar button:hover {
  transform: scale(1.06);
}

.finalize-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: rgba(15, 17, 21, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #e8e8ec;
}

.finalize-overlay.hidden {
  display: none;
}

.finalize-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #262838;
  border-top-color: #7d4dff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ════════════════════════════════════════════════════════════════════════════
   v2 — composants des modules (contacts, tâches, agenda, documents, IA, accueil)
   ════════════════════════════════════════════════════════════════════════════ */

:root { --paper: #ffffff; }
:root[data-theme="light"] { --paper: #fffdf8; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }

input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="url"],
input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-1) 22%, transparent);
}

.brand { text-decoration: none; color: inherit; }
.topbar .nav-assistant { color: var(--accent-1); }
.topbar .nav-assistant.active { color: var(--text); }

.page { max-width: 1120px; margin: 0 auto; padding: 36px 32px 64px; }
.page.narrow { max-width: 760px; }
.page.wide { max-width: 1400px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 1.6rem; }
.page-sub { margin: 0; color: var(--text-muted); font-size: 0.92rem; max-width: 720px; }
.page-sub a { color: var(--accent-1); text-decoration: none; }

a.btn, a.btn-secondary, a.btn-ghost, a.btn-danger { text-decoration: none; display: inline-block; }
.btn { display: inline-block; white-space: nowrap; font-family: inherit; }
.btn.small { padding: 6px 14px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.btn-secondary:hover { border-color: var(--text-faint); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-ghost { font-family: inherit; }
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; max-width: 640px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--text-muted); font-size: 0.85rem; text-decoration: none; cursor: pointer; font-family: inherit;
}
.chip span { color: var(--text-faint); font-size: 0.75rem; }
.chip:hover { color: var(--text); border-color: var(--text-faint); }
.chip.active { background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); color: #fff; border-color: transparent; }
.chip.active span { color: rgba(255, 255, 255, 0.8); }

.empty-block { text-align: center; padding: 48px 16px; border: 1px dashed var(--border); border-radius: 14px; color: var(--text-muted); margin-bottom: 24px; }
.empty-block p { margin: 0 0 14px; }

/* Badges */
.badge { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 9px; border-radius: 999px; background: var(--tag-bg); color: var(--tag-text); white-space: nowrap; }
.badge-client { background: rgba(60, 180, 120, 0.16); color: #2c9c66; }
.badge-prospect { background: rgba(240, 170, 60, 0.18); color: #b97a0d; }
.badge-locataire { background: rgba(120, 100, 220, 0.16); color: #6d5bd0; }
.badge-partenaire { background: rgba(80, 140, 255, 0.16); color: #4a7be8; }
.badge-fournisseur { background: rgba(230, 100, 170, 0.16); color: #cc4f96; }
.badge-prio-haute { background: rgba(255, 107, 129, 0.16); color: var(--danger); }
.badge-prio-basse { background: var(--tag-bg); color: var(--text-muted); }

/* Contacts */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.contact-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.contact-top { display: flex; align-items: center; gap: 12px; }
.avatar-initials { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); flex-shrink: 0; }
.avatar-initials.small { width: 28px; height: 28px; font-size: 0.7rem; }
.contact-id { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; text-decoration: none; color: var(--text); }
.contact-name:hover { color: var(--accent-1); }
.contact-company { font-size: 0.82rem; color: var(--text-muted); }
.contact-line { font-size: 0.88rem; }
.contact-note { font-size: 0.82rem; color: var(--text-muted); background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pill-link { font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); text-decoration: none; background: var(--bg); }
.pill-link:hover { color: var(--accent-1); border-color: var(--accent-1); }
.pill-link.static { cursor: default; }
.pill-link.static:hover { color: var(--text-muted); border-color: var(--border); }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }

/* Formulaires */
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.form-section { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; }
.form-section h2 { margin: 0 0 14px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .field.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .page { padding: 24px 16px 48px; } .topbar { padding: 12px 16px; } }

/* Tâches */
.quick-add { display: flex; gap: 10px; flex-wrap: wrap; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 26px; }
.quick-add .quick-title { flex: 1 1 280px; width: auto; }
.quick-add input[type="date"], .quick-add select { width: auto; }
.task-group { margin-bottom: 26px; }
.group-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 0 0 10px; display: flex; gap: 8px; align-items: center; }
.group-title span { background: var(--tag-bg); color: var(--tag-text); border-radius: 999px; padding: 1px 8px; font-size: 0.72rem; }
.group-title.danger { color: var(--danger); }
.group-title.accent { color: var(--accent-1); }
.task-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elevated); overflow: hidden; }
.task-row { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: none; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-faint); background: transparent; cursor: pointer; color: #fff; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; margin-top: 2px; }
.check:hover { border-color: var(--accent-1); }
.check.checked { background: var(--accent-1); border-color: var(--accent-1); }
.task-main { flex: 1; min-width: 0; }
.task-title { color: var(--text); text-decoration: none; font-weight: 500; }
.task-row.is-done .task-title { text-decoration: line-through; color: var(--text-faint); }
.task-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: 0.8rem; color: var(--text-muted); }
.task-date.late { color: var(--danger); font-weight: 600; }
.task-contact { color: var(--accent-1); text-decoration: none; }
.task-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }
.task-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.task-row:hover .task-actions, .task-row:focus-within .task-actions { opacity: 1; }
@media (hover: none) { .task-actions { opacity: 1; } }

/* Agenda */
#calendar { height: calc(100vh - 230px); min-height: 560px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.fc {
  --fc-border-color: var(--border);
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: var(--bg-elevated-2);
  --fc-today-bg-color: color-mix(in srgb, var(--accent-1) 10%, transparent);
  --fc-event-bg-color: var(--accent-1);
  --fc-event-border-color: var(--accent-1);
  --fc-event-text-color: #fff;
  --fc-button-bg-color: var(--bg-elevated-2);
  --fc-button-border-color: var(--border);
  --fc-button-text-color: var(--text);
  --fc-button-hover-bg-color: var(--border);
  --fc-button-hover-border-color: var(--border);
  --fc-button-active-bg-color: var(--accent-1);
  --fc-button-active-border-color: var(--accent-1);
  --fc-now-indicator-color: var(--danger);
  --fc-list-event-hover-bg-color: var(--bg-elevated-2);
  --fc-highlight-color: color-mix(in srgb, var(--accent-1) 18%, transparent);
}
.fc .fc-toolbar-title { font-size: 1.2rem; text-transform: capitalize; }
.fc .fc-button { text-transform: capitalize; box-shadow: none !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { color: #fff; }
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion, .fc .fc-timegrid-slot-label-cushion, .fc .fc-list-day-text, .fc .fc-list-day-side-text { color: var(--text); text-decoration: none; }
.fc .fc-list-day-cushion { background: var(--bg-elevated-2); }
.fc .fc-list-event-title a { color: var(--text); text-decoration: none; }

/* Fenêtres modales */
.modal { border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); border-radius: 16px; padding: 24px; width: min(560px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); }
.modal::backdrop { background: rgba(10, 10, 20, 0.55); }
.modal h2 { margin: 0 0 16px; font-size: 1.15rem; }
.modal .field { margin-bottom: 12px; }
.modal-large { width: min(860px, calc(100vw - 32px)); max-height: 88vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.check-inline { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; margin-bottom: 12px; }

/* Documents */
.template-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.template-label { color: var(--text-muted); font-size: 0.85rem; margin-right: 4px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.doc-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.doc-paper { display: block; height: 210px; overflow: hidden; background: var(--paper); color: #222; border-radius: 8px; padding: 16px 18px; font-size: 7.5px; line-height: 1.45; text-decoration: none; border: 1px solid var(--border); position: relative; }
.doc-paper::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 46px; background: linear-gradient(transparent, var(--paper)); }
.doc-paper h1 { font-size: 12px; margin: 0 0 6px; }
.doc-paper h2, .doc-paper h3 { font-size: 9.5px; margin: 6px 0 3px; }
.doc-paper p { margin: 0 0 5px; }
.doc-paper ul, .doc-paper ol { margin: 0 0 5px; padding-left: 12px; }
.doc-paper table { border-collapse: collapse; width: 100%; }
.doc-paper td, .doc-paper th { border: 1px solid #ccc; padding: 1px 3px; }
.doc-info { padding: 0 2px; }
.doc-title { font-weight: 600; color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-date { font-size: 0.78rem; color: var(--text-muted); }
.paper { background: var(--paper); color: #1d1b16; border-radius: 10px; }
.doc-content { line-height: 1.55; font-size: 0.95rem; padding: 28px 32px; }
.doc-content h1 { font-size: 1.6rem; margin: 0 0 12px; }
.doc-content h2 { font-size: 1.25rem; margin: 18px 0 8px; }
.doc-content h3 { font-size: 1.05rem; margin: 14px 0 6px; }
.doc-content p { margin: 0 0 10px; }
.doc-content table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.doc-content td, .doc-content th { border: 1px solid #cfcabb; padding: 6px 8px; }
.doc-content blockquote { border-left: 3px solid #cfcabb; margin: 8px 0; padding-left: 12px; color: #555; }
.doc-content .ql-align-center { text-align: center; }
.doc-content .ql-align-right { text-align: right; }
.doc-content .ql-align-justify { text-align: justify; }
.doc-content .ql-size-small { font-size: 0.75em; }
.doc-content .ql-size-large { font-size: 1.5em; }
.doc-content .ql-size-huge { font-size: 2.5em; }
.doc-content img { max-width: 100%; }

/* Éditeur de document */
.editor-page { max-width: 1000px; }
.editor-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.back-link { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--text); }
.doc-title-input { flex: 1 1 260px; width: auto; font-size: 1.25rem; font-weight: 600; background: transparent; border: 1px solid transparent; padding: 6px 10px; }
.doc-title-input:hover, .doc-title-input:focus { border-color: var(--border); background: var(--bg-elevated); }
.save-status { color: var(--text-muted); font-size: 0.82rem; }
.editor-toolbar.ql-toolbar { background: var(--bg-elevated); border: 1px solid var(--border) !important; border-radius: 12px 12px 0 0; position: sticky; top: 0; z-index: 5; }
.ql-snow.editor-toolbar .ql-stroke { stroke: var(--text-muted); }
.ql-snow.editor-toolbar .ql-fill { fill: var(--text-muted); }
.ql-snow.editor-toolbar .ql-picker { color: var(--text-muted); }
.ql-snow.editor-toolbar button:hover .ql-stroke, .ql-snow.editor-toolbar button.ql-active .ql-stroke, .ql-snow.editor-toolbar .ql-picker-label:hover .ql-stroke { stroke: var(--accent-1); }
.ql-snow.editor-toolbar button:hover .ql-fill, .ql-snow.editor-toolbar button.ql-active .ql-fill { fill: var(--accent-1); }
.ql-snow.editor-toolbar .ql-picker-label:hover, .ql-snow.editor-toolbar .ql-picker-item:hover { color: var(--accent-1); }
.ql-snow.editor-toolbar .ql-picker-options { background: var(--bg-elevated); border-color: var(--border) !important; }
.editor-toolbar.ql-snow .tbl-btn { width: auto; height: auto; padding: 3px 8px; font-size: 0.75rem; color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; background: none; margin-right: 2px; }
.editor-toolbar.ql-snow .tbl-btn:hover { color: var(--accent-1); border-color: var(--accent-1); }
.paper-wrap { background: var(--bg-elevated-2); border: 1px solid var(--border); border-top: none; border-radius: 0 0 12px 12px; padding: 28px 16px; display: flex; justify-content: center; }
#editor.paper { width: 100%; max-width: 794px; min-height: 900px; box-shadow: 0 2px 14px rgba(0, 0, 0, 0.2); border: none !important; border-radius: 4px; }
#editor .ql-editor { padding: 56px 64px; font-size: 1rem; line-height: 1.6; min-height: 900px; }
#editor .ql-editor table { border-collapse: collapse; width: 100%; }
#editor .ql-editor td { border: 1px solid #bdb7a6; padding: 6px 8px; min-width: 40px; }
@media (max-width: 720px) { #editor .ql-editor { padding: 28px 20px; } }

/* Tableau de bord */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; position: relative; }
.kpi:hover { border-color: var(--accent-1); }
.kpi-value { font-size: 1.9rem; font-weight: 700; }
.kpi-label { color: var(--text-muted); font-size: 0.85rem; }
.kpi-alert { position: absolute; top: 14px; right: 14px; font-size: 0.72rem; color: var(--danger); background: rgba(255, 107, 129, 0.12); padding: 2px 8px; border-radius: 999px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head a { font-size: 0.8rem; color: var(--accent-1); text-decoration: none; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mini-list li:last-child { border-bottom: none; }
.mini-list a { color: var(--text); text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list a:hover { color: var(--accent-1); }
.mini-meta { font-size: 0.78rem; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.tag-list { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; padding: 0; margin: 0 0 10px; }
.tag-list li { background: var(--tag-bg); color: var(--tag-text); border-radius: 999px; padding: 3px 10px; font-size: 0.8rem; }
.pipeline-steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; counter-reset: step; }
.pipeline-steps li { counter-increment: step; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-size: 0.8rem; }
.pipeline-steps li::before { content: counter(step) ". "; color: var(--text-faint); }
.mini-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin: 14px 0 6px; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.metier-tag.inline { margin: 0 0 0 6px; padding: 2px 10px; }

/* Assistant IA */
.assistant-page { max-width: 900px; }
.assistant-shell { display: flex; flex-direction: column; height: calc(100vh - 250px); min-height: 480px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.assistant-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 6px 4px 12px; }
.assistant-page .msg-assistant .bubble { background: var(--bg); max-width: 88%; }
.bubble.rich { white-space: normal; }
.bubble.rich p { margin: 0 0 6px; }
.bubble.rich p:last-child { margin-bottom: 0; }
.bubble.rich ul, .bubble.rich ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble.rich .gap { height: 6px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 4px; }
.assistant-input { background: var(--bg); }
.proposals { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.proposal { border: 1px solid var(--border); background: var(--bg-elevated); border-radius: 12px; padding: 12px 14px; }
.proposal-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.proposal-type { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-1); font-weight: 700; }
.proposal-state { font-size: 0.78rem; color: var(--text-muted); }
.proposal-applied { border-color: rgba(60, 180, 120, 0.55); }
.proposal-applied .proposal-state { color: #2c9c66; }
.proposal-dismissed { opacity: 0.55; }
.proposal dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 0.86rem; }
.proposal dt { color: var(--text-muted); }
.proposal dd { margin: 0; word-break: break-word; }
.proposal-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.proposal details { margin-top: 8px; }
.proposal summary { cursor: pointer; font-size: 0.82rem; color: var(--text-muted); }
.proposal .doc-content { margin-top: 8px; max-height: 320px; overflow: auto; padding: 16px 20px; font-size: 0.85rem; }

@media (max-width: 860px) { .topbar-nav { order: 3; width: 100%; } .user-name { display: none; } }

/* Assistant : modifications et suppressions */
.proposal-delete { border-color: rgba(255, 107, 129, 0.45); }
.proposal-delete .proposal-type { color: var(--danger); }
.proposal-update .proposal-type { color: #d18a1f; }
.proposal-warning { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255, 107, 129, 0.12); color: var(--danger); font-size: 0.84rem; font-weight: 500; }
.proposal-armed { border-color: var(--danger); }
.proposal .btn-danger.small { padding: 6px 14px; font-size: 0.82rem; }

/* ════════════════════════════════════════════════════════════════════════════
   Menu latéral (modules) + barre du haut
   ════════════════════════════════════════════════════════════════════════════ */

:root { --topbar-h: 61px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  min-height: var(--topbar-h);
  padding: 12px 20px;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 12px;
}
.topbar-spacer { flex: 1; }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: var(--bg-elevated); }
.only-mobile { display: none; }

.app-shell { display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }
.app-main { flex: 1; min-width: 0; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 18px 12px 14px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.side-nav { flex: 1; }
.side-section { margin-bottom: 20px; }
.side-title { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); padding: 0 10px 6px; }

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
}
.side-link:hover { background: var(--bg-elevated); color: var(--text); }
.side-link.active { background: var(--bg-elevated-2); color: var(--text); font-weight: 500; }
.side-link .ico { flex-shrink: 0; }

.side-row { display: flex; align-items: center; }
.side-row .side-link { flex: 1; min-width: 0; }
.side-caret { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-flex; }
.side-caret:hover { background: var(--bg-elevated); color: var(--text); }
.side-caret .ico { transition: transform 0.15s ease; }
.side-group.open .side-caret .ico { transform: rotate(90deg); }

.side-sub { display: none; margin: 2px 0 6px 20px; padding-left: 12px; border-left: 1px solid var(--border); }
.side-group.open .side-sub { display: block; }
.side-sublink { display: block; padding: 6px 10px; border-radius: 7px; color: var(--text-muted); text-decoration: none; font-size: 0.86rem; }
.side-sublink:hover { background: var(--bg-elevated); color: var(--text); }
.side-sublink.active { color: var(--accent-1); font-weight: 600; }

.side-foot { border-top: 1px solid var(--border); padding-top: 10px; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .only-mobile { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    width: 284px;
    z-index: 60;
    transform: translateX(-104%);
    transition: transform 0.2s ease;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: 0 0 44px rgba(0, 0, 0, 0.45); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(10, 10, 20, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar-head.only-mobile { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 14px; }
  .user-name { display: none; }
  .topbar { padding: 10px 14px; }
}

/* ── Page « Modules » ───────────────────────────────────────────────────────── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.module-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.module-card.is-on { border-color: color-mix(in srgb, var(--accent-1) 45%, var(--border)); }
.module-head { display: flex; align-items: center; gap: 12px; }
.module-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-elevated-2); color: var(--accent-1); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.module-name { font-weight: 600; }
.module-from { font-size: 0.72rem; color: var(--text-faint); }
.module-summary { font-size: 0.88rem; color: var(--text-muted); margin: 0; }
.module-actions { margin-top: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.status-pill { font-size: 0.7rem; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; margin-left: auto; white-space: nowrap; }
.status-on { background: rgba(60, 180, 120, 0.16); color: #2c9c66; }
.status-available { background: var(--tag-bg); color: var(--tag-text); }
.status-soon { background: var(--bg-elevated-2); color: var(--text-faint); }
.module-section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 28px 0 12px; }
.notice-banner { background: var(--bg-elevated); border: 1px solid var(--accent-1); color: var(--text); border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; font-size: 0.9rem; }

/* ── Module Comptabilité ───────────────────────────────────────────────────── */
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filter-bar label { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.88rem; }
.filter-bar input, .filter-bar select, .pay-form input, .pay-form select, .catalog-form input,
.lines-table input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }
.filter-bar input[type=search] { min-width: 220px; }
.table-wrap { overflow-x: auto; margin-bottom: 18px; }
.num { text-align: right; white-space: nowrap; }
.small { font-size: 0.8rem; }
.pos { color: #2c9c66; }
.neg { color: var(--danger, #ff6b81); }

.st { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 9px; border-radius: 999px; background: var(--bg-elevated-2); color: var(--text-muted); white-space: nowrap; vertical-align: middle; }
.st-payee, .st-accepte { background: rgba(60, 180, 120, 0.16); color: #2c9c66; }
.st-emise { background: rgba(80, 140, 240, 0.16); color: #4a86e8; }
.st-partiellement_payee { background: rgba(240, 170, 60, 0.18); color: #d08a1a; }
.st-en_retard, .st-refuse { background: rgba(255, 107, 129, 0.16); color: #e0475f; }
.st-converti { background: rgba(150, 110, 230, 0.16); color: #8a63d6; }

.lines-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.lines-table th { text-align: left; font-size: 0.75rem; color: var(--text-muted); padding: 6px 4px; font-weight: 500; }
.lines-table th.num { text-align: right; }
.lines-table td { padding: 4px; vertical-align: middle; }
.lines-table input { width: 100%; }
.lines-table input.num { text-align: right; min-width: 70px; }
.lines-table .l-des { min-width: 220px; }
.lines-table .l-total { min-width: 90px; }
.totals-box { margin-top: 16px; max-width: 320px; margin-left: auto; }
.sum-row { display: flex; justify-content: space-between; gap: 16px; margin: 4px 0; }
.sum-row.strong { font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.doc-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.doc-layout .card p { margin: 4px 0; }
.card { margin-bottom: 16px; }
.pay-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pay-form input[name=amount] { width: 120px; }
.form-actions .inline-form { display: inline; }
.row-actions { white-space: nowrap; }
.row-actions .inline-form { display: inline; }
.logo-preview { max-height: 70px; max-width: 200px; background: #fff; padding: 6px; border-radius: 8px; }
.catalog-form { margin-bottom: 20px; }

.bars { display: flex; gap: 6px; align-items: flex-end; height: 160px; margin-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-pair { flex: 1; display: flex; gap: 2px; align-items: flex-end; width: 100%; justify-content: center; }
.bar { width: 42%; min-height: 2px; border-radius: 3px 3px 0 0; }
.bar-billed { background: var(--accent-1); opacity: 0.55; }
.bar-collected { background: #2c9c66; }
.bar-label { font-size: 0.65rem; color: var(--text-faint); margin-top: 4px; }
.legend { font-size: 0.78rem; color: var(--text-muted); margin: 10px 0 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 4px 0 10px; }
.dot-billed { background: var(--accent-1); opacity: 0.55; }
.dot-collected { background: #2c9c66; }
.cat-row { display: grid; grid-template-columns: 110px 1fr 100px; gap: 10px; align-items: center; margin: 6px 0; font-size: 0.88rem; }
.cat-bar { background: var(--bg-elevated-2); height: 8px; border-radius: 4px; overflow: hidden; }
.cat-bar span { display: block; height: 100%; background: var(--accent-1); }

.sync-box { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; margin-bottom: 20px; }
.sync-box p { margin: 4px 0 0; }

/* ── Assistant flottant ───────────────────────────────────────────────────── */
.aw-fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer; color: #fff; background: linear-gradient(135deg, var(--accent-1), var(--accent-2, var(--accent-1))); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.3); display: flex; align-items: center; justify-content: center; }
.aw-fab:hover { transform: translateY(-1px); }
.aw-panel { position: fixed; right: 22px; bottom: 22px; z-index: 45; width: 390px; max-width: calc(100vw - 24px); height: min(600px, calc(100vh - 44px)); display: flex; flex-direction: column; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 18px 56px rgba(0, 0, 0, 0.35); overflow: hidden; }
.aw-panel.hidden, .aw-fab.hidden { display: none; }
.aw-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.aw-head .icon-btn { width: 30px; height: 30px; }
.aw-spacer { flex: 1; }
.aw-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.aw-panel .msg-assistant .bubble { background: var(--bg); max-width: 94%; }
.aw-panel .proposal { padding: 10px 12px; }
.aw-form { margin: 0 10px 10px; }
@media (max-width: 640px) { .aw-panel { right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 82vh; border-radius: 16px 16px 0 0; } .aw-fab { right: 14px; bottom: 14px; } }

.import-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 18px; }
.import-box select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }

.restore-hint { text-align: center; font-size: 0.85rem; margin: 6px 0 0; position: relative; z-index: 1; }
.restore-hint a { color: var(--text-muted); }

/* Réorganisation du menu */
.side-item { position: relative; }
.side-ctl { display: none; position: absolute; right: 4px; top: 5px; gap: 2px; }
.side-ctl button { background: var(--bg-elevated-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; width: 24px; height: 24px; cursor: pointer; padding: 0; line-height: 1; }
.sidebar.editing .side-ctl { display: inline-flex; }
.sidebar.editing .side-item { cursor: grab; border-radius: 9px; outline: 1px dashed var(--border); margin-bottom: 3px; }
.sidebar.editing .side-caret { display: none; }
.side-item.dragging { opacity: 0.45; }
.side-edit { width: 100%; background: none; border: none; cursor: pointer; font: inherit; text-align: left; }

/* ── Module Mails ─────────────────────────────────────────────────────────── */
.mail-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.mail-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-elevated); }
.mail-row:last-child { border-bottom: none; }
.mail-row.unread { background: var(--bg); }
.mail-row.unread .mail-from, .mail-row.unread .mail-subject { font-weight: 700; }
.mail-main { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.mail-top { display: flex; gap: 8px; align-items: center; }
.mail-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-date { color: var(--text-faint); font-size: 0.78rem; white-space: nowrap; }
.mail-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.mail-snippet { color: var(--text-muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-actions form { display: flex; gap: 2px; }
.mail-actions { opacity: 0; transition: opacity 0.15s; }
.mail-row:hover .mail-actions, .mail-row:focus-within .mail-actions { opacity: 1; }
@media (max-width: 720px) { .mail-actions { display: none; } }
.prio-badge { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.prio-urgent { background: rgba(255, 107, 129, 0.18); color: #e0475f; }
.prio-important { background: rgba(240, 170, 60, 0.2); color: #c78113; }
.prio-normal { background: var(--bg-elevated-2); color: var(--text-muted); }
.prio-faible { background: var(--bg-elevated-2); color: var(--text-faint); }
.prio-spam { background: rgba(150, 110, 230, 0.18); color: #8a63d6; }
.mail-body { overflow-wrap: anywhere; line-height: 1.55; }
.mail-body.pre { white-space: pre-wrap; }
.mail-body img { display: none; }
hr.soft { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Mails : sélection, glisser-déposer, rattachements */
.bulk-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 8px 4px; min-height: 44px; }
.bulk-actions { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bulk-actions select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font: inherit; }
.mail-row { cursor: default; }
.mail-row .mail-check { flex-shrink: 0; width: 17px; height: 17px; cursor: pointer; }
.mail-row.selected { background: color-mix(in srgb, var(--accent-1) 12%, var(--bg-elevated)); }
.mail-row.dragging { opacity: 0.45; }
.drop-zone.over { outline: 2px dashed var(--accent-1); background: color-mix(in srgb, var(--accent-1) 16%, transparent); }
.drag-ghost { position: fixed; top: -100px; left: -100px; padding: 6px 12px; border-radius: 8px; background: var(--accent-1); color: #fff; font-size: 0.85rem; z-index: 99; }
.drag-ghost.hidden { display: block; }
.link-tag { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; background: var(--tag-bg); color: var(--tag-text); white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.mail-section .mini-list a { text-decoration: none; }
.attach-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.attach-form select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; min-width: 220px; }

/* Menu contextuel des mails */
.ctx-menu { position: fixed; z-index: 80; min-width: 220px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35); }
.ctx-menu.hidden { display: none; }
.ctx-head { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); padding: 6px 10px 4px; }
.ctx-item { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text); padding: 8px 10px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 0.9rem; }
.ctx-item:hover { background: var(--bg-elevated-2); }
.ctx-item.danger { color: var(--danger, #e0475f); }
.ctx-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.ctx-sub-wrap { position: relative; }
.ctx-sub { display: none; position: absolute; left: 100%; top: -6px; min-width: 190px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35); }
.ctx-sub-wrap:hover .ctx-sub { display: block; }
.ctx-menu.flip .ctx-sub { left: auto; right: 100%; }

/* Indicateurs */
.side-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--accent-1); }
.side-badge.hidden { display: none; }
.side-badge.tone-danger { background: #e0475f; }
.side-badge.tone-warn { background: #d08a1a; }
.side-badge.tone-info { background: var(--accent-1); }
.indic-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 20px; }
.indic-row:empty { display: none; }
.indic-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.indic-card.has-danger { border-color: rgba(224, 71, 95, 0.55); }
.indic-head { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; }
.indic-line { text-decoration: none; color: var(--text); font-size: 0.95rem; }
.indic-line strong { font-size: 1.35rem; margin-right: 4px; }
.indic-line.tone-danger strong { color: #e0475f; }
.indic-line.tone-warn strong { color: #d08a1a; }
.indic-line.tone-info strong { color: var(--accent-1); }
.indic-ok { color: #2c9c66; font-size: 0.9rem; }

/* Champs modifiables dans les cartes de l'assistant */
.proposal-field { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.proposal-field label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.proposal-field textarea, .proposal-field input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 0.9rem; resize: vertical; }

/* À traiter maintenant */
.todo-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; margin-bottom: 20px; }
.todo-card h2 { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 9px 0 9px 12px; border-left: 3px solid var(--border); margin: 6px 0; }
.todo-item.lvl-urgent { border-left-color: #e0475f; }
.todo-item.lvl-important { border-left-color: #d08a1a; }
.todo-item.lvl-info { border-left-color: var(--accent-1); }
.todo-title { color: var(--text); font-weight: 600; text-decoration: none; }
.todo-title:hover { color: var(--accent-1); }
@media (max-width: 640px) { .todo-item { flex-direction: column; align-items: flex-start; } }

/* Alerte quotidienne de l'assistant */
@keyframes nz-pulse-orange { 0% { box-shadow: 0 0 0 0 rgba(224, 150, 40, 0.55); } 70% { box-shadow: 0 0 0 12px rgba(224, 150, 40, 0); } 100% { box-shadow: 0 0 0 0 rgba(224, 150, 40, 0); } }
@keyframes nz-pulse-red { 0% { box-shadow: 0 0 0 0 rgba(224, 71, 95, 0.65); } 70% { box-shadow: 0 0 0 14px rgba(224, 71, 95, 0); } 100% { box-shadow: 0 0 0 0 rgba(224, 71, 95, 0); } }
@keyframes nz-shake { 0%, 100% { transform: translateX(0) rotate(0); } 10% { transform: translateX(-4px) rotate(-6deg); } 20% { transform: translateX(4px) rotate(6deg); } 30% { transform: translateX(-4px) rotate(-5deg); } 40% { transform: translateX(4px) rotate(5deg); } 50% { transform: translateX(-3px) rotate(-3deg); } 60% { transform: translateX(3px) rotate(3deg); } 70% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }

.side-link.alert-attention, .aw-fab.alert-attention, #sidebar-toggle.alert-attention { color: #fff !important; background: #d98a1f !important; border-color: #d98a1f !important; animation: nz-pulse-orange 1.8s ease-out infinite; }
.side-link.alert-critical, .aw-fab.alert-critical, #sidebar-toggle.alert-critical { color: #fff !important; background: #e0475f !important; border-color: #e0475f !important; animation: nz-pulse-red 1.2s ease-out infinite; }
.side-link.alert-shake, .aw-fab.alert-shake, #sidebar-toggle.alert-shake { animation: nz-shake 0.6s ease-in-out 6, nz-pulse-red 1.2s ease-out infinite; }
.side-link.alert-critical, .aw-fab.alert-critical { animation-name: nz-pulse-red, nz-shake-burst; animation-duration: 1.2s, 3.5s; animation-iteration-count: infinite; }
@keyframes nz-shake-burst { 0%, 80%, 100% { transform: translateX(0); } 84% { transform: translateX(-3px) rotate(-4deg); } 88% { transform: translateX(3px) rotate(4deg); } 92% { transform: translateX(-3px) rotate(-3deg); } 96% { transform: translateX(2px); } }
.side-link.alert-attention svg, .side-link.alert-critical svg { color: #fff; }
@media (prefers-reduced-motion: reduce) {
  .side-link.alert-attention, .aw-fab.alert-attention, #sidebar-toggle.alert-attention,
  .side-link.alert-critical, .aw-fab.alert-critical, #sidebar-toggle.alert-critical,
  .side-link.alert-shake, .aw-fab.alert-shake, #sidebar-toggle.alert-shake { animation: none !important; }
}
.todo-actions { display: inline-flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* Boîte de tri */
.dropzone { border: 2px dashed var(--border); border-radius: 16px; padding: 22px; text-align: center; margin-bottom: 18px; background: var(--bg-elevated); transition: border-color 0.15s, background 0.15s; }
.dropzone.over { border-color: var(--accent-1); background: color-mix(in srgb, var(--accent-1) 10%, var(--bg-elevated)); }
.upload-list { list-style: none; margin: 12px 0 0; padding: 0; text-align: left; font-size: 0.88rem; }
.upload-list li { padding: 3px 0; }
.up-state.pos { color: #2c9c66; }
.up-state.neg { color: #e0475f; }
.read-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--bg-elevated-2); color: var(--text-muted); }
.read-badge.tone-good { background: rgba(60, 180, 120, 0.16); color: #2c9c66; }
.read-badge.tone-warn { background: rgba(240, 170, 60, 0.2); color: #b87410; }
.read-badge.tone-bad { background: rgba(255, 107, 129, 0.18); color: #e0475f; }
.plain-list { margin: 6px 0 0; padding-left: 20px; }

.usage-bar { background: var(--bg-elevated-2); height: 10px; border-radius: 6px; overflow: hidden; margin: 8px 0; }
.usage-fill { display: block; height: 100%; background: var(--accent-1); }
.usage-fill.state-near { background: #d98a1f; }
.usage-fill.state-soft, .usage-fill.state-blocked { background: #e0475f; }
.usage-note { background: var(--bg-elevated-2); color: var(--text-muted); font-size: 0.82rem; padding: 8px 12px; border-radius: 10px; margin-bottom: 8px; }

/* ── Gestion locative ── */
.doc-checklist { list-style: none; margin: 8px 0 0; padding: 0; }
.doc-checklist > li { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; background: var(--bg-elevated); }
.doc-checklist > li.ok { border-color: rgba(60, 180, 120, 0.45); }
.doc-checklist > li.missing { border-color: rgba(240, 170, 60, 0.55); }
.doc-head { display: flex; align-items: center; gap: 12px; }
.doc-mark { width: 22px; text-align: center; font-weight: 700; color: var(--text-muted); }
.doc-checklist > li.ok .doc-mark { color: #2c9c66; }
.doc-checklist > li.missing .doc-mark { color: #d08a1a; }
.doc-title { flex: 1; min-width: 0; }
.doc-add { cursor: pointer; white-space: nowrap; }
.doc-file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 0 34px; font-size: 0.88rem; }
.pay-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.pay-form input, .pay-form select { padding: 5px 8px; font-size: 0.85rem; max-width: 130px; }
.small-title { font-size: 0.85rem; margin: 14px 0 4px; color: var(--text-muted); }
.data-table .inline-form, .mini-list .inline-form, .doc-file-row .inline-form, .card .small .inline-form { display: inline; border: 0; padding: 0; background: none; max-width: none; margin: 0; box-shadow: none; }
.doc-title .muted, .doc-title .small { white-space: normal; overflow-wrap: anywhere; }

/* ── Administration ── */
.meter { height: 8px; background: var(--bg-elevated-2); border-radius: 999px; overflow: hidden; margin: 4px 0 12px; }
.meter span { display: block; height: 100%; background: var(--accent-1); border-radius: 999px; }
.meter span.warn { background: #d08a1a; }
.meter span.over { background: var(--danger); }
.bars-30 { gap: 2px; }
.bars-30 .bar-label { font-size: 0.55rem; }
.admin-nav { margin-bottom: 18px; }

/* ── Activités (espaces) ── */
.space-switch { margin-left: 14px; }
.space-switch select { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); font-size: 0.85rem; max-width: 220px; }

/* ── Prospection ── */
.st-nouveau { background: var(--bg-elevated-2); }
.st-contacte { background: rgba(80, 140, 240, 0.16); color: #4a86e8; }
.st-repondu { background: rgba(240, 170, 60, 0.18); color: #d08a1a; }
.st-interesse, .st-gagne { background: rgba(60, 180, 120, 0.16); color: #2c9c66; }
.st-pas_interesse, .st-ne_pas_contacter { background: rgba(255, 107, 129, 0.16); color: #e0475f; }
.st-a_rappeler { background: rgba(150, 110, 230, 0.16); color: #8a63d6; }
.bulk-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.bubble { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; background: var(--bg-elevated); max-width: 92%; }
.bubble.out { align-self: flex-end; }
.bubble.in { align-self: flex-start; border-color: rgba(60, 180, 120, 0.5); }
.bubble.draft { border-style: dashed; }
.bubble-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bubble-body { white-space: pre-wrap; margin-top: 6px; }
.draft-card { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: var(--bg-elevated); max-width: none; }
.draft-card textarea, .draft-card input { width: 100%; }
.preview-box { border: 1px dashed var(--border); border-radius: 10px; padding: 12px; margin-top: 8px; }
.merge-chip { cursor: pointer; }
.head-actions .inline-form, .pay-form .inline-form { display: inline; border: 0; padding: 0; background: none; max-width: none; margin: 0; box-shadow: none; }
[hidden] { display: none !important; }

/* ── Contrats ── */
.tpl-choice { display: flex; gap: 12px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.tpl-choice:last-child { border-bottom: 0; }
.clause { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--bg-elevated); }
.clause-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.clause-head input { flex: 1; font-weight: 600; }
.clause textarea { width: 100%; }
.clause-ctl { display: flex; gap: 4px; }
.clause-ctl button { padding: 2px 8px; }
