/* CRM Kentaurus i Agena
   Fond blanc chaud, surfaces gris très clair, texte anthracite, accent olive discret.
   Listes compactes à séparateurs fins ; rouge réservé aux échéances dépassées. */
:root {
  --bg: #FBFAF8; --surface: #F3F2EF; --surface-2: #ECEAE5; --line: #E4E1DB;
  --ink: #2A2A28; --ink-2: #6B6963; --ink-3: #9A978F;
  --olive: #66713A; --olive-ink: #4F5829; --olive-soft: #EEF0E4;
  --red: #B3261E; --red-soft: #FBEDEC;
  --r: 8px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --side: 216px; --panel: 440px; --tab: 60px;
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; }
.chargement { padding: 40px; color: var(--ink-2); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; }
.marque { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.marque b { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--olive); color: #fff; font-size: 12px; letter-spacing: .02em; }
.marque span { font-weight: 600; font-size: 14px; line-height: 1.2; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--r); text-align: left; color: var(--ink); }
.nav:hover { background: var(--surface-2); }
.nav[aria-current="page"] { background: #fff; box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.nav .n { margin-left: auto; font-size: 12px; color: var(--ink-2); }
.nav .n.retard { color: var(--red); font-weight: 600; }
.side-bas { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); display: grid; gap: 8px; }
.side-bas select { width: 100%; }
.badge-demo { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--olive-soft); color: var(--olive-ink); }

.main { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.top { display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--bg); }
.recherche { position: relative; flex: 1; max-width: 560px; }
.recherche input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: 15px; }
.recherche input:focus { background: #fff; }
.recherche > svg { position: absolute; left: 11px; top: 10px; color: var(--ink-3); }
.resultats { position: absolute; z-index: 30; top: 44px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.08); max-height: 60vh; overflow: auto; }
.resultats .vide { padding: 14px; color: var(--ink-2); }
.zones { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; }
.zones.avec-fiche { grid-template-columns: minmax(0, 1fr) var(--panel); }
.liste { overflow-y: auto; min-height: 0; padding: 4px 18px 40px; }
.liste > * { max-width: 940px; }
.fiche { border-left: 1px solid var(--line); background: #fff; overflow-y: auto; min-height: 0; }

/* ---------- Boutons, champs, puces ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface); }
.btn.principal { background: var(--olive); border-color: var(--olive); color: #fff; }
.btn.principal:hover { background: var(--olive-ink); }
.btn.discret { border-color: transparent; background: none; color: var(--olive-ink); }
.btn.discret:hover { background: var(--olive-soft); }
.btn.petit { min-height: 30px; padding: 0 10px; font-size: 13px; }
.champ { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.champ input, .champ select, .champ textarea, select.sel { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; font-size: 16px; color: var(--ink); }
.champ textarea { min-height: 96px; resize: vertical; }
.filtres { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 14px 0 6px; }
.seg { display: inline-flex; background: var(--surface); border-radius: var(--r); padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; font-size: 14px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.puce { display: inline-block; font-size: 12px; line-height: 1; padding: 4px 8px; border-radius: 99px; background: var(--surface); color: var(--ink-2); white-space: nowrap; }
.puce.olive { background: var(--olive-soft); color: var(--olive-ink); }
.puce.rouge { background: var(--red-soft); color: var(--red); }
.puce.fictif { background: none; border: 1px dashed var(--ink-3); color: var(--ink-3); }

/* ---------- Listes compactes ---------- */
h1 { font-size: 24px; line-height: 1.15; margin: 18px 0 2px; letter-spacing: -.01em; }
.sous-titre { margin: 0; color: var(--ink-2); font-size: 14px; }
.groupe { margin-top: 20px; }
.groupe h2 { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 4px; padding: 0 2px; }
.groupe h2 .c { font-weight: 500; color: var(--ink-3); }
.groupe.retard h2 { color: var(--red); }
.lignes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ligne { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 14px; align-items: center; width: 100%; padding: 9px 8px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; border-radius: 0; }
.ligne:hover { background: var(--surface); }
.ligne[aria-current="true"] { background: var(--olive-soft); }
.ligne .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .a { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; grid-column: 1; }
.ligne .meta { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.ligne .resp { font-size: 13px; color: var(--ink-2); }
.ligne .date { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 64px; text-align: right; white-space: nowrap; }
.ligne .date.retard { color: var(--red); font-weight: 600; }
.ligne .type { font-size: 12px; color: var(--ink-3); }
.vide-liste { padding: 14px 8px; color: var(--ink-3); font-size: 14px; border-bottom: 1px solid var(--line); }
.etat-vide { margin: 40px auto; max-width: 360px; text-align: center; color: var(--ink-2); }
.etat-vide strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* ---------- Fiche ---------- */
.fiche-tete { position: sticky; top: 0; z-index: 5; background: #fff; padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.fiche-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.fiche-tete h2 { font-size: 20px; line-height: 1.2; margin: 0 0 6px; overflow-wrap: anywhere; }
.fiche-tete .puces { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions .btn { min-height: 42px; }
.bloc { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.bloc h3 { font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 0 0 8px; }
.prochaine { background: var(--surface); border-radius: var(--r); padding: 12px; }
.prochaine.retard { background: var(--red-soft); }
.prochaine .quoi { font-weight: 600; }
.prochaine .quand { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.prochaine.retard .quand { color: var(--red); font-weight: 600; }
.prochaine .boutons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.alerte-sans { color: var(--ink-2); font-size: 14px; }
dl.infos { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 14px; }
dl.infos dt { color: var(--ink-2); }
dl.infos dd { margin: 0; overflow-wrap: anywhere; }
dl.infos a { color: var(--olive-ink); }
.lien-fiche { display: block; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; text-align: left; margin-bottom: 6px; }
.lien-fiche:hover { background: var(--surface); }
.lien-fiche span { display: block; font-size: 13px; color: var(--ink-2); }
.histo { list-style: none; margin: 0; padding: 0; }
.histo li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.histo li:first-child { border-top: 0; }
.histo .q { font-size: 12px; color: var(--ink-3); }

/* ---------- Formulaires ---------- */
fieldset.bloc { margin: 0; border: 0; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
fieldset.bloc legend { float: left; width: 100%; font-size: 13px; color: var(--ink-2); font-weight: 600; margin-bottom: 2px; padding: 0; }
.case { display: flex; gap: 8px; align-items: center; font-size: 14px; min-height: 32px; }
.case input { width: 18px; height: 18px; accent-color: var(--olive); }
.pied-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pied-form span { flex: 1; }
.erreur { margin: 8px 0 0; padding: 8px 10px; border-radius: var(--r); background: var(--red-soft); color: var(--red); font-size: 14px; }
.erreur[hidden] { display: none; }
.lien { border: 0; background: none; padding: 0; color: var(--red); text-decoration: underline; font-weight: 600; }
.titre-liste { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.titre-liste h1 { margin-bottom: 2px; }
.fiche-nav .puces { display: flex; gap: 6px; align-items: center; }

/* ---------- Fenêtre, message ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(30,30,28,.32); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.boite { width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; background: #fff; border-radius: 12px; padding: 18px; box-shadow: 0 16px 48px rgba(0,0,0,.18); display: grid; gap: 12px; }
.boite h3 { margin: 0; font-size: 17px; }
.boite .pied { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.raccourcis { display: flex; flex-wrap: wrap; gap: 6px; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r); font-size: 14px; max-width: calc(100vw - 32px); }
.toast[hidden] { display: none; }
.menu-nouveau { position: relative; }
.menu-nouveau .menu { position: absolute; right: 0; top: 42px; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.08); padding: 4px; min-width: 180px; }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 6px; }
.menu button:hover { background: var(--surface); }

/* ---------- Connexion ---------- */
.connexion { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.connexion .boite { box-shadow: none; border: 1px solid var(--line); }

/* ---------- Tablette : fiche en surimpression ---------- */
@media (max-width: 1180px) {
  .zones.avec-fiche { grid-template-columns: minmax(0, 1fr); }
  .zones.avec-fiche .fiche { position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; width: min(var(--panel), 100vw); box-shadow: -12px 0 32px rgba(0,0,0,.10); }
}
/* ---------- Téléphone : onglets en bas, fiche plein écran ---------- */
.tabs { display: none; }
@media (max-width: 760px) {
  body { font-size: 16px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { padding-bottom: calc(var(--tab) + env(safe-area-inset-bottom)); }
  .top { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .top .btn.principal .lib { display: none; }
  .liste { padding: 0 12px 24px; }
  .tabs { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; height: calc(var(--tab) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(251,250,248,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
  .tabs button { display: grid; justify-items: center; align-content: center; gap: 2px; border: 0; background: none; font-size: 11px; color: var(--ink-2); position: relative; }
  .tabs button[aria-current="page"] { color: var(--olive-ink); font-weight: 600; }
  .tabs .n { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; }
  .zones.avec-fiche .fiche { width: 100vw; border-left: 0; box-shadow: none; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .ligne { padding: 11px 4px; }
  .ligne .t { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .ligne .meta { flex-direction: column; align-items: flex-end; gap: 2px; }
  .ligne .date { min-width: 0; }
  .actions .btn { font-size: 14px; padding: 0 8px; white-space: normal; line-height: 1.2; }
  dl.infos { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dl.infos dd { margin-bottom: 8px; }
  h1 { font-size: 22px; margin-top: 14px; }
}
@media (prefers-reduced-motion: no-preference) {
  .zones.avec-fiche .fiche { animation: entree .16s ease-out; }
  @keyframes entree { from { opacity: .4; transform: translateX(12px); } to { opacity: 1; transform: none; } }
}
