/* Fondations R1 — refonte UI/UX (voir CONSIGNES_REFONTE_UI.md, SUIVI_REFONTE_R1.md).
   Variables et composants réutilisables ; navigation latérale responsive ;
   boutons/formulaires/badges/retours. Les gabarits de contenu (listes,
   fiches, formulaires métier) seront restructurés en R4 — ce fichier ne
   fait qu'appliquer la nouvelle direction artistique aux composants
   partagés existants. */

:root {
  /* Palette "clair premium" */
  --nav: #0F1D3A;
  --nav-active: #1C2D55;
  --nav-hover: #182750;
  --nav-text: #C7D0E3;
  --nav-text-muted: #8A97B5;
  --nav-border: #1E2E55;

  --accent: #0E6E78;
  --accent-hover: #0A5A62;
  --accent-soft: #E6F3F4;

  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-alt: #F7F9FB;
  --border: #E3E7EE;
  --border-strong: #D3D9E2;
  --muted-bg: #EEF1F5;

  --ink: #111827;
  --ink-secondary: #5B6577;
  --ink-muted: #8A93A3;

  --late: #B42318;
  --late-bg: #FEF3F2;
  --waiting: #B54708;
  --waiting-bg: #FFFAEB;
  --success: #067647;
  --success-bg: #ECFDF3;
  --danger: #B42318;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;

  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidenav-width: 220px;
  --sidenav-width-collapsed: 64px;
}

* { box-sizing: border-box; }

/* Garantit que l'attribut HTML `hidden` masque toujours l'élément, même
   quand une classe (ex. .form-full { display: flex }) fixe `display` par
   ailleurs avec la même spécificité qu'un sélecteur d'attribut — sans ce
   correctif, la règle posée en dernier dans la feuille l'emportait sur le
   `[hidden]` natif du navigateur et laissait l'élément visible malgré
   l'attribut (constaté : le champ libre de localisation d'un dossier
   restait affiché après un bien choisi, retour terrain du 01/10/2026). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; }
h1, h2 { font-weight: 600; margin: 0; }

/* --------------------------------------------------------------------
   Coquille applicative : navigation latérale + zone de contenu
   -------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidenav {
  width: var(--sidenav-width);
  flex-shrink: 0;
  background: var(--nav);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  /* Pas d'overflow ici (reste "visible") : le popover du compte
     (.sidenav-account-menu) est un enfant DIRECT de .sidenav, pas de
     .sidenav-scroll, pour ne jamais être rogné par un ancêtre en overflow.
     Voir le commentaire dans base.html. */
}
.sidenav-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.sidenav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-name {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-agence {
  font-size: 11px;
  color: var(--nav-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidenav-section {
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6F7D9C;
  padding: 14px 8px 4px;
  font-weight: 600;
}

.sidenav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--nav-text);
  font-size: 13px;
  font-weight: 500;
}
.sidenav-link:hover { background: var(--nav-hover); color: #fff; }
.sidenav-link.is-active { background: var(--nav-active); color: #fff; font-weight: 600; }
.sidenav-icon { flex-shrink: 0; }
.sidenav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidenav-account {
  /* Pousse naturellement en bas : .sidenav-scroll (flex:1) occupe le reste
     de la hauteur disponible, .sidenav-account suit en dernier enfant. */
  flex-shrink: 0;
  border-top: 1px solid var(--nav-border);
  padding-top: 10px;
}
.sidenav-account summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
}
.sidenav-account summary::-webkit-details-marker { display: none; }
.sidenav-account summary:hover { background: var(--nav-hover); }
.sidenav-account[open] summary { background: var(--nav-hover); }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #2A3C68;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.sidenav-user { min-width: 0; display: flex; flex-direction: column; }
.user-name {
  color: #fff;
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--nav-text-muted); }

.sidenav-account-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 4px 2px;
}
.sidenav-account-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--nav-text);
  font-size: 13px;
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.sidenav-account-link:hover { background: var(--nav-hover); color: #fff; }
.sidenav-account-logout { color: #F0B0AA; }
.sidenav-account-logout:hover { color: #fff; background: var(--late); }
.sidenav-account-menu form { margin: 0; }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 16px 24px 0;
}

.container {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 80px;
}

/* --------------------------------------------------------------------
   Boutons
   -------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink-secondary); }
.btn-ghost:hover { color: var(--ink); background: var(--muted-bg); }
.btn-danger { background: transparent; color: var(--late); border-color: #F0CFC9; }
.btn-danger:hover { background: var(--late-bg); }
.btn-block { width: 100%; justify-content: center; height: 38px; }

/* --------------------------------------------------------------------
   Formulaires
   -------------------------------------------------------------------- */
.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input { resize: vertical; }

form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-secondary);
  font-weight: 500;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.form-full { display: flex; margin-bottom: 16px; }
/* Un <details> utilisé comme repli de commande (ex. "Modifier"/"Ajouter une
   tâche" dans _taches_actions.html) n'est pas un <label> : le display:flex
   générique de .form-full en fait sinon deux items d'une même ligne —
   <summary> étiré sur toute la hauteur du <form> qui suit, contenu
   comprimé à droite (revue T2, point 3, constaté à 390px). Flux normal
   (summary au-dessus, formulaire en dessous) pour ce cas précis, sans
   toucher .form-full sur les <label> (qui reste en colonne via la règle
   générique `form label`, ci-dessus). */
details.form-full { display: block; }
details.form-full > summary { margin-bottom: 12px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 4px; }

/* B2 : autocomplétion d'adresse (CONSIGNES_FICHE_BIEN.md) — liste de
   suggestions positionnée sous le champ, jamais au-dessus des autres
   groupes du formulaire (z-index borné à ce composant). */
.adresse-autocomplete { position: relative; }
.adresse-suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 5;
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15, 29, 58, .12); max-height: 240px; overflow-y: auto;
}
.adresse-suggestion { padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; }
.adresse-suggestion.is-active, .adresse-suggestion:hover { background: var(--muted-bg); }
.adresse-statut { font-size: 12px; color: var(--ink-secondary); margin: -10px 0 16px; min-height: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
/* Bloc d'information en lecture seule dans un formulaire (ex. localisation
   automatique du bien choisi) : plus léger qu'une .card imbriquée dans la
   .card du formulaire lui-même. */
.card-flat {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.card-flat .info-grid { margin-bottom: 0; }
.form { display: block; }

/* Filters */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-search { flex: 1; min-width: 220px; }
.filters select.input { width: auto; }

/* --------------------------------------------------------------------
   Tableaux
   -------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--ink-secondary);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}
.table-row { cursor: pointer; }
.table-row:hover { background: var(--surface-alt); }
.table-row:last-child td { border-bottom: none; }
.cell-truncate {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono { font-family: var(--font-mono); font-size: 13px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

/* Utilitaires (R2) — remplacent des style="" inline incompatibles CSP */
.inline-form { display: inline; }
.section-spaced { margin-top: 32px; }

/* --------------------------------------------------------------------
   Badges — toujours couleur + libellé
   -------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-gray  { background: var(--muted-bg); color: var(--ink-secondary); }
.badge-amber { background: var(--waiting-bg); color: var(--waiting); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-slate { background: var(--muted-bg); color: #3F4750; }
.badge-blue  { background: var(--accent-soft); color: var(--accent); }
.badge-coral { background: var(--late-bg); color: var(--late); }
.badge-purple{ background: #EFEBF7; color: #5B4A8A; }

.badge-select {
  width: auto;
  border: none;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.badge-select:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* --------------------------------------------------------------------
   En-tête de page / retours
   -------------------------------------------------------------------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; letter-spacing: -.01em; margin-top: 4px; }
.page-header-actions { display: flex; gap: 10px; }
.back-link { font-size: 13px; color: var(--ink-secondary); text-decoration: none; font-weight: 500; }
.back-link:hover { color: var(--accent); }

/* Dossier info card */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 20px;
  margin-bottom: 4px;
}
.info-label {
  display: block;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.info-value { font-size: 14px; color: var(--ink); margin: 0; }
.info-block { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.info-block p.info-value { line-height: 1.6; white-space: pre-wrap; }

/* Actions / historique */
.actions-section h2, .panel-section-taches h2 {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.count {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  background: var(--muted-bg);
  padding: 2px 9px;
  border-radius: 999px;
}
.add-action-form { margin-bottom: 24px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; padding-bottom: 0; }
.timeline-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.timeline-date { font-size: 12px; color: var(--ink-secondary); font-variant-numeric: tabular-nums; }
.timeline-objet { font-size: 14px; font-weight: 500; margin: 0 0 4px; }
.timeline-comment {
  font-size: 14px;
  color: var(--ink-secondary);
  margin: 0 0 8px;
  white-space: pre-wrap;
}
.timeline-delete { margin: 0; }
.link-danger {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}
.link-danger:hover { color: var(--late); }

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-state p { margin: 0 0 16px; }

/* --------------------------------------------------------------------
   Connexion / compte
   -------------------------------------------------------------------- */
.auth-body { background: var(--bg); }
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 380px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 1px 2px rgba(15,29,58,.06), 0 12px 32px rgba(15,29,58,.08);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 32px; height: 32px; font-size: 14px; }
.login-brand .brand-name { color: var(--ink); font-size: 17px; }
.login-subtitle { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; margin: 0 0 16px; }

/* Errors */
.form-error {
  background: var(--late-bg);
  color: var(--late);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.empty-inline { color: var(--ink-muted); font-size: 14px; }
.field-hint { color: var(--ink-muted); font-size: 12px; margin: -10px 0 16px; }

/* --------------------------------------------------------------------
   Listes diverses (historique, corbeille…)
   -------------------------------------------------------------------- */
.dashboard-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.dashboard-list a { text-decoration: none; font-weight: 500; }
.dashboard-list a:hover { color: var(--accent); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 13px;
}
.pagination-info { color: var(--ink-secondary); }

/* Focus visibility */
a:focus-visible, button:focus-visible, .table-row:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------
   Réactif — navigation latérale
   -------------------------------------------------------------------- */
@media (max-width: 1023px) {
  .sidenav { width: var(--sidenav-width-collapsed); padding: 14px 8px; }
  .sidenav-brand { padding: 4px 0 14px; justify-content: center; }
  .brand-text, .brand-agence, .sidenav-label, .sidenav-user { display: none; }
  .sidenav-link { justify-content: center; padding: 10px; width: 100%; }
  .sidenav-section { text-align: center; padding: 12px 2px 4px; }
  .sidenav-account summary { justify-content: center; padding: 8px 4px; }
  .sidenav-account-menu { position: absolute; left: calc(var(--sidenav-width-collapsed) + 6px); bottom: 8px; background: var(--nav); border: 1px solid var(--nav-border); border-radius: var(--radius); min-width: 160px; box-shadow: 0 12px 32px rgba(15,29,58,.25); z-index: 20; }
  .sidenav-account { position: relative; }
}

@media (max-width: 720px) {
  .form-row { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select.input { width: 100%; }
  .container { padding: 16px 14px 60px; }
  .app-toolbar { padding: 12px 14px 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table-row { border-bottom: 1px solid var(--border); padding: 10px 16px; }
  .table td { border-bottom: none; padding: 4px 0; }
}

/* --------------------------------------------------------------------
   Tableau de bord « Aujourd'hui » (R3)
   -------------------------------------------------------------------- */
.container-wide { max-width: 1440px; }

.avatar-sm { width: 28px; height: 28px; font-size: 11px; background: var(--muted-bg); color: #2A3C68; }

.today-layout { display: flex; gap: 20px; align-items: flex-start; }
.today-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.today-toast {
  background: var(--success-bg); color: var(--success); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; font-weight: 500;
}

.today-header { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.today-header h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
.today-subtitle { color: var(--ink-secondary); margin-top: 4px; }
.today-header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.today-search {
  display: flex; align-items: center; gap: 8px; width: 300px; height: 36px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink-muted);
}
.today-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.today-search-input { flex: 1; border: 0; outline: none; font: inherit; background: transparent; color: var(--ink); }
.today-search-kbd { font: inherit; font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; color: var(--ink-muted); }

/* T2 : la vue « Mes tâches » affiche 5 cartes (contre 4 pour « Mes
   dossiers ») — auto-fit garde une grille lisible dans les deux cas, sans
   dépendre d'un nombre de colonnes figé. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi-card {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.kpi-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kpi-dot-dashed { border: 1.5px dashed var(--ink-muted); box-sizing: border-box; background: transparent; }
.kpi-number { font-size: 30px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--ink); }
.kpi-detail { font-size: 12px; color: var(--ink-secondary); }
.kpi-late .kpi-label { color: var(--late); } .kpi-late .kpi-dot { background: var(--late); }
.kpi-late:hover, .kpi-late.is-active { border-color: var(--late); box-shadow: 0 0 0 3px var(--late-bg); }
.kpi-today .kpi-label { color: var(--accent); } .kpi-today .kpi-dot { background: var(--accent); }
.kpi-today:hover, .kpi-today.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kpi-waiting .kpi-label { color: var(--waiting); } .kpi-waiting .kpi-dot { background: var(--waiting); }
.kpi-waiting:hover, .kpi-waiting.is-active { border-color: var(--waiting); box-shadow: 0 0 0 3px var(--waiting-bg); }
.kpi-none .kpi-label, .kpi-planifier .kpi-label { color: var(--ink-secondary); }
.kpi-none:hover, .kpi-none.is-active, .kpi-planifier:hover, .kpi-planifier.is-active { border-color: var(--ink-secondary); box-shadow: 0 0 0 3px var(--muted-bg); }
.kpi-soon .kpi-label { color: var(--accent); } .kpi-soon .kpi-dot { background: var(--accent); opacity: .5; }
.kpi-soon:hover, .kpi-soon.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* T2 : bascule « Mes tâches » / « Mes dossiers » (brief section 4, « deux
   vues distinctes, sélection persistante dans l'URL »). */
.view-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.view-tab {
  padding: 8px 4px; font-size: 14px; font-weight: 600; color: var(--ink-secondary); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.view-tab:hover { color: var(--ink); }
.view-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.work-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; }
.work-list-header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.work-list-title { font-weight: 600; font-size: 14px; }
.work-list-count { color: var(--ink-secondary); }
.work-list-chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 10px; border-radius: var(--radius-sm);
  background: var(--muted-bg); font-size: 12px; font-weight: 500; color: var(--ink); text-decoration: none;
}
.chip-x { color: var(--ink-muted); }
.chip-late { background: var(--late-bg); color: var(--late); font-weight: 600; }
.chip-today { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip-waiting { background: var(--waiting-bg); color: var(--waiting); font-weight: 600; }
.work-list-tri { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 12px; white-space: nowrap; }
.work-list-tri span { color: var(--ink-secondary); }

.work-list-cols {
  display: grid; grid-template-columns: 1.2fr 1fr 1.6fr 150px 40px; gap: 12px; padding: 8px 16px;
  border-bottom: 1px solid var(--border); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-secondary); font-weight: 600;
}
.work-list-body { display: flex; flex-direction: column; max-height: 620px; overflow: auto; }
.work-row {
  display: grid; grid-template-columns: 1.2fr 1fr 1.6fr 150px 40px; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--muted-bg); align-items: center; min-height: 56px; cursor: pointer;
}
.work-row:last-child { border-bottom: none; }
.work-row:hover { background: var(--surface-alt); }
.work-cell { min-width: 0; }
.work-cell-sub { font-size: 12px; color: var(--ink-secondary); margin-top: 2px; }
.row-open-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.row-open-link:hover { color: var(--accent); }
.work-action { font-weight: 500; color: var(--ink); }
.work-action-late { font-weight: 600; color: var(--late); }
.work-action-today { font-weight: 600; color: var(--ink); }
.work-cell-resp { display: flex; justify-content: center; }

.work-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 40px 20px; text-align: center; }
.work-empty svg { color: var(--accent); }

/* Squelette de chargement (fetch en cours) — largeurs en classes, jamais
   en attribut style="" (CSP style-src sans 'unsafe-inline'). */
.skeleton-line {
  height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--muted-bg) 25%, var(--surface-alt) 50%, var(--muted-bg) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-line + .skeleton-line { margin-top: 10px; }
.skeleton-w-50 { width: 50%; }
.skeleton-w-60 { width: 60%; }
.skeleton-w-70 { width: 70%; }
.skeleton-w-80 { width: 80%; }
.skeleton-center { margin-left: auto; margin-right: auto; }
.today-error { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 20px; text-align: center; }

.today-aside { width: 340px; flex-shrink: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.panel-empty { padding: 40px 20px; color: var(--ink-secondary); font-size: 13px; text-align: center; }

.panel-resume { display: flex; flex-direction: column; font-size: 13px; }
.panel-header { padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.panel-header-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-ref { font-size: 12px; color: var(--ink-secondary); }
.panel-close { margin-left: auto; border: 0; background: transparent; color: var(--ink-secondary); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 4px; }
.panel-title { font-size: 17px; font-weight: 600; line-height: 1.25; margin: 0; }
.panel-meta { color: var(--ink-secondary); margin-top: 3px; }

.panel-pa { padding: 16px 22px; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.panel-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-secondary); font-weight: 600; margin-bottom: 8px; }
.panel-pa-objet { font-weight: 600; font-size: 14px; }
.panel-pa-meta { color: var(--ink-secondary); margin-top: 3px; }
.panel-pa-attente { margin-top: 8px; display: flex; align-items: center; gap: 6px; color: var(--waiting); font-weight: 500; }
.panel-pa-vide { color: var(--ink-secondary); margin: 0; }

.panel-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 18px; }
.panel-echanges, .panel-contacts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.panel-echanges li { display: grid; grid-template-columns: 48px 1fr; gap: 10px; }
.panel-echange-date { color: var(--ink-secondary); }
.panel-echange-type { font-weight: 500; }
.panel-echange-commentaire { color: var(--ink-secondary); }
.panel-contacts li { display: flex; justify-content: space-between; gap: 10px; }
.panel-contact-nom { font-weight: 500; }
.panel-contact-role { font-size: 12px; color: var(--ink-secondary); }
.panel-contact-coord { text-align: right; font-variant-numeric: tabular-nums; }

.panel-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
/* Empilés verticalement, jamais côte à côte : le panneau fait 340px de
   large même en plein écran (brief P1, « disposition des boutons ») — deux
   boutons flex:1 y laissaient « Ajouter un échange »/« Ouvrir le dossier »
   trop étroits (texte compressé/coupé), constaté à 1440/820/390px. */
.panel-footer-row { display: flex; flex-direction: column; gap: 8px; }
.panel-footer-row .btn,
.panel-footer-row > details.panel-quickform { width: 100%; }
.panel-footer-row .btn { justify-content: center; }
.panel-quickform summary { list-style: none; cursor: pointer; }
.panel-quickform summary::-webkit-details-marker { display: none; }
.panel-quickform[open] summary { margin-bottom: 12px; }
.panel-form-status { font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); }
.panel-form-status[data-tone="error"] { background: var(--late-bg); color: var(--late); }
.panel-form-status[data-tone="ok"] { background: var(--success-bg); color: var(--success); }

/* T2 : liste complète des tâches du dossier dans le panneau (340px) — cartes
   et grille d'infos resserrées, mêmes composants que la fiche dossier
   (.card/.info-grid) mais sans leur espacement pensé pour une page pleine
   largeur. */
.panel-section-taches .card { padding: 14px 16px; margin-bottom: 14px; }
.panel-section-taches .card:last-child { margin-bottom: 0; }
.panel-section-taches .info-grid { grid-template-columns: 1fr 1fr; gap: 10px 14px; }

@media (max-width: 1023px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .work-list-cols { display: none; }
  .work-row {
    grid-template-columns: 1fr; gap: 4px; padding: 12px 16px; border-bottom: 8px solid var(--bg);
    /* Le rail (5 cellules empilées) est bien plus haut que 56px : sans ceci,
       .work-list-body (flex + max-height + overflow:auto) réduit chaque
       ligne à min-height via flex-shrink, et son contenu déborde sur les
       lignes suivantes au lieu de défiler (constaté en recette R4, écran
       mobile avec de nombreux dossiers). */
    flex-shrink: 0; min-height: auto;
  }
  .work-cell-resp { justify-content: flex-start; margin-top: 4px; }
  .today-aside { display: none; width: auto; }
  .today-layout.panel-open .today-aside {
    display: block; position: fixed; inset: 0; z-index: 50; border-radius: 0; overflow-y: auto;
  }
  .today-header-actions { width: 100%; margin-left: 0; }
  .today-search { width: 100%; }
}

@media (max-width: 640px) {
  .today-header { flex-direction: column; align-items: stretch; }
  .today-header-actions { flex-direction: column; align-items: stretch; }
}

/* --------------------------------------------------------------------
   Barre de navigation basse mobile (R4, exigée sous 768px)
   -------------------------------------------------------------------- */
.bottomnav { display: none; }

@media (max-width: 767px) {
  .sidenav { display: none; }
  .bottomnav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: 58px;
    background: var(--nav);
    border-top: 1px solid var(--nav-border);
    padding: 0 2px;
  }
  .bottomnav-link {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    color: var(--nav-text-muted);
    text-decoration: none;
    font-size: 10.5px;
    border: 0; background: transparent; cursor: pointer; font-family: inherit;
  }
  .bottomnav-link.is-active { color: #fff; }
  .bottomnav-more { position: relative; flex: 1; }
  .bottomnav-more summary { list-style: none; }
  .bottomnav-more summary::-webkit-details-marker { display: none; }
  .bottomnav-more-menu {
    position: absolute; bottom: calc(100% + 8px); right: 4px;
    background: var(--nav); border: 1px solid var(--nav-border); border-radius: var(--radius);
    min-width: 200px; padding: 6px;
    box-shadow: 0 -12px 32px rgba(15, 29, 58, .28);
  }
  .bottomnav-more-menu a, .bottomnav-more-menu button {
    display: block; width: 100%; text-align: left; padding: 10px 12px;
    color: var(--nav-text); text-decoration: none; font: inherit; font-size: 14px;
    border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer;
  }
  .bottomnav-more-menu a[aria-current="page"] { background: var(--nav-active); color: #fff; }
  .bottomnav-more-menu a:hover, .bottomnav-more-menu button:hover { background: var(--nav-hover); color: #fff; }
  .bottomnav-more-menu hr { border: 0; border-top: 1px solid var(--nav-border); margin: 6px 4px; }

  .app-main { padding-bottom: 58px; }
  .container { padding-bottom: 78px; }
  .today-layout.panel-open .today-aside { z-index: 50; } /* la feuille recouvre la barre basse quand ouverte */
}
