/* ══════════════════════════════════════════════════════════════════════════
   Solo : feuille de style unique. Thème sombre, sobre, lisible, responsive.
   Aucune police externe, aucune image : tout tient dans ce fichier.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #0f1115;
  --fg: #e8e8ea;
  --muted: #9aa0a6;
  --accent: #4f8cff;
  --card: #171a21;
  --card2: #12151b;
  --line: #262a33;
  --line2: #2c313c;
  --ok: #3ecf8e;
  --warn: #f5b301;
  --bad: #ff5f5f;
}

* { box-sizing: border-box; }

/* L'attribut hidden doit gagner contre les display posés plus bas. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: .3px; }
h2 { margin: 0 0 12px; font-size: 16px; letter-spacing: .2px; }
h3 { margin: 0 0 14px; font-size: 16px; }

p { margin: 0 0 10px; }
.sub, .muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grow { flex: 1 1 auto; }

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

/* ── connexion ─────────────────────────────────────────────────────────── */
.screen-center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(420px, 94vw); }
.login .btn { margin-top: 18px; }

/* ── barre du haut ─────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--card2);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .5px; color: var(--fg); text-decoration: none; font-size: 17px; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 11px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px;
}
.topbar nav a:hover { background: var(--line); color: var(--fg); text-decoration: none; }
.topbar nav a[aria-current="page"] { background: var(--line); color: var(--fg); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }

.view { width: min(1120px, 100%); margin: 0 auto; padding: 20px 18px 60px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 0 18px 24px; }

/* ── bandeau de message ────────────────────────────────────────────────── */
.flash {
  margin: 0; padding: 11px 18px; font-size: 14px;
  background: rgba(255, 95, 95, .12); color: #ffb3b3; border-bottom: 1px solid rgba(255, 95, 95, .3);
}
.flash.ok { background: rgba(62, 207, 142, .12); color: #9fe8c6; border-bottom-color: rgba(62, 207, 142, .3); }

/* ── cartes et grilles ─────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  margin: 0 0 16px;
}
.cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tile .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; }
.toolbar .field { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── jauge de franchise ────────────────────────────────────────────────── */
.gauge { height: 12px; border-radius: 7px; background: var(--line); overflow: hidden; margin: 4px 0 8px; }
.gauge > div { height: 100%; border-radius: 7px; transition: width .3s ease; }
.lvl-ok { background: var(--ok); } .lvl-alerte { background: var(--warn); } .lvl-depasse { background: var(--bad); }
.t-ok { color: var(--ok); } .t-alerte { color: var(--warn); } .t-depasse { color: var(--bad); }

/* ── formulaires ───────────────────────────────────────────────────────── */
label, .field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.field { margin: 0 0 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 14px; }
.field.wide, .fields > .wide { grid-column: 1 / -1; }
/* Ligne d'explication sous un champ : elle porte une règle, pas un ornement. */
.field .hint { display: block; margin: 5px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
/* Encart d'avertissement : identité verrouillée, adresse manquante, pièce non
   transmissible, point d'accès absent. Il porte une règle, jamais un ornement. */
.note {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  background: rgba(245, 179, 1, .1); border: 1px solid rgba(245, 179, 1, .3); color: #ffd873;
}
.note:last-child { margin-bottom: 0; }
/* Dans une barre d'actions (flex), l'avertissement prend sa propre ligne. */
.actions .note { flex: 1 0 100%; margin: 4px 0 0; }
.note .btn { margin-left: 6px; vertical-align: baseline; }

input, select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--line2); background: var(--bg); color: var(--fg);
  font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
input[type="checkbox"] { width: auto; margin-right: 8px; vertical-align: -2px; }
.check { display: flex; align-items: center; gap: 0; font-size: 14px; color: var(--fg); margin: 22px 0 12px; }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); background: var(--card2); }
::placeholder { color: #616772; }

.btn {
  display: inline-block; padding: 9px 14px; border: 1px solid transparent; border-radius: 8px;
  background: var(--line2); color: var(--fg); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.15); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; border-color: var(--line2); color: var(--fg); }
.btn.danger { background: transparent; border-color: rgba(255, 95, 95, .5); color: #ff8f8f; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon { padding: 4px 9px; font-size: 15px; line-height: 1.3; }

.msg { color: var(--bad); font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.msg.ok { color: var(--ok); }

/* ── tableaux ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600; padding: 0 10px 8px; white-space: nowrap;
}
td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr[data-href] { cursor: pointer; }
tbody tr[data-href]:hover { background: var(--card2); }
td input, td select { padding: 6px 8px; font-size: 13px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap;
  background: var(--line); color: var(--muted);
}
.badge.st-emise, .badge.st-envoyee { background: rgba(79, 140, 255, .16); color: #a9c6ff; }
.badge.st-payee { background: rgba(62, 207, 142, .16); color: #9fe8c6; }
.badge.st-annulee { background: rgba(255, 95, 95, .16); color: #ffb3b3; }
.badge.warn { background: rgba(245, 179, 1, .16); color: #ffd873; }
.badge.bad { background: rgba(255, 95, 95, .16); color: #ffb3b3; }

/* ── lignes de pièce ───────────────────────────────────────────────────── */
/* En édition, le tableau des lignes ne se comprime pas : il défile horizontalement. */
.lines.editable table { min-width: 940px; }
.lines td { vertical-align: middle; }
.lines .col-art { width: 165px; }
.lines .col-label { width: auto; min-width: 190px; }
.lines .col-acc { width: 185px; }
.lines .col-n { width: 90px; }
.lines .col-u { width: 74px; }
.totaux { display: flex; justify-content: flex-end; margin-top: 12px; }
.totaux table { width: auto; min-width: 260px; }
.totaux td { border-top: 0; padding: 3px 0 3px 24px; }
.totaux tr.grand td { border-top: 1px solid var(--line); padding-top: 8px; font-size: 16px; font-weight: 600; }

/* ── fenêtres modales ──────────────────────────────────────────────────── */
dialog.modal {
  width: min(560px, 94vw); padding: 0; border: 1px solid var(--line2); border-radius: 14px;
  background: var(--card); color: var(--fg);
}
dialog.modal.wide { width: min(820px, 94vw); }
dialog.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal-form { padding: 20px; }
.modal-body { max-height: 62vh; overflow-y: auto; padding-right: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ── responsive ────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .cards2 { grid-template-columns: 1fr; }
  .topbar { gap: 10px; padding: 10px 12px; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .view { padding: 16px 12px 48px; }
  .hide-sm { display: none; }
}

/* Textes longs d'une échéance.
   `texte-libre` : de la prose, police normale.
   `texte-fixe`  : une note du titulaire, en CHASSE FIXE. Ces notes portent des
   blocs alignés en colonnes (coordonnées de virement, décomposition d'un
   montant) : en police proportionnelle les colonnes s'écrasent et le bloc
   devient illisible. Le `pre-wrap` conserve les retours à la ligne voulus tout
   en repliant les lignes trop longues, et `overflow-x` évite qu'un IBAN collé
   fasse déborder la page entière. */
.texte-libre { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; margin: 4px 0 0; }
.texte-fixe {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px; line-height: 1.55; color: var(--fg);
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin: 6px 0 0; overflow-x: auto;
}
textarea.texte-fixe { display: block; resize: vertical; min-height: 220px; }

/* ── pilotage : jauges de seuils, gestes datés, veille ─────────────────────
   Réutilise .gauge pour la barre. Ce qui s'ajoute ici est ce que la franchise
   n'avait pas : un état à quatre valeurs, un enjeu chiffré, et une date. */
.jg { padding: 12px 0; border-bottom: 1px solid var(--line); }
.jg:last-child { border-bottom: 0; padding-bottom: 0; }
.jg:first-child { padding-top: 0; }
.jg-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.jg-t { font-weight: 600; font-size: 14px; }
.jg-v { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.jg-v strong { color: var(--fg); }
.jg-a { font-size: 12.5px; line-height: 1.5; color: var(--muted); margin: 6px 0 0; }
.jg-s { font-size: 11.5px; color: var(--muted); opacity: .7; margin: 4px 0 0; }
/* Quatre états, et le vocabulaire compte : « sous » est neutre quand la cible
   est un seuil à franchir, il n'est mauvais que quand la cible est un objectif. */
.jg-f.ok      { background: var(--ok); }
.jg-f.partiel { background: var(--warn); }
.jg-f.vide    { background: var(--bad); }
.jg-f.proche  { background: var(--warn); }
.jg-f.sous    { background: var(--line2); }
.jg-b { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; vertical-align: 1px; }
.jg-b.ok  { background: rgba(62, 207, 142, .15); color: var(--ok); }
.jg-b.mid { background: rgba(245, 179, 1, .15); color: var(--warn); }
.jg-b.ko  { background: rgba(255, 95, 95, .15); color: var(--bad); }
.jg-b.off { background: var(--card2); color: var(--muted); }

/* Un geste : une date, un titre, un enjeu en euros, et ce qu'il faut faire. */
.geste { padding: 11px 12px; border-radius: 10px; background: var(--card2); border-left: 3px solid var(--line2); margin: 0 0 8px; }
.geste:last-child { margin-bottom: 0; }
.geste.bloquant { border-left-color: var(--bad); }
.geste.a_faire { border-left-color: var(--accent); }
.geste.optionnel { border-left-color: var(--warn); }
.geste.rien_a_faire { border-left-color: var(--ok); }
.geste.passe { opacity: .55; }
.geste-q { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.geste-t { font-weight: 600; font-size: 13.5px; margin: 3px 0 4px; }
.geste-e { font-variant-numeric: tabular-nums; color: var(--ok); font-size: 12px; margin-left: 6px; }
.geste-q .tard { color: var(--bad); font-weight: 600; }
.geste p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }

/* La veille : un seuil, ce qu'il déclenche, et l'écart qui reste. */
.vl { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.vl:last-child { border-bottom: 0; }
.vl-s { font-weight: 600; }
.vl-d { color: var(--muted); margin-top: 2px; }
.vl-e { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.vl-e.atteint { color: var(--ok); }

/* ── calendrier des prestations ────────────────────────────────────────── */
/* Ordinateur : la grille du mois, le résumé à droite. Téléphone : la saisie en
   haut, puis la liste des SEULS jours travaillés (et aujourd'hui), lisible au
   pouce ; une grille de sept colonnes de 50 px n'y serait qu'illisible. */
.cal-head { align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 10px; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-titre { min-width: 150px; text-align: center; font-size: 16px; }
.cal-bar { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-client-seul { margin: 0; }
.cal-saisie { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.cal-saisie .field { margin: 0; }
.cal-h input { width: 90px; }
.cal-puces { display: flex; gap: 6px; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.cal-grille { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-entete { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0; text-transform: uppercase; letter-spacing: .5px; }
.cal-case {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  min-height: 92px; padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; min-width: 0;
}
.cal-case:hover { border-color: var(--line2); }
.cal-case.hors { opacity: .35; cursor: default; }
.cal-case.we { background: var(--card2); }
.cal-case.auj { border-color: var(--accent); }
.cal-num { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.cal-num .cal-jl { display: none; }
.cal-num em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-seance {
  display: flex; justify-content: space-between; gap: 6px; width: 100%;
  border: 0; border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 12px; text-align: left; cursor: pointer;
  background: rgba(79, 140, 255, .16); color: var(--fg);
}
.cal-seance span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-seance b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-seance.brouillon { background: rgba(245, 179, 1, .16); }   /* posée sur le brouillon du mois */
.cal-seance.facturee { background: rgba(62, 207, 142, .14); }    /* facturée, figée */
.cal-seance:hover { outline: 1px solid var(--line2); }
.cal-vide { margin-top: 10px; }
.cal-resume { position: sticky; top: 72px; }
.cal-total { font-size: 15px; }
.cal-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; }
.cal-table td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.cal-table td.num { padding-left: 10px; }
.cal-afacturer { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; font-size: 15px; }
.cal-afacturer b { font-size: 18px; }
.cal-pieces { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; font-size: 14px; }
.cal-pieces li { display: flex; gap: 8px; align-items: center; }
.cal-pieces .num { margin-left: auto; }
.cal-action { margin: 12px 0 8px; }
.cal-action .btn { width: 100%; text-align: center; display: block; }
.cal-alerte { color: var(--warn); }
.cal-forfaits { margin-top: 16px; }

@media (max-width: 860px) {
  .cal-layout { grid-template-columns: 1fr; }
  .cal-resume { position: static; }
}
@media (max-width: 640px) {
  .cal-saisie .field.grow { flex: 1 1 100%; }
  .cal-saisie .btn.primary { flex: 1 1 100%; }
  .cal-grille { grid-template-columns: 1fr; gap: 6px; }
  .cal-entete, .cal-case.hors, .cal-case.vide:not(.auj) { display: none; }
  .cal-case { min-height: 0; }
  .cal-num .cal-jl { display: inline; }
  .cal-num .cal-jc { display: none; }
  .cal-seance { font-size: 14px; padding: 6px 8px; }
}
.cal-ok { flex: 1 1 100%; margin: 0; font-size: 13px; color: var(--ok); }
.cal-ok:empty { display: none; }
