/* ============================================================
   Styles V1 — sobre, propre, SaaS moderne.
   On affinera à l'étape 10 (polissage démo).
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-subtle: #64748b;
  --border: #e2e8f0;

  /* Palette forêt — vert profond inspirant la confiance + accents mint */
  --accent: #0f5132;          /* vert forêt principal */
  --accent-hover: #0c6b41;    /* vert moyen au survol */
  --accent-deep: #0a3d27;     /* vert très foncé */
  --accent-soft: #e7f3ec;     /* fond très pâle pour iconcells */
  --accent-mint: #d6ebdf;     /* mint clair */

  --error-bg: #fef2f2;
  --error-border: #fca5a5;
  --error-text: #991b1b;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --ok-bg: #dcfce7;
  --ok-text: #166534;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.subtle { color: var(--text-subtle); }

/* ----- Pages d'auth (login, select-tenant) ----- */

.page-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background: linear-gradient(180deg, #f6f7f9 0%, #eef1f5 100%);
}

.card-auth {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}

.card-auth--wide { max-width: 480px; }

.card-auth__header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.card-auth__header h1 { margin-top: 0.5rem; }
.card-auth__header .brand {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-subtle);
}

.card-auth__footer {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.9rem;
}

/* ----- Formulaires ----- */

label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.9rem;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 81, 50, 0.15);
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-subtle);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font);
}
.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.inline-form { display: inline; margin: 0; }

/* ----- Alertes ----- */

.alert {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
.alert-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

/* ----- Topbar (app connectée) ----- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.topbar--super { border-bottom-color: var(--accent); }

.topbar__brand {
  font-weight: 600;
  color: var(--accent);
}

.topbar__role {
  background: var(--accent);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.4rem;
}

.topbar__tenant {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-subtle);
}

/* ----- Container & cards ----- */

.container {
  max-width: 880px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-top: 1.5rem;
}

.checklist {
  margin: 0;
  padding-left: 1.2rem;
}
.checklist li { margin: 0.3rem 0; }

/* ----- Tenant list (écran de sélection de société) ----- */

.tenant-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.5rem;
}

.tenant-list__item form { margin: 0; }

.tenant-list__btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color 0.15s, transform 0.05s;
}
.tenant-list__btn:hover {
  border-color: var(--accent);
}
.tenant-list__btn:active { transform: scale(0.99); }

.tenant-list__nom { font-weight: 500; }

/* ----- Role pills ----- */

.role-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.role-admin_tenant   { background: #fef3c7; color: #92400e; }
.role-worker_senior  { background: #dbeafe; color: #1e40af; }
.role-worker_junior  { background: #e0e7ff; color: #3730a3; }
.role-client         { background: #d1fae5; color: #065f46; }

/* ----- Responsive ----- */

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
  }
  .topbar__tenant { order: 3; flex-basis: 100%; }
  .container { padding: 0 1rem; margin: 1rem auto; }
  .data-table { font-size: 0.85rem; }
  .actions-cell { white-space: normal !important; }
}

/* ============================================================
   Composants étape 3 — gestion des comptes / tenants
   ============================================================ */

.container--narrow { max-width: 640px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
}
.page-header h1 { margin: 0 0 0.25rem; }
.page-header > div { flex: 1; }

.btn-inline { display: inline-block; width: auto; padding: 0.55rem 1rem; }
.btn-sm     { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-danger { color: var(--error-text); border-color: var(--error-border); }
.btn-danger:hover { background: var(--error-bg); color: var(--error-text); }

.btn-ghost--on-dark {
  color: #fff;
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.05);
}
.btn-ghost--on-dark:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* ----- Cards en mode tableau ----- */

.card--table { padding: 0; overflow-x: auto; }
.card--danger { border-color: var(--error-border); background: #fff7f7; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.data-table th,
.data-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-subtle);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbfc; }
.data-table code {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.85em;
  background: #f1f5f9;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.row-disabled { opacity: 0.5; }
.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ----- Pills (statut, rôle, etc.) ----- */

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pill-ok  { background: #dcfce7; color: #166534; }
.pill-off { background: #fee2e2; color: #991b1b; }

.role-super_admin { background: #fee2e2; color: #991b1b; }

/* ----- Empty state ----- */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}
.empty-state p { color: var(--text-subtle); margin-bottom: 1rem; }

/* ----- Bandeau "voir comme super-admin" ----- */

.view-as-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #1e1b4b;
  color: #fef3c7;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 2px solid #fbbf24;
  font-size: 0.9rem;
}
.view-as-banner strong { color: #fff; }

/* ----- Quick actions (dashboards) ----- */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.05s;
}
.quick-action:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.quick-action:active { transform: scale(0.99); }

.quick-action__icon {
  font-size: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 10px;
  color: var(--accent);
  font-weight: 700;
}
.quick-action__title { font-weight: 600; }

/* ----- Form helpers ----- */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 540px) { .grid-2 { grid-template-columns: 1fr; } }

.hint {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
}

.client-fields h2 { font-size: 1rem; margin-top: 1rem; }

/* ----- Affichage de la clé watcher (révélation unique) ----- */

.alert-warning {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  color: #92400e;
  font-size: 0.9rem;
}

.key-display {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
  padding: 0.65rem 0.85rem;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.key-display code {
  flex: 1;
  background: transparent;
  padding: 0;
  user-select: all;
  font-size: 0.8rem;
  color: var(--text);
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.82rem;
  overflow-x: auto;
  white-space: pre;
  margin-top: 0.5rem;
}

/* ============================================================
   Composants étape 5 — espace client (courrier)
   ============================================================ */

.container--wide { max-width: 1100px; }

/* ----- Liste de documents ----- */

.doc-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.5rem;
}

.doc-list__item { margin: 0; }

.doc-list__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.05s;
}
.doc-list__link:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.doc-list__link:active { transform: scale(0.998); }

.doc-list__main {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.doc-list__icon {
  font-size: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 8px;
  flex-shrink: 0;
  color: var(--accent);
}

.doc-list__title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.doc-list__meta {
  font-size: 0.85rem;
  margin-top: 0.1rem;
}
.doc-list__chevron {
  color: var(--text-subtle);
  font-size: 1.5rem;
  margin-left: 0.5rem;
}

.badge-nouveau {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ----- Détail document (page avec PDF viewer) ----- */

.doc-detail__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
}
.doc-detail__title { word-break: break-all; margin: 0 0 0.3rem; }
.doc-detail__meta { font-size: 0.9rem; }
.doc-detail__actions { flex-shrink: 0; }

.pdf-viewer-wrap {
  margin-top: 1.2rem;
}

.pdf-viewer {
  width: 100%;
  height: calc(100vh - 230px);
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.pdf-viewer__fallback {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  text-align: center;
}

/* ============================================================
   Composants étape 6 — file d'attribution admin
   ============================================================ */

.suggestion-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: #ede9fe;
  color: #5b21b6;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.suggestion-pill--none {
  background: #f1f5f9;
  color: var(--text-subtle);
}

.pill-warn {
  background: #fef3c7;
  color: #92400e;
}

/* Split-view : PDF à gauche, panneau d'attribution à droite */
.split-view {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.2rem;
  margin-top: 1.2rem;
  align-items: start;
}
@media (max-width: 900px) {
  .split-view { grid-template-columns: 1fr; }
}

.split-view__pdf .pdf-viewer-wrap { margin-top: 0; }

.pdf-viewer--small {
  height: calc(100vh - 260px);
  min-height: 420px;
}

.split-view__side > * + * { margin-top: 1rem; }

.suggestion-card { background: linear-gradient(180deg, #f5f3ff 0%, #ffffff 60%); }
.suggestion-card h2 { margin-top: 0; }
.suggestion-card__client { font-size: 1.05rem; }

.ocr-block summary {
  cursor: pointer;
  user-select: none;
  padding: 0.3rem 0;
}
.ocr-content {
  margin: 0.7rem 0 0;
  padding: 0.8rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: ui-monospace, "SF Mono", monospace;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   Composants étape 9 — journal d'audit + pagination
   ============================================================ */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
}
.filter-bar label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-subtle);
}
.filter-bar select {
  flex: 1;
  max-width: 320px;
  margin: 0;
}

/* ============================================================
   Composants étape 10 — polissage démo
   ============================================================ */

/* Footer minimal sur toutes les pages internes */
.footer {
  margin-top: 3rem;
  padding: 1.25rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-subtle);
}
.footer__brand { font-weight: 600; color: var(--text); }
.footer a { color: var(--text-subtle); }
.footer a:hover { color: var(--accent); }

/* Empty states améliorés : icône large + texte */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
}
.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 0.8rem;
  display: inline-grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
}
.empty-state h2 {
  margin: 0.5rem 0 0.3rem;
  font-size: 1.05rem;
}
.empty-state p { color: var(--text-subtle); margin-bottom: 1rem; }

/* Topbar : accent plus visible (logo coloré) */
.topbar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  margin-right: 0.5rem;
  vertical-align: middle;
}
.topbar__logo svg { width: 16px; height: 16px; }

.topbar__brand {
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
}

.topbar--super .topbar__role {
  background: var(--accent);
}

/* Boutons primary version verte */
.btn-primary {
  background: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }

/* Page d'auth : gradient mint vers blanc */
.page-auth {
  background: linear-gradient(180deg, var(--accent-mint) 0%, #f6f7f9 60%);
}

/* Carte d'auth avec un léger glow vert */
.card-auth {
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
}

/* Pill rôles : tons harmonisés avec la palette verte */
.role-client         { background: var(--accent-soft); color: var(--accent); }
.role-worker_senior  { background: #dbeafe; color: #1e40af; }
.role-worker_junior  { background: #e0e7ff; color: #3730a3; }
.role-admin_tenant   { background: #fef3c7; color: #92400e; }
.role-super_admin    { background: #fee2e2; color: #991b1b; }
.role-watcher        { background: #f1f5f9; color: #475569; }
.role-system         { background: #f1f5f9; color: #475569; }

/* Carte de quick-action au survol : léger effet de profondeur */
.quick-action {
  border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.quick-action:hover {
  box-shadow: var(--shadow-sm);
}

/* Card-auth header : pastille mailbox au-dessus du titre */
.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem 0.25rem 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}
.brand-pill__dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
}

/* ============================================================
   COMMAND CENTER — refonte dashboard admin/worker (Concept B)
   ============================================================ */

/* ----- Topbar app moderne (logo + nav + avatar) ----- */

.app-page { background: #f8faf9; min-height: 100vh; }

.app-topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Variante super-admin : fine bande supérieure rouge pour signaler le contexte
   "vue plateforme" sans dépayser visuellement */
.app-topbar--super {
  border-top: 3px solid #991b1b;
}
.app-topbar--super .avatar--super_admin {
  outline: 2px solid #991b1b;
  outline-offset: 1px;
}

.app-topbar__left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.app-topbar__logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.app-topbar__logo svg { width: 32px; height: 32px; }

.app-topbar__brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}
.app-topbar__brand:hover { text-decoration: none; }
.app-topbar__tenant {
  color: var(--text-subtle);
  font-weight: 500;
  font-size: 0.92rem;
}

.app-topbar__nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.app-topbar__nav a {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-subtle);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.app-topbar__nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}
.app-topbar__nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.app-topbar__right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.app-topbar__search { margin: 0; }
.app-topbar__search input {
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.85rem;
  width: 200px;
  margin: 0;
}
.app-topbar__search input:focus {
  background: #fff;
  width: 240px;
  border-color: var(--accent);
}
@media (max-width: 900px) {
  .app-topbar__search { display: none; }
}

/* Sélecteur de langue */
.lang-switcher {
  display: inline-flex;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.lang-switcher__btn {
  background: transparent;
  border: none;
  padding: 0.4rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  letter-spacing: 0.04em;
}
.lang-switcher__btn:hover { background: var(--accent-soft); }
.lang-switcher__btn.is-active {
  background: var(--accent);
  color: #fff;
}
.lang-switcher__btn + .lang-switcher__btn {
  border-left: 1px solid var(--border);
}

/* Variante : sélecteur de langue positionné sur les pages d'auth */
.lang-switcher--auth {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
}

.app-topbar__user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.avatar--admin_tenant  { background: #92400e; }
.avatar--worker_senior { background: #1e40af; }
.avatar--worker_junior { background: #3730a3; }
.avatar--client        { background: #166534; }
.avatar--super_admin   { background: #991b1b; }
.avatar--watcher       { background: #475569; font-size: 0.7rem; }
.avatar--system        { background: #475569; font-size: 0.7rem; }

.app-topbar__user-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  line-height: 1.1;
}
.app-topbar__user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.app-topbar__logout {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 1rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.app-topbar__logout:hover {
  border-color: var(--error-border);
  color: var(--error-text);
  background: var(--error-bg);
}

/* ----- Container app (padding et largeur) ----- */

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ----- Greeting block ----- */

.dashboard-greeting {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dashboard-greeting h1 {
  font-size: 1.75rem;
  margin: 0.15rem 0 0.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.date-line {
  font-size: 0.82rem;
  color: var(--text-subtle);
  text-transform: capitalize;
  margin: 0;
}

/* ----- Metric grid (4 cards) ----- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.metric-card__label {
  font-size: 0.78rem;
  color: var(--text-subtle);
  font-weight: 500;
  text-transform: none;
  margin: 0;
}
.metric-card__value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0.2rem 0 0.1rem;
}
.metric-unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-subtle);
  margin-left: 0.2rem;
}
.metric-card__delta {
  font-size: 0.78rem;
  margin: 0;
}
.metric-card__delta.is-up   { color: var(--ok-text); }
.metric-card__delta.is-down { color: var(--error-text); }

.metric-card__value--small {
  font-size: 1.4rem;
  line-height: 1.2;
}

/* Cards secondaires (KPI moins prioritaires) */
.metric-card--secondary {
  background: #f8faf9;
}
.metric-card--secondary .metric-card__value {
  font-size: 1.6rem;
}

/* Table compacte pour le dashboard super-admin */
.data-table--compact th,
.data-table--compact td {
  padding: 0.45rem 0.7rem;
  font-size: 0.86rem;
}

/* ----- Layout 2 colonnes activity + quotas ----- */

.dashboard-cols {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px) {
  .dashboard-cols { grid-template-columns: 1fr; }
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.card-header h2 { margin: 0; }
.card-header__link {
  font-size: 0.82rem;
  color: var(--text-subtle);
  text-decoration: none;
}
.card-header__link:hover { color: var(--accent); }

/* ----- Activity feed ----- */

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-item__avatar { width: 32px; height: 32px; font-size: 0.7rem; }

.activity-item__body { flex: 1; min-width: 0; font-size: 0.9rem; }
.activity-item__time {
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

/* ----- Quotas (barres de progression) ----- */

.quota { margin-bottom: 1.1rem; }
.quota:last-child { margin-bottom: 0; }

.quota__head {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}
.quota__label { font-weight: 500; }

.quota__bar {
  height: 8px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}
.quota__bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s;
}
.quota__bar-fill--warn   { background: #f59e0b; }
.quota__bar-fill--danger { background: var(--error-text); }

.quota__subtitle {
  margin: 1.5rem 0 0.8rem;
  font-size: 1.05rem;
}

.quick-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ----- Back link et page-header actions ----- */

.back-link {
  font-size: 0.85rem;
  color: var(--text-subtle);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 0.2rem;
}
.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* View-as banner : passe en relative (non-sticky) pour cohabiter avec
   le topbar sticky sans conflit visuel */
.view-as-banner {
  position: relative;
  top: auto;
}

/* Sur les pages app, on enlève le margin-top du container car le topbar
   est déjà parfait pour l'espacement */
.app-page .container {
  margin-top: 1.5rem;
}

/* Responsive : nav qui scroll horizontalement sur mobile */
@media (max-width: 760px) {
  .app-topbar { flex-wrap: wrap; }
  .app-topbar__left { width: 100%; }
  .app-topbar__nav { width: 100%; order: 3; }
  .app-topbar__right { margin-left: auto; }
  .app-topbar__user-info { display: none; }
  .dashboard-greeting { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Module 2 — Calendrier des réservations
   ============================================================ */

.room-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 0.25rem;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.82rem;
}
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }

.calendar-card { padding: 0; overflow: hidden; }

.calendar {
  display: flex;
  flex-direction: column;
  background: #fff;
}

.calendar__header {
  display: grid;
  grid-template-columns: 72px repeat(7, 1fr);
  background: #f8faf9;
  border-bottom: 1px solid var(--border);
}
.calendar__col-time {
  font-size: 0.72rem;
  color: var(--text-subtle);
  padding: 0.4rem 0.5rem;
  text-align: right;
}
.calendar__col-day {
  padding: 0.55rem 0.5rem;
  text-align: center;
  border-left: 1px solid var(--border);
}
.calendar__day-name { font-weight: 600; font-size: 0.82rem; }
.calendar__day-date { font-size: 0.72rem; margin-top: 0.1rem; }

.calendar__body { position: relative; }

.calendar__row {
  display: grid;
  grid-template-columns: 72px repeat(7, 1fr);
  height: 56px;
  border-bottom: 1px solid var(--border);
}
.calendar__row:last-child { border-bottom: none; }
.calendar__row .calendar__col-time {
  display: flex;
  align-items: flex-start;
  padding-top: 0.2rem;
}
.calendar__cell { border-left: 1px solid var(--border); }

.resa-block {
  position: absolute;
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  font-size: 0.72rem;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  z-index: 1;
}
.resa-block__top { font-weight: 700; }
.resa-block__obj { opacity: 0.95; }
.resa-block__user { font-size: 0.68rem; opacity: 0.92; }
.resa-block__time { font-size: 0.66rem; opacity: 0.85; margin-top: 0.1rem; }

.resa-block--mine  { outline: 2px solid var(--accent); }
.resa-block--other {
  background: repeating-linear-gradient(45deg, #cbd5e1, #cbd5e1 6px, #94a3b8 6px, #94a3b8 12px);
  color: #475569;
}
.resa-block__busy {
  font-weight: 600;
  font-size: 0.7rem;
  text-align: center;
  padding-top: 4px;
}

/* Layout côté client : calendrier à gauche + formulaire à droite */
.reservations-layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .reservations-layout { grid-template-columns: 1fr; }
}
.reservations-side > * + * { margin-top: 1rem; }

.my-resa-list { list-style: none; padding: 0; margin: 0; }
.my-resa-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.my-resa-item:last-child { border-bottom: none; }

/* ============================================================
   Module 3 — Comptabilité
   ============================================================ */

.row-warn { background: #fff7ed; }
.text-warn { color: #b45309; }

input[type="file"], input[type="color"], input[type="date"], input[type="datetime-local"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
}
input[type="color"] { padding: 0.25rem 0.4rem; max-width: 80px; height: 38px; }

.form-inline { margin-bottom: 1rem; }

/* View switcher (calendrier jour / semaine) */
.view-switcher {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  margin-right: 0.5rem;
}
.view-switcher a {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  color: var(--text-subtle);
  text-decoration: none;
  border-radius: 6px;
}
.view-switcher a.is-active {
  background: var(--accent);
  color: #fff;
}

/* Prix estimé sur le form de réservation */
.prix-estime {
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-top: 0.8rem;
  font-size: 0.9rem;
}
.prix-estime:empty { display: none; }

/* Bouton × pour retirer une assignation */
.btn-icon-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-subtle);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
.btn-icon-x:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

.assign-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin: 0;
}
.assign-row select { margin: 0; flex: 1; }
.assign-row button { flex-shrink: 0; }

/* Accordéons type "demande" */
.card-action {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
}
.card-action summary {
  cursor: pointer;
  user-select: none;
  outline: none;
  padding: 0.2rem 0;
}
.card-action[open] {
  background: #fff;
  border-color: var(--accent);
}

.form-traiter input[type="text"] { margin-top: 0.3rem; }

/* Groupes d'utilisateurs sur la page super-admin/tenants/:id/users */
.users-group {
  margin-top: 1.2rem;
}
.users-group__header {
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg);
  border-left: 3px solid var(--border);
  border-radius: 6px;
}
.users-group--prio .users-group__header {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.card--prio {
  border-left: 3px solid var(--accent);
}

/* ============================================================
   Vue mois — grille type Google Calendar
   ============================================================ */

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #fff;
  border-top: 1px solid var(--border);
}
.month-grid__weekday {
  text-align: center;
  padding: 0.55rem 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-subtle);
  background: #f8faf9;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.month-grid__weekday:first-child { border-left: none; }

.month-cell {
  min-height: 110px;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-decoration: none;
  color: var(--text);
  background: #fff;
  transition: background 0.1s;
}
.month-cell:hover { background: #f8faf9; text-decoration: none; }
.month-cell:nth-child(7n+2) { border-left: none; }
.month-cell.is-other-month { background: #fafbfc; color: var(--text-subtle); }
.month-cell.is-today .month-cell__num {
  background: var(--accent);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.78rem;
}

.month-cell__num {
  font-size: 0.85rem;
  font-weight: 600;
  align-self: flex-end;
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
}

.month-cell__resa {
  font-size: 0.7rem;
  padding: 0.18rem 0.4rem;
  border-radius: 4px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.month-cell__resa.is-busy {
  background: repeating-linear-gradient(45deg, #cbd5e1, #cbd5e1 4px, #94a3b8 4px, #94a3b8 8px);
  color: #475569;
  font-weight: 600;
}
.month-cell__plus {
  font-size: 0.7rem;
  text-align: center;
  font-weight: 500;
}

@media (max-width: 760px) {
  .month-cell { min-height: 70px; padding: 0.3rem; }
  .month-cell__num { width: 22px; height: 22px; font-size: 0.75rem; }
  .month-cell__resa { font-size: 0.65rem; padding: 0.1rem 0.3rem; }
}

/* ============================================================
   POLISH DEMO — V1 finalisé pour démo client
   Améliorations transverses : login hero, dashboards, mobile, branding.
   ============================================================ */

/* ----- Variables additionnelles (palette de profondeur) ----- */

:root {
  --shadow-xl: 0 24px 60px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 0 4px rgba(15, 81, 50, 0.12);
  --bg-soft: linear-gradient(180deg, #f6f7f9 0%, #ecf2ee 100%);
  --bg-mint-radial: radial-gradient(ellipse at top, #e7f3ec 0%, #f6f7f9 60%);

  /* Tailles de touch targets — accessibilité mobile (Apple HIG : 44pt) */
  --touch-min: 44px;
}

/* Smoothing typo */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ----- Page auth : layout split-screen (hero + form) ----- */

.page-auth--split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
  padding: 0;
  background: #f6f7f9;
  place-items: stretch;
}

.auth-hero {
  position: relative;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f5132 0%, #083d24 100%);
  overflow: hidden;
  padding: 3rem;
  color: #fff;
}

.auth-hero__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.95;
  z-index: 0;
}

.auth-hero__overlay {
  position: relative;
  z-index: 1;
  max-width: 440px;
  text-align: left;
  padding: 2rem;
  background: rgba(8, 61, 36, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
  border: 1px solid rgba(214, 235, 223, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.auth-hero__eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #d6ebdf;
  opacity: 0.85;
}

.auth-hero__title {
  margin: 0 0 1rem;
  font-size: 1.65rem;
  line-height: 1.25;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.auth-hero__subtitle {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #d6ebdf;
  opacity: 0.9;
}

.auth-hero__features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.65rem;
  font-size: 0.92rem;
  color: #ffffff;
}
.auth-hero__features li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

/* Card auth côté droit en split-screen */
.page-auth--split .card-auth {
  align-self: center;
  justify-self: center;
  border: none;
  box-shadow: none;
  max-width: 380px;
  background: transparent;
  padding: 2rem 2.5rem;
}

.card-auth--clean {
  animation: fadeUp 0.5s ease-out both;
}

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

/* Branding avec logo SVG */
.brand--with-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -0.005em;
}
.brand__logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
}

/* Page super-admin login — fond plus sombre/marqué */
.page-auth--super {
  background: var(--bg-mint-radial);
}

.card-auth--super {
  border-top: 4px solid var(--accent);
}

.badge-super {
  display: inline-block;
  margin: 0.5rem 0 0.75rem;
  padding: 0.2rem 0.7rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Sur mobile, on revient à un seul écran (hero masqué) */
@media (max-width: 880px) {
  .page-auth--split {
    grid-template-columns: 1fr;
  }
  .auth-hero { display: none; }
  .page-auth--split .card-auth {
    padding: 1.5rem 1.25rem;
    max-width: 100%;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .page-auth--split .card-auth > * { width: 100%; max-width: 380px; margin-left: auto; margin-right: auto; }
}

/* ----- Metric cards améliorées : icônes, animations, hover ----- */

.metric-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 81, 50, 0.025) 0%, rgba(15, 81, 50, 0) 100%);
  pointer-events: none;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-mint);
}

.metric-card .metric-card__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  font-weight: 600;
  margin: 0 0 0.65rem;
}

.metric-card .metric-card__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.3rem;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum" 1;
}
.metric-card__value--small { font-size: 1.1rem; font-weight: 600; }

.metric-card .metric-card__delta {
  font-size: 0.82rem;
  font-weight: 500;
  margin: 0;
}
.metric-card .metric-card__delta.is-up   { color: var(--accent); font-weight: 600; }
.metric-card .metric-card__delta.is-down { color: #b45309; font-weight: 600; }

.metric-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-subtle);
  margin-left: 0.2rem;
}

/* Variante secondaire : cards plus petites */
.metric-card--secondary {
  padding: 1rem;
}
.metric-card--secondary .metric-card__value {
  font-size: 1.5rem;
}

/* Apparition stagger des cards au load */
.metric-grid > .metric-card {
  animation: cardFadeIn 0.4s ease-out both;
}
.metric-grid > .metric-card:nth-child(1) { animation-delay: 0.03s; }
.metric-grid > .metric-card:nth-child(2) { animation-delay: 0.08s; }
.metric-grid > .metric-card:nth-child(3) { animation-delay: 0.13s; }
.metric-grid > .metric-card:nth-child(4) { animation-delay: 0.18s; }
.metric-grid > .metric-card:nth-child(5) { animation-delay: 0.23s; }
.metric-grid > .metric-card:nth-child(6) { animation-delay: 0.28s; }

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

/* ----- App topbar plus moderne ----- */

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.app-topbar__logo {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  border-radius: 9px;
  box-shadow: 0 2px 6px rgba(15, 81, 50, 0.2);
}
.app-topbar__logo svg {
  width: 28px;
  height: 28px;
}
.app-topbar__logo rect { fill: transparent !important; }

.app-topbar__brand {
  font-weight: 700;
  letter-spacing: -0.005em;
}

.app-topbar__tenant {
  font-weight: 400;
  color: var(--text-subtle);
}

/* Nav links plus marqués au survol */
.app-topbar__nav a {
  position: relative;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-weight: 500;
  color: var(--text-subtle);
  transition: color 0.12s, background 0.12s;
}
.app-topbar__nav a:hover {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}
.app-topbar__nav a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

/* Avatar avec léger ring */
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.avatar--admin_tenant   { background: linear-gradient(135deg, #f59e0b, #b45309); }
.avatar--worker_senior  { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.avatar--worker_junior  { background: linear-gradient(135deg, #6366f1, #4338ca); }
.avatar--client         { background: linear-gradient(135deg, #10b981, #065f46); }
.avatar--comptable      { background: linear-gradient(135deg, #8b5cf6, #5b21b6); }
.avatar--super_admin    { background: linear-gradient(135deg, #ef4444, #991b1b); }
.avatar--watcher        { background: linear-gradient(135deg, #64748b, #334155); }
.avatar--system         { background: linear-gradient(135deg, #94a3b8, #475569); }

.app-topbar__logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-subtle);
  width: var(--touch-min);
  height: var(--touch-min);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.app-topbar__logout:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

/* ----- Boutons : touch target accessible ----- */

.btn-primary, .btn-ghost {
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary.btn-inline, .btn-ghost.btn-inline { min-height: 40px; }
.btn-sm { min-height: 32px; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 2px 6px rgba(15, 81, 50, 0.25);
  letter-spacing: -0.005em;
  transition: transform 0.08s, box-shadow 0.15s;
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 4px 10px rgba(15, 81, 50, 0.3);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* Focus visible — accessibilité */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

/* ----- Card hover subtil (sauf data tables) ----- */

.quick-action {
  position: relative;
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.quick-action:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-mint);
}
.quick-action__icon {
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(15, 81, 50, 0.12);
}
.quick-action:hover .quick-action__icon {
  transform: scale(1.06) rotate(-3deg);
}

/* ----- Doc list cards plus modernes ----- */

.doc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

.doc-list__item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.08s;
}
.doc-list__item:hover {
  border-color: var(--accent-mint);
  box-shadow: var(--shadow-sm);
}
.doc-list__item:active { transform: scale(0.998); }

.doc-list__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.doc-list__link:hover { text-decoration: none; }

.doc-list__main {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex: 1;
  min-width: 0;
}

.doc-list__icon {
  font-size: 1.4rem;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 10px;
  flex-shrink: 0;
}

.doc-list__title {
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-width: 0;
  word-break: break-word;
}

.doc-list__meta {
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.doc-list__chevron {
  color: var(--text-subtle);
  font-size: 1.4rem;
  font-weight: 300;
  margin-left: 0.5rem;
}

/* ----- Badge nouveau plus pop ----- */

.badge-nouveau {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
  vertical-align: middle;
}

.suggestion-pill {
  display: inline-block;
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-weight: 500;
}
.suggestion-pill--none { background: #fef2f2; color: #991b1b; opacity: 0.7; }

/* ----- Activity feed plus aéré ----- */

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-item__avatar {
  width: 32px;
  height: 32px;
  font-size: 0.7rem;
}

.activity-item__body {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
}
.activity-item__time {
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

/* ----- Mobile : améliorations navigation ----- */

@media (max-width: 880px) {
  /* Topbar : on cache la nav, on garde le sélecteur de langue + user + logout */
  .app-topbar {
    padding: 0.6rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .app-topbar__nav {
    order: 5;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 0.25rem;
    margin: 0 -0.25rem;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
  }
  .app-topbar__nav::-webkit-scrollbar { display: none; }
  .app-topbar__nav a {
    flex-shrink: 0;
    scroll-snap-align: start;
    white-space: nowrap;
    font-size: 0.9rem;
  }
  .app-topbar__right { gap: 0.5rem; }
  .app-topbar__user { gap: 0.4rem; }
  .app-topbar__user-info { display: none; }

  /* Containers app */
  .app-container {
    padding: 1rem 0.75rem !important;
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-header__actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  /* Métriques : 2 cols sur mobile au lieu de 4 */
  .metric-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem !important;
  }
  .metric-card {
    padding: 0.85rem !important;
  }
  .metric-card .metric-card__value { font-size: 1.4rem; }
  .metric-card .metric-card__label { font-size: 0.7rem; }

  /* Dashboard cols : empilement vertical */
  .dashboard-cols {
    grid-template-columns: 1fr !important;
  }

  /* Quick actions plein largeur */
  .quick-actions {
    grid-template-columns: 1fr;
  }

  /* Reservations side : empilement */
  .reservations-layout {
    grid-template-columns: 1fr !important;
  }

  /* Split view file detail */
  .split-view {
    grid-template-columns: 1fr !important;
  }
  .pdf-viewer {
    min-height: 50vh;
  }

  /* Sélecteur langue plus petit */
  .lang-switcher__btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.72rem;
  }

  /* Pills plus lisibles */
  .pill, .role-pill {
    font-size: 0.66rem;
  }
}

@media (max-width: 480px) {
  /* Une seule colonne pour les KPI sur très petit écran */
  .metric-grid {
    grid-template-columns: 1fr !important;
  }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1rem; }
}

/* ----- Flash messages ----- */

.flash {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  border: 1px solid;
  animation: flashIn 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.flash--success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.flash--error   { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.flash--warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.flash--info    { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----- Empty state pop ----- */

.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--bg-mint-radial);
  border: 1px dashed var(--accent-mint);
  border-radius: var(--radius-lg);
}
.empty-state .empty-state__icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  filter: grayscale(0.2);
  opacity: 0.9;
}
.empty-state h2 {
  margin: 0 0 0.5rem;
  color: var(--text);
}
.empty-state p {
  color: var(--text-subtle);
  margin: 0 0 0.5rem;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

/* ----- Footer ----- */

.footer {
  max-width: 1200px;
  margin: 2.5rem auto 1.5rem;
  padding: 1rem 1.5rem;
  font-size: 0.82rem;
  color: var(--text-subtle);
  text-align: center;
}
.footer__brand {
  font-weight: 600;
  color: var(--text);
}

/* ----- Sélecteur de langue plus discret ----- */

.lang-switcher {
  display: inline-flex;
  gap: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  box-shadow: var(--shadow-sm);
}
.lang-switcher__btn {
  background: transparent;
  border: none;
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font);
  transition: all 0.12s;
}
.lang-switcher__btn:hover {
  color: var(--text);
  background: var(--surface);
}
.lang-switcher__btn.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.lang-switcher--auth {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
}

/* ----- View-as banner plus pro ----- */

.view-as-banner {
  background: linear-gradient(135deg, #4c1d95, #1e1b4b);
  color: #fef3c7;
  font-weight: 500;
}

/* ----- Card auth padding mieux sur mobile ----- */

@media (min-width: 881px) {
  .card-auth--clean {
    padding: 2.5rem !important;
  }
}

/* ----- Print-friendly ----- */

@media print {
  .app-topbar, .footer, .lang-switcher, .view-as-banner { display: none; }
  body { background: #fff; }
  .card, .metric-card { box-shadow: none; border: 1px solid #ccc; }
}

/* ----- Smooth scroll ----- */

html { scroll-behavior: smooth; }

/* ----- Réduction de mouvement ----- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----- Badge IA (factures enrichies automatiquement) ----- */

.ai-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 0.35rem;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
  cursor: help;
}

/* ----- Statuts IA (analyse en cours / échec) ----- */

.ia-pill-pending {
  background: linear-gradient(135deg, #ddd6fe, #c7d2fe);
  color: #4338ca;
  border: 1px solid #a5b4fc;
  animation: iaPulse 1.4s ease-in-out infinite;
}

.ia-pill-fail {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.ia-spinner {
  display: inline-block;
  animation: iaPulse 1.4s ease-in-out infinite;
  font-size: 1rem;
}

@keyframes iaPulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}


/* ----- Carte "Mon comptable" (côté client compta) ----- */

.comptable-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #e7f3ec 0%, #d6ebdf 100%);
  border: 1px solid #b8d4c2;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.comptable-card__icon {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.comptable-card__body { flex: 1; min-width: 180px; }
.comptable-card__label {
  margin: 0 0 0.15rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--accent-deep);
}
.comptable-card__name { margin: 0 0 0.1rem; color: var(--text); font-size: 1.05rem; }
.comptable-card__email { margin: 0; font-size: 0.85rem; }
.comptable-card__hint { font-size: 0.82rem; flex-basis: 100%; margin-top: 0.5rem; }
.comptable-card__hint p { margin: 0; }

.comptable-card--empty {
  background: #fffbeb;
  border-color: #fcd34d;
}
.comptable-card--empty .comptable-card__icon { background: #d97706; }
.comptable-card--empty .comptable-card__label { color: #92400e; }

/* ----- Cards clients pour le comptable ----- */

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.client-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.client-card:hover {
  text-decoration: none;
  border-color: var(--accent-mint);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.client-card__head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.client-card__avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #10b981, #065f46);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.client-card__id { flex: 1; min-width: 0; }
.client-card__societe {
  margin: 0 0 0.25rem;
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
  word-break: break-word;
}
.client-card__contact {
  margin: 0.1rem 0;
  font-size: 0.82rem;
  word-break: break-word;
}

.client-card__stats {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}
.client-card__stat {
  flex: 1;
  text-align: center;
  padding: 0.4rem;
  background: var(--bg);
  border-radius: 8px;
}
.client-card__stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  font-feature-settings: "tnum" 1;
}
.client-card__stat-value.is-warn { color: #b45309; }
.client-card__stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  margin-top: 0.2rem;
}

/* ----- Meta du client en haut de la fiche ----- */

.client-meta {
  font-size: 0.92rem;
  line-height: 1.7;
}
.client-meta a { color: var(--accent); }


/* ----- Avertissement de désaccord IA ----- */

.ia-disagree {
  margin-top: 0.35rem;
  padding: 0.4rem 0.55rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #92400e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.ia-disagree strong { color: #78350f; }
.ia-disagree .btn-ghost {
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  min-height: 24px;
  border-color: #fcd34d;
  color: #92400e;
}
.ia-disagree .btn-ghost:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}

/* ============================================================
   Module Compta avancé : tuiles catégories, impact fiscal, statuts
   ============================================================ */

/* ----- Page détail facture : split-screen PDF + panneau ----- */

.facture-detail {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 1.2rem;
  margin-top: 1rem;
}
.facture-detail__pdf {
  position: sticky;
  top: 80px;
  align-self: start;
  height: calc(100vh - 120px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.facture-detail__pdf iframe { width: 100%; height: 100%; border: 0; }
.facture-detail__panel { display: flex; flex-direction: column; gap: 1rem; }
.facture-detail__panel .card { margin: 0; }

@media (max-width: 980px) {
  .facture-detail { grid-template-columns: 1fr; }
  .facture-detail__pdf { position: static; height: 60vh; }
}

/* ----- Type facture en boutons (radio inline) ----- */

.type-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}
.type-toggle__opt {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.type-toggle__opt input { display: none; }
.type-toggle__opt span {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-subtle);
  transition: all 0.12s;
}
.type-toggle__opt:hover span { border-color: var(--accent-mint); }
.type-toggle__opt input:checked + span {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

/* ----- Tuiles catégories ----- */

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.cat-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 0.5rem;
  text-align: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s;
  min-height: 90px;
}
.cat-tile input { display: none; }
.cat-tile:hover {
  border-color: var(--accent-mint);
  background: #f8fbf9;
}
.cat-tile.is-selected,
.cat-tile:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.cat-tile__icon {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}
.cat-tile__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.2rem;
}
.cat-tile__deduct {
  font-size: 0.66rem;
  color: var(--text-subtle);
  letter-spacing: 0.02em;
}
.cat-tile:has(input:checked) .cat-tile__deduct { color: var(--accent); font-weight: 600; }

/* ----- Slider % usage pro ----- */

.range-pro {
  width: 100%;
  margin: 0.5rem 0;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--val, 100%), var(--border) var(--val, 100%), var(--border) 100%);
  border-radius: 999px;
  outline: none;
}
.range-pro::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.range-pro::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

/* ----- Panneau impact fiscal ----- */

.fiscal-impact {
  margin-top: 1.2rem;
  padding: 1rem;
  background: linear-gradient(135deg, #f0fdf4 0%, #e7f3ec 100%);
  border: 1px solid #86efac;
  border-radius: 10px;
}
.fiscal-impact hr {
  border: none;
  border-top: 1px solid #bbf7d0;
  margin: 0.6rem 0;
}
.fiscal-impact__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.92rem;
}
.fiscal-impact__row strong { color: var(--text); font-feature-settings: "tnum" 1; }
.fiscal-impact__row--accent {
  margin: 0.4rem -0.5rem;
  padding: 0.5rem;
  background: rgba(15, 81, 50, 0.08);
  border-radius: 6px;
}
.fiscal-impact__row--accent strong {
  color: var(--accent);
  font-size: 1.15rem;
}

/* ----- Statut paiement (badge gros sur fiche) ----- */

.payment-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
}
.payment-status .pill { font-size: 0.85rem; padding: 0.35rem 0.8rem; }

/* ----- Filtre / recherche sur liste factures ----- */

.filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.filter-search {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: 0.45rem 0.7rem !important;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.filter-select {
  width: auto !important;
  padding: 0.45rem 0.7rem !important;
  font-size: 0.85rem;
}

/* ----- Catégorie inline dans le tableau ----- */

.cat-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

/* Hover sur les lignes cliquables */
.facture-row { transition: background 0.1s; }
.facture-row:hover { background: var(--accent-soft); }
.facture-row:hover td { color: var(--text); }

/* ----- Bar list (dashboard analytics) ----- */

.bar-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.bar-list__item { display: flex; flex-direction: column; gap: 0.25rem; }
.bar-list__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.92rem;
}
.bar-list__head strong { font-feature-settings: "tnum" 1; color: var(--text); }
.bar-list__bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.bar-list__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
}
.bar-list__meta { font-size: 0.72rem; }

/* ----- Page Mon compte ----- */

.profil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-top: 0.5rem;
}
.profil-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin: 0 0 0.25rem;
  font-weight: 600;
}
.profil-value {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
  word-break: break-word;
}

.profil-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}
.profil-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.profil-list li:last-child { border-bottom: none; }
.profil-list a { color: var(--text); }
.profil-list a:hover { color: var(--accent); }

/* Avatar cliquable dans la topbar */
a.app-topbar__user {
  text-decoration: none;
  color: inherit;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  transition: background 0.12s;
}
a.app-topbar__user:hover {
  background: var(--bg);
  text-decoration: none;
}

/* ----- Pill "vient du courrier scanné" ----- */
.origin-pill {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: #fff;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  margin-top: 0.3rem;
  cursor: help;
  text-decoration: none;
}
a.origin-pill:hover { text-decoration: none; opacity: 0.9; }

/* ----- Timeline d'activité client ----- */

.timeline {
  margin-top: 1rem;
  padding-left: 0.5rem;
}

.timeline-group {
  margin-bottom: 1.5rem;
}
.timeline-group__title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  font-weight: 700;
  margin: 0 0 0.6rem;
  padding-left: 0.3rem;
}

.timeline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  border-left: 2px solid var(--border);
  padding-left: 1.2rem;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.4rem 0;
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.5rem;
  top: 0.7rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface);
}
.timeline-item__icon {
  font-size: 1.1rem;
  width: 1.6rem;
  text-align: center;
  flex-shrink: 0;
}
.timeline-item__body { flex: 1; min-width: 0; }
.timeline-item__line {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.timeline-item__time {
  font-size: 0.75rem;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  flex-shrink: 0;
}
.timeline-item__titre {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 500;
}
a.timeline-item__titre { color: var(--accent); }
a.timeline-item__titre:hover { text-decoration: underline; }
.timeline-item__meta {
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

/* ----- Sélecteur de société (company switcher) ----- */
.company-switcher {
  position: relative;
  display: inline-flex;
}
.company-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  max-width: 220px;
}
.company-switcher__btn:hover { background: var(--bg); border-color: var(--accent); }
.company-switcher__current {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.company-switcher__chevron {
  font-size: 0.7rem;
  color: var(--text-subtle);
  transition: transform 0.15s;
}
.company-switcher.is-open .company-switcher__chevron { transform: rotate(180deg); }

.company-switcher__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
  padding: 0.4rem;
  z-index: 1000;
  display: none;
}
.company-switcher.is-open .company-switcher__menu { display: block; }
.company-switcher__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  padding: 0.4rem 0.6rem 0.3rem;
}
.company-switcher__form { margin: 0; }
.company-switcher__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.company-switcher__item:hover:not(:disabled) { background: var(--bg); }
.company-switcher__item.is-current { cursor: default; opacity: 0.85; }
.company-switcher__item-nom { flex: 1; font-weight: 600; }
.company-switcher__item-role {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-subtle);
  background: var(--bg);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}
.company-switcher__check { color: var(--accent); font-weight: 700; }

@media (max-width: 640px) {
  .company-switcher__btn { max-width: 140px; font-size: 0.82rem; }
  .company-switcher__menu { min-width: 220px; }
}

/* ----- Modules par client (fieldset cases à cocher + pastilles) ----- */
.modules-fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
}
.modules-fieldset legend {
  font-weight: 700;
  padding: 0 0.5rem;
  font-size: 0.92rem;
}
.module-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.module-check:hover { background: var(--bg); }
.module-check.is-locked { cursor: default; opacity: 0.9; }
.module-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.module-check__txt { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.module-check__tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-style: normal;
}
.module-check__tag--opt {
  color: var(--text-subtle);
  background: var(--bg);
}
.module-chips { display: inline-flex; gap: 0.2rem; margin-left: 0.4rem; }
.module-chip { font-size: 0.85rem; opacity: 0.9; }

/* Chips toggle directement dans la liste des comptes */
.module-toggles { display: flex; gap: 0.3rem; margin-top: 0.35rem; }
.module-toggles .inline-form { margin: 0; }
.mtoggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s, filter 0.12s;
}
.mtoggle.is-on {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: var(--accent);
}
.mtoggle.is-off { opacity: 0.4; filter: grayscale(1); }
button.mtoggle:hover { filter: none; opacity: 1; border-color: var(--accent); }
.mtoggle.is-locked { cursor: default; }

/* Boutons d'action compacts (icône seule) */
.row-actions { display: flex; align-items: center; gap: 0.3rem; justify-content: flex-end; }
.row-actions .inline-form { margin: 0; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.icon-btn:hover { background: var(--bg); border-color: var(--accent); text-decoration: none; }
.icon-btn--danger:hover { border-color: #ef4444; background: color-mix(in srgb, #ef4444 10%, transparent); }

/* ----- Cloche de notifications dans topbar ----- */
.topbar-bell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: 50%;
  font-size: 1.2rem;
  text-decoration: none;
  color: var(--text-subtle);
  transition: background 0.12s;
}
.topbar-bell:hover { background: var(--bg); text-decoration: none; }
.topbar-bell__count {
  position: absolute;
  top: 4px; right: 4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
  border: 2px solid var(--surface);
}

/* ----- Bouton toggle thème (topbar) ----- */
.topbar-theme-btn {
  display: grid;
  place-items: center;
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-subtle);
  transition: background 0.12s, transform 0.15s;
}
.topbar-theme-btn:hover { background: var(--bg); transform: scale(1.1); }
.topbar-theme-btn:active { transform: scale(0.95); }

/* ----- Notes / commentaires ----- */
.notes-card { margin-top: 1rem; }
.notes-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.note-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-item__avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #8b5cf6, #5b21b6);
  color: #fff;
  display: grid; place-items: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}
.note-item__body { flex: 1; min-width: 0; }
.note-item__head { font-size: 0.88rem; margin-bottom: 0.2rem; }
.note-item__contenu {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.mention {
  background: #ddd6fe;
  color: #4338ca;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
}

.note-form {
  background: var(--bg);
  padding: 0.85rem;
  border-radius: 10px;
  margin-top: 0.5rem;
}
.note-form textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: var(--font);
  resize: vertical;
  min-height: 60px;
  background: var(--surface);
  color: var(--text);
}
.note-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-glow); }

/* ----- Liste notifications ----- */
.notif-list { list-style: none; padding: 0; margin: 0; }
.notif-item {
  display: flex;
  gap: 0.8rem;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
.notif-item__icon {
  font-size: 1.4rem;
  width: 40px; height: 40px;
  background: var(--accent-soft);
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.notif-item__body { flex: 1; min-width: 0; }

/* ----- Command Palette ⌘K ----- */

.cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-subtle);
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.12s;
  min-width: 180px;
}
.cmdk-trigger:hover {
  background: var(--surface);
  border-color: var(--accent-mint);
}
.cmdk-trigger__text { flex: 1; text-align: left; }
.cmdk-trigger__kbd {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--text-subtle);
}

@media (max-width: 880px) {
  .cmdk-trigger__text, .cmdk-trigger__kbd { display: none; }
  .cmdk-trigger { min-width: auto; padding: 0.4rem 0.6rem; }
}

.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  animation: cmdkFadeIn 0.15s ease-out;
}
@keyframes cmdkFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.cmdk-modal {
  width: 92%;
  max-width: 600px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.3);
  overflow: hidden;
  animation: cmdkSlide 0.18s ease-out;
}
@keyframes cmdkSlide {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.cmdk-input-wrap .cmdk-icon { font-size: 1.1rem; opacity: 0.7; }
.cmdk-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.05rem;
  padding: 0.3rem 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  box-shadow: none;
}
.cmdk-input-wrap input:focus { box-shadow: none; }
.cmdk-kbd {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: var(--text-subtle);
}

.cmdk-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.5rem;
}
.cmdk-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.9rem;
  margin: 0;
}
.cmdk-empty kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.78rem;
  margin: 0 0.1rem;
}

.cmdk-section {
  padding: 0.4rem 0;
}
.cmdk-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: 0.4rem 0.75rem 0.25rem;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.08s;
}
.cmdk-item:hover, .cmdk-item.is-active {
  background: var(--accent-soft);
  text-decoration: none;
}
.cmdk-item-icon {
  font-size: 1rem;
  width: 1.6rem;
  text-align: center;
  flex-shrink: 0;
}
.cmdk-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.cmdk-item-label {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmdk-item-sub {
  font-size: 0.75rem;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Barre flottante bulk actions ----- */
.bulk-bar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--text);
  color: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-xl);
  z-index: 100;
  animation: bulkBarUp 0.2s ease-out;
  font-size: 0.88rem;
}
@keyframes bulkBarUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.bulk-bar__count { font-weight: 600; }
.bulk-bar strong { color: #fde68a; }
.bulk-bar .btn-ghost {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}
.bulk-bar .btn-ghost:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

/* Checkboxes lignes */
.row-check, #check-all {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ----- Vue Kanban des courriers ----- */

.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

@media (max-width: 880px) {
  .kanban { grid-template-columns: 1fr; }
}

.kanban-col {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.kanban-col__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.kanban-col__head h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}
.kanban-col__count {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.kanban-col__body {
  padding: 0.6rem;
  min-height: 200px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: box-shadow 0.12s, transform 0.05s;
}
.kanban-card:active { cursor: grabbing; transform: scale(1.02); }
.kanban-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent-mint); }
.kanban-card--ghost { opacity: 0.4; background: var(--accent-soft); border-style: dashed; }
.kanban-card__link {
  display: block;
  padding: 0.7rem 0.85rem;
  text-decoration: none;
  color: var(--text);
}
.kanban-card__link:hover { text-decoration: none; }
.kanban-card__title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 0.3rem;
}
.kanban-card__meta {
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-bottom: 0.4rem;
}
.kanban-card__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.72rem;
  flex-wrap: wrap;
}
.kanban-card__tag {
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-weight: 600;
}
.kanban-empty {
  text-align: center;
  padding: 1.5rem 0.5rem;
  font-size: 0.85rem;
  font-style: italic;
}

/* ----- Widget Comptable IA (chat flottant) ----- */

.ai-chat-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: var(--font);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
  transition: transform 0.12s, box-shadow 0.15s;
}
.ai-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.45);
}
.ai-chat-btn__icon { font-size: 1.2rem; }

.ai-chat-panel {
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 540px;
  max-height: calc(100vh - 8rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
  z-index: 95;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aiChatIn 0.18s ease-out;
}
@keyframes aiChatIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-chat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #ddd6fe, #c7d2fe);
  border-bottom: 1px solid var(--border);
}
.ai-chat-panel__head strong { color: #4338ca; font-size: 0.95rem; }

.ai-chat-panel__close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--text-subtle);
}
.ai-chat-panel__close:hover { background: rgba(255,255,255,0.5); color: var(--text); }

.ai-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: linear-gradient(180deg, #fafafe 0%, #f5f5fc 100%);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.ai-chat-msg {
  display: flex;
  max-width: 85%;
}
.ai-chat-msg--user { justify-content: flex-end; align-self: flex-end; }
.ai-chat-msg--ai   { justify-content: flex-start; align-self: flex-start; }

.ai-chat-bubble {
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-chat-msg--user .ai-chat-bubble {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-chat-msg--ai .ai-chat-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-chat-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.7rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.ai-chat-form input {
  flex: 1;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.92rem;
}
.ai-chat-form input:focus { outline: none; border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139,92,246,0.15); }
.ai-chat-form .btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

@media (max-width: 480px) {
  .ai-chat-panel {
    width: calc(100vw - 1rem);
    right: 0.5rem;
    bottom: 5.5rem;
    height: 70vh;
  }
  .ai-chat-btn__label { display: none; }
  .ai-chat-btn { padding: 0.85rem; }
}

/* ----- Fix : forcer display:none quand attribut hidden présent ----- */
[hidden].cmdk-overlay,
[hidden].ai-chat-panel,
[hidden].bulk-bar {
  display: none !important;
}

/* ----- Onboarding modal ----- */
/* Ancienne règle .onb-overlay (V1, modal centré) — désactivée au profit
   de la V2 spotlight plus bas dans ce fichier. */
.onb-overlay--legacy-deprecated {
  display: none;
}
.onb-modal {
  background: var(--surface);
  width: 100%; max-width: 480px;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
  padding: 2rem 2rem 1.2rem;
  position: relative;
  animation: cmdkSlide 0.25s ease-out;
}
.onb-skip {
  position: absolute; top: 1rem; right: 1rem;
  background: transparent; border: none;
  color: var(--text-subtle); cursor: pointer;
  font-size: 0.85rem;
}
.onb-skip:hover { color: var(--text); }
.onb-content { min-height: 200px; }
.onb-slide { text-align: center; padding: 1rem 0; }
.onb-icon {
  font-size: 3rem;
  margin-bottom: 0.8rem;
  animation: onbBounce 0.5s ease-out;
}
@keyframes onbBounce {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
.onb-titre { font-size: 1.4rem; margin: 0 0 0.6rem; color: var(--text); font-weight: 700; }
.onb-texte { font-size: 0.95rem; color: var(--text-subtle); line-height: 1.55; margin: 0; }
.onb-foot {
  margin-top: 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
}
.onb-dots { display: flex; gap: 0.35rem; }
.onb-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  transition: all 0.15s;
}
.onb-dot.is-active { background: var(--accent); width: 24px; border-radius: 999px; }

/* ----- Card "Import auto par email" ----- */
.alias-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: #93c5fd;
  margin-bottom: 1rem;
}
.alias-card__icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.alias-card__body { flex: 1; min-width: 0; }
.alias-card__label {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: #1e40af;
}
.alias-card__key { margin-top: 0.5rem; }
.alias-card__key code {
  font-size: 0.82rem !important;
  word-break: break-all;
}

/* ============================================================
   MOBILE POLISH (≤ 480px et ≤ 880px)
   Fixes ciblés pour les vues qui débordaient ou étaient peu utilisables
   ============================================================ */

@media (max-width: 880px) {
  /* Tableaux : scroll horizontal au lieu de casser la page */
  .card--table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table {
    min-width: 600px;
    font-size: 0.82rem;
  }
  .data-table th, .data-table td {
    padding: 0.45rem 0.6rem;
    white-space: nowrap;
  }

  /* Filter bar : empilable */
  .filter-bar {
    width: 100%;
  }
  .filter-search { max-width: 100%; flex-basis: 100%; }
  .filter-select { flex-basis: calc(50% - 0.25rem); }

  /* Page header : actions sous le titre */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .page-header__actions .btn-primary,
  .page-header__actions .btn-ghost { flex: 1; min-width: 130px; }

  /* Formulaires grid-2 → 1 col */
  .grid-2 { grid-template-columns: 1fr; }

  /* Bulk bar : adaptée au mobile */
  .bulk-bar {
    bottom: 4.5rem; /* au-dessus du chat AI button */
    width: calc(100vw - 1rem);
    max-width: 600px;
    padding: 0.4rem 0.7rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  .bulk-bar .btn-ghost { font-size: 0.78rem; padding: 0.3rem 0.6rem; }

  /* AI Chat panel : prend tout l'écran mobile */
  .ai-chat-panel {
    width: calc(100vw - 1rem) !important;
    right: 0.5rem !important;
    bottom: 5rem !important;
    height: 70vh !important;
  }

  /* Cards plus aérées sur mobile */
  .card { padding: 1rem; border-radius: 12px; }

  /* Kanban : scroll horizontal entre les colonnes */
  .kanban {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
  }
  .kanban-col { min-height: 300px; }

  /* Calendar : scroll horizontal */
  .calendar { overflow-x: auto; }
  .calendar-card { padding: 0.5rem; }

  /* Compte topbar : éléments scrollables */
  .app-topbar__nav {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .app-topbar__nav::-webkit-scrollbar { display: none; }

  /* Container app */
  .app-container { padding: 1rem 0.75rem; }

  /* Notes : full width */
  .note-item__avatar { width: 32px; height: 32px; }

  /* Devis form : lignes empilées */
  .ligne-devis {
    grid-template-columns: 1fr !important;
    gap: 0.4rem !important;
  }

  /* AI chat button : sans label */
  .ai-chat-btn { padding: 0.85rem; }
  .ai-chat-btn__label { display: none; }

  /* Onboarding modal : presque plein écran */
  .onb-modal {
    max-width: calc(100vw - 1rem);
    padding: 1.5rem 1.2rem 1rem;
  }
  .onb-titre { font-size: 1.15rem; }
  .onb-texte { font-size: 0.88rem; }

  /* Command Palette : plein écran */
  .cmdk-modal {
    width: calc(100vw - 1rem);
    max-width: none;
    margin: 0 0.5rem;
  }
}

@media (max-width: 480px) {
  /* Métriques : 1 col */
  .metric-grid { grid-template-columns: 1fr !important; }

  /* Titles plus petits */
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.05rem; }

  /* Footer compact */
  .footer { font-size: 0.75rem; padding: 0.75rem; }

  /* Kanban : 1 colonne visible à la fois (swipe) */
  .kanban { grid-template-columns: repeat(3, 85vw); }

  /* Topbar : padding plus serré */
  .app-topbar { padding: 0.5rem 0.75rem; }
  .app-topbar__brand { font-size: 0.92rem; }
  .app-topbar__tenant { display: none; }

  /* Detail facture : split → 1 col */
  .facture-detail { grid-template-columns: 1fr !important; }
  .facture-detail__pdf {
    position: static !important;
    height: 50vh !important;
  }

  /* Categories grid plus serré */
  .categories-grid { grid-template-columns: repeat(2, 1fr); }

  /* Login hero caché sur mobile, formulaire centré */
  .page-auth--split { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* Touch target minimum 44px (Apple HIG / a11y) */
@media (pointer: coarse) {
  button, .btn-primary, .btn-ghost, .btn-inline,
  a.btn-primary, a.btn-ghost,
  .row-check, input[type="checkbox"], input[type="radio"] {
    min-height: 36px;
  }
  .btn-sm { min-height: 32px; }
}

/* ----- Logo branding custom dans la topbar ----- */
.app-topbar__logo--custom {
  background: transparent !important;
  box-shadow: none !important;
  width: auto;
  height: 36px;
  padding: 4px;
  display: flex;
  align-items: center;
}
.app-topbar__logo--custom img {
  max-height: 36px;
  max-width: 160px;
  object-fit: contain;
}

/* ----- Liste des tâches ----- */
.taches-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.tache-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow 0.12s, border-color 0.12s;
}
.tache-item:hover { border-color: var(--accent-mint); box-shadow: var(--shadow-sm); }
.tache-item--done { opacity: 0.55; }
.tache-item--done .tache-titre { text-decoration: line-through; }
.tache-item--late { border-left: 4px solid #ef4444; }

.tache-check-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: transform 0.12s;
}
.tache-check-btn:hover { transform: scale(1.15); }

.tache-body { flex: 1; min-width: 0; }
.tache-titre { font-weight: 600; color: var(--text); margin-bottom: 0.2rem; }
.tache-desc { font-size: 0.85rem; margin-bottom: 0.3rem; }
.tache-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.78rem;
  margin-top: 0.3rem;
}
.tache-late { color: #991b1b; font-weight: 600; }
.tache-actions { flex-shrink: 0; }

/* ============================================================
   DARK MODE
   Activé via [data-theme="dark"] sur <html>
   ============================================================ */
html[data-theme="dark"] {
  --bg: #0b1019;
  --surface: #131a26;
  --text: #e5e7eb;
  --text-subtle: #9ca3af;
  --border: #1f2937;
  --accent-soft: #1a2920;
  --accent-mint: #134e2e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

html[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] code {
  background: #1f2937 !important;
  color: #e5e7eb !important;
}
html[data-theme="dark"] .data-table th {
  background: #1a2230;
  color: var(--text-subtle);
}
html[data-theme="dark"] .data-table tr:hover td { background: #1c2433; }
html[data-theme="dark"] .pdf-viewer {
  filter: invert(0.92) hue-rotate(180deg);
}
html[data-theme="dark"] .app-topbar {
  background: rgba(19, 26, 38, 0.92);
}
html[data-theme="dark"] .empty-state {
  background: radial-gradient(ellipse at top, #134e2e22 0%, var(--bg) 60%);
  border-color: #134e2e;
}
html[data-theme="dark"] .comptable-card {
  background: linear-gradient(135deg, #134e2e 0%, #0f3e25 100%);
  border-color: #166534;
}
html[data-theme="dark"] .fiscal-impact {
  background: linear-gradient(135deg, #0c2a18 0%, #133520 100%);
  border-color: #166534;
}
html[data-theme="dark"] .alias-card {
  background: linear-gradient(135deg, #1e3a5f, #1e4b7c);
  border-color: #3b82f6;
}
html[data-theme="dark"] .alias-card__label { color: #93c5fd; }
html[data-theme="dark"] .ia-pill-pending {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  color: #c7d2fe;
  border-color: #4338ca;
}
html[data-theme="dark"] .ai-chat-panel__head {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
}
html[data-theme="dark"] .ai-chat-msgs {
  background: linear-gradient(180deg, #0d1117 0%, #131a26 100%);
}
html[data-theme="dark"] .ai-chat-msg--ai .ai-chat-bubble {
  background: #1f2937;
  border-color: #374151;
  color: var(--text);
}

/* Toggle button thème */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font);
}
.theme-toggle:hover { background: var(--surface); }

/* ----- Dropzone fullscreen ----- */
.dropzone-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 81, 50, 0.85);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: cmdkFadeIn 0.15s;
  pointer-events: none;
}
.dropzone-overlay[hidden] { display: none !important; }
.dropzone-modal {
  text-align: center;
  color: #fff;
  border: 3px dashed #d6ebdf;
  border-radius: 24px;
  padding: 4rem 6rem;
  background: rgba(0,0,0,0.2);
  pointer-events: none;
}
.dropzone-icon { font-size: 5rem; margin-bottom: 1rem; animation: bounce 0.8s infinite alternate; }
@keyframes bounce {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}
.dropzone-modal h2 { margin: 0 0 0.5rem; font-size: 1.8rem; color: #fff; }
.dropzone-modal p { color: #d6ebdf; }

/* ----- Onboarding modal — boutons plus visibles ----- */

.onb-modal {
  max-width: 520px;
  padding: 2.5rem 2rem 1.5rem;
}

.onb-skip {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-weight: 500;
  transition: all 0.12s;
}
.onb-skip:hover {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

.onb-progress {
  position: absolute;
  top: 1rem;
  left: 1.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-subtle);
}
.onb-progress__current {
  color: var(--accent);
  font-size: 1.05rem;
}

.onb-foot {
  margin-top: 2rem !important;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}
.onb-foot .onb-dots { justify-content: center; }

#onb-prev {
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  min-height: 38px;
}
#onb-prev:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.onb-next-big {
  padding: 0.65rem 1.4rem !important;
  font-size: 0.95rem !important;
  font-weight: 600;
  min-height: 42px !important;
  box-shadow: 0 4px 14px rgba(15, 81, 50, 0.25);
}
.onb-next-big:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(15, 81, 50, 0.35);
}

.onb-dot {
  cursor: pointer;
}
.onb-dot:hover {
  background: var(--accent-mint);
}

@media (max-width: 480px) {
  .onb-foot {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .onb-foot .onb-dots {
    order: -1;
    margin-bottom: 0.5rem;
  }
  .onb-next-big { width: 100%; }
}

/* ============================================================
   ONBOARDING SPOTLIGHT (V2) — tour guidé interactif
   ============================================================ */

/* L'overlay : PAS DE VOILE — l'app est 100% visible.
   Le halo lumineux sur la cible + le popover suffisent à guider. */
.onb-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 250 !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  display: block !important;
  pointer-events: none !important;
}

/* Sauf pour les slides centrées (intro/conclusion sans cible), petit voile
   pour faire ressortir le popover central */
.onb-overlay.onb-overlay--bg {
  background: rgba(15, 23, 42, 0.3) !important;
  backdrop-filter: blur(2px) !important;
  -webkit-backdrop-filter: blur(2px) !important;
}

/* Le popover : flottant, pas centré par défaut */
.onb-popover {
  position: fixed;
  width: 360px;
  max-width: calc(100vw - 2rem);
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--accent);
  padding: 1.5rem 1.25rem 1rem;
  z-index: 260;
  pointer-events: auto;
  animation: onbPopIn 0.25s ease-out;
}
@keyframes onbPopIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* Mode centré (pour les slides sans cible) */
.onb-popover--center {
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
  width: 480px;
  padding: 2rem;
}

/* Highlight de l'élément cible : halo lumineux.
   ATTENTION : on ne FORCE PAS position:relative ici, sinon ça casse le
   position:fixed des éléments comme #ai-chat-btn ou .topbar (qui se
   retrouveraient mal positionnés). Le halo est purement visuel via box-shadow. */
.onb-highlight {
  z-index: 255 !important;
  box-shadow: 0 0 0 4px rgba(15, 81, 50, 0.4),
              0 0 0 8px rgba(15, 81, 50, 0.2),
              0 0 32px rgba(15, 81, 50, 0.6) !important;
  border-radius: 10px;
  animation: onbPulse 1.8s ease-in-out infinite;
}
@keyframes onbPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(15, 81, 50, 0.4),
                         0 0 0 8px rgba(15, 81, 50, 0.2),
                         0 0 32px rgba(15, 81, 50, 0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(15, 81, 50, 0.5),
                         0 0 0 14px rgba(15, 81, 50, 0.25),
                         0 0 48px rgba(15, 81, 50, 0.7); }
}

/* Petite icône au lieu de l'énorme */
.onb-icon-small {
  font-size: 2rem;
  margin-bottom: 0.6rem;
  animation: onbBounce 0.5s ease-out;
}

.onb-popover .onb-titre {
  font-size: 1.15rem;
  margin: 0 0 0.4rem;
}
.onb-popover .onb-texte {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Sur mobile : popover plein largeur en bas */
@media (max-width: 640px) {
  .onb-popover {
    left: 0.5rem !important;
    right: 0.5rem !important;
    bottom: 1rem !important;
    top: auto !important;
    width: auto;
    max-width: none;
    transform: none;
  }
  .onb-popover--center {
    top: auto !important;
    bottom: 1rem !important;
    transform: none;
  }
}

/* ============================================================
   DASHBOARD CLIENT V2 — cards modules + widgets contextuels
   ============================================================ */

.dashboard-hero {
  margin-bottom: 2rem;
}
.dashboard-hero h1 {
  font-size: 1.8rem;
  margin: 0 0 0.4rem;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.module-card {
  display: block;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.18s, border-color 0.18s;
  cursor: pointer;
  min-height: 200px;
}
.module-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-mint);
}

.module-card--locked {
  cursor: not-allowed;
  background: var(--bg);
  opacity: 0.75;
}
.module-card--locked:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
}

.module-card__head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
}
.module-card__icon {
  font-size: 2rem;
  line-height: 1;
}
.module-card__head h2 {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.module-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.module-badge--actif {
  background: #dcfce7;
  color: #166534;
}
.module-badge--locked {
  background: #f1f5f9;
  color: #64748b;
}

.module-card__desc {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  color: var(--text-subtle);
  line-height: 1.5;
}

.module-card__locked-msg {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0;
}
.module-card__locked-msg a { color: #92400e; font-weight: 600; }

/* Widget interne aux cards */
.module-card__widget {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}
.widget-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-subtle);
  margin: 0 0 0.5rem;
}
.widget-stats {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
  flex-wrap: wrap;
}
.widget-stat {
  flex: 1;
  min-width: 100px;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: 8px;
}
.widget-stat__num {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  font-feature-settings: "tnum" 1;
}
.widget-stat__label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.1rem;
}
.widget-stat--alert {
  background: #fef2f2;
  border: 1px solid #fca5a5;
}
.widget-stat--alert .widget-stat__num { color: #991b1b; }
.widget-stat--warn {
  background: #fef3c7;
  border: 1px solid #fcd34d;
}
.widget-stat--warn .widget-stat__num { color: #92400e; }

.widget-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.widget-list li {
  font-size: 0.85rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.widget-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dashboard-info {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--accent-mint) 100%);
  border-color: var(--accent-mint);
}

/* Hover sur les cards actives : effet "presser légèrement" */
.module-card:not(.module-card--locked):active {
  transform: scale(0.99);
}

@media (max-width: 640px) {
  .dashboard-hero h1 { font-size: 1.4rem; }
  .modules-grid { grid-template-columns: 1fr; gap: 0.8rem; }
  .module-card { padding: 1.2rem; min-height: auto; }
}

/* === Mon courrier : sidebar dossiers + drag-drop ============================ */
.courrier-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

.courrier-sidebar {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 1rem 0.5rem;
  height: fit-content;
  position: sticky;
  top: 80px;
}

.sidebar-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #6b7280);
  padding: 0 0.7rem;
  margin: 0 0 0.5rem 0;
}

.sidebar-folders {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-folders li {
  display: flex;
  align-items: center;
  position: relative;
  margin-bottom: 0.15rem;
}

.sidebar-divider {
  height: 1px !important;
  background: var(--border, #e5e7eb);
  margin: 0.5rem 0.7rem !important;
}

.folder-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text, #1f2937);
  font-size: 0.92rem;
  transition: background 0.12s, transform 0.06s;
}

.folder-link:hover {
  background: var(--hover, #f3f4f6);
}

.folder-link.is-active {
  background: var(--folder-color, #0f5132);
  color: #fff;
}

.folder-link.is-active .folder-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.folder-link.is-drag-over {
  background: #d1fae5;
  outline: 2px dashed #0f5132;
  transform: scale(1.02);
}

.folder-icon {
  font-size: 1.05rem;
  width: 1.4rem;
  text-align: center;
}

.folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  background: var(--badge-bg, #e5e7eb);
  color: var(--text-muted, #6b7280);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 9px;
  min-width: 1.4rem;
  text-align: center;
}

.folder-count--alert {
  background: #fef3c7;
  color: #92400e;
}

.folder-ia-tag {
  font-size: 0.75rem;
  opacity: 0.7;
}

.folder-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted, #9ca3af);
  padding: 0.2rem 0.4rem;
  opacity: 0;
  transition: opacity 0.12s;
}

.sidebar-folders li:hover .folder-menu-btn { opacity: 1; }

.folder-menu-btn:hover { color: var(--text, #1f2937); }

.courrier-main { min-width: 0; }

.courrier-filter-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1rem;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  margin-bottom: 0.8rem;
}

.doc-list__item.is-dragging {
  opacity: 0.45;
  transform: scale(0.99);
}

.drag-handle {
  display: inline-block;
  cursor: grab;
  color: var(--text-muted, #9ca3af);
  margin-right: 0.3rem;
  user-select: none;
}

.drag-handle:active { cursor: grabbing; }

.suggestion-pill--ia {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px dashed #a78bfa;
}

.page-header__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Responsive */
@media (max-width: 768px) {
  .courrier-layout {
    grid-template-columns: 1fr;
  }
  .courrier-sidebar {
    position: static;
    margin-bottom: 1rem;
  }
  .sidebar-folders {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .sidebar-folders li {
    flex: 0 0 auto;
    margin: 0;
  }
  .sidebar-divider { display: none; }
  .folder-link {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 16px;
  }
  .folder-menu-btn { display: none; }
}
