/* =============================================================================
   A17 CRM - Design system (app.css)
   Proprietaire : agent Design system. Documentation : docs/DESIGN_SYSTEM.md.
   Regles : mobile-first, aucune ressource externe (CSP stricte), contrastes AA verifies par
   tests/Ui/ContrastTest.php (les jetons --c-* de ce fichier sont lus par le test).
   Plan : 1 jetons - 2 base - 3 coque - 4 composants - 5 auth/erreurs - 6 utilitaires - 7 compatibilite MVP-0
   ============================================================================= */

/* ---------- Polices locales (OFL, voir fonts/OFL-*.txt) ---------- */
@font-face { font-family: "Inter"; src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("/assets/fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("/assets/fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

/* ---------- 1. Jetons ---------- */
:root {
  color-scheme: light; /* pas de mode sombre : choix assume (voir docs/DESIGN_SYSTEM.md) */

  /* Neutres : anthracite et creme (releves sur le site V4) */
  --c-ink: #20201e;          /* anthracite : texte, coque */
  --c-ink-2: #2d2c29;        /* anthracite releve : survol de la coque */
  --c-ivory: #f5f2ec;        /* fond de page */
  --c-surface: #ffffff;      /* cartes, champs */
  --c-surface-2: #faf8f4;    /* fonds secondaires (en-tetes de tableau, zones) */
  --c-sand: #e7e0d5;
  --c-line: #dad3c6;         /* filets decoratifs */
  --c-line-strong: #8a8378;  /* bordures de champs (>= 3:1 sur blanc) */
  --c-text: #20201e;
  --c-text-muted: #5a554d;

  /* Accent : cuivre */
  --c-accent: #8c4a28;
  --c-accent-hover: #733a1d;
  --c-accent-soft: #f3e4d8;
  --c-accent-lite: #e0a47c;  /* accent sur fond sombre */
  --c-on-accent: #ffffff;

  /* Couleurs semantiques de statut : fond (-bg), texte (-fg), filet (-bd) */
  --c-neutral-bg: #ece8e0;  --c-neutral-fg: #3f3b35;  --c-neutral-bd: #cfc8bb;
  --c-info-bg: #e4ecf4;     --c-info-fg: #1f4568;     --c-info-bd: #b5c9dc;
  --c-progress-bg: #f3e4d8; --c-progress-fg: #7a3d1c; --c-progress-bd: #dfbfa6;
  --c-attention-bg: #fbefd0; --c-attention-fg: #6b4600; --c-attention-bd: #e5cb8a;
  --c-success-bg: #e1f0e5;  --c-success-fg: #1b5a33;  --c-success-bd: #a9d1b6;
  --c-danger-bg: #f8e3df;   --c-danger-fg: #8f2417;   --c-danger-bd: #e4b0a8;
  --c-closed-bg: #f0eeea;   --c-closed-fg: #5a554d;   --c-closed-bd: #cfc8bb;

  --c-focus: #8c4a28;        /* anneau de focus (>= 3:1 sur creme, blanc) */
  --c-focus-dark: #e0a47c;   /* anneau de focus sur fond anthracite */

  /* Typographie */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Cormorant Garamond", "Iowan Old Style", Palatino, Georgia, serif;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-base: .9375rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 2rem; --fs-3xl: 2.75rem;
  --lh-tight: 1.2; --lh-base: 1.55;

  /* Espacement (echelle de 4px) */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem; --s-8: 4rem;

  /* Rayons, ombres sobres, mouvement */
  --r-sm: .25rem; --r-md: .5rem; --r-lg: .75rem; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(32, 32, 30, .06);
  --sh-2: 0 8px 28px rgba(32, 32, 30, .16);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: .16s;

  /* Mesures */
  --tap: 2.75rem;              /* cible tactile minimale : 44px */
  --sidebar-w: 15rem; --sidebar-w-collapsed: 4.5rem; --topbar-h: 3.5rem;
  --content-max: 76rem;

  /* Alias historiques (modules MVP-0) : ne pas utiliser dans le code neuf */
  --bg: var(--c-ivory); --fg: var(--c-text); --muted: var(--c-text-muted); --card: var(--c-surface);
  --line: var(--c-line); --accent: var(--c-accent); --accent-fg: var(--c-on-accent);
  --err: var(--c-danger-fg); --ok: var(--c-success-fg); --info: var(--c-info-fg);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 1rem); }
body { margin: 0; font: 400 var(--fs-base)/var(--lh-base) var(--font-sans); background: var(--c-ivory); color: var(--c-text); min-height: 100vh; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
[hidden] { display: none !important; }
img, svg { max-width: 100%; }
a { color: var(--c-accent); text-underline-offset: .15em; }
a:hover { color: var(--c-accent-hover); }
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); color: var(--c-text); }
h1 { font: 600 var(--fs-2xl)/1.1 var(--font-serif); letter-spacing: -.005em; margin-bottom: var(--s-4); }
h2 { font: 600 var(--fs-lg)/var(--lh-tight) var(--font-sans); margin: var(--s-5) 0 var(--s-2); }
h3 { font: 600 var(--fs-base)/var(--lh-tight) var(--font-sans); margin: var(--s-4) 0 var(--s-2); }
p { margin: 0 0 var(--s-3); }
hr { border: 0; border-top: 1px solid var(--c-line); margin: var(--s-5) 0; }
small { font-size: var(--fs-sm); }
code, kbd { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; }
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--c-accent-soft); }
.muted { color: var(--c-text-muted); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: var(--s-3); top: -4rem; z-index: 300; background: var(--c-ink); color: #fff; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); text-decoration: none; font-weight: 600; transition: top var(--dur) var(--ease); }
.skip-link:focus { top: var(--s-3); color: #fff; outline-color: var(--c-focus-dark); }

.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.icon-sm { width: 1rem; height: 1rem; }
.icon-lg { width: 1.75rem; height: 1.75rem; }

/* ---------- 3. Coque applicative ---------- */
.shell { display: block; min-height: 100vh; }
.shell-main { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

/* Barre superieure */
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: var(--s-2); height: var(--topbar-h); padding: 0 var(--s-3); background: var(--c-surface); border-bottom: 1px solid var(--c-line); }
.topbar-menu { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: var(--r-md); color: var(--c-text); background: none; border: 0; cursor: pointer; text-decoration: none; }
.topbar-menu:hover { background: var(--c-surface-2); color: var(--c-text); }
.topbar-brand { display: inline-flex; align-items: center; min-height: var(--tap); font: 600 1.35rem/1 var(--font-serif); color: var(--c-text); text-decoration: none; white-space: nowrap; }
.topbar-brand:hover { color: var(--c-text); }
.topbar-spacer { flex: 1; }
.quicksearch { position: relative; flex: 100 1 auto; max-width: 28rem; margin: 0; display: none; }
.quicksearch .icon { position: absolute; left: .75rem; top: 50%; translate: 0 -50%; color: var(--c-text-muted); pointer-events: none; }
.quicksearch input { padding-left: 2.5rem; padding-right: 2.75rem; background: var(--c-surface-2); border-color: var(--c-line-strong); }
.quicksearch kbd { position: absolute; right: .6rem; top: 50%; translate: 0 -50%; font-size: var(--fs-xs); border: 1px solid var(--c-line-strong); border-bottom-width: 2px; border-radius: var(--r-sm); padding: 0 .4rem; color: var(--c-text-muted); background: var(--c-surface); pointer-events: none; }
.topbar-search-link { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: var(--r-md); color: var(--c-text); }
.topbar-search-link:hover { background: var(--c-surface-2); color: var(--c-text); }

/* Menu utilisateur (details natif : fonctionne sans JS) */
.usermenu { position: relative; }
.usermenu > summary { list-style: none; display: flex; align-items: center; gap: var(--s-2); min-height: var(--tap); padding: 0 var(--s-2); border-radius: var(--r-md); cursor: pointer; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover { background: var(--c-surface-2); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--c-ink); color: var(--c-ivory); font-size: var(--fs-sm); font-weight: 600; flex: none; }
.usermenu-name { display: none; font-weight: 500; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-panel { position: absolute; right: 0; top: calc(100% + .25rem); z-index: 60; min-width: 15rem; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--sh-2); padding: var(--s-2); }
.usermenu-id { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--c-line); margin-bottom: var(--s-2); }
.usermenu-id strong { display: block; overflow-wrap: anywhere; }
.usermenu-id span { color: var(--c-text-muted); font-size: var(--fs-sm); }
.usermenu-panel a, .usermenu-panel button { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: var(--tap); padding: 0 var(--s-3); border: 0; border-radius: var(--r-sm); background: none; font: inherit; color: var(--c-text); text-decoration: none; cursor: pointer; text-align: left; }
.usermenu-panel a:hover, .usermenu-panel button:hover { background: var(--c-surface-2); color: var(--c-text); }
.usermenu-panel form { margin: 0; }

/* Navigation laterale : tiroir sur mobile (sans JS : ancre :target), fixe sur ordinateur */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 100; width: min(18rem, 86vw); display: flex; flex-direction: column; background: var(--c-ink); color: #e9e4da; transform: translateX(-102%); visibility: hidden; transition: transform .22s var(--ease), visibility 0s linear .22s; overflow-y: auto; overscroll-behavior: contain; }
.sidebar:target, .sidebar.is-open { transform: none; visibility: visible; transition: transform .22s var(--ease); box-shadow: var(--sh-2); }
.sidebar :focus-visible { outline-color: var(--c-focus-dark); }
.sidebar-scrim { position: fixed; inset: 0; z-index: 90; background: rgba(20, 20, 18, .5); display: none; }
.sidebar:target ~ .sidebar-scrim, .sidebar.is-open ~ .sidebar-scrim { display: block; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-4) var(--s-4) var(--s-3); }
.brand { display: block; color: #fff; text-decoration: none; font: 600 1.55rem/1 var(--font-serif); letter-spacing: .005em; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand-sub { display: block; font: 600 .6875rem/1 var(--font-sans); letter-spacing: .24em; text-transform: uppercase; color: var(--c-accent-lite); margin-top: .4rem; }
.brand-mark { display: none; }
.sidebar-close { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: var(--r-md); color: #e9e4da; background: none; border: 0; cursor: pointer; text-decoration: none; }
.sidebar-close:hover { background: var(--c-ink-2); color: #fff; }
.sidebar nav { padding: var(--s-2) var(--s-3) var(--s-4); flex: 1; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); padding: 0 var(--s-3); border-radius: var(--r-md); color: #d6d0c4; text-decoration: none; font-weight: 500; position: relative; }
.nav a:hover { background: var(--c-ink-2); color: #fff; }
.nav a[aria-current="page"] { background: rgba(245, 242, 236, .1); color: #fff; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -.75rem; top: .6rem; bottom: .6rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--c-accent-lite); }
.nav-group { margin: var(--s-4) 0 var(--s-1); padding: 0 var(--s-3); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #b9b2a4; }
.sidebar-foot { padding: var(--s-3) var(--s-4) var(--s-4); border-top: 1px solid rgba(245, 242, 236, .12); font-size: var(--fs-xs); color: #b9b2a4; }
.sidebar-collapse { display: none; }

.main { flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s-4) var(--s-4) var(--s-6); }
.main:focus { outline: none; }
.site-footer { text-align: center; padding: var(--s-4); color: var(--c-text-muted); font-size: var(--fs-sm); }

/* Page sans coque (connexion, erreurs anonymes) */
.body-bare { background: var(--c-ivory); }

@media (min-width: 48rem) {
  .quicksearch { display: block; }
  .topbar-search-link { display: none; }
  .quicksearch { min-width: 16rem; }
  .topbar { padding: 0 var(--s-5); }
  .main { padding: var(--s-5) var(--s-5) var(--s-7); }
}
@media (min-width: 64rem) {
  .usermenu-name { display: inline; }
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; height: 100vh; width: auto; transform: none; visibility: visible; box-shadow: none; z-index: 50; }
  .sidebar:target, .sidebar.is-open { box-shadow: none; }
  .sidebar-scrim, .sidebar:target ~ .sidebar-scrim { display: none; }
  .sidebar-close, .topbar-menu, .topbar-brand { display: none; }
  .js .sidebar-collapse { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: var(--tap); padding: 0 var(--s-3); margin-top: var(--s-2); border: 0; border-radius: var(--r-md); background: none; color: #b9b2a4; font: inherit; font-size: var(--fs-sm); cursor: pointer; }
  .sidebar-collapse:hover { background: var(--c-ink-2); color: #fff; }
  html[data-nav="collapsed"] .shell { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  html[data-nav="collapsed"] .sidebar-head { justify-content: center; padding-inline: var(--s-2); }
  html[data-nav="collapsed"] .brand-full, html[data-nav="collapsed"] .brand-sub { display: none; }
  html[data-nav="collapsed"] .brand-mark { display: inline; }
  html[data-nav="collapsed"] .nav a { justify-content: center; padding: 0; }
  html[data-nav="collapsed"] .nav-label, html[data-nav="collapsed"] .sidebar-foot, html[data-nav="collapsed"] .nav-group { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  html[data-nav="collapsed"] .sidebar nav { padding-inline: var(--s-2); }
  html[data-nav="collapsed"] .js .sidebar-collapse, html[data-nav="collapsed"] .sidebar-collapse { justify-content: center; padding: 0; }
  html[data-nav="collapsed"] .sidebar-collapse .icon { rotate: 180deg; }
  html[data-nav="collapsed"] .nav a[aria-current="page"]::before { left: -.5rem; }
}

/* ---------- 4. Composants ---------- */

/* 4.1 Boutons : .btn (secondaire par defaut), .btn-primary, .btn-danger, .btn-ghost, .btn-sm, .btn-block */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); font: 500 var(--fs-base)/1.2 var(--font-sans); min-height: var(--tap); padding: .5rem 1.1rem; border: 1px solid var(--c-line-strong); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text); text-decoration: none; cursor: pointer; transition: background-color var(--dur), border-color var(--dur), color var(--dur); -webkit-appearance: none; appearance: none; text-align: center; }
.btn:hover { background: var(--c-surface-2); border-color: var(--c-text); color: var(--c-text); }
.btn:active { background: var(--c-sand); }
.btn-primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.btn-primary:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); color: var(--c-on-accent); }
.btn-primary:active { background: #5f2f17; }
.btn-danger { background: var(--c-danger-fg); border-color: var(--c-danger-fg); color: #fff; }
.btn-danger:hover { background: #721b11; border-color: #721b11; color: #fff; }
.btn-ghost, .btn-link { background: transparent; border-color: transparent; color: var(--c-accent); }
.btn-ghost:hover, .btn-link:hover { background: var(--c-accent-soft); border-color: transparent; color: var(--c-accent-hover); }
.btn-link { text-decoration: underline; padding-inline: .5rem; }
.btn-sm { min-height: var(--tap); padding: .35rem .8rem; font-size: var(--fs-sm); }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
@media (min-width: 64rem) { .btn-sm { min-height: 2.25rem; } }

/* 4.2 Champs et formulaires */
label { display: block; font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--s-1); }
input, select, textarea { width: 100%; font: inherit; font-size: var(--fs-md); padding: .55rem .75rem; min-height: var(--tap); border: 1px solid var(--c-line-strong); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text); -webkit-appearance: none; appearance: none; }
input::placeholder, textarea::placeholder { color: #6e685e; opacity: 1; }
textarea { min-height: 7rem; resize: vertical; line-height: var(--lh-base); }
select { padding-right: 2.25rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a554d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .6rem center; background-size: 1.1rem; }
input:hover, select:hover, textarea:hover { border-color: var(--c-text); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 1px; border-color: var(--c-text); }
input[disabled], select[disabled], textarea[disabled], input[readonly] { background: var(--c-surface-2); color: var(--c-text-muted); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: 1.25rem; height: 1.25rem; min-height: 0; padding: 0; accent-color: var(--c-accent); -webkit-appearance: auto; appearance: auto; flex: none; }
input[type="file"] { padding: .4rem; }
@media (min-width: 48rem) { input, select, textarea { font-size: var(--fs-base); } }

.field { margin-bottom: var(--s-4); }
.field-hint, .hint { margin: var(--s-1) 0 0; color: var(--c-text-muted); font-size: var(--fs-sm); }
.field-error, .err { margin: var(--s-1) 0 0; color: var(--c-danger-fg); font-size: var(--fs-sm); font-weight: 600; }
.field.has-error input, .field.has-error select, .field.has-error textarea, .has-error input, .has-error select, .has-error textarea { border-color: var(--c-danger-fg); border-width: 2px; }
.req { color: var(--c-danger-fg); }
.form-grid, .grid2 { display: grid; grid-template-columns: 1fr; gap: 0 var(--s-4); }
.form-narrow { max-width: 36rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--c-line); }
fieldset.group { border: 1px solid var(--c-line); border-radius: var(--r-md); padding: var(--s-3) var(--s-4) var(--s-2); margin: 0 0 var(--s-4); min-width: 0; }
fieldset.group > legend { font-weight: 600; font-size: var(--fs-sm); padding: 0 var(--s-2); }
.field.check, .check-field { display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); }
.field.check label, .check-field label { margin: 0; font-weight: 400; font-size: var(--fs-base); }
label.check { display: flex; align-items: center; gap: var(--s-3); font-weight: 400; font-size: var(--fs-base); min-height: var(--tap); margin: 0; }
.error-summary { border: 2px solid var(--c-danger-fg); border-radius: var(--r-md); background: var(--c-danger-bg); color: var(--c-danger-fg); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4); }
.error-summary h2 { margin: 0 0 var(--s-2); font-size: var(--fs-md); color: inherit; }
.error-summary ul { margin: 0; padding-left: 1.2rem; }
.error-summary a { color: inherit; font-weight: 600; }
@media (min-width: 40rem) { .form-grid, .grid2 { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: 1 / -1; } }

/* 4.3 Cartes et panneaux */
.card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: var(--s-4); box-shadow: var(--sh-1); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-3); }
.card-head h2, .card-head h3 { margin: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card--flush > .card-head { padding: var(--s-4) var(--s-4) 0; }
.card--muted { background: var(--c-surface-2); box-shadow: none; }
.card--warn { border-color: var(--c-attention-bd); background: var(--c-attention-bg); }
.cards-grid { display: grid; gap: var(--s-4); grid-template-columns: 1fr; }
section.card { margin-bottom: var(--s-4); }
@media (min-width: 48rem) { .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .card { padding: var(--s-5); } .card--flush { padding: 0; } }

/* 4.4 En-tete de page et fil d'Ariane */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-4); }
.page-head h1, .page-head .page-title { margin: 0; }
.page-head .page-title { font: 600 var(--fs-2xl)/1.1 var(--font-serif); }
.page-head .page-sub { margin: var(--s-1) 0 0; color: var(--c-text-muted); }
.page-head .actions { margin: 0; }
.breadcrumb { margin: 0 0 var(--s-1); font-size: var(--fs-sm); }
.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s-1); }
.breadcrumb li { display: inline-flex; align-items: center; }
.breadcrumb li + li::before { content: "/"; margin-right: var(--s-1); color: var(--c-text-muted); }
.breadcrumb a { color: var(--c-text-muted); display: inline-block; padding: .75rem .25rem; }
.breadcrumb a:hover { color: var(--c-accent-hover); }
.breadcrumb [aria-current="page"] { color: var(--c-text); font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.actions form { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }

/* 4.5 Pastilles de statut (.pill) et badges (.badge) : definitions dans templates/_components/_statuses.php */
.pill { display: inline-flex; align-items: center; gap: .4rem; padding: .15rem .65rem .15rem .55rem; border-radius: var(--r-pill); border: 1px solid var(--c-neutral-bd); background: var(--c-neutral-bg); color: var(--c-neutral-fg); font-size: var(--fs-sm); font-weight: 600; line-height: 1.4; white-space: nowrap; vertical-align: middle; }
.pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; flex: none; }
.pill--info { background: var(--c-info-bg); color: var(--c-info-fg); border-color: var(--c-info-bd); }
.pill--progress { background: var(--c-progress-bg); color: var(--c-progress-fg); border-color: var(--c-progress-bd); }
.pill--attention { background: var(--c-attention-bg); color: var(--c-attention-fg); border-color: var(--c-attention-bd); }
.pill--success { background: var(--c-success-bg); color: var(--c-success-fg); border-color: var(--c-success-bd); }
.pill--danger { background: var(--c-danger-bg); color: var(--c-danger-fg); border-color: var(--c-danger-bd); }
.pill--closed { background: var(--c-closed-bg); color: var(--c-closed-fg); border-color: var(--c-closed-bd); }
.pill--closed::before { background: transparent; border: 2px solid currentColor; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .55rem; border-radius: var(--r-sm); border: 1px solid var(--c-neutral-bd); background: var(--c-neutral-bg); color: var(--c-neutral-fg); font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; vertical-align: middle; white-space: nowrap; }
.badge--high, .badge-high { background: var(--c-attention-bg); color: var(--c-attention-fg); border-color: var(--c-attention-bd); }
.badge--duplicate { background: var(--c-progress-bg); color: var(--c-progress-fg); border-color: var(--c-progress-bd); }
.badge--late, .badge-late { background: var(--c-danger-bg); color: var(--c-danger-fg); border-color: var(--c-danger-bd); }
.badge--low { background: var(--c-surface); color: var(--c-text-muted); }
.badge--count { border-radius: var(--r-pill); min-width: 1.5rem; justify-content: center; }
.chips { list-style: none; padding: 0; margin: 0 0 var(--s-3); display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chips li { background: var(--c-neutral-bg); color: var(--c-neutral-fg); border-radius: var(--r-pill); padding: .1rem .7rem; font-size: var(--fs-sm); }

/* 4.6 Tableaux denses ; version carte sur mobile avec .table--cards + data-label sur chaque td */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table, .table { border-collapse: collapse; width: 100%; background: var(--c-surface); font-size: var(--fs-base); }
th, td { text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--c-line); vertical-align: top; }
thead th { background: var(--c-surface-2); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); white-space: nowrap; border-bottom: 1px solid var(--c-line-strong); }
thead th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; min-height: 1.5rem; }
thead th a:hover { color: var(--c-text); }
tbody tr:hover { background: var(--c-surface-2); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody th { font-weight: 500; font-size: inherit; text-transform: none; letter-spacing: 0; color: inherit; background: none; }
.table .num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { text-align: right; white-space: nowrap; }
.table .cell-main { font-weight: 600; }
.table .cell-sub { display: block; color: var(--c-text-muted); font-size: var(--fs-sm); }
@media (max-width: 47.99rem) {
  .table--cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td, .table--cards th { display: block; width: 100%; }
  .table--cards { background: none; }
  .table--cards tr { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); margin-bottom: var(--s-3); padding: var(--s-2) var(--s-3); box-shadow: var(--sh-1); }
  .table--cards td, .table--cards th { position: relative; border: 0; padding: .35rem 0 .35rem 7.75rem; min-height: 1.9rem; text-align: left; overflow-wrap: anywhere; }
  .table--cards td::before, .table--cards th[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: .5rem; width: 7.25rem; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-muted); line-height: 1.5; }
  .table--cards td.col-actions { text-align: left; display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-2) 0 .35rem; }
  .table--cards td.col-actions::before { content: none; }
  .table--cards .num { text-align: left; }
  .table--cards tbody tr:hover { background: var(--c-surface); }
}

/* 4.7 Onglets (liens : fonctionnent sans JS) */
.tabs { display: flex; gap: var(--s-1); overflow-x: auto; border-bottom: 1px solid var(--c-line); margin-bottom: var(--s-4); -webkit-overflow-scrolling: touch; }
.tabs a { display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap); padding: 0 var(--s-4); color: var(--c-text-muted); text-decoration: none; font-weight: 500; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--c-text); background: var(--c-surface-2); }
.tabs a[aria-current="page"] { color: var(--c-text); border-bottom-color: var(--c-accent); font-weight: 600; }

/* 4.8 Liste d'activite (timeline) : ol.timeline > li */
.timeline, .rel, .history { list-style: none; padding: 0; margin: 0 0 var(--s-4); }
.timeline > li { position: relative; padding: 0 0 var(--s-4) 1.75rem; margin: 0; border: 0; }
.timeline > li::before { content: ""; position: absolute; left: .45rem; top: 1.35rem; bottom: -.1rem; width: 1px; background: var(--c-line); }
.timeline > li:last-child::before { display: none; }
.timeline > li::after { content: ""; position: absolute; left: 0; top: .3rem; width: .95rem; height: .95rem; border-radius: 50%; background: var(--c-surface); border: 2px solid var(--c-line-strong); }
.timeline > li.is-note::after { border-color: var(--c-accent); }
.timeline > li.is-system::after { border-color: var(--c-info-fg); }
.timeline > li.is-done::after { border-color: var(--c-success-fg); background: var(--c-success-fg); }
.timeline-title { font-weight: 600; margin: 0; }
.timeline-meta, .timeline .meta { color: var(--c-text-muted); font-size: var(--fs-sm); margin: 0; }
.timeline-body, .timeline p { margin: var(--s-1) 0 0; }
.rel li { padding: var(--s-2) 0; border-bottom: 1px solid var(--c-line); }
.history { padding-left: 1.2rem; list-style: disc; }
.history li { margin-bottom: var(--s-1); }

/* 4.9 Barre de filtres, recherche, filtres rapides */
.filterbar, form.filters, div.filters { display: grid; grid-template-columns: 1fr; gap: 0 var(--s-4); align-items: end; margin-bottom: var(--s-4); }
.filterbar { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: var(--s-3) var(--s-4) var(--s-1); }
.filterbar .field { margin-bottom: var(--s-3); }
.filterbar-actions { display: flex; gap: var(--s-2); align-items: center; margin-bottom: var(--s-3); flex-wrap: wrap; }
.search { display: flex; gap: var(--s-2); margin-bottom: var(--s-3); }
.search input { flex: 1; }
ul.filters { list-style: none; margin: 0 0 var(--s-4); padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
ul.filters a { display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap); padding: 0 var(--s-4); border: 1px solid var(--c-line-strong); border-radius: var(--r-pill); background: var(--c-surface); color: var(--c-text); text-decoration: none; font-weight: 500; }
ul.filters a:hover { border-color: var(--c-text); background: var(--c-surface-2); }
ul.filters a[aria-current="true"], ul.filters a[aria-current="page"] { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }
@media (min-width: 40rem) { .filterbar, form.filters, div.filters { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); } }

/* 4.10 Pagination */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); margin: var(--s-4) 0; color: var(--c-text-muted); font-size: var(--fs-sm); }
.pager-links { display: flex; align-items: center; gap: var(--s-2); }

/* 4.11 Alertes et messages flash : .alert / .flash + --success --error --warning --info */
.alert, .flash { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); margin-bottom: var(--s-4); border: 1px solid var(--c-neutral-bd); border-left-width: 4px; background: var(--c-neutral-bg); color: var(--c-neutral-fg); }
.alert .icon, .flash .icon { margin-top: .1rem; }
.alert-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.alert-body > :last-child { margin-bottom: 0; }
.alert--error, .flash-error { background: var(--c-danger-bg); color: var(--c-danger-fg); border-color: var(--c-danger-bd); border-left-color: var(--c-danger-fg); }
.alert--success, .flash-success { background: var(--c-success-bg); color: var(--c-success-fg); border-color: var(--c-success-bd); border-left-color: var(--c-success-fg); }
.alert--warning, .flash-warning, .warn { background: var(--c-attention-bg); color: var(--c-attention-fg); border-color: var(--c-attention-bd); border-left-color: var(--c-attention-fg); }
.alert--info, .flash-info { background: var(--c-info-bg); color: var(--c-info-fg); border-color: var(--c-info-bd); border-left-color: var(--c-info-fg); }
.alert a, .flash a { color: inherit; font-weight: 600; }

/* 4.12 Modales et confirmations : <dialog class="dialog"> ; repli sans JS = details.confirm */
dialog.dialog { border: 0; border-radius: var(--r-lg); padding: 0; width: min(30rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-2); overflow: auto; }
dialog.dialog::backdrop { background: rgba(20, 20, 18, .55); }
.dialog-head { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-5) var(--s-5) var(--s-2); }
.dialog-head h2 { margin: 0; font-size: var(--fs-lg); }
.dialog-head .icon { color: var(--c-danger-fg); margin-top: .1rem; }
.dialog-body { padding: 0 var(--s-5) var(--s-4); color: var(--c-text-muted); }
.dialog-body p { margin: 0 0 var(--s-2); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5) var(--s-5); }
.dialog-actions form { margin: 0; }
details.confirm { display: inline-block; vertical-align: top; }
details.confirm > summary { list-style: none; cursor: pointer; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] { display: block; flex-basis: 100%; }
.confirm-panel { margin-top: var(--s-2); padding: var(--s-3) var(--s-4); border: 1px solid var(--c-danger-bd); background: var(--c-danger-bg); border-radius: var(--r-md); color: var(--c-danger-fg); max-width: 32rem; }
.confirm-panel p { margin: 0 0 var(--s-2); }
.confirm-panel .actions { margin: 0; }

/* 4.13 Etats vides */
.empty { text-align: center; padding: var(--s-6) var(--s-4); background: var(--c-surface); border: 1px dashed var(--c-line-strong); border-radius: var(--r-lg); color: var(--c-text-muted); }
.empty .icon { width: 2.25rem; height: 2.25rem; color: var(--c-text-muted); margin-bottom: var(--s-2); }
.empty h2, .empty h3 { margin: 0 0 var(--s-1); color: var(--c-text); font-size: var(--fs-lg); }
.empty p { margin: 0 auto var(--s-3); max-width: 32rem; }
.empty .actions { justify-content: center; margin: var(--s-3) 0 0; }

/* 4.14 Squelettes de chargement (discrets ; inertes si mouvement reduit) */
.skeleton { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--c-sand) 0%, var(--c-surface-2) 50%, var(--c-sand) 100%); background-size: 200% 100%; animation: skeleton 1.6s ease-in-out infinite; }
.skeleton-line { height: .9rem; margin: .5rem 0; width: 100%; }
.skeleton-line.is-short { width: 40%; }
.skeleton-block { height: 5rem; border-radius: var(--r-md); }
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* 4.15 Cartes de statistiques */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.stat { display: block; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: var(--s-3) var(--s-4); box-shadow: var(--sh-1); color: var(--c-text); text-decoration: none; }
a.stat:hover { border-color: var(--c-accent); color: var(--c-text); }
.stat-label { display: block; font-size: var(--fs-sm); color: var(--c-text-muted); font-weight: 500; }
.stat-value { display: block; font: 600 var(--fs-3xl)/1.05 var(--font-serif); margin: var(--s-1) 0; font-variant-numeric: lining-nums tabular-nums; }
.stat-note { display: block; font-size: var(--fs-sm); color: var(--c-text-muted); }
.stat--alert { border-color: var(--c-danger-bd); background: var(--c-danger-bg); }
.stat--alert .stat-value, .stat--alert .stat-label, .stat--alert .stat-note { color: var(--c-danger-fg); }
@media (min-width: 48rem) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* 4.16 Fiche : liste de definitions (kv), mise en page principale + colonne laterale */
.kv { display: grid; grid-template-columns: 1fr; gap: var(--s-1) var(--s-4); margin: 0; }
.kv dt { font-weight: 600; color: var(--c-text-muted); font-size: var(--fs-sm); }
.kv dd { margin: 0 0 var(--s-2); overflow-wrap: anywhere; }
.detail { display: grid; grid-template-columns: 1fr; gap: var(--s-4); }
.detail > * { min-width: 0; }
@media (min-width: 40rem) { .kv { grid-template-columns: 11rem 1fr; } .kv dd { margin: 0 0 var(--s-1); } }
@media (min-width: 64rem) { .detail { grid-template-columns: minmax(0, 1fr) 21rem; align-items: start; } }

/* ---------- 5. Pages d'authentification et d'erreur ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth-aside { display: none; background: var(--c-ink); color: #e9e4da; padding: var(--s-7); flex-direction: column; justify-content: space-between; }
.auth-aside .brand { font-size: 2.4rem; }
.auth-aside p { color: #cfc8ba; max-width: 24rem; font: 500 1.6rem/1.3 var(--font-serif); margin: 0; }
.auth-aside small { color: #b9b2a4; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: var(--s-5) var(--s-4); }
.auth-card { width: 100%; max-width: 24rem; margin: 0 auto; }
.auth-card .brand-mobile { font: 600 2rem/1 var(--font-serif); color: var(--c-text); display: block; margin-bottom: var(--s-5); }
.auth-card h1 { font-size: 2.1rem; margin-bottom: var(--s-1); }
.auth-card .lead { color: var(--c-text-muted); margin-bottom: var(--s-5); }
.auth-help { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--c-line); color: var(--c-text-muted); font-size: var(--fs-sm); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 5.5rem; }
.pw-toggle { position: absolute; right: .25rem; top: 50%; translate: 0 -50%; min-height: var(--tap); padding: 0 .75rem; border: 0; background: none; color: var(--c-accent); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; border-radius: var(--r-sm); }
@media (min-width: 56rem) { .auth { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } .auth-aside { display: flex; } .auth-card .brand-mobile { display: none; } }

.error-page { max-width: 34rem; margin: var(--s-7) auto; padding: 0 var(--s-4); text-align: center; }
.error-code { display: block; font: 500 6rem/1 var(--font-serif); color: var(--c-accent); letter-spacing: -.02em; margin-bottom: var(--s-2); }
.error-page h1 { font-size: 2rem; }
.error-page p { color: var(--c-text-muted); font-size: var(--fs-md); }
.error-page .actions { justify-content: center; margin-top: var(--s-5); }
.error-ref { display: inline-block; margin-top: var(--s-3); padding: .25rem .75rem; border-radius: var(--r-sm); background: var(--c-neutral-bg); color: var(--c-neutral-fg); font-size: var(--fs-sm); }

/* ---------- 6. Utilitaires ---------- */
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-4 { margin-top: var(--s-4); } .mb-0 { margin-bottom: 0; } .mb-4 { margin-bottom: var(--s-4); }
.flow > * + * { margin-top: var(--s-3); }
.narrow { max-width: 28rem; margin: var(--s-6) auto; }
.late, .task-late { color: var(--c-danger-fg); font-weight: 600; }
.danger-zone { margin-top: var(--s-6); border-color: var(--c-danger-bd); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .topbar, .site-footer, .skip-link { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

/* ---------- 7. Compatibilite : classes des modules MVP-0 (a migrer vers les composants ci-dessus) ---------- */
.badge-received { background: var(--c-attention-bg); color: var(--c-attention-fg); border-color: var(--c-attention-bd); }
.badge-linked { background: var(--c-success-bg); color: var(--c-success-fg); border-color: var(--c-success-bd); }
form.inline { display: inline-block; margin-left: .5rem; }
form.stack { margin-top: 1rem; }

/* Composant confirm avec champs de saisie (motif) : le panneau reste deroulant, sans boite de dialogue */
.confirm-panel .field { margin-bottom: var(--s-3); }
