:root {
  --primary: #0F2444;
  --primary-light: #1e3a6f;
  --accent: #a21caf;
  --accent-hover: #86198f;
  --accent-soft: #fdf4ff;
  --bg: #f1f5f9;
  --bg-elev: #f8fafc;
  --card: #fff;
  --card-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-on-accent: #fff;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --orange: #f59e0b;
  --orange-soft: #fef3c7;
  --red: #ef4444;
  --red-soft: #fee2e2;
  --blue: #3b82f6;
  --blue-soft: #dbeafe;
  --modal-overlay: rgba(15,36,68,0.85);
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.12);
  --transition: 0.18s ease;
}

[data-theme="dark"] {
  --primary: #c026d3;
  --primary-light: #a21caf;
  --accent: #d946ef;
  --accent-hover: #c026d3;
  --accent-soft: #2a1235;
  --bg: #0f172a;
  --bg-elev: #1e293b;
  --card: #1e293b;
  --card-hover: #273449;
  --border: #334155;
  --border-strong: #475569;
  --text: #e2e8f0;
  --text-on-accent: #fff;
  --muted: #94a3b8;
  --muted-soft: #64748b;
  --green: #4ade80;
  --green-soft: #052e16;
  --orange: #fbbf24;
  --orange-soft: #422006;
  --red: #f87171;
  --red-soft: #450a0a;
  --blue: #60a5fa;
  --blue-soft: #1e3a8a;
  --modal-overlay: rgba(0,0,0,0.7);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}
* { box-sizing: border-box; }
html, body { transition: background-color var(--transition), color var(--transition); }
body {
  margin: 0; font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
.muted-label { color: var(--muted); font-weight: 400; font-size: 13px; }

/* ── Login ─────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; background: linear-gradient(135deg, #0f2444, #1e3a6f);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.login-box {
  background: #fff; padding: 36px 40px; border-radius: 18px; max-width: 380px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand i { font-size: 40px; color: var(--accent); }
.login-brand h1 { margin: 8px 0 4px; font-size: 22px; color: var(--text); }
.login-brand p { color: var(--muted); font-size: 13px; margin: 0; }
.login-user {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 10px; border: 2px solid var(--border);
  cursor: pointer; margin-bottom: 8px; transition: all 0.15s;
}
.login-user:hover { border-color: var(--accent); background: var(--accent-soft); }
.login-user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.login-user-info { flex: 1; }
.login-user-name { font-weight: 700; }
.login-user-role { font-size: 11px; color: var(--muted); }
.login-selected-user { background: var(--accent-soft); padding: 10px 14px; border-radius: 8px; font-weight: 700; margin-bottom: 12px; text-align: center; }
#login-pin-input { width: 100%; padding: 12px 14px; border: 2px solid var(--border); border-radius: 10px; font-size: 18px; letter-spacing: 0.5em; text-align: center; }
#login-pin-input:focus { border-color: var(--accent); outline: none; }
.login-error { background: var(--red-soft); color: var(--red); padding: 8px 12px; border-radius: 8px; font-size: 12px; margin-top: 8px; }

/* ── App layout ─────────────────────────────── */
.app-header {
  background: #fff; border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: 220px 1fr auto; align-items: center;
  padding: 0 24px; height: 56px;
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 50;
}
.app-brand { font-size: 16px; color: var(--primary); }
.app-brand i { color: var(--accent); margin-right: 6px; }
.app-nav { display: flex; gap: 4px; justify-content: center; }
.nav-btn {
  border: none; background: transparent; padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; position: relative;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-btn .badge { background: var(--red); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 99px; }
.app-user { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.header-import-btn { padding: 6px 12px; font-size: 12px; box-shadow: var(--shadow-sm); }
.header-import-btn i { font-size: 11px; }
.btn-icon { width: 32px; height: 32px; border: none; background: transparent; border-radius: 8px; color: var(--muted); cursor: pointer; }
.btn-icon:hover { background: var(--bg); color: var(--text); }

#app-main { padding: 20px 24px 40px; max-width: 1600px; margin: auto; }
.view { display: none; }
.view.active { display: block; }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.view-header h2 { margin: 0; font-size: 22px; font-weight: 800; color: var(--primary); }
.view-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input, select, textarea {
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: var(--card); color: var(--text);
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input::placeholder { color: var(--muted-soft); }
.btn-primary {
  background: var(--accent); color: var(--text-on-accent); border: none; padding: 8px 16px;
  border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--transition), transform 0.05s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border-strong); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; transition: background var(--transition); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; }
.btn-ghost:hover { background: var(--bg-elev); color: var(--text); }
.btn-danger-outline { background: var(--card); color: var(--red); border: 1px solid var(--red); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; transition: all var(--transition); }
.btn-danger-outline:hover { background: var(--red); color: #fff; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 12px; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cnt-pill { background: var(--accent); color: #fff; font-size: 10px; padding: 2px 8px; border-radius: 99px; }
.cnt-pill.zero { background: var(--green); }

/* Dashboard tiles */
.tiles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; position: relative; box-shadow: var(--shadow-sm); }
.tile-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; display: flex; align-items: center; gap: 6px; }
.tile-title i { color: var(--accent); font-size: 12px; }
.tile-value { font-size: 24px; font-weight: 800; margin: 6px 0 2px; color: var(--primary); }
.tile-bar { background: var(--border); height: 6px; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.tile-bar > div { height: 100%; transition: width 0.4s; background: var(--green); border-radius: 99px; }
.tile-sub { font-size: 11px; color: var(--muted); margin-top: 6px; }
.tile-delta { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; margin-left: 6px; }
.tile-delta-pos { background: var(--green-soft); color: var(--green); }
.tile-delta-neg { background: var(--red-soft); color: var(--red); }
.tile-delta-zero { background: var(--bg); color: var(--muted); }
.tile-hero { background: linear-gradient(135deg, #0f2444, #1e3a6f); color: #fff; border-color: #0f2444; }
.tile-hero .tile-title { color: rgba(255,255,255,0.7); }
.tile-hero .tile-title i { color: rgba(255,255,255,0.9); }
.tile-hero .tile-value { color: #fff; }
.tile-hero .tile-sub { color: rgba(255,255,255,0.7); }
.tile-hero .tile-bar { background: rgba(255,255,255,0.18); }

.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }
.charts-grid-3-2 { grid-template-columns: 3fr 2fr; }
@media (max-width: 920px) { .charts-grid, .charts-grid-3-2 { grid-template-columns: 1fr; } }

/* Wrappers Chart.js — taille fixe pour éviter la croissance infinie */
.chart-wrap { position: relative; width: 100%; height: 260px; }
.chart-wrap-lg { height: 220px; }
.chart-wrap canvas { max-height: 100%; }

/* Top clients */
.top-clients-row {
  display: grid; grid-template-columns: 22px 1fr auto auto; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid var(--border); align-items: center; font-size: 12px;
}
.top-clients-row:last-child { border-bottom: none; }
.top-clients-rank { font-weight: 800; color: var(--accent); font-size: 13px; text-align: center; }
.top-clients-name { font-weight: 600; }
.top-clients-meta { font-size: 11px; color: var(--muted); }
.top-clients-ca { font-weight: 700; color: var(--green); white-space: nowrap; }

/* Pipeline (vue dashboard) */
#pipeline-bars { display: flex; flex-direction: column; gap: 6px; }
.pipeline-step { padding: 8px 12px; border-radius: 8px; color: #fff; font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pipeline-step .nb { font-size: 17px; font-weight: 800; }
.pipeline-emis                    { background: #64748b; }
.pipeline-relance                 { background: #f59e0b; }
.pipeline-en_attente_facturation  { background: #ea580c; }
.pipeline-signe                   { background: var(--green); }
.pipeline-refuse                  { background: var(--red); opacity: 0.85; }
.pipeline-perdu                   { background: #1f2937; opacity: 0.85; }
.pipeline-expire                  { background: #475569; opacity: 0.85; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table th, table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
table th { background: var(--bg-elev); font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.3px; font-weight: 700; user-select: none; }
table th.sortable { cursor: pointer; }
table th.sortable:hover { color: var(--accent); }
table th.sortable .sort-arrow { font-size: 9px; margin-left: 3px; opacity: 0.5; }
table th.sortable.active .sort-arrow { opacity: 1; color: var(--accent); }
table tbody tr { cursor: pointer; transition: background var(--transition); }
table tbody tr:hover td { background: var(--card-hover); }
table tr.client-row { cursor: pointer; }

/* Statut badges */
.statut { font-size: 10px; padding: 2px 9px; border-radius: 99px; font-weight: 800; display: inline-block; white-space: nowrap; }
.statut-emis                    { background: #e2e8f0; color: var(--muted); }
.statut-relance                 { background: #fef3c7; color: #92400e; }
.statut-signe                   { background: var(--green-soft); color: #15803d; }
.statut-refuse                  { background: var(--red-soft); color: #991b1b; }
.statut-perdu                   { background: #1f2937; color: #fff; }
.statut-expire                  { background: #475569; color: #fff; }
.statut-en_attente_facturation  { background: #fed7aa; color: #9a3412; }

/* Age dot */
.age-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.age-vert { background: var(--green); }
.age-orange { background: var(--orange); }
.age-rouge { background: var(--red); }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 12px 0; }
.pagination button { padding: 6px 10px; border: 1px solid var(--border-strong); background: var(--card); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; transition: all var(--transition); }
.pagination button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.pagination button.active { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .pg-info { font-size: 11px; color: var(--muted); margin: 0 8px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: var(--modal-overlay);
  display: flex; align-items: center; justify-content: center; z-index: 90; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal { background: var(--card); color: var(--text); border-radius: 14px; max-width: 600px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-body { padding: 18px 22px; overflow: auto; }

.dropzone {
  display: block; border: 2px dashed var(--accent); background: var(--accent-soft);
  padding: 36px 24px; text-align: center; border-radius: 10px; cursor: pointer;
  color: var(--accent); font-weight: 600;
}
.dropzone i { font-size: 32px; display: block; margin-bottom: 8px; }
.dropzone.dragover { background: #fae8ff; }

/* Catégorie badges (cohérents avec pdfx) */
.cat { font-size: 9px; padding: 1px 7px; border-radius: 4px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.cat-extincteur      { background: var(--red-soft); color: #991b1b; }
.cat-signaletique    { background: var(--blue-soft); color: #1e40af; }
.cat-prevention      { background: #fae8ff; color: #86198f; }
.cat-maintenance     { background: var(--orange-soft); color: #92400e; }
.cat-forfait         { background: #cffafe; color: #0e7490; }
.cat-frais_livraison { background: #ccfbf1; color: #115e59; }
.cat-frais_admin     { background: #e0e7ff; color: #3730a3; }
.cat-frais_etude     { background: var(--bg); color: #475569; }
.cat-remise          { background: #fce7f3; color: #be185d; }
.cat-autre           { background: #fafafa; color: #71717a; }

/* Remises consenties (dashboard) */
.remises-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 8px;
}
.remise-stat {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  text-align: center;
}
.remise-stat.remise-total {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
  border-color: #ec4899;
}
.remise-stat .remise-val { font-size: 20px; font-weight: 800; color: var(--primary); }
.remise-stat.remise-total .remise-val { color: #be185d; }
.remise-stat .remise-lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }
@media (max-width: 700px) { .remises-stats { grid-template-columns: 1fr 1fr; } }
.remises-clients-list { margin-top: 4px; }

/* Catégorie éditable (badge cliquable dans devis modal) */
.cat-editable { cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; }
.cat-editable:hover { transform: scale(1.05); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.cat-editable:hover i { opacity: 1 !important; }

/* Picker catégorie */
.cat-picker-option { padding: 10px 12px; border: 1px solid var(--border); background: var(--card); border-radius: 8px; cursor: pointer; text-align: left; transition: all var(--transition); }
.cat-picker-option:hover { background: var(--accent-soft); border-color: var(--accent); }
.cat-picker-current { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
.cat-picker-current::after { content: ' ✓'; color: var(--accent); font-weight: 800; float: right; }

/* Devis detail */
.devis-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 18px; margin-bottom: 16px; padding: 14px; background: var(--bg); border-radius: 10px; }
.devis-meta-grid > div { font-size: 12.5px; }
.devis-meta-grid strong { display: block; font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.3px; font-weight: 700; margin-bottom: 2px; }
.devis-action-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; padding: 10px 12px; background: var(--bg); border-radius: 10px; }

/* Section Suivi (devis) */
.suivi-section { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.suivi-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.suivi-header h3 { margin: 0; font-size: 13px; font-weight: 800; color: var(--primary); text-transform: none; letter-spacing: 0; }
.suivi-header h3 i { color: var(--accent); margin-right: 6px; }
.suivi-count { font-size: 11px; color: var(--muted); }
.suivi-rappels { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.suivi-rappels-label { font-size: 11px; font-weight: 800; color: #92400e; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 6px; }
.suivi-rappel-item { display: flex; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; flex-wrap: wrap; }
.suivi-rappel-date { background: var(--accent); color: #fff; padding: 1px 7px; border-radius: 4px; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.suivi-rappel-note { color: var(--muted); font-size: 11px; }

.suivi-form { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; padding: 10px; background: var(--accent-soft); border-radius: 8px; border: 1px solid #f5d0fe; }
.suivi-type-select { min-width: 170px; font-weight: 600; }
.suivi-hint { font-size: 11px; color: var(--muted); padding: 4px 6px 8px; min-height: 16px; }
.suivi-hint:empty { display: none; }

.suivi-timeline { position: relative; padding-left: 8px; }
.suivi-timeline-item { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.suivi-timeline-item:last-child { border-bottom: none; }
.suivi-timeline-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; flex-shrink: 0; }
.suivi-timeline-body { flex: 1; min-width: 0; }
.suivi-timeline-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.suivi-timeline-label { font-size: 12.5px; font-weight: 700; color: var(--text); }
.suivi-timeline-date { font-size: 11px; color: var(--muted); white-space: nowrap; }
.suivi-timeline-note { font-size: 12px; color: var(--text); margin-top: 3px; padding: 5px 8px; background: var(--bg); border-radius: 6px; border-left: 3px solid var(--accent); }
.suivi-timeline-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.suivi-timeline-meta i { color: var(--accent); }
.suivi-timeline-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 11px; color: var(--muted); }
.suivi-delete { color: var(--red); padding: 2px 8px; }
.suivi-delete:hover { background: var(--red-soft); }

/* Tags clients */
.client-tags-card { padding: 12px 14px; margin-bottom: 14px; }
.client-tags-card h3 { margin-bottom: 10px; }
.tags-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.tag-pill-sm { font-size: 10px; padding: 1px 7px; }
.tag-remove { background: none; border: none; color: var(--accent); padding: 0; margin-left: 2px; cursor: pointer; font-size: 14px; line-height: 1; font-weight: 700; }
.tag-remove:hover { color: var(--red); }
.tag-input {
  min-width: 180px; flex: 1; padding: 5px 10px; border: 1px dashed var(--border-strong);
  background: transparent; font-size: 12px;
}
.tag-input:focus { border-style: solid; border-color: var(--accent); }
.client-notes-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); background: var(--bg-elev); border-radius: 8px; font-family: inherit; font-size: 12.5px; resize: vertical; min-height: 50px; }
.client-notes-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

/* Mails (templates et préview) */
.mail-tpl-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; padding: 10px 12px; background: var(--bg-elev); border-radius: 8px; }
.mail-tpl-bar select { flex: 1; min-width: 200px; }
.mail-field { margin-bottom: 12px; }
.mail-field label { display: block; font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: 0.3px; margin-bottom: 4px; }
.mail-field input, .mail-field textarea { width: 100%; font-family: inherit; }
.mail-field textarea { font-size: 13px; line-height: 1.55; }
.mail-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.mail-vars-hint { font-size: 11px; color: var(--muted); padding: 8px 10px; background: var(--bg-elev); border-radius: 6px; margin-top: 8px; }
.mail-vars-hint code { background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 4px; font-size: 10.5px; margin: 0 2px; }

.tpls-toolbar { margin-bottom: 14px; }
.tpls-list { display: flex; flex-direction: column; gap: 10px; }
.tpl-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--card); }
.tpl-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.tpl-name { font-weight: 800; font-size: 14px; color: var(--text); }
.tpl-subject { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tpl-actions { display: flex; gap: 4px; }
.tpl-body { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--text); background: var(--bg-elev); padding: 10px 12px; border-radius: 6px; white-space: pre-wrap; max-height: 180px; overflow-y: auto; line-height: 1.5; margin: 0; }
.tpl-edit { display: flex; flex-direction: column; }

/* Activité récente (modal client) */
.activite-list { max-height: 320px; overflow-y: auto; }
.activite-item { display: flex; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--border); cursor: pointer; }
.activite-item:hover { background: var(--bg); }
.activite-item:last-child { border-bottom: none; }
.activite-icon { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; flex-shrink: 0; }

/* Clients view */
.client-card-stats { display: flex; gap: 18px; padding: 16px; background: var(--bg); border-radius: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.client-card-stats > div { flex: 1; min-width: 120px; }
.client-card-stats .stat-title { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.3px; font-weight: 700; }
.client-card-stats .stat-value { font-size: 20px; font-weight: 800; margin-top: 4px; color: var(--primary); }

/* Kanban — 7 colonnes (incluant 'expire'). Pour 6 colonnes : retirer 'expire' de KANBAN_STATUTS dans app.js */
.kanban-board { display: grid; grid-template-columns: repeat(7, minmax(170px, 1fr)); gap: 10px; overflow-x: auto; }
@media (max-width: 1400px) { .kanban-board { grid-template-columns: repeat(4, minmax(200px, 1fr)); } }
@media (max-width: 1000px) { .kanban-board { grid-template-columns: repeat(3, minmax(220px, 1fr)); } }
@media (max-width: 700px)  { .kanban-board { grid-template-columns: repeat(2, minmax(180px, 1fr)); } }
.kanban-col { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-height: 220px; max-height: 70vh; overflow-y: auto; transition: background var(--transition); }
.kanban-col.drag-over { background: var(--accent-soft); border-color: var(--accent); }
.kanban-col-header { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px; position: sticky; top: -8px; background: var(--bg-elev); }
.kanban-col-title { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); letter-spacing: 0.4px; }
.kanban-col-count { background: var(--accent); color: var(--text-on-accent); font-size: 10px; padding: 1px 8px; border-radius: 99px; font-weight: 700; }
.kanban-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: grab; font-size: 12px; transition: box-shadow var(--transition), transform 0.1s; }
.kanban-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; transform: scale(0.95); }
.kanban-card-num { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
.kanban-card-client { font-weight: 700; margin-top: 2px; color: var(--text); }
.kanban-card-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 11px; }
.kanban-card-ht { font-weight: 800; color: var(--green); }

/* Calendrier */
.cal-board { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-sm); }
.cal-header { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-day-label { padding: 6px 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); letter-spacing: 0.4px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { background: var(--bg-elev); border: 1px solid transparent; border-radius: 8px; min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-cell-empty { background: transparent; }
.cal-cell-today { background: var(--accent-soft); border-color: var(--accent); }
.cal-cell-past { opacity: 0.65; }
.cal-cell-day { font-size: 12px; font-weight: 700; color: var(--text); }
.cal-cell-events { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-event { display: flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 6px; border-radius: 4px; cursor: pointer; color: #fff; }
.cal-event:hover { filter: brightness(1.1); }
.cal-event i { font-size: 9px; flex-shrink: 0; }
.cal-event-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event-relance_prevue   { background: #f59e0b; }
.cal-event-signature_prevue { background: #a21caf; }
.cal-event-expiration       { background: #ef4444; }
.cal-event-signe            { background: #16a34a; }
.cal-more { font-size: 10px; color: var(--muted); padding: 0 6px; }
.cal-summary { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; }
.cal-summary-pill { padding: 5px 12px; border-radius: 99px; color: #fff; font-weight: 600; }
.cal-summary-relance_prevue   { background: #f59e0b; }
.cal-summary-signature_prevue { background: #a21caf; }
.cal-summary-expiration       { background: #ef4444; }
.cal-summary-signe            { background: #16a34a; }
.cal-legend { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); }
.cal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.cal-dot-relance_prevue   { background: #f59e0b; }
.cal-dot-signature_prevue { background: #a21caf; }
.cal-dot-expiration       { background: #ef4444; }
.cal-dot-signe            { background: #16a34a; }

/* Alertes grid */
.alertes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.alerte-card-full { grid-column: 1 / -1; }
@media (max-width: 1000px) { .alertes-grid { grid-template-columns: 1fr; } }
.alerte-list { max-height: 380px; overflow-y: auto; }
.alerte-item { padding: 9px 10px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 12px; cursor: pointer; transition: background 0.1s; gap: 8px; }
.alerte-item:hover { background: var(--bg); }
.alerte-item:last-child { border-bottom: none; }
.alerte-item-main { flex: 1; min-width: 0; }
.alerte-item-num { font-family: ui-monospace, monospace; font-weight: 700; }
.alerte-item-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.alerte-item-right { white-space: nowrap; text-align: right; }
.alerte-item-money { font-weight: 700; color: var(--primary); }
.alerte-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 12px; }
.alerte-empty i { font-size: 28px; color: var(--green); display: block; margin-bottom: 8px; }

/* Objectifs en retard cards */
.objretard-row { padding: 12px; border-bottom: 1px solid var(--border); }
.objretard-row:last-child { border-bottom: none; }
.objretard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.objretard-head strong { font-size: 14px; }
.objretard-bar { background: var(--border); height: 14px; border-radius: 99px; overflow: hidden; position: relative; }
.objretard-bar-fill { height: 100%; background: linear-gradient(90deg, var(--red), var(--orange)); }
.objretard-bar-attendu { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--accent); }
.objretard-legend { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; }

/* ═══ Contrôles (À vérifier) ═══ */
.controles-card { margin-bottom: 18px; }
.controles-card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.controles-card .hint { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.controles-list { max-height: 600px; overflow-y: auto; }

.controles-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 10px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.controles-row:last-child { border-bottom: none; }
.controles-row:hover { background: var(--bg); }
.controles-row .ctrl-main strong { font-family: ui-monospace, monospace; }
.controles-row .ctrl-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.controles-row .ctrl-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.bulk-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 12px; background: var(--accent-soft); border-radius: 8px;
  margin-bottom: 10px; font-size: 13px;
}

.dup-pair {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  margin-bottom: 10px; background: var(--bg);
}
.dup-raison { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.dup-bodies {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  margin-bottom: 10px;
}
.dup-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; cursor: pointer; transition: border-color 0.1s;
}
.dup-card:hover { border-color: var(--accent); }
.dup-card strong { font-family: ui-monospace, monospace; font-size: 13px; }
.dup-card .ctrl-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.dup-vs { font-weight: 800; color: var(--accent); font-size: 18px; text-align: center; }
.dup-actions { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 700px) {
  .dup-bodies { grid-template-columns: 1fr; }
  .dup-vs { display: none; }
}

/* Toast */
#toast {
  position: fixed; top: 18px; right: 18px; padding: 10px 18px; border-radius: 8px;
  color: #fff; font-weight: 600; opacity: 0; transition: opacity 0.3s; z-index: 200;
  box-shadow: var(--shadow-md);
}
#toast.show { opacity: 1; }
#toast.success { background: var(--green); }
#toast.error { background: var(--red); }
#toast.info { background: var(--primary); }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
