:root {
  --fond: #f4f5f7;
  --surface: #ffffff;
  --encre: #18212f;
  --discret: #5f6b7a;
  --trait: #e2e6ec;
  --marine: #1f3a5f;
  --marine-clair: #e9eff7;
  --rouge: #b42318;
  --rouge-fond: #fdeceb;
  --orange: #9a4a07;
  --orange-fond: #fdf1e3;
  --vert: #0f6b5c;
  --vert-fond: #e4f4f0;
  --violet: #4c3fa8;
  --violet-fond: #eeecfb;
  --rayon: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--marine); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .75rem; }
p { margin: 0 0 .6rem; }
code { background: #eef0f3; padding: .1rem .35rem; border-radius: 4px; font-size: .88em; }
.discret { color: var(--discret); }
.petit { color: var(--discret); font-size: .84rem; }
.attention { color: var(--orange); }
.negatif { color: var(--rouge); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- bandeau ---- */
.bandeau {
  background: var(--marine); color: #fff; display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem; min-height: 52px; flex-wrap: wrap;
}
.marque { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.bandeau nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.bandeau nav a {
  color: #d5deea; text-decoration: none; padding: .95rem .75rem; border-bottom: 3px solid transparent; font-weight: 500;
}
.bandeau nav a:hover { color: #fff; }
.bandeau nav a.actif { color: #fff; border-bottom-color: #f97316; }
.sortie { display: flex; align-items: center; gap: .75rem; margin: 0; }
.qui { color: #d5deea; font-size: .9rem; }
.pastille {
  display: inline-block; background: #f97316; color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700;
  padding: .05rem .45rem; margin-left: .35rem; vertical-align: 1px;
}
button.lien { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.bandeau button.lien { color: #d5deea; }
button.lien.danger { color: var(--rouge); }

main { max-width: 1320px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.entete-page { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fil { margin-bottom: .5rem; }
.fil a { text-decoration: none; }
.messages p, .bandeau-info {
  background: var(--marine-clair); border: 1px solid #c9d7ea; color: var(--marine); border-radius: var(--rayon);
  padding: .6rem .9rem; margin: 0 0 1rem;
}
.alerte { background: var(--rouge-fond); color: var(--rouge); border-radius: 8px; padding: .6rem .8rem; }

/* ---- boutons et champs ---- */
.bouton {
  display: inline-block; background: var(--surface); color: var(--encre); border: 1px solid #cdd3dc; border-radius: 8px;
  padding: .5rem .9rem; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.bouton:hover { border-color: var(--marine); }
.bouton.principal { background: var(--marine); border-color: var(--marine); color: #fff; }
.bouton[disabled] { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid #cdd3dc; border-radius: 8px; padding: .48rem .65rem;
  max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus, .bouton:focus-visible, a:focus-visible { outline: 2px solid #f97316; outline-offset: 1px; }
label { display: block; font-size: .88rem; color: var(--discret); }
label input, label select, label textarea { display: block; width: 100%; margin-top: .25rem; color: var(--encre); font-size: .95rem; }
.pile { display: grid; gap: .75rem; }
.pile.separe { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--trait); }
.ligne { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; }
.case-simple { display: flex; align-items: center; gap: .5rem; color: var(--encre); }
.case-simple input { width: auto; margin: 0; }

/* ---- onglets et filtres ---- */
.onglets { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .85rem; }
.onglets a {
  text-decoration: none; color: var(--discret); background: var(--surface); border: 1px solid var(--trait); border-radius: 999px;
  padding: .38rem .85rem; font-weight: 600; font-size: .9rem;
}
.onglets a span { font-weight: 700; color: var(--encre); margin-left: .25rem; }
.onglets a.actif { background: var(--marine); border-color: var(--marine); color: #fff; }
.onglets a.actif span { color: #fff; }
.filtres { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filtres input[type=search] { flex: 1 1 240px; min-width: 200px; }
.cases { display: flex; gap: .35rem; flex-wrap: wrap; }
.case {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid #cdd3dc; background: var(--surface); border-radius: 999px;
  padding: .36rem .75rem; color: var(--encre); cursor: pointer; font-size: .88rem; user-select: none;
}
.case input { width: auto; margin: 0; accent-color: var(--marine); }
.case.cochee { border-color: var(--marine); background: var(--marine-clair); }

/* ---- blocs ---- */
.bloc { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.bloc.vide { text-align: center; padding: 2.5rem 1rem; color: var(--discret); }
.deux-colonnes { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
.deux-colonnes.egales { grid-template-columns: repeat(2, minmax(0, 1fr)); }
details summary { cursor: pointer; color: var(--marine); font-weight: 600; margin: .5rem 0; }

/* ---- classement ---- */
.tableau-defilant { overflow-x: auto; background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); }
.bloc .tableau-defilant { border: 0; border-radius: 0; }
table { border-collapse: collapse; width: 100%; }
.classement th, .classement td { padding: .65rem .8rem; border-bottom: 1px solid var(--trait); vertical-align: top; text-align: left; }
.classement th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--discret); background: #fafbfc; white-space: nowrap; }
.classement th.num, .classement td.num { text-align: right; }
.classement tbody tr:last-child td { border-bottom: 0; }
.classement tbody tr:hover { background: #fafbfd; }
.classement tr.ecartee { opacity: .55; }
a.nom { font-weight: 650; text-decoration: none; color: var(--encre); }
a.nom:hover { color: var(--marine); text-decoration: underline; }
.pied { margin-top: .75rem; font-size: .86rem; }

.puce {
  display: inline-block; border-radius: 6px; padding: .1rem .5rem; font-size: .8rem; font-weight: 600; background: #eef0f3; color: #3b4656;
  white-space: nowrap;
}
.puce.groupe { background: var(--violet-fond); color: var(--violet); }
.puce.inde { background: var(--vert-fond); color: var(--vert); }
.puce.reseau { background: #e6f1fb; color: #1d5a94; }
.puce.cible { background: var(--rouge-fond); color: var(--rouge); }
.puce.suivi { background: var(--marine-clair); color: var(--marine); }
.etiquettes { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }

.signal { font-size: .86rem; border-left: 3px solid #d97706; padding: .08rem 0 .08rem .55rem; margin-bottom: .3rem; }
.signal.fort { border-left-color: var(--rouge); }
.signal b { font-weight: 650; }
.signal span { color: var(--discret); }
.signal.grand { font-size: .95rem; padding: .35rem 0 .35rem .75rem; margin-bottom: .5rem; }
.signal.grand span { display: block; }

.score { display: inline-block; min-width: 2.3rem; text-align: center; border-radius: 999px; padding: .12rem .55rem; font-weight: 700; font-size: .85rem; background: #eef0f3; color: #3b4656; }
.score.s20 { background: #fdf1e3; color: #9a4a07; }
.score.s40 { background: #fbe0c4; color: #8a3c05; }
.score.s60 { background: #f9c9c4; color: #91170f; }
.score.s80 { background: #b42318; color: #fff; }

/* ---- fiche ---- */
.comptes th, .comptes td { padding: .5rem .7rem; border-bottom: 1px solid var(--trait); }
.comptes thead th { font-size: .8rem; color: var(--discret); font-weight: 600; }
.comptes tbody th { text-align: left; font-weight: 500; white-space: nowrap; }
.comptes tbody tr:last-child th, .comptes tbody tr:last-child td { border-bottom: 0; }
.annonces { list-style: none; margin: 0; padding: 0; }
.annonces li { display: flex; gap: .9rem; padding: .6rem 0; border-top: 1px solid var(--trait); }
.annonces li:first-child { border-top: 0; }
.annonces li.forte b { color: var(--rouge); }
.annonces .date { flex: 0 0 5.4rem; color: var(--discret); font-size: .86rem; font-variant-numeric: tabular-nums; }
.annonces p { margin: .2rem 0 0; }
.annonces.compactes li { padding: .3rem 0; font-size: .88rem; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { padding: .45rem 0; border-top: 1px solid var(--trait); }
.liste li:first-child { border-top: 0; }
.infos { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 .75rem; }
.infos dt { color: var(--discret); }
.infos dd { margin: 0; text-align: right; font-weight: 600; }
.liens { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0; }

/* ---- nouveautés ---- */
.fil-nouveautes { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); }
.fil-nouveautes li { display: flex; gap: 1rem; padding: .8rem 1rem; border-top: 1px solid var(--trait); align-items: flex-start; }
.fil-nouveautes li:first-child { border-top: 0; }
.fil-nouveautes li.nouveau { background: #fffaf3; }
.fil-nouveautes .date { flex: 0 0 5.4rem; color: var(--discret); font-size: .86rem; font-variant-numeric: tabular-nums; padding-top: .1rem; }
.fil-nouveautes li > div { flex: 1; min-width: 0; }
.fil-nouveautes p { margin: .25rem 0 0; }
.puce.t-procedure { background: var(--rouge-fond); color: var(--rouge); }
.puce.t-cession, .puce.t-cible { background: var(--orange-fond); color: var(--orange); }
.puce.t-signal { background: #fbe0c4; color: #8a3c05; }
.puce.t-comptes { background: var(--marine-clair); color: var(--marine); }

/* ---- réglages ---- */
.seuils { display: grid; gap: .7rem; }
.seuils label { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: var(--encre); font-size: .95rem; }
.seuils label small { display: block; color: var(--discret); font-size: .8rem; }
.champ { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.champ input { width: 8.5rem; margin: 0; text-align: right; }
.champ em { font-style: normal; color: var(--discret); min-width: 4.2rem; font-size: .85rem; }
.journal td { padding: .4rem .5rem .4rem 0; border-top: 1px solid var(--trait); font-size: .88rem; vertical-align: top; }
.journal tr:first-child td { border-top: 0; }
.journal tr.echec td { color: var(--rouge); }

/* ---- carte ---- */
#carte { height: calc(100vh - 190px); min-height: 420px; border: 1px solid var(--trait); border-radius: var(--rayon); background: #dfe6ee; }
.legende { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .88rem; }
.legende label { display: inline-flex; align-items: center; gap: .35rem; color: var(--encre); cursor: pointer; }
.legende input { width: auto; margin: 0; }
.pt { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #cdd3dc; }
.pt.cible { background: #c2410c; } .pt.signal { background: #d97706; } .pt.sain { background: #0f766e; } .pt.autre { background: #64748b; }
.leaflet-popup-content ul { margin: .35rem 0; padding-left: 1.1rem; }

/* ---- connexion ---- */
.page-connexion main { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.carte-connexion {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--trait); border-radius: 14px; padding: 1.75rem;
  display: grid; gap: .9rem; box-shadow: 0 10px 30px rgba(24, 33, 47, .06);
}
.carte-connexion h1 { color: var(--marine); }

/* ---- téléphone ---- */
@media (max-width: 900px) {
  .deux-colonnes, .deux-colonnes.egales { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  main { padding: 1rem .9rem 2.5rem; }
  .bandeau { padding: .5rem .9rem 0; gap: .25rem 1rem; }
  .bandeau nav { order: 3; flex-basis: 100%; }
  .bandeau nav a { padding: .6rem .6rem; }
  .sortie { margin-left: auto; }
  .tableau-defilant { border: 0; background: none; overflow: visible; }
  .classement thead { display: none; }
  .classement, .classement tbody, .classement tr, .classement td { display: block; width: 100%; }
  .classement tr { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); margin-bottom: .7rem; padding: .5rem .2rem; }
  .classement td { border: 0; padding: .3rem .8rem; text-align: left !important; }
  .classement td[data-titre]:not([data-titre="Clinique"]):not([data-titre="Signaux"])::before {
    content: attr(data-titre) " : "; color: var(--discret); font-size: .84rem;
  }
  .classement td:empty { display: none; }
  .classement td .petit { display: inline; margin-left: .3rem; }
  .classement td[data-titre="Clinique"] .petit { display: block; margin-left: 0; }
  .filtres select { flex: 1 1 100%; }
  .seuils label { flex-direction: column; align-items: stretch; }
  .champ input { flex: 1; width: auto; }
  #carte { height: 70vh; }
}
