/*
 * Ma copro — style sobre : fond gris très clair, cartes blanches à bord fin, une couleur d'action
 * (indigo) et une teinte par catégorie, utilisée seulement sur les icônes et les pastilles.
 */
:root {
  --fond: #f4f5f8;
  --carte: #ffffff;
  --carte-2: #f8f9fb;
  --texte: #161a26;
  --discret: #667085;
  --bord: #e3e6ec;
  --accent: #4f46e5;
  --accent-texte: #ffffff;
  --accent-doux: #eef0ff;
  --rouge: #d92d20;
  --orange: #c4570c;
  --vert-statut: #067647;
  --ombre: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --ombre-haute: 0 12px 32px rgba(16, 24, 40, .14);
  --rayon: 14px;
  --nav-h: 64px;
  /* teintes des catégories (le fond est dérivé avec color-mix) */
  --c-violet: #7a5af8; --c-bleu: #2e90fa; --c-corail: #f04438; --c-vert: #12b76a; --c-orange: #f79009;
  --c-rose: #ee46bc; --c-ambre: #eaaa08; --c-cyan: #06aed4; --c-gris: #667085;
  --teinte-fond: 12%;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0e1016;
    --carte: #171a23;
    --carte-2: #1d212c;
    --texte: #e8eaf0;
    --discret: #98a2b3;
    --bord: #2a2f3c;
    --accent: #7c74ff;
    --accent-texte: #0e1016;
    --accent-doux: #23224a;
    --rouge: #f97066;
    --orange: #fdb022;
    --vert-statut: #47cd89;
    --ombre: none;
    --ombre-haute: 0 12px 32px rgba(0, 0, 0, .5);
    --teinte-fond: 20%;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0; line-height: 1.2; letter-spacing: -.02em; }
h2 { font-size: 1rem; font-weight: 650; margin: 0 0 .5rem; }
h3 { font-size: .95rem; }
small, .discret { color: var(--discret); }
hr { border: 0; border-top: 1px solid var(--bord); margin: 1rem 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.t-violet { --t: var(--c-violet); } .t-bleu { --t: var(--c-bleu); } .t-corail { --t: var(--c-corail); }
.t-vert { --t: var(--c-vert); } .t-orange { --t: var(--c-orange); } .t-rose { --t: var(--c-rose); }
.t-ambre { --t: var(--c-ambre); } .t-cyan { --t: var(--c-cyan); } .t-gris { --t: var(--c-gris); }

/* ---------- Navigation : barre en bas sur téléphone, colonne à gauche sur grand écran ---------- */
.nav {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom);
  display: flex; gap: 4px; background: color-mix(in srgb, var(--carte) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--bord);
}
.nav a, .nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--discret); font: 500 .7rem/1 inherit; font-family: inherit; background: none; border: 0;
  border-radius: 12px; cursor: pointer; text-decoration: none;
}
.nav svg { width: 22px; height: 22px; }
.nav .actif { color: var(--accent); }
.nav .actif svg { stroke-width: 2.2; }
.nav .marque, .nav .deco { display: none; }
.contenu {
  max-width: 1080px; margin: 0 auto;
  padding: 20px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
.page-login .contenu { padding-bottom: 24px; }

@media (min-width: 900px) {
  .nav {
    top: 0; right: auto; width: 232px; height: auto; flex-direction: column; padding: 20px 14px; gap: 2px;
    border-top: 0; border-right: 1px solid var(--bord); background: var(--carte); backdrop-filter: none;
  }
  .nav a, .nav button { flex: 0; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 9px 12px; font-size: .93rem; width: 100%; color: var(--texte); }
  .nav a svg, .nav button svg { color: var(--discret); }
  .nav a:hover, .nav button:hover { background: var(--carte-2); text-decoration: none; }
  .nav .actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
  .nav .actif svg { color: var(--accent); }
  .nav .marque { display: flex; font-weight: 700; font-size: 1.05rem; margin: 0 0 18px; gap: 10px; }
  .nav .marque:hover { background: none; }
  .nav .deco { display: block; margin-top: auto; }
  body:not(.page-login) .contenu { margin-left: 232px; padding: 32px 36px; }
}
@media (min-width: 1380px) { body:not(.page-login):not(.page-chat) .contenu { margin-left: calc(232px + (100vw - 232px - 1080px) / 2); } }

/* ---------- Éléments communs ---------- */
.entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 20px; min-height: 40px; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 18px; box-shadow: var(--ombre); margin-bottom: 16px; }
.carte-tete { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.carte-tete h2 { margin: 0; }
.carte-tete a { font-size: .87rem; font-weight: 500; }
.grille2 { display: grid; gap: 16px; }
.grille2 .carte { margin: 0; }
@media (min-width: 760px) { .grille2 { grid-template-columns: 1fr 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--bord);
  background: var(--carte); color: var(--texte); font: 600 .9rem inherit; font-family: inherit; cursor: pointer;
  white-space: nowrap; box-shadow: var(--ombre); transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { text-decoration: none; background: var(--carte-2); }
.btn:active { transform: scale(.98); }
.btn.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.btn.principal:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 40%, var(--bord)); }
.btn.petit { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.btn.large { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.actions.gauche { justify-content: flex-start; }
.actions form { margin: 0; }

input, select, textarea {
  width: 100%; font: 16px inherit; font-family: inherit; color: var(--texte); background: var(--carte);
  border: 1px solid var(--bord); border-radius: 10px; padding: 9px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
label { display: flex; flex-direction: column; gap: 6px; font-size: .87rem; font-weight: 600; }
.pile { display: flex; flex-direction: column; gap: 14px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 340px) { .deux { grid-template-columns: 1fr; } }

.alerte { background: color-mix(in srgb, var(--rouge) 10%, var(--carte)); color: var(--rouge); border: 1px solid color-mix(in srgb, var(--rouge) 30%, transparent); padding: 10px 12px; border-radius: 10px; margin: 8px 0; }
.info { background: color-mix(in srgb, var(--orange) 10%, var(--carte)); color: var(--orange); border: 1px solid color-mix(in srgb, var(--orange) 30%, transparent); padding: 10px 12px; border-radius: 10px; }
.vide { color: var(--discret); margin: 6px 0; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li + li { border-top: 1px solid var(--bord); }
.liste.carte { padding: 2px 18px; }
.ligne-doc, .ligne-echeance { display: flex; align-items: center; gap: 12px; padding: 12px 0; color: inherit; }
.ligne-doc:hover { text-decoration: none; }
.ligne-doc:hover strong { color: var(--accent); }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.grow strong { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.grow small { font-size: .82rem; margin-top: 2px; }
.notes { white-space: pre-line; }
.ico-doc {
  flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  color: var(--t, var(--c-gris)); background: color-mix(in srgb, var(--t, var(--c-gris)) var(--teinte-fond), var(--carte));
}
.pastille {
  flex: none; min-width: 64px; text-align: center; font-size: .75rem; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; white-space: nowrap; color: var(--vert-statut);
  background: color-mix(in srgb, var(--vert-statut) 12%, var(--carte));
}
.pastille.proche { color: var(--orange); background: color-mix(in srgb, var(--orange) 12%, var(--carte)); }
.pastille.retard { color: var(--rouge); background: color-mix(in srgb, var(--rouge) 12%, var(--carte)); }
.etiquette {
  display: inline-block; font-size: .74rem; font-weight: 600; padding: 0 8px; border-radius: 999px; margin-right: 4px;
  color: var(--t); background: color-mix(in srgb, var(--t) var(--teinte-fond), var(--carte));
}
.grow small svg { width: 13px; height: 13px; vertical-align: -2px; }

/* Accueil */
.bonjour small { display: block; font-size: .92rem; font-weight: 400; margin-top: 4px; letter-spacing: 0; }
.deco-mobile { margin: 0; }
@media (min-width: 900px) { .deco-mobile { display: none; } }
.chiffres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.chiffre {
  background: var(--carte); color: var(--texte); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 14px; display: flex; flex-direction: column; gap: 2px; text-decoration: none;
}
.chiffre:hover { text-decoration: none; border-color: color-mix(in srgb, var(--t) 45%, var(--bord)); }
.chiffre-ico {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 6px;
  color: var(--t); background: color-mix(in srgb, var(--t) var(--teinte-fond), var(--carte));
}
.chiffre-ico svg { width: 18px; height: 18px; }
.chiffre b { font-size: 1.6rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.chiffre span:last-child { font-size: .8rem; color: var(--discret); }
@media (max-width: 400px) { .chiffre { padding: 12px 10px; } .chiffre b { font-size: 1.35rem; } .chiffres { gap: 8px; } }
.question-rapide { display: flex; gap: 8px; margin-bottom: 16px; }
.question-rapide input { box-shadow: var(--ombre); }

/* Échéances */
.ligne-echeance form { margin: 0; }
.coche {
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--discret) 60%, transparent);
  background: var(--carte); color: #fff; cursor: pointer; font-weight: 700; font-size: .8rem; flex: none; padding: 0;
}
.coche:hover { border-color: var(--accent); }
.faite .coche { background: var(--vert-statut); border-color: var(--vert-statut); }
.faite strong { text-decoration: line-through; color: var(--discret); }
.ligne-bouton { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }

/* Fenêtres : feuille qui monte du bas sur téléphone, boîte centrée sur grand écran */
dialog.feuille {
  border: 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); background: var(--carte); color: var(--texte);
  width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92vh; overflow: auto;
  box-shadow: var(--ombre-haute);
}
dialog.feuille[open] { animation: monte .22s ease-out; }
@keyframes monte { from { transform: translateY(24px); opacity: 0; } }
dialog.feuille::backdrop { background: rgba(16, 24, 40, .45); }
@media (min-width: 640px) { dialog.feuille { width: 520px; margin: auto; border-radius: 16px; padding: 24px; } }
.depot { border: 1.5px dashed var(--bord); border-radius: 12px; padding: 16px; text-align: center; font-weight: 400; color: var(--discret); background: var(--carte-2); }
.depot input { background: none; border: 0; padding: 0; min-height: 0; margin-bottom: 8px; box-shadow: none; }

.filtres { margin-bottom: 12px; }
.puces { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; margin-bottom: 6px; scrollbar-width: none; }
.puces::-webkit-scrollbar { display: none; }
.puce {
  flex: none; font-size: .82rem; font-weight: 500; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--bord); background: var(--carte); color: var(--texte); white-space: nowrap;
}
.puce:hover { text-decoration: none; border-color: var(--discret); }
.puce.actif { background: var(--texte); border-color: var(--texte); color: var(--carte); }

/* Fiche document */
.retour { font-weight: 500; font-size: .92rem; }
.tete-doc { display: flex; gap: 14px; align-items: flex-start; }
.tete-doc .ico-doc { width: 48px; height: 48px; border-radius: 12px; }
.tete-doc .ico-doc svg { width: 24px; height: 24px; }
.titre-doc { overflow-wrap: anywhere; margin: 2px 0 4px; font-size: 1.35rem; }
.tete-doc + .actions, .carte > .actions { margin-top: 14px; }
.apercu { width: 100%; height: 75vh; border: 1px solid var(--bord); border-radius: var(--rayon); margin-bottom: 16px; background: var(--carte); }
.apercu-img { max-width: 100%; border-radius: var(--rayon); border: 1px solid var(--bord); margin-bottom: 16px; }
@media (max-width: 640px) { .apercu { display: none; } }
.texte-extrait summary { cursor: pointer; font-weight: 600; }
.texte-extrait pre { white-space: pre-wrap; overflow-wrap: anywhere; font: .85rem/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--discret); }

/* Connexion */
.page-login .contenu { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.login { width: 100%; max-width: 380px; text-align: center; padding: 30px 26px; }
.login form { text-align: left; margin-top: 22px; }
.login h1 { margin-top: 12px; font-size: 1.4rem; }

/* ---------- Assistant ---------- */
.page-chat .contenu { padding: 0; max-width: none; }
.chat-cadre {
  display: flex;
  height: calc(100vh - var(--nav-h) - env(safe-area-inset-bottom));
  height: calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom));
}
.convs {
  display: none; position: fixed; z-index: 20; inset: 0 0 calc(var(--nav-h) + env(safe-area-inset-bottom)) 0;
  background: var(--carte); padding: 16px; overflow: auto;
}
.convs.ouvert { display: block; }
.convs ul { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 2px; }
.convs li a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--texte); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
.convs li a:hover { background: var(--carte-2); text-decoration: none; }
.convs li a.actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.convs li.discret { padding: 9px 12px; }
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-tete { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--bord); background: var(--carte); }
.chat-tete form { margin: 0; }
.titre-conv { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.fil { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.bulle { max-width: min(740px, 92%); padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; line-height: 1.55; }
.bulle.user { align-self: flex-end; background: var(--accent); color: var(--accent-texte); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.bulle.assistant { align-self: flex-start; background: var(--carte); border: 1px solid var(--bord); border-bottom-left-radius: 4px; box-shadow: var(--ombre); }
.bulle p { margin: 0 0 .6em; }
.bulle p:last-child { margin-bottom: 0; }
.bulle ul, .bulle ol { margin: 0 0 .6em; padding-left: 1.3em; }
.bulle h4 { margin: .7em 0 .3em; font-size: .97rem; }
.bulle code { background: var(--carte-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.bulle a.source {
  display: inline-block; font-size: .78em; font-weight: 600; color: var(--accent); background: var(--accent-doux);
  padding: 1px 8px; border-radius: 999px; margin: 1px 0;
}
.bulle a.source:hover { text-decoration: none; filter: brightness(.96); }
.etapes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.etapes span { font-size: .74rem; color: var(--discret); background: var(--carte-2); border: 1px solid var(--bord); padding: 1px 8px; border-radius: 999px; }
.attente { color: var(--discret); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
.accueil-chat { margin: auto; max-width: 540px; text-align: center; color: var(--discret); }
.accueil-chat .gros {
  display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; margin-bottom: 8px;
  color: var(--accent); background: var(--accent-doux);
}
.accueil-chat .gros svg { width: 26px; height: 26px; }
.suggestions { display: grid; gap: 8px; margin-top: 14px; }
.suggestions button {
  font: inherit; font-size: .9rem; text-align: left; padding: 11px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--bord); background: var(--carte); color: var(--texte); box-shadow: var(--ombre);
}
.suggestions button:hover { border-color: var(--accent); color: var(--accent); }
.saisie { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--bord); background: var(--carte); align-items: flex-end; }
.saisie textarea { resize: none; max-height: 160px; }
.saisie .btn { width: 44px; height: 44px; padding: 0; font-size: 1rem; flex: none; }

@media (min-width: 900px) {
  body.page-chat .contenu { padding: 0; max-width: none; margin-left: 232px; }
  .chat-cadre { height: 100vh; height: 100dvh; }
  .convs { display: block; position: static; width: 270px; flex: none; border-right: 1px solid var(--bord); }
  [data-basculer="convs"] { display: none; }
  .fil, .saisie, .chat-tete { padding-left: 28px; padding-right: 28px; }
}
