:root {
  --bg: #f1f5f9; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #1d4ed8; --accent-soft: #dbeafe; --danger: #b91c1c; --danger-soft: #fee2e2;
  --warn: #b45309; --warn-soft: #fef3c7; --ok: #047857; --ok-soft: #d1fae5;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 8px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
h2.retard { color: var(--danger); }
h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1em; }
[hidden] { display: none !important; }

/* boutons et champs */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 8px 14px;
  font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
  background: #fff; color: var(--ink); width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }
label.check input { width: auto; }
.small-select { width: auto; padding: 5px 8px; font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 140px; }
.row > .fixe { flex: 0 0 auto; }

/* connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: #fff; padding: 28px; border-radius: 18px; width: 100%; max-width: 360px; box-shadow: var(--shadow);
  display: grid; gap: 10px; text-align: center; }
.logo { width: 52px; height: 52px; border-radius: 14px; background: var(--ink); color: #fbbf24; font-weight: 800;
  display: grid; place-items: center; margin: 0 auto; font-size: 20px; }
.logo.sm { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; margin: 0; }

/* en-tête */
.top { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; display: flex; align-items: center;
  gap: 14px; padding: 8px 16px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; }
.tabs { display: flex; gap: 2px; flex: 1; }
.tabs a { color: #cbd5e1; padding: 7px 11px; border-radius: 8px; display: flex; gap: 6px; align-items: center; }
.tabs a.on, .tabs a:hover { background: rgba(255,255,255,.1); color: #fff; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.top .btn.ghost { color: #fff; }
.pill { background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.pill.warn { background: #d97706; }
.pill:empty { display: none; }
.bandeau { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: 13px; padding: 4px; font-weight: 600; }
main { max-width: 1250px; margin: 0 auto; padding: 16px 16px 90px; }
main.large { max-width: none; }
.bottom { display: none; }

/* cartes */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.list { display: grid; gap: 8px; }
.empty { color: var(--muted); padding: 10px 2px; font-size: 14px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  background: #e2e8f0; color: #334155; vertical-align: middle; }
.badge.marque { color: #fff; }
.badge.rouge { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.vert { background: var(--ok-soft); color: var(--ok); }
.badge.bleu { background: var(--accent-soft); color: var(--accent); }
.count { color: var(--muted); font-weight: 500; font-size: 13px; }

/* tâches */
.task { display: flex; gap: 12px; align-items: flex-start; }
.task .ico { font-size: 18px; width: 26px; text-align: center; padding-top: 2px; }
.task .corps { flex: 1; min-width: 0; }
.task .t-titre { font-weight: 600; }
.task .t-dossier { font-size: 13px; }
.task .t-meta { font-size: 13px; color: var(--muted); }
.task .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.task.retard { border-left: 4px solid var(--danger); }
.date-retard { color: var(--danger); font-weight: 600; }
.grille .task { flex-wrap: wrap; }
.grille .task .actions { width: 100%; justify-content: flex-start; padding-left: 38px; }

/* kanban */
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { flex: 0 0 255px; background: #e2e8f0; border-radius: var(--radius); padding: 8px; min-height: 120px; }
.col.drop { outline: 2px dashed var(--accent); }
.col-tete { font-weight: 700; font-size: 13px; padding: 2px 4px 8px; display: flex; justify-content: space-between; gap: 6px; }
.col-tete .somme { font-weight: 500; color: var(--muted); }
.kcard { background: #fff; border-radius: 10px; padding: 9px 10px; margin-bottom: 7px; box-shadow: var(--shadow);
  border-left: 4px solid #94a3b8; cursor: pointer; font-size: 13px; }
.kcard:hover { box-shadow: 0 2px 10px rgba(15,23,42,.12); }
.kcard .k-titre { font-weight: 600; font-size: 14px; }
.kcard .k-bas { display: flex; justify-content: space-between; gap: 6px; margin-top: 4px; color: var(--muted); }

/* fiche dossier */
.fiche-tete { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; }
.fiche-tete .titre { flex: 1 1 320px; }
.barre { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.grille { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
.bloc { margin-bottom: 12px; }
.bloc h3 { margin-top: 0; display: flex; justify-content: space-between; align-items: center; }
.champ { margin: 6px 0; font-size: 14px; white-space: pre-wrap; }
.champ b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.personne { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.personne:first-of-type { border-top: 0; }
.pastille { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 2px 9px; font-size: 12px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .pastille { margin: 0; width: 8px; height: 8px; flex-basis: 8px; }

/* fil chronologique */
.fil { display: grid; gap: 8px; }
.item { background: #fff; border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; border-left: 4px solid #cbd5e1; }
.item.sortant { background: #f8fafc; }
.item.evt { box-shadow: none; background: transparent; border-left-color: transparent; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.item.evt.fort { background: #fff; color: var(--ink); box-shadow: var(--shadow); border-left-color: #94a3b8; font-size: 14px; }
.item .i-tete { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; font-size: 13px; }
.item .i-sujet { font-weight: 600; margin: 3px 0; }
.item .i-corps { white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; }
.item .i-corps.replie { max-height: 150px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); }
.item .pieces { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.item .i-actions { display: flex; gap: 6px; margin-top: 6px; }
.jour-sep { font-size: 12px; color: var(--muted); font-weight: 700; margin: 8px 2px 0; }

/* table */
.tableau { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tableau td, .tableau th { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.tableau th { font-size: 12px; color: var(--muted); background: #f8fafc; }
.tableau tr.clic { cursor: pointer; }
.tableau tr.clic:hover td { background: #f8fafc; }

/* modale */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 16px; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; padding: 18px; }
.modal-card.large { max-width: 860px; }
.modal-pied { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: 90vw; }
.dest { display: flex; flex-wrap: wrap; gap: 6px; }
.dest label.chip { margin: 0; color: var(--ink); font-size: 13px; padding: 4px 10px; }
.dest label.chip input { width: auto; margin: 0; }
.enregistreur { display: flex; gap: 10px; align-items: center; background: #f8fafc; border-radius: 10px; padding: 10px; }
.rec { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: clig 1s infinite; }
@keyframes clig { 50% { opacity: .2; } }
.cr-tache { display: grid; grid-template-columns: auto 1fr 150px; gap: 6px; align-items: center; margin: 4px 0; }
.cr-tache input[type=checkbox] { width: auto; }

@media (max-width: 900px) {
  .grille { grid-template-columns: 1fr; }
  .tabs { display: none; }
  .brand-txt { display: none; }
  .top { gap: 8px; }
  .top-actions { margin-left: auto; }
  .bottom { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
    z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottom a { flex: 1; text-align: center; font-size: 11px; color: var(--muted); padding: 6px 0 7px; display: flex;
    flex-direction: column; align-items: center; position: relative; }
  .bottom a span { font-size: 18px; line-height: 1.2; }
  .bottom a.on { color: var(--accent); }
  .bottom .pill { position: absolute; top: 2px; right: 18%; }
  .task { flex-wrap: wrap; }
  .task .actions { width: 100%; justify-content: flex-start; padding-left: 38px; }
  .col { flex-basis: 82vw; }
  .modal { padding: 0; align-items: end; }
  .modal-card { border-radius: 16px 16px 0 0; max-height: 94vh; }
  .cr-tache { grid-template-columns: auto 1fr; }
  .cr-tache input[type=date] { grid-column: 2; }
  .masque-mobile { display: none; }
}
