/* Tableau de bord Aliris — feuille de style unique.
 * Conçue mobile d'abord : les règles de base visent le téléphone, les
 * @media (min-width) ajoutent la mise en page large.
 * Les thèmes ne définissent que des variables ; le reste n'utilise qu'elles.
 * Ils s'appliquent à tout élément portant data-theme (la page entière via
 * <html>, ou un aperçu de thème dans la page Apparence).
 * Aucun style inline : la politique de sécurité (CSP) l'interdit. */

/* ---------- Thèmes ---------- */

:root,
[data-theme="aliris"] {
  color-scheme: light;
  --bg: #fbf0f2;
  --surface: #ffffff;
  --border: #f0d9e0;
  --border-strong: #e3c2cd;
  --text: #2d1d24;
  --muted: #5c4650;
  --brand: #9b4565;
  --on-brand: #ffffff;
  --accent: #ad5277;
  --on-accent: #ffffff;
  --accent-soft: #fbe4ec;
  --mint: #a8e6cf;
  /* Menu de gauche en rose poudré, texte prune foncé (contraste). */
  --side-1: #f6d6e0;
  --side-2: #e7adc0;
  --on-side: #4a1f30;
  --side-glow: rgb(255 255 255 / 0.32);
  --logo-a: #c06a8b;
  --logo-b: #6fcaa4;
  /* Surlignage menthe du prénom dans « Bonjour ». */
  --hl: #bff0dc;
  /* Fond teinté des en-têtes de tableaux. */
  --bg-2: #f7e4e9;
  --ok: #1f7a5a;
  --warn: #9a5d00;
  --ko: #c62828;
  --ko-soft: #fbe9ee;
  --info-soft: #dcf3ea;
  --info-text: #1d6b52;
  --warn-soft: #fff3e3;
  --pros-bg: #e6effa;
  --pros-fg: #1e4f8a;
  --cli-bg: #dcf3ea;
  --cli-fg: #1d6b52;
  --shadow: 0 10px 30px rgb(45 29 36 / 0.18);
}

[data-theme="ardoise"] {
  color-scheme: dark;
  --bg: #111c31;
  --surface: #18263f;
  --border: #2a3b5c;
  --border-strong: #3a4f78;
  --text: #e6edf7;
  --muted: #9fb0c8;
  --brand: #132039;
  --on-brand: #e2e8f0;
  --accent: #60a5fa;
  --on-accent: #0b1324;
  --accent-soft: #1f3a63;
  --mint: #60a5fa;
  --side-1: #1b2a45;
  --side-2: #0f1a2e;
  --on-side: #e2e8f0;
  --side-glow: rgb(96 165 250 / 0.12);
  --logo-a: #7fb3f5;
  --logo-b: #60a5fa;
  --hl: transparent;
  --bg-2: #1d2d4a;
  --ok: #4ade80;
  --warn: #fbbf24;
  --ko: #f87171;
  --ko-soft: #3a2030;
  --info-soft: #123a2e;
  --info-text: #86e0b8;
  --warn-soft: #3a3020;
  --pros-bg: #1e3358;
  --pros-fg: #a7c8fb;
  --cli-bg: #123a2e;
  --cli-fg: #86e0b8;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.45);
}

/* ---------- Base ---------- */

:root {
  --radius: 12px;
  --touch: 44px; /* Zone tactile minimale. */
  --sidebar-width: 220px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

h1 { font-size: 1.5rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
/* Prénom de « Bonjour » : surligné en menthe (thème Aliris). */
.who-first {
  padding: 0 2px; border-radius: 2px;
  background: linear-gradient(transparent 58%, var(--hl) 58%);
}
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Formulaires et boutons ---------- */

form { display: grid; gap: 0.75rem; margin: 0.75rem 0; }
label { display: grid; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }

input, select, textarea {
  font: inherit;
  min-height: var(--touch);
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch);
  padding: 0 1.1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: wait; }
button.secondary, .button.secondary {
  width: 100%;
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}
button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
button.danger {
  background: transparent;
  color: var(--ko);
  border-color: transparent;
  text-decoration: underline;
}
.icon-button {
  width: var(--touch);
  padding: 0;
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.icon-button svg, .nav-list svg, .chevron {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

summary { min-height: var(--touch); display: flex; align-items: center; cursor: pointer; }

.separator { text-align: center; color: var(--muted); margin: 0.5rem 0; }

/* ---------- Cartes et messages ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
details.card > summary { font-weight: 600; }

.message {
  position: fixed;
  z-index: 60;
  left: 1rem; right: 1rem; bottom: 1rem;
  margin: 0 auto;
  max-width: 560px;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--ko-soft);
  color: var(--ko);
  border: 1px solid var(--ko);
  box-shadow: var(--shadow);
}
.message.info { background: var(--info-soft); color: var(--info-text); border-color: var(--info-text); }

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 70;
  margin: 0;
  padding: 0.7rem 1rem;
  background: var(--ko);
  color: #ffffff;
  font-weight: 600;
  text-align: center;
}

.key { display: block; margin: 0.4rem 0; font-size: 1.05rem; word-break: break-all; }
.codes { columns: 2; font-family: ui-monospace, monospace; padding-left: 1.2rem; }

/* ---------- Écrans de connexion ---------- */

.auth { max-width: 460px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  margin-bottom: 1.25rem;
  font-size: 1.4rem; font-weight: 800; letter-spacing: 0.06em; color: var(--brand);
}
.auth .card h1 { margin-bottom: 0.75rem; font-size: 1.3rem; }

/* ---------- Coquille : menu latéral ---------- */

.sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  width: min(82vw, 280px);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem 0.85rem calc(1rem + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: linear-gradient(180deg, var(--side-1) 0%, var(--side-2) 100%);
  color: var(--on-side);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}
.shell.menu-open .sidebar { transform: none; box-shadow: var(--shadow); }

.sidebar-brand {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0 0.5rem 1.25rem;
  color: inherit; text-decoration: none;
}
.sidebar-brand b { display: block; font-size: 1.3rem; font-weight: 800; letter-spacing: 0.06em; line-height: 1; }
.sidebar-brand small { display: block; font-size: 0.72rem; opacity: 0.85; margin-top: 0.25rem; }

.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.nav-list a {
  display: flex; align-items: center; gap: 0.75rem;
  min-height: var(--touch);
  padding: 0 0.75rem;
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  font-size: 0.92rem; font-weight: 600;
  text-decoration: none;
  opacity: 0.92;
}
.nav-list a:hover { background: rgb(255 255 255 / 0.08); }
.nav-list a[aria-current="page"] {
  background:
    radial-gradient(circle at calc(100% - 16px) 50%, var(--mint) 0 2.5px, transparent 3px) no-repeat,
    rgb(255 255 255 / 0.16);
  border-color: rgb(255 255 255 / 0.3);
  box-shadow: inset 3px 0 0 var(--mint);
  opacity: 1;
}
.sidebar-foot { margin: auto 0 0; padding: 0 0.6rem; font-size: 0.75rem; font-weight: 600; line-height: 1.7; opacity: 0.9; }

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgb(0 0 0 / 0.4);
}

/* ---------- Coquille : barre du haut ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 0.5rem;
  min-height: 60px;
  padding: 0.5rem 0.75rem;
  padding-top: max(0.5rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.crumb { min-width: 0; flex: 1; font-size: 0.9rem; color: var(--muted); }
.crumb ol { display: flex; align-items: center; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.crumb li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb li + li::before { content: "›"; margin-right: 0.4rem; }
.crumb [aria-current] { color: var(--text); font-weight: 700; }
#crumb-space { display: none; }

.profile-menu { position: relative; }
.profile-menu > summary {
  list-style: none; gap: 0.5rem;
  padding: 0 0.4rem; border-radius: 9px;
  font-weight: 600; font-size: 0.9rem;
}
.profile-menu > summary::-webkit-details-marker { display: none; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.profile-name { display: none; }
.profile-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 45;
  width: min(280px, calc(100vw - 1.5rem));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.profile-head { display: grid; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.profile-head span { font-size: 0.85rem; color: var(--muted); }
.profile-dropdown a, .profile-dropdown button {
  display: flex; align-items: center; width: 100%;
  min-height: var(--touch); padding: 0 1rem;
  border: 0; border-radius: 0;
  background: transparent; color: var(--text);
  font: inherit; font-weight: 400; text-decoration: none; text-align: left;
}
.profile-dropdown a:hover, .profile-dropdown button:hover { background: var(--accent-soft); }
.profile-dropdown .danger-item { color: var(--ko); border-top: 1px solid var(--border); justify-content: flex-start; }

/* ---------- Pages ---------- */

.content { padding: 1rem 0.75rem calc(3rem + env(safe-area-inset-bottom)); max-width: 1240px; margin: 0 auto; }
.content:focus { outline: none; }
.page-head { margin-bottom: 1rem; }
.page-head p { margin: 0.25rem 0 0; }
.profile-section { margin-bottom: 1.5rem; }

/* Voyants des automatisations */
.lights { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.lights li {
  display: grid; grid-template-columns: auto 1fr; align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border); border-radius: 10px;
}
.light { width: 14px; height: 14px; border-radius: 50%; grid-row: span 2; }
.light.ok { background: var(--ok); }
.light.attention { background: var(--warn); }
.light.panne { background: var(--ko); }
.lights .name { font-weight: 600; }
.lights .desc { color: var(--muted); font-size: 0.88rem; }
.state { font-size: 0.85rem; font-weight: 600; grid-column: 2; }
.state.ok { color: var(--ok); }
.state.attention { color: var(--warn); }
.state.panne { color: var(--ko); }

/* Tableaux : cartes sur mobile, tableau au-delà de 768 px.
 * Chaque cellule porte son intitulé dans data-label (rempli par le script). */
.table-cards { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table-cards thead { display: none; }
.table-cards tr {
  display: block;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: 10px;
}
.table-cards td {
  display: grid; grid-template-columns: 9.5rem 1fr; gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.table-cards td:last-child { border-bottom: 0; }
.table-cards td::before { content: attr(data-label); color: var(--muted); font-weight: 600; }

/* Clés d'accès */
.keys { list-style: none; padding: 0; margin: 0.5rem 0; display: grid; gap: 0.4rem; }
.keys li {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem;
  padding: 0.25rem 0.25rem 0.25rem 0.75rem;
  border: 1px solid var(--border); border-radius: 8px;
}
.keys .date { color: var(--muted); font-size: 0.85rem; }

/* Réglages : barre d'onglets arrondie, défilante sur petit écran. */
.tabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 1rem;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  scrollbar-width: thin;
}
.tab {
  flex: none;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
}
.tab:hover { background: var(--accent-soft); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.tab-panel .card + .card { margin-top: 1rem; }
.inline-form { align-items: end; }
/* Bouton à sa taille naturelle, pas étiré sur toute la largeur. */
.inline-form button { justify-self: start; }
.option-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.4rem; }
.option {
  display: flex; align-items: center; gap: 0.25rem;
  min-height: var(--touch);
  padding: 0.15rem 0.15rem 0.15rem 0.75rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface);
}
.option-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.option.is-hidden .option-label { color: var(--muted); text-decoration: line-through; }
.option form { flex: 1; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.25rem 0; }
.option form input { flex: 1 1 10rem; }
.manage { position: relative; display: inline-block; }
.manage > summary {
  display: inline-flex;
  list-style: none; padding: 0 0.75rem;
  border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 0.88rem; font-weight: 600;
}
.manage > summary::-webkit-details-marker { display: none; }
.manage-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20;
  min-width: 11rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden;
}
.manage-menu button {
  width: 100%; justify-content: flex-start;
  border-radius: 0; background: transparent; color: var(--text); font-weight: 400;
}
.manage-menu button:hover { background: var(--accent-soft); }
.hidden-options { margin-top: 0.5rem; }
.hidden-options > summary { color: var(--muted); font-size: 0.9rem; }
.add-form { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.add-form input { flex: 1 1 12rem; }

/* Contacts */
.page-head-actions {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 0.75rem;
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.toolbar .tabs { margin-bottom: 0; }
.search { flex: 1 1 16rem; }
.search input { width: 100%; }
.tab[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* Couleur réservée au sens : prospect, client, retard, aujourd'hui. */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}
.badge-prospect { background: var(--pros-bg); color: var(--pros-fg); }
.badge-client { background: var(--cli-bg); color: var(--cli-fg); }
.pill {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 0.85rem; white-space: nowrap;
}
.pill-late { background: var(--ko-soft); color: var(--ko); border-color: var(--ko); font-weight: 600; }
.pill-today { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); font-weight: 600; }

.contact-link {
  display: inline-flex; align-items: center; gap: 0.6rem;
  min-height: var(--touch);
  color: var(--text); text-decoration: none;
}
.contact-link:hover .contact-name { text-decoration: underline; }
.contact-names { display: grid; }
.contact-name { font-weight: 600; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.8rem; flex: none; }

.fiche-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.fiche-head .avatar { width: 48px; height: 48px; font-size: 1.1rem; }
.fiche-title { flex: 1; min-width: 12rem; }
.fiche-title h1 { display: inline; margin-right: 0.5rem; font-size: 1.4rem; }
.fiche-title p { margin: 0.2rem 0 0; }
.notice {
  padding: 0.75rem 1rem; border-radius: 10px;
  background: var(--accent-soft); color: var(--text);
}
#contact-view > .tabs { margin-top: 0.5rem; }

.fiche-stage { margin-bottom: 1rem; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.steps li {
  padding: 0.3rem 0.75rem; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--muted); font-size: 0.88rem;
}
.steps li.done { color: var(--text); border-color: var(--accent); }
.steps li.current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }

.fiche-fields { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.5rem 1rem; margin: 0 0 1rem; }
.fiche-fields dt { color: var(--muted); font-weight: 600; }
.fiche-fields dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.follow-up { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.timeline li { padding-left: 0.9rem; border-left: 3px solid var(--border-strong); }
.timeline-meta { font-size: 0.82rem; color: var(--muted); }
.timeline-text { margin: 0.2rem 0 0; white-space: pre-line; overflow-wrap: anywhere; }

textarea { resize: vertical; min-height: 5rem; }
.form-grid { display: grid; gap: 0.75rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
/* Aide sous le champ : gris discret, jamais vert (le vert porte un sens). */
.hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.segmented { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.segmented legend { margin-bottom: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.segmented label {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: var(--touch); padding: 0 1rem;
  border: 1px solid var(--border-strong); border-radius: 9px;
  color: var(--text); cursor: pointer;
}
.segmented label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.segmented input { min-height: auto; }

/* Relances */
.followup-group h2 { display: flex; align-items: center; gap: 0.5rem; }
.followup-group .count {
  margin-left: auto; padding: 0 0.55rem; border-radius: 999px;
  background: var(--accent-soft); font-size: 0.85rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-late { background: var(--ko); }
.dot-today { background: var(--warn); }
.dot-week { background: var(--accent); }
.dot-later { background: var(--muted); }
.followups { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.followup {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border); border-radius: 10px;
}
.followup-main { flex: 1 1 16rem; display: grid; gap: 0.25rem; min-width: 0; }
.followup-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.followup-who {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.35em;
  min-height: var(--touch); color: var(--text); text-decoration: none;
}
.followup-who:hover strong { text-decoration: underline; }
.followup-sep { color: var(--muted); }
.followup-what { font-size: 0.88rem; color: var(--muted); }
.followup-actions { display: flex; align-items: center; gap: 0.5rem; }
.followup-done {
  flex: 1 1 100%;
  display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem;
  margin: 0; padding-top: 0.5rem; border-top: 1px solid var(--border);
}
.followup-done label { flex: 1 1 12rem; }
.followup-done .hint { flex: 1 1 100%; }

/* CRM : onglets communs, vue générale, aperçu des contacts */
.crm-tabs .tab {
  display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 38px; text-decoration: none;
}
.crm-tabs .tab[aria-current="page"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.4rem; height: 1.4rem; padding: 0 0.35rem; border-radius: 999px;
  background: var(--ko); color: #ffffff; font-size: 0.75rem; font-weight: 700;
}
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; margin-bottom: 0.75rem; }
.section-head h2 { margin: 0; }
.section-head > :last-child { margin-left: auto; font-size: 0.9rem; }
.urgent-cards { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.urgent-cards .followup { flex-direction: column; align-items: stretch; background: var(--bg); }
.urgent-cards .followup-main { flex: none; }
.stat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; margin-bottom: 0.35rem; border-radius: 10px;
}
.stat-icon svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
/* Entonnoir : une étape par case ; chevrons à partir de 768 px. */
.funnel {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
}
.funnel-step {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 4.5rem; padding: 0.6rem 1.4rem; border-radius: 8px; text-align: center;
}
.funnel-label { font-size: 0.85rem; font-weight: 600; }
.funnel-count { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.funnel-step-0 { --step: var(--pros-fg); }
.funnel-step-1 { --step: var(--accent); }
.funnel-step-2 { --step: var(--warn); }
.funnel-step-3 { --step: var(--cli-fg); }
.funnel-step { background: color-mix(in srgb, var(--step) 16%, var(--surface)); color: var(--step); }
.contacts-layout { display: grid; gap: 1rem; align-items: start; }
.contacts-list { padding: 0; overflow-x: auto; }
.contact-preview { display: none; }
.contact-row { cursor: pointer; }
.contact-row.is-selected { background: var(--accent-soft); }
.preview-head { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.75rem; }
.preview-name { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.preview-head p { margin: 0.1rem 0 0.35rem; }
.preview-follow-up {
  margin: 0.75rem 0; padding: 0.6rem 0.75rem; border-radius: 8px;
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.preview-follow-up p { margin: 0.15rem 0; }
.preview-follow-up-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-weight: 600; }

/* Accueil */
.stat-cards {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem; margin-bottom: 1rem;
}
.stat-card {
  display: grid; gap: 0.15rem; align-content: start;
  min-height: var(--touch); padding: 0.9rem 1rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none;
}
.stat-card:hover { border-color: var(--accent); }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-weight: 600; }
.stat-detail { font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }
/* Couleur réservée au sens : le retard en rouge, le jour en orange. */
.home-columns { display: grid; gap: 1rem; margin-bottom: 1rem; }
.home-columns .card { margin: 0; }
.attention-list, .quick-links {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem;
}
.attention-item {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem;
  min-height: var(--touch); padding: 0.4rem 0.75rem;
  border: 1px solid var(--border); border-left: 3px solid var(--ko); border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.attention-item:hover strong { text-decoration: underline; }
.attention-text { display: grid; }
.quick-links a {
  display: flex; align-items: center;
  min-height: var(--touch); padding: 0 0.75rem;
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-weight: 600; text-decoration: none;
}
.quick-links a:hover { background: var(--accent-soft); }

/* Agenda : liste du jour sur mobile, mois + panneau du jour au-delà. */
.agenda-layout { display: grid; gap: 1rem; }
.agenda-layout .card { margin: 0; }
.agenda-month { display: none; }
.agenda-nav, .agenda-day-nav { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.agenda-nav h2, .agenda-day-nav h2 { flex: 1; margin: 0; text-transform: capitalize; }
.agenda-weekdays, .agenda-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.agenda-weekdays span { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-align: center; }
.agenda-cell {
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 2px;
  min-height: 5.5rem; padding: 4px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-weight: 400; text-align: left; overflow: hidden;
}
.agenda-cell.is-empty { border: 0; background: transparent; }
.agenda-cell.is-today .agenda-day-number { background: var(--accent); color: var(--on-accent); }
.agenda-cell[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.agenda-day-number {
  align-self: flex-start; min-width: 1.6rem; padding: 0 0.3rem;
  border-radius: 999px; font-size: 0.85rem; font-weight: 700; text-align: center;
}
.chip {
  display: block; padding: 1px 6px; border-radius: 6px;
  font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Couleur réservée au sens : rendez-vous, tâche, relance. */
.chip-rendez-vous, .badge-rendez-vous { background: var(--pros-bg); color: var(--pros-fg); }
.chip-tache, .badge-tache { background: var(--accent-soft); color: var(--text); }
.chip-relance, .badge-relance { background: var(--warn-soft); color: var(--warn); }
.chip-more { font-size: 0.72rem; color: var(--muted); }
.agenda-items { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.6rem; }
.agenda-item {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.4rem 0.75rem;
  padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 10px;
}
.agenda-item-head { display: flex; flex-direction: column; gap: 0.25rem; min-width: 5.5rem; }
.agenda-time { font-weight: 700; font-size: 0.9rem; }
.agenda-item-body { flex: 1 1 10rem; display: grid; gap: 0.15rem; min-width: 0; }
.agenda-item-body a { display: inline-flex; align-items: center; min-height: var(--touch); }
.agenda-note { margin: 0.2rem 0 0; white-space: pre-line; overflow-wrap: anywhere; font-size: 0.88rem; }
#form-event h3 { margin: 0 0 0.5rem; }

/* Gestion du temps */
.time-top { display: grid; gap: 1rem; margin-bottom: 1rem; align-items: start; }
.time-top > .card { margin: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.card-head h2 { margin: 0; }
.timer-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem; margin: 0; }
.timer-clock { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 0.5rem 0 0.75rem; }
.timer-elapsed { font-size: 2.4rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.pill-running { background: var(--cli-bg); color: var(--cli-fg); border-color: var(--cli-fg); font-weight: 600; }
.menu-item {
  display: grid; gap: 0.1rem; padding: 0.6rem 0.9rem;
  color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border);
}
.menu-item:hover { background: var(--accent-soft); }
.menu-item .muted { font-size: 0.82rem; }
#temps-export-menu .manage-menu { min-width: 16rem; }
/* Bouton secondaire à sa taille naturelle (jamais étiré). */
.button-outline { background: var(--surface); color: var(--accent); border-color: var(--accent); justify-self: start; }
.time-status.status-ok { background: var(--cli-bg); color: var(--cli-fg); border-color: transparent; }
.time-status.status-none { color: var(--muted); }
.time-status.status-over { background: var(--ko-soft); border-color: transparent; }
.time-status.status-warn { background: var(--warn-soft); border-color: transparent; }
/* Mini-fenêtre du minuteur détaché (construite par temps.js). */
body.mini-timer {
  display: grid; gap: 0.4rem; align-content: start; min-height: 0;
  padding: 0.75rem 1rem; background: var(--surface);
}
.mini-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.mini-brand { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); }
.mini-small { min-height: 34px; padding: 0 0.75rem; font-size: 0.85rem; }
.mini-clock { font-size: 2.2rem; }
.mini-status { font-size: 0.85rem; color: var(--muted); }
.mini-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.time-clients { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.time-client { display: grid; gap: 0.35rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: 10px; }
.time-client-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.6rem; }
.time-status { margin-left: auto; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
/* Couleur réservée au sens : dépassement en rouge, bientôt atteint en orange. */
.time-status.status-over { color: var(--ko); }
.time-status.status-warn { color: var(--warn); }
.time-track {
  position: relative; display: block; height: 10px; overflow: hidden;
  border-radius: 5px; background: var(--accent-soft);
}
/* Report du mois précédent : vert hachuré, affiché à part. */
.time-carry {
  position: absolute; top: 0; bottom: 0;
  background: repeating-linear-gradient(
    135deg,
    color-mix(in srgb, var(--cli-fg) 35%, transparent) 0 4px,
    color-mix(in srgb, var(--cli-fg) 12%, transparent) 4px 8px
  );
}
.time-used { position: absolute; top: 0; bottom: 0; left: 0; background: var(--accent); border-radius: 5px; }
.time-used.is-over { background: var(--ko); }
.time-summary, .time-carry-text { margin: 0; font-size: 0.88rem; }
.time-carry-text { color: var(--cli-fg); font-weight: 600; }
.time-releve { justify-self: start; }
.badge-alert { background: var(--warn-soft); color: var(--warn); }
.carry-detail > summary { font-size: 0.88rem; color: var(--muted); }
.carry-months { margin: 0.25rem 0 0; padding-left: 1.2rem; font-size: 0.85rem; }

/* Relevé imprimable */
.releve { max-width: 820px; background: var(--surface); padding: 1.5rem; border-radius: var(--radius); }
.releve-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.5rem; }
.releve-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.releve-head div { display: grid; }
.releve-head strong { font-size: 1.3rem; letter-spacing: 0.06em; }
.releve h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.releve-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.releve-table th, .releve-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.releve-totals { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 0.3rem 1.5rem; }
.releve-totals dt { font-weight: 600; }
.releve-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.releve-foot { margin-top: 2rem; color: var(--muted); font-size: 0.85rem; }

@media print {
  .sidebar, .topbar, .offline-banner, .message, .no-print, .scrim { display: none !important; }
  .workspace { margin: 0 !important; }
  .content { padding: 0; max-width: none; }
  body, .releve { background: #ffffff; color: #000000; }
  .releve { padding: 0; max-width: none; }
}

/* Apparence */
.theme-choices { border: 0; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.theme-card {
  display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 0.75rem;
  min-height: var(--touch);
  padding: 0.75rem 1rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.theme-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-card input { min-height: auto; width: 1.25rem; height: 1.25rem; }
/* Aperçu d'un thème : peint uniquement avec ses propres variables, puisque
 * l'élément porte data-theme (fond, surface, accent, menthe pour Aliris). */
.theme-preview {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 8px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg);
}
.theme-preview i { width: 18px; height: 18px; border-radius: 50%; }
.theme-preview .tp-surface { background: var(--surface); border: 1px solid var(--border); }
.theme-preview .tp-accent { background: var(--accent); }
.theme-preview .tp-mint { background: var(--mint); }

/* ---------- Tablette et plus (768 px) ---------- */

@media (min-width: 48em) {
  .content { padding: 1.5rem 1.5rem 3rem; }
  h1 { font-size: 1.8rem; }
  .card { padding: 1.25rem; }
  #crumb-space { display: block; }
  .profile-name { display: inline; }

  .lights li { grid-template-columns: auto 1fr auto; }
  .light { grid-row: auto; }
  .state { grid-column: auto; }

  .table-cards thead { display: table-header-group; }
  .table-cards tr { display: table-row; margin: 0; padding: 0; border: 0; }
  .table-cards td, .table-cards th {
    display: table-cell;
    padding: 0.5rem;
    text-align: left; vertical-align: top;
    border-bottom: 1px solid var(--border);
  }
  .table-cards th { color: var(--muted); font-weight: 600; }
  .table-cards td::before { content: none; }

  .inline-form { grid-template-columns: minmax(0, 22rem) auto; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .time-top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-cards thead th { background: var(--bg-2); }
  .table-cards thead th:first-child { border-top-left-radius: 8px; }
  .table-cards thead th:last-child { border-top-right-radius: 8px; }
  .funnel { display: flex; gap: 4px; }
  .funnel-step { flex: 1; min-width: 0; border-radius: 0; clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%, 18px 50%); }
  .funnel-step:first-child { clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
  .funnel-step:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 18px 50%); border-radius: 0 8px 8px 0; }
  .agenda-month { display: block; }
  .day-nav { display: none; }
  .home-columns { grid-template-columns: 2fr 1fr; align-items: start; }
  .theme-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .message { left: auto; right: 1.5rem; bottom: 1.5rem; }
}

/* ---------- Bureau (1024 px) : menu toujours visible ---------- */

@media (min-width: 64em) {
  .agenda-layout { grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr); align-items: start; }
  .contacts-layout { grid-template-columns: minmax(0, 2fr) minmax(19rem, 1fr); }
  .contact-preview { display: block; position: sticky; top: 5rem; }
  .sidebar { width: var(--sidebar-width); transform: none; transition: none; }
  .shell.menu-open .sidebar { box-shadow: none; }
  .scrim, .menu-toggle { display: none !important; }
  .workspace { margin-left: var(--sidebar-width); }
  .topbar { padding: 0.5rem 1.75rem; }
  .content { padding: 1.75rem 2rem 3rem; }
}


/* ================= Partie N : composants communs ================= */

/* Fond de page légèrement dégradé. */
body {
  background:
    radial-gradient(1000px 560px at 90% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 62%),
    radial-gradient(800px 500px at 30% 0%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

/* Menu de gauche : dégradé, cercle décoratif en bas, logo à feuille double. */
.sidebar { overflow-x: hidden; }
.sidebar::before {
  content: ""; position: absolute; left: 46px; bottom: -150px;
  width: 320px; height: 230px; border-radius: 50%;
  background: var(--side-glow); pointer-events: none;
}
.sidebar > * { position: relative; }
.logo { width: 34px; height: 34px; flex: none; }
.logo-leaf-a { fill: var(--logo-a); opacity: 0.85; }
.logo-leaf-b { fill: var(--logo-b); }
.nav-list a:hover { background: color-mix(in srgb, var(--on-side) 8%, transparent); }
.nav-list a[aria-current="page"] {
  background:
    radial-gradient(circle at calc(100% - 16px) 50%, var(--mint) 0 2.5px, transparent 3px) no-repeat,
    color-mix(in srgb, var(--surface) 30%, transparent);
  border-color: color-mix(in srgb, var(--on-side) 18%, transparent);
}

/* Barre du haut : date du jour et cloche. */
.topbar-chip {
  display: none; align-items: center; gap: 0.45rem;
  height: 36px; padding: 0 0.75rem;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--muted); font-size: 0.8rem; text-decoration: none;
}
.topbar-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.topbar-bell { position: relative; display: inline-flex; padding: 0 0.6rem; }
.topbar-bell i { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--ko); }

/* Icônes et tuiles d'icônes. */
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.1rem; height: 2.1rem; border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent);
}

/* Menu « Gérer ▾ » commun : ~300 px, titre, actions icône + libellé + aide. */
.manage-menu { width: min(300px, calc(100vw - 2rem)); padding: 0.3rem 0; }
.menu-title {
  margin: 0; padding: 0.55rem 1rem 0.35rem;
  font-size: 0.78rem; font-weight: 700; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu-group + .menu-group { border-top: 1px solid var(--border); margin-top: 0.25rem; padding-top: 0.25rem; }
.menu-group:not(:has(.menu-action:not([hidden]))) { display: none; }
.manage-menu .menu-action {
  display: flex; align-items: center; justify-content: flex-start; gap: 0.7rem;
  width: 100%; min-height: var(--touch); padding: 0.4rem 1rem;
  border: 0; border-radius: 0; background: transparent;
  color: var(--text); font-weight: 400; text-align: left; text-decoration: none; white-space: normal;
}
.manage-menu .menu-action:hover, .manage-menu .menu-action:focus-visible { background: var(--accent-soft); }
.menu-text { display: grid; flex: 1; min-width: 0; text-align: left; }
.menu-label { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.menu-hint { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.manage-menu .menu-action.is-danger { color: var(--ko); }
.menu-action.is-danger .icon-tile { background: var(--ko-soft); color: var(--ko); }
.menu-code {
  flex: none; padding: 0.05rem 0.45rem; border-radius: 999px;
  border: 1px solid currentColor; font-size: 0.7rem; font-weight: 700;
}

/* Cartes chiffrées : chiffre coloré en haut à gauche, icône en tuile en haut à
   droite, dégradé teinté depuis le coin bas droit. Un zéro reste neutre. */
.stat-card {
  --tint: var(--muted);
  position: relative;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "value icon" "label icon" "detail detail";
  column-gap: 0.75rem; row-gap: 0.15rem;
  padding: 1rem 1.1rem; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--tint) 24%, var(--border));
  background:
    radial-gradient(130% 120% at 100% 100%, color-mix(in srgb, var(--tint) 16%, transparent) 0%, transparent 62%),
    var(--surface);
}
.stat-card:hover { border-color: color-mix(in srgb, var(--tint) 50%, var(--border)); }
.stat-value { grid-area: value; color: var(--tint); font-size: 2rem; }
.stat-label { grid-area: label; color: var(--text); }
.stat-detail { grid-area: detail; }
.stat-icon {
  grid-area: icon; align-self: start; margin: 0;
  width: 2.3rem; height: 2.3rem; border-radius: 10px;
  background: color-mix(in srgb, var(--tint) 14%, var(--surface)); color: var(--tint);
}
.tint-late { --tint: var(--ko); }
.tint-today { --tint: var(--warn); }
.tint-pros { --tint: var(--pros-fg); }
.tint-cli { --tint: var(--cli-fg); }
.tint-accent { --tint: var(--accent); }
.stat-card.is-zero { --tint: var(--muted); }
.stat-card.is-zero .stat-value { color: var(--text); }

/* Liens « Voir tout → » : sans soulignement. */
.see-all { text-decoration: none; font-weight: 600; white-space: nowrap; }
.see-all:hover { text-decoration: underline; }

/* Formulaires : champs d'une ligne alignés en haut, même hauteur ; l'aide
   sous le champ ne décale pas le voisin. */
.form-grid { align-items: start; }
input, select { min-height: var(--touch); }
label .hint { display: block; }

/* Listes : tuile d'icône à gauche, pastille d'état à droite. */
.icon-list { list-style: none; margin: 0; padding: 0; }
.icon-list > li {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0; border-bottom: 1px solid var(--border);
}
.icon-list > li:last-child { border-bottom: 0; }
.icon-list .item-text { flex: 1; min-width: 0; display: grid; }
.icon-list .item-text strong { overflow-wrap: anywhere; }
.icon-list .item-text span { font-size: 0.82rem; color: var(--muted); }

@media (min-width: 48em) {
  .topbar-chip { display: inline-flex; }
}

/* Accueil (partie N3) */
.since-card { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; }
.since-text { flex: 1 1 16rem; min-width: 0; }
.since-text h2 { margin: 0; }
.since-text p { margin: 0.15rem 0 0; font-size: 0.85rem; }
.since-pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill-pros { background: var(--pros-bg); color: var(--pros-fg); border-color: transparent; }
.pill-cli { background: var(--cli-bg); color: var(--cli-fg); border-color: transparent; }
.pill-accent, .pill-rendez-vous { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill-tache { background: color-mix(in srgb, var(--muted) 14%, var(--surface)); color: var(--text); border-color: transparent; }
.home-grid { display: grid; gap: 1rem; margin-bottom: 1rem; align-items: start; }
.home-grid > .card { margin: 0; }
.day-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.attention-item.is-late { border-left-color: var(--ko); background: var(--ko-soft); }
.attention-item.is-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.quick-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.quick-tile {
  display: grid; justify-items: center; gap: 0.4rem; padding: 0.85rem 0.5rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--muted); font-size: 0.85rem; text-align: center; text-decoration: none;
}
.quick-tile:hover { border-color: var(--accent); color: var(--text); }
.quick-tile svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 64em) {
  .home-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); }
}

/* CRM (partie N4) */
.count-pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.count-pill { font-size: 0.78rem; padding: 0.1rem 0.55rem; }
.followup-top { flex-wrap: wrap; }
.followup-when { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.followup-who strong { font-weight: 700; }
.contacts-list .table-cards { margin: 0; }
.contacts-list .table-cards td, .contacts-list .table-cards th { padding-left: 1rem; padding-right: 1rem; }

/* Gestion du temps (partie N5) : deux cartes sur le même modèle. */
.time-top { align-items: stretch; }
.time-card { display: flex; flex-direction: column; }
.time-card-body { display: flex; flex-direction: column; gap: 0.75rem; flex: 1; }
.time-card-actions { margin-top: auto; padding-top: 0.25rem; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.timer-clock { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0; }
.note-toggle > summary {
  display: inline-flex; min-height: 0; color: var(--accent); font-weight: 600; font-size: 0.9rem;
  list-style: none;
}
.note-toggle > summary::-webkit-details-marker { display: none; }
.note-toggle[open] > summary { margin-bottom: 0.5rem; }
.hint-lock { display: inline-flex; align-items: center; gap: 0.3rem; }
.hint-lock .icon { width: 14px; height: 14px; }
/* États du minuteur (data-state sur la carte). */
.timer-running-info, .timer-detached-info, .timer-idle-only, .timer-running-only,
.timer-paused-only, .timer-active-only { display: none; }
.time-card[data-state="idle"] .timer-idle-only { display: inline-flex; }
.time-card[data-state="running"] .timer-running-only,
.time-card[data-state="paused"] .timer-paused-only,
.time-card[data-state="running"] .timer-active-only,
.time-card[data-state="paused"] .timer-active-only { display: inline-flex; }
.time-card[data-state="running"] .timer-running-info,
.time-card[data-state="paused"] .timer-running-info { display: flex; }
.time-card:not([data-state="idle"]) .timer-fields { display: none; }
/* Détaché : la carte se réduit au bandeau, chrono en lecture, un seul bouton. */
.time-card[data-state="detached"] .timer-detached-info { display: block; }
.time-card[data-state="detached"] .timer-detached-info { margin: 0; }
/* Mini-fenêtre : boutons de 44 px au moins, lisible dès 320 px. */
body.mini-timer { gap: 0.6rem; padding: 0.75rem; }
.mini-idle { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; }
.mini-active { display: grid; gap: 0.5rem; }
.mini-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.mini-actions .manage > summary { min-width: var(--touch); justify-content: center; }
.mini-small { min-height: var(--touch); }
@media (max-width: 22em) {
  .mini-idle { grid-template-columns: 1fr; }
  .mini-clock { font-size: 1.8rem; }
}
@media (max-width: 30em) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* Technique (partie N6) : onglets, grilles, jauges en demi-cercle. */
.dot-ok { background: var(--ok); display: inline-block; }
.dot-today, .dot-late { display: inline-block; }
#tech-tabs { margin-bottom: 1rem; }
.tech-grid { display: grid; gap: 1rem; margin-bottom: 1rem; align-items: start; }
.tech-grid > .card { margin: 0; }
.tech-note { margin: 0.75rem 0 0; font-size: 0.85rem; }
.tech-legend { margin-top: 0.75rem; }
.gauge-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.gauge-card { margin: 0; display: grid; justify-items: center; gap: 0.25rem; }
.gauge-card h2 { justify-self: start; margin: 0; }
.gauge { width: 120px; height: 68px; }
.gauge path { fill: none; stroke-width: 9; stroke-linecap: round; }
.gauge-track { stroke: color-mix(in srgb, var(--muted) 22%, transparent); }
.gauge-value { stroke: var(--accent); }
.gauge-reading { margin: 0; font-weight: 700; color: var(--muted); }
@media (min-width: 48em) {
  .tech-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gauge-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ================= Partie O : corrections après la revue du 30/11 ================= */

/* O1. Messages : fermables d'un clic (croix), disparition gérée par ui.js. */
.message { display: flex; align-items: flex-start; gap: 0.75rem; cursor: pointer; }
.message[hidden] { display: none !important; }
.message-text { flex: 1; min-width: 0; }
.message-close { flex: none; font-size: 1.2rem; line-height: 1; opacity: 0.7; }
.message:hover .message-close { opacity: 1; }

/* O2. Pastilles d'état : jamais de contour (elles ne sont pas des boutons) ;
   fond teinté seulement quand la valeur compte ; rien de coloré à zéro. */
.pill,
.pill-late, .pill-today, .pill-running, .pill-pros, .pill-cli, .pill-accent,
.pill-rendez-vous, .pill-tache, .time-status { border: 0; }
.pill { color: var(--muted); }
.pill-late { color: var(--ko); }
.pill-today { color: var(--warn); }
.pill-relance { background: var(--warn-soft); color: var(--warn); }
.pill-pros { color: var(--pros-fg); }
.pill-cli { color: var(--cli-fg); }
.pill-accent, .pill-rendez-vous { color: var(--accent); }
.pill-tache { color: var(--text); }
.count-pill:not(.pill-late):not(.pill-today):not(.pill-cli):not(.pill-pros) { background: transparent; padding-left: 0; }
/* État d'un élément : point de couleur + texte. */
.state-label {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.88rem; font-weight: 600; color: var(--muted);
}
.state-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state-running { color: var(--ok); }
.state-paused { color: var(--warn); }

/* O3. Liens : un seul style, sans soulignement, flèche dans le texte. */
a { text-decoration: none; }
a:hover { text-decoration: none; }
.see-all, .back-link, .content p > a:not(.button) { color: var(--accent); font-weight: 600; text-decoration: none; }
.see-all:hover, .back-link:hover, .content p > a:not(.button):hover,
.contact-link:hover .contact-name, .followup-who:hover strong, .attention-item:hover strong {
  text-decoration: none; color: var(--accent);
}
button.danger { text-decoration: none; }

/* O4. Tableaux : séparateur de ligne sur toute la largeur, dernière colonne comprise. */
@media (min-width: 48em) {
  .table-cards td:last-child, .table-cards th:last-child { border-bottom: 1px solid var(--border); }
  .table-cards tbody tr:last-child td { border-bottom: 0; }
}

/* O5. Cartes chiffrées : dégradé marqué depuis le coin bas droit ; à zéro, carte unie. */
:root, [data-theme="aliris"] { --stat-wash: 30%; }
[data-theme="ardoise"] { --stat-wash: 42%; }
.stat-card {
  background:
    radial-gradient(150% 140% at 100% 100%, color-mix(in srgb, var(--tint) var(--stat-wash), transparent) 0%, transparent 68%),
    var(--surface);
}
.stat-card.is-zero { background: var(--surface); border-color: var(--border); }
.stat-card.is-zero .stat-icon { background: color-mix(in srgb, var(--muted) 10%, var(--surface)); color: var(--muted); }

/* Icônes dans une tuile : trait toujours visible (bandeau « Depuis votre dernière connexion »). */
.icon-tile svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* O6. Minuteur : commandes façon lecteur audio. */
.small-button { min-height: 36px; padding: 0 0.8rem; font-size: 0.85rem; font-weight: 600; }
.span-all { grid-column: 1 / -1; }
.player-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 0.5rem; }
.round-button {
  width: var(--touch); height: var(--touch); min-height: var(--touch); padding: 0; flex: none;
  border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--accent);
}
.round-button:hover { background: var(--accent-soft); }
.round-button .icon { width: 20px; height: 20px; }
.round-menu > summary {
  width: var(--touch); height: var(--touch); padding: 0; justify-content: center;
  border-radius: 50%; font-size: 1rem; letter-spacing: 0.05em;
}
.time-card .card-head { margin-bottom: 0.5rem; }
.timer-running-info { gap: 0.5rem; }
.time-card[data-state="running"] .timer-running-info,
.time-card[data-state="paused"] .timer-running-info,
.time-card[data-state="detached"]:not([data-timer="idle"]) .timer-running-info { display: grid; }
/* Carte détachée : rappel du client, de l'activité et du chrono, sans grand vide. */
.time-card[data-state="detached"] .time-card-body { flex: none; }
/* Détachée : les commandes sont masquées par leur état ; seul « Rattacher » reste. */
#temps-quotes { justify-self: end; }

/* Mini-fenêtre : en-tête discret, chrono en grand, une rangée de commandes. */
body.mini-timer .timer-clock { justify-content: flex-start; }
.mini-idle { grid-template-columns: 1fr; }
.mini-idle .round-button { justify-self: start; }
.mini-active { grid-template-columns: 1fr; }
body.mini-timer .small-button { min-height: var(--touch); }

/* O7. Accueil : trois blocs de même hauteur ; accès rapides sur 3 colonnes. */
.home-grid { align-items: stretch; }
/* S8. Accès rapides : 6 tuiles de même hauteur, icône et libellé sur une
   ligne, bloc plus bas (moins de vide dans les blocs voisins). */
/* U1-1 : toujours 2 colonnes (une seule rendait le bloc trop haut) ; tous
   les libellés à 12,5 px (jamais sous 12 px), marges et icônes plus petites ;
   la colonne Accès rapides est un peu élargie, au détriment d'« À votre
   attention », pour que « Nouveau contact » tienne sur une ligne. */
.quick-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 0.3rem; }
.quick-tile {
  display: flex; align-items: center; justify-content: flex-start; gap: 0.4rem;
  height: 100%; padding: 0.2rem 0.5rem; font-size: 12.5px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quick-tile .icon-tile { flex: none; width: 20px; height: 20px; border-radius: 6px; }
.quick-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.quick-tile .icon-tile svg { width: 12px; height: 12px; }
@media (min-width: 64em) {
  .home-grid { grid-template-columns: minmax(0, 1.45fr) minmax(0, 0.85fr) minmax(0, 1.2fr); }
}

/* O9. Comptes : email sous le nom, en gris, sur sa propre ligne. */
.item-text { display: grid; min-width: 0; }
.item-text > span { font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }

/* O10. Filtres des automatisations au-dessus de la liste. */
.filter-pills { margin-bottom: 0.75rem; }
.filter-pills .tab { min-height: 36px; }

/* O11. Agenda : ‹ mois › regroupés, « Aujourd'hui » à part. */
.agenda-nav { justify-content: space-between; }
.month-switch { display: flex; align-items: center; gap: 0.25rem; min-width: 0; }
.agenda-nav .month-switch h2 { flex: none; min-width: 9.5rem; margin: 0; text-align: center; }

/* ================= Partie P : comptes ================= */

/* Lecture seule (invité technique, employé en lecture, technique sur le CRM) :
   formulaires, menus « Gérer ▾ » et boutons d'écriture masqués ; le
   serveur refuse de toute façon toute écriture. */
.page[data-readonly] form,
.page[data-readonly] details.manage,
.page[data-readonly] [data-write],
.page[data-readonly] .followup-actions { display: none !important; }
.account-link { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.account-link p { margin: 0; }
.account-link-row { display: flex; gap: 0.5rem; }
.account-link-row input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.permission-fields { border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; margin: 0; display: grid; gap: 0.5rem; }
.permission-fields legend { padding: 0 0.3rem; font-size: 0.9rem; color: var(--muted); }
@media (min-width: 48em) {
  .permission-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ================= Partie Q : bulles de liens (PC uniquement) ================= */

.home-links {
  display: flex; flex-direction: row-reverse; flex-wrap: wrap; align-content: flex-start;
  gap: 8px; max-width: calc(10 * 36px + 9 * 8px); margin-left: auto;
}
.link-bubble {
  position: relative; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
  color: var(--muted); font-size: 0.72rem; font-weight: 800; letter-spacing: -0.02em;
  text-decoration: none; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.link-bubble svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link-bubble svg.link-logo { width: 17px; height: 17px; fill: currentColor; stroke: none; }
.link-initial { max-width: 30px; overflow: hidden; white-space: nowrap; }
a.link-bubble:hover, a.link-bubble:focus-visible, .link-more-button:hover {
  transform: scale(1.1);
  color: color-mix(in srgb, var(--brand, var(--accent)) 85%, var(--text));
  border-color: color-mix(in srgb, var(--brand, var(--accent)) 55%, var(--border));
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
}
/* Nom au-dessus de la bulle, au survol ou au clavier. */
a.link-bubble::after {
  content: attr(data-name);
  position: absolute; bottom: calc(100% + 6px); left: 50%; z-index: 5;
  transform: translateX(-50%);
  padding: 2px 8px; border-radius: 6px; white-space: nowrap;
  background: var(--text); color: var(--surface); font-size: 0.75rem; font-weight: 600; letter-spacing: 0;
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
a.link-bubble:hover::after, a.link-bubble:focus-visible::after { opacity: 1; }
.link-more { position: relative; }
.link-more > summary { list-style: none; min-height: 0; }
.link-more > summary::-webkit-details-marker { display: none; }
.link-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 25;
  min-width: 14rem; margin: 0; padding: 0.3rem 0; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.link-panel-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0.9rem; color: var(--text); }
.link-panel-item:hover { background: var(--accent-soft); }
.link-bubble-small { width: 28px; height: 28px; font-size: 0.62rem; box-shadow: none; }
.link-bubble-small svg, .link-bubble-small svg.link-logo { width: 15px; height: 15px; }
@media (prefers-reduced-motion: reduce) {
  .link-bubble, a.link-bubble::after { transition: none; }
  a.link-bubble:hover, a.link-bubble:focus-visible, .link-more-button:hover { transform: none; }
}
/* Téléphone : pas de bulles. */
@media (max-width: 47.99em) {
  .home-links { display: none !important; }
}

/* Mon profil : liste réordonnable et formulaire d'ajout. */
.link-rows { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.4rem; }
.link-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.3rem 0.4rem 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: grab;
}
.link-row .item-text { flex: 1; }
.link-row .icon-button:disabled { opacity: 0.35; cursor: default; }
.link-form { display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: 0.6rem; }
.link-preview { display: inline-flex; min-width: 36px; min-height: 44px; align-items: center; }
@media (max-width: 47.99em) {
  .link-form { grid-template-columns: 1fr; }
}

/* ================= Partie R : téléphone (< 768 px), version allégée ================= */

.phone-quick { display: none; }
.desktop-only { max-width: 32rem; }
.desktop-only h1 { font-size: 1.3rem; margin-bottom: 0.5rem; }
@media (max-width: 47.99em) {
  /* Notifications : la cloche reste visible dans la barre du haut. */
  #topbar-bell:not([hidden]) { display: inline-flex; }
  /* La cloche mène aux relances, pas proposées à l'admin sur téléphone. */
  body[data-role="admin"] #topbar-bell { display: none; }
  /* Accueil allégé : depuis la dernière connexion, rendez-vous, relances. */
  #page-accueil .home-quick { display: none; }
  body[data-role="direction"] #home-automations,
  body[data-role="employe"] #home-automations { display: none; }
  /* CRM : pas de vue générale ; contacts en lecture (appel et email en un toucher). */
  #crm-tabs [data-crm-tab="crm"] { display: none; }
  #page-contacts form, #page-contacts details.manage, #page-contacts [data-write] { display: none !important; }
  .phone-quick:not([hidden]) { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
  .phone-quick .button { flex: 1; }
  /* Technique : onglets proposés seulement (vue, automatisations, journal). */
  #tech-tabs [data-tech-tab="comptes"], #tech-tabs [data-tech-tab="serveur"], #tech-tabs [data-tech-tab="rgpd"] { display: none; }
}

/* ================= Partie S : minuteur ================= */

/* S3. « Détacher » en bas à droite, sur la ligne du ▶, bouton plein. */
.player-row .timer-detach { margin-left: auto; }
.timer-activity { margin: 0; }

/* S4-S5. Mini-fenêtre : marges régulières, apparition en douceur. */
body.mini-timer { display: grid; align-content: start; gap: 0.75rem; padding: 0.9rem; }
.mini-attach { min-height: 30px; padding: 0 0.6rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
body.mini-timer .mini-attach { min-height: 30px; }
.mini-idle { display: grid; grid-template-columns: 1fr; gap: 0.6rem; }
.mini-idle > select, .mini-idle > input { width: 100%; animation: mini-appear 0.2s ease both; }
.mini-idle .round-button { justify-self: start; }
.mini-idle .round-button:disabled { opacity: 0.4; cursor: not-allowed; }
.mini-active { display: grid; gap: 0.6rem; }
.mini-client { font-size: 1rem; }
.mini-clock-idle .mini-clock { font-size: 1.3rem; color: var(--muted); font-weight: 600; }
@keyframes mini-appear { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .mini-idle > select, .mini-idle > input { animation: none; }
}

/* S6. Exporter ▾ : recherche des relevés ; tous les relevés, un par page. */
.menu-search { width: 100%; min-height: 36px; margin: 0.2rem 0 0.35rem; }
.releve-sheet + .releve-sheet { margin-top: 2.5rem; padding-top: 2rem; border-top: 1px solid var(--border); }
@media print {
  .releve-sheet + .releve-sheet { margin-top: 0; padding-top: 0; border-top: 0; break-before: page; }
}

/* S7. Bulles : glisser-déposer sur l'accueil (la bulle se soulève). */
.home-links a.link-bubble { touch-action: none; user-select: none; -webkit-user-drag: none; }
.home-links.is-sorting a.link-bubble { cursor: grabbing; }
.home-links.is-sorting a.link-bubble::after { opacity: 0; }
.home-links a.link-bubble.is-lifted {
  transform: scale(1.18) translateY(-3px); z-index: 6;
  box-shadow: 0 8px 20px rgb(0 0 0 / 0.25);
  color: color-mix(in srgb, var(--brand, var(--accent)) 85%, var(--text));
}
@media (prefers-reduced-motion: reduce) {
  .home-links a.link-bubble.is-lifted { transform: none; }
}

/* S9. Aperçu d'un client sans relance : gris neutre (orange : prospect seulement). */
.preview-follow-up.is-neutral { background: color-mix(in srgb, var(--muted) 8%, var(--surface)); border-color: var(--border); color: var(--muted); }

/* S10. Comptes : accès en point de couleur ; aide ⓘ en bulle. */
.state-ko { color: var(--ko); }
.access-cell { display: inline-flex; flex-wrap: wrap; align-items: center; }
.info-tip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 1.3rem; height: 1.3rem; border-radius: 50%; cursor: help;
  color: var(--accent); font-style: normal; font-weight: 700; vertical-align: middle;
}
.info-bubble {
  position: absolute; bottom: calc(100% + 6px); right: -0.5rem; z-index: 20;
  width: max-content; max-width: 18rem; padding: 0.5rem 0.7rem; border-radius: 8px;
  background: var(--text); color: var(--surface); font-size: 0.8rem; font-weight: 500; line-height: 1.4;
  opacity: 0; visibility: hidden; transition: opacity 0.15s ease;
}
.info-bubble code { color: inherit; }
.info-tip:hover .info-bubble, .info-tip:focus-visible .info-bubble { opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: reduce) { .info-bubble { transition: none; } }

/* ================= S12 : téléphone, lignes compactes ================= */

.date-short { display: none; }
@media (max-width: 47.99em) {
  .date-long { display: none; }
  .date-short { display: inline; }

  /* Votre journée et journal : une ligne par élément, pas de fiche
     étiquette/valeur (« 15:30  entretien · Guénard Alex  [Tâche] »). */
  #day-table tr, #journal-table tr {
    display: flex; align-items: center; gap: 0.5rem;
    margin: 0; padding: 0.5rem 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  }
  #day-table tbody tr:last-child, #journal-table tbody tr:last-child { border-bottom: 0; }
  #day-table td, #journal-table td { display: block; padding: 0; border: 0; min-width: 0; }
  #day-table td::before, #journal-table td::before { content: none; }
  #day-table td:nth-child(1), #journal-table td:nth-child(1) {
    flex: none; font-variant-numeric: tabular-nums; font-size: 0.82rem; color: var(--muted);
  }
  #day-table td:nth-child(2), #journal-table td:nth-child(3) {
    flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #day-table td:nth-child(3) { flex: none; }
  /* Journal : date, action · auteur, [type]. */
  #journal-table td:nth-child(1) { order: 1; }
  #journal-table td:nth-child(3) { order: 2; flex: 0 1 auto; }
  #journal-table td:nth-child(4) {
    order: 3; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted);
  }
  #journal-table td:nth-child(4)::before { content: "· "; }
  #journal-table td:nth-child(2) { order: 4; flex: none; }

  /* Prochains événements : « date  texte  [type] » sur une ligne, sans icône. */
  #upcoming-list > li { gap: 0.5rem; padding: 0.5rem 0; }
  #upcoming-list .icon-tile { display: none; }
  #upcoming-list .item-text { display: flex; gap: 0.5rem; align-items: baseline; }
  #upcoming-list .item-text strong { flex: none; font-size: 0.82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
  #upcoming-list .item-text span { flex: 1; min-width: 0; font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Relances : une ligne par relance, « ✓ Fait » au bout. */
  #relances-groups .followups { gap: 0; }
  #relances-groups .followup {
    flex-wrap: nowrap; gap: 0.5rem; padding: 0.5rem 0;
    border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  }
  #relances-groups .followup:last-child { border-bottom: 0; }
  #relances-groups .followup-main { flex: 1; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
  #relances-groups .followup-when { order: -1; flex: none; flex-wrap: nowrap; }
  #relances-groups .followup-what, #relances-groups .followup-top .badge { display: none; }
  #relances-groups .followup-top { flex: 1; min-width: 0; flex-wrap: nowrap; }
  #relances-groups .followup-who { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #relances-groups .followup-actions .manage { display: none; }

  /* Accueil de la direction : 4 petits chiffres cliquables, sans icône ni
     dégradé (relances en retard, du jour, aujourd'hui, heures du mois). */
  #page-accueil .home-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; margin-bottom: 0.75rem; }
  #page-accueil .home-stats .stat-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
    min-width: 0; padding: 0.45rem 0.2rem; border-radius: 10px; text-align: center;
    background: var(--surface); border: 1px solid var(--border);
  }
  #page-accueil .home-stats .stat-icon, #page-accueil .home-stats .stat-detail,
  #page-accueil .home-stats .stat-label { display: none; }
  #page-accueil .home-stats .stat-value { font-size: 1.15rem; line-height: 1.2; white-space: nowrap; }
  #page-accueil .home-stats .stat-card::after {
    content: attr(data-short); font-size: 0.68rem; line-height: 1.2; color: var(--muted);
  }
}

/* ================= T1 : notes personnelles ================= */

.notes-layout { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 64em) {
  .notes-layout { grid-template-columns: minmax(16rem, 0.75fr) minmax(0, 1.6fr); }
}
.notes-side { display: grid; gap: 0.6rem; margin: 0; }
.notes-side input[type="search"] { width: 100%; }
.notes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.note-item {
  display: flex; align-items: center; gap: 0.75rem; width: 100%;
  padding: 0.75rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); text-align: left; font-weight: 400;
}
.note-item:hover { border-color: var(--accent); background: var(--surface); }
.note-item[aria-current="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.note-item .item-text { display: grid; min-width: 0; }
.note-item strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item .item-text span { font-size: 0.82rem; color: var(--muted); }
.notes-main { margin: 0; min-height: 24rem; }
.note-editor { display: grid; gap: 0.75rem; }
.note-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.note-head-text { flex: 1; min-width: 0; }
.note-title {
  width: 100%; border: 0; padding: 0; background: transparent; color: var(--text);
  font-size: 1.35rem; font-weight: 700;
}
.note-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.note-meta { margin: 0.2rem 0 0; font-size: 0.82rem; }
#note-delete { display: inline-flex; align-items: center; gap: 0.35rem; flex: none; }
#note-delete .icon { width: 15px; height: 15px; }
.note-body { min-height: 20rem; border: 0; padding: 0; background: transparent; line-height: 1.6; }
.note-body:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ================= T2 : statistiques ================= */

/* Teintes catégorielles dans un ordre fixe (palette validée en clair et en sombre). */
:root, [data-theme="aliris"] {
  --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-4: #eda100; --viz-5: #e87ba4; --viz-other: #9a9a94;
}
[data-theme="ardoise"] {
  --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500; --viz-5: #d55181; --viz-other: #7d8aa0;
}
.viz-1 { --viz: var(--viz-1); } .viz-2 { --viz: var(--viz-2); } .viz-3 { --viz: var(--viz-3); }
.viz-4 { --viz: var(--viz-4); } .viz-5 { --viz: var(--viz-5); } .viz-other { --viz: var(--viz-other); }

.stats-periods { display: inline-flex; gap: 0.25rem; padding: 0.25rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.stats-grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.stats-grid > .card { margin: 0; }
@media (min-width: 64em) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stats-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; }
.stats-ring-wrap { position: relative; width: 9rem; height: 9rem; flex: none; }
.stats-ring { width: 100%; height: 100%; }
.stats-ring-part { fill: none; stroke: var(--viz); stroke-width: 5; }
.stats-ring-part:hover { stroke-width: 6; }
.stats-ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.stats-ring-center strong { font-size: 1.5rem; line-height: 1; }
.stats-ring-center span { font-size: 0.75rem; color: var(--muted); }
.stats-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; flex: 1; min-width: 12rem; }
.stats-legend li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: 0.9rem; }
.stats-legend-label { display: inline-flex; align-items: center; gap: 0.45rem; min-width: 0; }
.stats-legend-value { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.stats-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--viz); }
.stats-legend-inline { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; margin: 0.5rem 0 0.75rem; }
.stats-bars, .stats-hours-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.stats-bar-row { display: grid; grid-template-columns: minmax(6rem, 9rem) minmax(0, 1fr) auto; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.stats-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-track { height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--muted) 14%, var(--surface)); overflow: hidden; }
.stats-bar { display: block; height: 100%; border-radius: 4px; background: var(--viz, var(--accent)); }
.stats-bar-stage { --viz: var(--accent); }
.stats-bar-clients { --viz: var(--cli-fg); }
.stats-bar-value { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3.5rem; text-align: right; }
.stats-hours { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.stats-hours-name { margin: 0 0 0.3rem; }
.stats-hours-bars .stats-bar-row { grid-template-columns: 5rem minmax(0, 1fr) auto; font-size: 0.85rem; }

/* U0-8 : défauts vus dans Chrome. Titre de note aligné à gauche (les boutons
   centrent leur contenu par défaut) ; champs d'une grille à deux colonnes
   qui ne débordent plus sur leur voisin (liste des clients du minuteur). */
.note-item { justify-content: flex-start; }
.form-grid-2 > * { min-width: 0; }
.form-grid-2 select, .form-grid-2 input { width: 100%; min-width: 0; }
