/* LexCH — feuille de style de l'interface.
   Couleurs en variables, redéfinies pour le mode sombre (automatique, selon le réglage
   d'apparence de macOS ; voir templates/_theme.html). */
:root {
  --brand-dark: #1c2b3a;
  --brand-accent: #b08d57;
  --fond: #f3f5f8;
  --surface: #ffffff;
  --bordure: #e5e8ed;
  --texte-doux: #5b6472;
  --survol-ligne: rgba(28, 43, 58, .035);
  --graphe-facture: #1c2b3a;
  --graphe-encaisse: #b08d57;
  --graphe-grille: #e3e6ea;
  --graphe-texte: #6c757d;
  --graphe-texte-doux: #adb5bd;
}

[data-bs-theme="dark"] {
  --brand-dark: #0f1720;
  --fond: #11171e;
  --surface: #19212b;
  --bordure: #2a3440;
  --texte-doux: #9aa4b1;
  --survol-ligne: rgba(255, 255, 255, .04);
  --graphe-facture: #8fb3d9;
  --graphe-grille: #2a3440;
  --graphe-texte: #9aa4b1;
  --graphe-texte-doux: #6c7784;
  --bs-body-bg: #11171e;
  --bs-body-color: #dfe4ea;
  --bs-secondary-color: #9aa4b1;
}

body {
  background-color: var(--fond);
  font-size: .95rem;
  -webkit-font-smoothing: antialiased;
}

h4, h5, h6 { font-weight: 600; letter-spacing: -.01em; }

/* Barre latérale : toujours à hauteur d'écran, la liste défile, le bas (paramètres, compte,
   version, licence) reste visible. */
.sidebar {
  width: 250px;
  height: 100vh;
  position: sticky;
  top: 0;
  background-color: var(--brand-dark);
}

.sidebar > ul.nav {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  overflow-y: auto;
  min-height: 0;
}

.sidebar .nav-link {
  color: rgba(255,255,255,.75);
  border-radius: .5rem;
  padding: .45rem .75rem;
}

.sidebar .nav-link:hover {
  color: #fff;
  background-color: rgba(255,255,255,.08);
}

.sidebar .nav-link.active {
  background-color: var(--brand-accent);
  color: #fff;
}

.content {
  min-height: 100vh;
  min-width: 0;
}

/* Barre de titre fixe en haut de la page. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background-color: var(--surface) !important;
  border-color: var(--bordure) !important;
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--bordure);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  border-radius: .75rem;
}

.btn { border-radius: .5rem; }
.btn-sm { padding: .3rem .7rem; }
.form-control, .form-select { border-radius: .5rem; }

.table { --bs-table-bg: transparent; }
.table > tbody > tr:hover > * { background-color: var(--survol-ligne); }

/* Mode sombre : boutons « foncés » éclaircis pour rester lisibles. */
[data-bs-theme="dark"] .btn-dark {
  --bs-btn-bg: #e4e8ee; --bs-btn-border-color: #e4e8ee; --bs-btn-color: #1c2b3a;
  --bs-btn-hover-bg: #ffffff; --bs-btn-hover-border-color: #ffffff; --bs-btn-hover-color: #1c2b3a;
  --bs-btn-active-bg: #ffffff; --bs-btn-active-color: #1c2b3a;
}
[data-bs-theme="dark"] .btn-outline-dark {
  --bs-btn-color: #dfe4ea; --bs-btn-border-color: #5b6878;
  --bs-btn-hover-bg: #dfe4ea; --bs-btn-hover-color: #1c2b3a; --bs-btn-hover-border-color: #dfe4ea;
  --bs-btn-active-bg: #dfe4ea; --bs-btn-active-color: #1c2b3a;
}

/* Fiche dossier : chiffres clés, barre d'actions, onglets. */
.fiche-chiffres > div + div { border-left: 1px solid var(--bordure); }
.fiche-actions { border-top: 1px solid var(--bordure); }
.fiche-chrono #chrono-display { min-width: 5.2em; text-align: right; }
.fiche-onglets { border-bottom-color: var(--bordure); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.fiche-onglets .nav-link { color: var(--texte-doux); border: none; border-bottom: 2px solid transparent; padding: .5rem .65rem; white-space: nowrap; }
.fiche-onglets .nav-link:hover { color: var(--bs-body-color); border-bottom-color: var(--bordure); }
.fiche-onglets .nav-link.active { color: var(--bs-body-color); background: transparent; border-bottom-color: var(--brand-accent); font-weight: 600; }
@media (max-width: 991px) {
  .fiche-chiffres > div:nth-child(3) { border-left: none; }
}

/* Graphiques du tableau de bord. */
.graphe-facture { fill: var(--graphe-facture); }
.graphe-encaisse { fill: var(--graphe-encaisse); }
.graphe-grille { stroke: var(--graphe-grille); }
.graphe-texte { fill: var(--graphe-texte); }
.graphe-texte-doux { fill: var(--graphe-texte-doux); }

.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 600;
}

.badge-statut-ouvert { background-color: #2e7d32; }
.badge-statut-suspendu { background-color: #ef6c00; }
.badge-statut-clos { background-color: #757575; }

.badge-priorite-critique { background-color: #c62828; }
.badge-priorite-haute { background-color: #ef6c00; }
.badge-priorite-normale { background-color: #1565c0; }
.badge-priorite-basse { background-color: #616161; }

.echeance-retard { color: #c62828; font-weight: 600; }

.conflit-alert { border-left: 4px solid #c62828; }

table.table thead th {
  border-bottom-width: 1px;
  color: var(--texte-doux);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

a { text-decoration: none; }

.calendrier-grille {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendrier-entete {
  text-align: center;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--texte-doux);
  padding-bottom: 4px;
}

.calendrier-jour {
  background-color: var(--surface);
  border-radius: .5rem;
  min-height: 110px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.calendrier-jour.hors-mois {
  background-color: var(--fond);
  opacity: .6;
}

.calendrier-jour.aujourdhui {
  border: 2px solid var(--brand-accent);
}

.calendrier-numero {
  font-weight: 600;
  font-size: .85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calendrier-numero a {
  color: inherit;
  visibility: hidden;
}

.calendrier-jour:hover .calendrier-numero a {
  visibility: visible;
}

.calendrier-evenement {
  display: block;
  font-size: .72rem;
  padding: 1px 5px;
  border-radius: .3rem;
  margin-top: 3px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* Tableau de bord : graphiques */
.legende-carre {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: baseline;
}

.barre-domaine {
  height: 8px;
  background-color: var(--bordure);
  border-radius: 4px;
  overflow: hidden;
}

.barre-domaine > div {
  height: 100%;
  background-color: var(--brand-accent);
  border-radius: 4px;
}

/* Menu des paramètres. */
.menu-parametres { position: sticky; top: 5rem; }
.menu-parametres-titre { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-doux); margin: 0 0 .35rem .25rem; }
.menu-parametres .list-group { border-radius: .6rem; }
.menu-parametres .list-group-item { background-color: var(--surface); border-color: var(--bordure); padding: .5rem .75rem; font-size: .9rem; }
.menu-parametres .list-group-item.active { background-color: var(--brand-accent); border-color: var(--brand-accent); color: #fff; }
@media (max-width: 991px) { .menu-parametres { position: static; } }

/* Version téléphone (templates/mobile) */
body.mobile { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
.mobile input, .mobile select, .mobile textarea { font-size: 16px; }   /* sinon Safari zoome à la saisie */
.mobile-entete {
  position: sticky; top: 0; z-index: 10; color: #fff; background-color: var(--brand-dark);
  padding: calc(.75rem + env(safe-area-inset-top)) 1rem .75rem;
}
.mobile-contenu { padding: 1rem; max-width: 640px; margin: 0 auto; }
.mobile-chrono:not([hidden]) {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; margin-bottom: 1rem;
  background: var(--bs-body-bg); border: 1px solid var(--brand-accent); border-radius: .5rem;
  font-variant-numeric: tabular-nums; position: sticky; top: .5rem; z-index: 5;
}
.mobile-ligne {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--bordure);
}
.mobile-ligne:last-child { border-bottom: 0; }
.mobile-lien { color: inherit; text-decoration: none; min-height: 3rem; }
.mobile-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background-color: var(--surface); border-top: 1px solid var(--bordure);
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; padding: .5rem 0;
  color: var(--texte-doux); text-decoration: none; font-size: .75rem;
}
.mobile-nav a i { font-size: 1.25rem; }
.mobile-nav a.actif { color: var(--brand-accent); }

.sidebar a[data-bs-toggle="collapse"] .bi-chevron-down { transition: transform .15s; }
.sidebar a[data-bs-toggle="collapse"]:not(.collapsed) .bi-chevron-down { transform: rotate(180deg); }
