:root {
  --rouge: #92181c; --rouge-clair: #f6e8e8; --texte: #1f2328; --muted: #6b7280;
  --bord: #e3e5e8; --fond: #f6f7f9; --carte: #fff; --rayon: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texte); background: var(--fond); }
a { color: var(--rouge); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
h2 { font-size: 1.15rem; margin: 1.2em 0 .5em; }
h3 { font-size: 1rem; margin: 1em 0 .4em; }
.muted { color: var(--muted); } .small { font-size: .85em; }

.top { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between;
  padding: .7rem 1.2rem; background: #fff; border-bottom: 1px solid var(--bord); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 600; color: var(--texte); display: flex; align-items: center; gap: .55rem; }
.logo { width: 18px; height: 18px; background: var(--rouge); display: inline-block; }
.top nav { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .93rem; }
.top nav a { color: var(--texte); }
main { max-width: 1280px; margin: 0 auto; padding: 1rem 1.2rem 3rem; }

.card { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.2rem; margin: 0 0 1rem; }
.card.narrow { max-width: 440px; margin: 3rem auto; }
.card.warn { border-left: 4px solid #fdab3d; }
.card.total { display: flex; flex-wrap: wrap; gap: .5rem 2rem; background: var(--rouge-clair); border-color: #e9cfcf; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.card.link { display: flex; flex-direction: column; gap: .3rem; color: var(--texte); }
.card.link:hover { border-color: var(--rouge); text-decoration: none; }

.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; }
.bar h1, .bar h2 { margin: .4em 0; }
.crumb { margin: 0 0 .3rem; font-size: .9rem; }
.btn { display: inline-block; border: 1px solid var(--rouge); background: var(--rouge); color: #fff; padding: .5rem .95rem;
  border-radius: 6px; font: inherit; cursor: pointer; text-decoration: none !important; }
.btn.light { background: #fff; color: var(--rouge); }
.btn.danger { background: #fff; color: #b42318; border-color: #b42318; margin-left: auto; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--rouge); }
button.link.danger { color: #b42318; font-size: .85em; }

.flash { padding: .65rem 1rem; border-radius: 6px; margin: 0 0 1rem; background: #e7f6ee; border: 1px solid #b7e3c9; }
.flash.err { background: #fdecec; border-color: #f3c0c0; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: #374151; margin: 0 0 .8rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #cfd3d8; border-radius: 6px; background: #fff; width: 100%; }
input[type=checkbox] { width: auto; }
input[type=file] { border-style: dashed; }
textarea { resize: vertical; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 1rem; }
.fields .wide { grid-column: 1 / -1; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.filters input { flex: 1 1 240px; width: auto; } .filters select { width: auto; }
.filebox { border: 1px solid var(--bord); border-radius: 6px; padding: .7rem; margin: 0 0 .7rem; }
.fileline { display: flex; gap: 1rem; align-items: center; margin: .3rem 0; }
.copy { font-family: ui-monospace, monospace; font-size: .85rem; }

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); font-size: .92rem; }
.grid th, .grid td { padding: .5rem .65rem; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: top; white-space: nowrap; }
.grid td { white-space: normal; min-width: 90px; }
.grid th { font-weight: 600; font-size: .8rem; color: var(--muted); background: #fafbfc; }
.grid .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid tfoot td { font-weight: 600; background: #fafbfc; }
.grid tr.child td:first-child { padding-left: 1.8rem; }
.grid tr.child td:first-child::before { content: "↳ "; color: var(--muted); }
.grid tr.off td { color: var(--muted); }
.group { margin: 0 0 1.2rem; }
.group h2, .group h3 { display: flex; align-items: center; gap: .5rem; border-left: 4px solid var(--rouge); padding-left: .55rem; }
.count { font-size: .8rem; font-weight: 500; color: var(--muted); }
.add { font-size: 1.1rem; line-height: 1; padding: 0 .35rem; border: 1px solid var(--bord); border-radius: 4px; }
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 99px; color: #fff; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.file { display: inline-block; font-size: .8rem; background: var(--rouge-clair); padding: .05rem .4rem; border-radius: 4px; margin: 0 .2rem .2rem 0; }
.late { color: #b42318; }
.plain { list-style: none; padding: 0; margin: 0; } .plain li { padding: .25rem 0; }
.recap summary { cursor: pointer; font-weight: 600; }
.recap table { margin-top: .7rem; }

.infos dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem 1.2rem; margin: 0; }
.infos dt, .extra dt { font-size: .78rem; color: var(--muted); } .infos dd, .extra dd { margin: 0; }
.extra dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem 1rem; }
.notes { background: #fffbea; border-radius: 6px; padding: .6rem .8rem; }
.jalons { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .5rem; list-style: none; padding: 0; margin: 0; counter-reset: j; }
.jalons li { border-top: 4px solid var(--bord); padding: .4rem .2rem 0; display: flex; flex-direction: column; font-size: .88rem; }
.jalons li.done { border-color: var(--rouge); }
.jalons span { color: var(--muted); font-size: .8rem; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--bord); margin: 1.2rem 0 .5rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--texte); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { border-color: var(--rouge); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: #fff; }

@media (max-width: 640px) {
  main { padding: .8rem .7rem 3rem; }
  .top { padding: .6rem .8rem; }
  h1 { font-size: 1.3rem; }
  .card { padding: .8rem; }
}

/* Mobile : chaque ligne devient une fiche lisible sans défilement horizontal */
@media (max-width: 640px) {
  table.rows, table.rows tbody, table.rows tfoot, table.rows tr, table.rows td { display: block; width: 100%; }
  table.rows thead { display: none; }
  table.rows tr { border-bottom: 1px solid var(--bord); padding: .45rem 0; }
  table.rows td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .15rem .7rem; min-width: 0; text-align: right; }
  table.rows td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; max-width: 45%; }
  table.rows td.first { font-size: 1rem; text-align: left; }
  table.rows td.first::before { display: none; }
  table.rows td:empty, table.rows tfoot td.lbl { display: none; }
  table.rows tfoot tr { background: #fafbfc; }
  table.rows tr.child td.first { padding-left: 1.6rem; }
}

/* Actions : compteurs et groupes repliables */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; margin: 0 0 1rem; }
.kpi { background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); padding: .7rem .9rem; color: var(--texte); }
.kpi strong { display: block; font-size: 1.5rem; line-height: 1.1; }
.kpi.late strong { color: #b42318; }
.kpi.on { border-color: var(--rouge); box-shadow: inset 0 0 0 1px var(--rouge); }
.kpi:hover { text-decoration: none; border-color: var(--rouge); }
details.group > summary { cursor: pointer; list-style: none; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary h3 { display: inline-flex; }
details.group > summary h3::after { content: "▸ afficher"; font-size: .8rem; font-weight: 400; color: var(--muted); }
details.group[open] > summary h3::after { content: "▾ masquer"; }
td.late, td.late a { color: #b42318; font-weight: 600; }

/* Étiquettes modifiables d'un clic (comme dans monday) */
.tag-edit { border: 0; background: none; padding: 0; margin: 0; font: inherit; cursor: pointer; text-align: left; border-radius: 99px; }
.tag-edit:hover .pill, .tag-edit:focus-visible .pill { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(146, 24, 28, .35); }
.tag-edit:focus-visible { outline: none; }
.tag-edit .tag-empty { display: inline-block; min-width: 3.2rem; padding: .12rem .55rem; border: 1px dashed #c9ccd1; border-radius: 99px;
  color: var(--muted); font-size: .8rem; text-align: center; }
.tag-edit:hover .tag-empty { border-color: var(--rouge); color: var(--rouge); }
.tag-edit.saving { opacity: .5; pointer-events: none; }
.tag-menu { position: absolute; z-index: 50; background: #fff; border: 1px solid var(--bord); border-radius: 10px; padding: .55rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15); display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: .4rem; }
.tag-menu button { border: 0; border-radius: 6px; padding: .45rem .6rem; font: inherit; font-size: .85rem; font-weight: 500; color: #fff;
  cursor: pointer; text-align: center; white-space: nowrap; }
.tag-menu button.plain { background: #eceef1; color: var(--texte); }
.tag-menu button.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--texte); }
.tag-menu button.clear { grid-column: 1 / -1; background: none; color: var(--muted); border: 1px dashed #c9ccd1; }
.tag-menu button:hover { filter: brightness(1.08); }
.toast-err { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 60; background: #b42318; color: #fff;
  padding: .6rem 1rem; border-radius: 8px; font-size: .9rem; }

/* Menu déroulant « Administration » */
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; color: var(--texte); }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; font-size: .8em; color: var(--muted); }
.menu[open] summary::after { content: " ▴"; }
.menu.on summary { font-weight: 600; }
.menu-list { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 20; min-width: 190px; background: #fff;
  border: 1px solid var(--bord); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); padding: .35rem 0;
  display: flex; flex-direction: column; }
.top nav .menu-list a { padding: .5rem .9rem; color: var(--texte); white-space: nowrap; }
.top nav .menu-list a:hover { background: var(--fond); text-decoration: none; }
.top nav .menu-list a.on { color: var(--rouge); font-weight: 600; }
@media (max-width: 640px) { .menu-list { right: auto; left: 0; } }

/* Suivi des dépenses (1.6.0) */
.form small.help { display: block; font-weight: 400; color: var(--gris, #6b7280); font-size: .8rem; margin-top: .2rem; }
.form input[readonly] { background: #f4f4f5; }
tr.hors-total td { color: #8a8f98; font-style: italic; }
tr.hors-total td .pill { font-style: normal; }
.recap h4 { margin: 1rem 0 .4rem; font-size: .95rem; }
.kpi.muted strong { color: #8a8f98; }

/* Import monday par lots (1.6.1) */
[hidden] { display: none !important; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row-between h2 { margin: 0; }
.actions-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }
form.inline { display: inline; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent, #92181c); text-decoration: underline; cursor: pointer; font: inherit; }
.imp-bar { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; margin-top: .25rem; min-width: 80px; }
.imp-bar i { display: block; height: 100%; background: #00c875; }
#imp-table td.err { color: #c0392b; }

/* Historique des modifications (1.7.0) */
.histo-box > summary { cursor: pointer; font-weight: 600; }
ol.histo { list-style: none; padding: 0; margin: .6rem 0 0; }
ol.histo > li { border-left: 2px solid #e4dcdc; padding: .1rem 0 .7rem .9rem; position: relative; }
ol.histo > li::before { content: ""; position: absolute; left: -5px; top: .45rem; width: 8px; height: 8px; border-radius: 50%; background: #92181c; }
.histo-tete { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; font-size: .9rem; }
.histo-tete time { color: #555; }
.histo-src { font-size: .75rem; background: #f1efef; border-radius: 9px; padding: 0 .45rem; color: #666; }
.histo-objet { color: #333; }
ol.histo ul { list-style: none; padding: 0; margin: .2rem 0 0; font-size: .88rem; }
ol.histo ul li { padding: .1rem 0; }
.histo-champ { font-weight: 600; }
ol.histo del { color: #a33; text-decoration: line-through; }
ol.histo ins { color: #127a3c; text-decoration: none; }
.histo-suppression { color: #a33; }
.histo-creation, .histo-restauration { color: #127a3c; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: end; }
.filters label.check { display: flex; gap: .4rem; align-items: center; padding-bottom: .5rem; }

/* Historique des connexions (1.7.2) */
table.connexions tr.echec td { background: #fdf1f2; }
.kpi.alerte strong { color: #df2f4a; }

/* Marchés et propositions de paiement (1.8.0) */
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .7rem 1rem; }
.grid-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.grid-form label.wide { grid-column: 1 / -1; }
table.saisie input, table.saisie textarea { width: 100%; box-sizing: border-box; font: inherit; padding: .25rem .35rem; border: 1px solid #ddd; border-radius: 4px; }
table.saisie textarea { resize: vertical; min-height: 1.9rem; }
table.saisie input.num { text-align: right; }
table.saisie tr.modele { display: none; }
.postes .bar h3 { margin: 0; }
details.coller { margin-top: -.4rem; }
details.coller textarea { width: 100%; font-family: ui-monospace, monospace; font-size: .8rem; }
.inline-details { display: inline-block; vertical-align: top; }
.inline-details > summary { list-style: none; display: inline-block; cursor: pointer; }
.inline-details[open] > .card { margin-top: .5rem; max-width: 640px; }
table.avancement td.des { max-width: 420px; }
table.avancement input.pct { width: 5.2rem; text-align: right; font: inherit; padding: .2rem .3rem; border: 1px solid #ccc; border-radius: 4px; }
table.avancement input.pct.change { border-color: #92181c; font-weight: 600; }
table.avancement input.pct.trop { background: #fdecec; border-color: #df2f4a; }
table.avancement tr.groupe td { background: #f4eded; color: #92181c; font-weight: 600; }
table.avancement tr.chapitre td { font-weight: 600; color: #444; }
.synthese .kpi.alerte-ok strong { color: #92181c; }
.actions .spacer { flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
dl.grid2 { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.4rem; margin: .5rem 0; }
dl.grid2 dt { color: #6b6f76; } dl.grid2 dd { margin: 0; }
strong.err { color: #c0392b; }
/* Plans (1.8.5) */
h3.plan-niveau { display: flex; align-items: center; gap: .5rem; border-left: 4px solid var(--rouge); padding-left: .55rem; margin-top: 1.4rem; }
.row3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 1rem; }
.indice { display: inline-block; min-width: 1.7em; padding: .05em .45em; border-radius: 4px; background: var(--rouge); color: #fff;
  font-weight: 600; text-align: center; font-size: .9em; vertical-align: middle; }
.indice.ancien { background: #c9ccd1; color: #333; }
tr.ancien td { color: #6b6f76; }
a.fic { display: inline-block; padding: .05em .4em; border: 1px solid #d6d8dc; border-radius: 4px; font-size: .78rem; font-weight: 600; text-decoration: none; }
a.fic:hover { border-color: var(--rouge); }
table.plans details summary { cursor: pointer; font-size: .85rem; color: #6b6f76; white-space: nowrap; }
ul.histo-indices { list-style: none; padding: 0; margin: .3rem 0 0; } ul.histo-indices li { margin: 0 0 .4rem; font-size: .85rem; }
details.plans-annules { margin-top: 1.5rem; } details.plans-annules > summary { cursor: pointer; color: #6b6f76; }
.btn.trimble { display: inline-flex; align-items: center; gap: .35rem; }
table.plans { table-layout: fixed; width: 100%; min-width: 900px; }
table.plans th:nth-child(1) { width: 8%; } table.plans th:nth-child(2) { width: 19%; } table.plans th:nth-child(3) { width: 6%; }
table.plans th:nth-child(4) { width: 7%; } table.plans th:nth-child(5) { width: 6%; } table.plans th:nth-child(6) { width: 9%; }
table.plans th:nth-child(7) { width: 18%; } table.plans th:nth-child(8) { width: 9%; } table.plans th:nth-child(9) { width: 18%; }
table.plans td { overflow-wrap: anywhere; }
