* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #1d2433; background: #f5f6f8; }
a { color: #2557d6; text-decoration: none; }
a:hover { text-decoration: underline; }
nav.top { display: flex; gap: 18px; align-items: center; padding: 12px 24px; background: #1d2433; }
nav.top a, nav.top button.link { color: #e6e9f0; }
nav.top .brand { font-weight: 700; color: #fff; margin-right: 12px; }
nav.top .spacer { flex: 1; }
main { max-width: 1200px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 8px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card { background: #fff; border: 1px solid #e2e5ea; border-radius: 8px; padding: 20px; margin: 16px 0; }
.card.narrow { max-width: 420px; margin: 60px auto; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; margin-bottom: 12px; font-weight: 500; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 7px 9px; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; background: #fff; }
label.inline input, form.inline input, .filters input, .filters select { display: inline-block; width: auto; margin-top: 0; }
form.inline { display: inline; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; }
.grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 12px; align-items: center; }
button, .btn { display: inline-block; padding: 7px 14px; border: 0; border-radius: 6px; background: #2557d6; color: #fff; font: inherit; cursor: pointer; }
.btn:hover { text-decoration: none; }
button.secondary, .btn.secondary { background: #e8ecf4; color: #1d2433; }
button.danger { background: #fbe9e9; color: #b42318; }
button.link { background: none; padding: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.totals { display: flex; gap: 12px; margin: 12px 0 16px; flex-wrap: wrap; }
.totals div { background: #fff; border: 1px solid #e2e5ea; border-radius: 8px; padding: 10px 16px; min-width: 150px; }
.totals span { display: block; color: #6b7385; font-size: 12px; }
.totals strong { font-size: 18px; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e2e5ea; border-radius: 8px; overflow: hidden; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: middle; }
th { background: #fafbfc; font-size: 12px; color: #6b7385; font-weight: 600; }
.r { text-align: right; white-space: nowrap; }
.pos { color: #137a3a; }
.neg { color: #b42318; }
.muted { color: #9aa1b0; }
.center { text-align: center; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; background: #e7f6ec; color: #137a3a; }
.flash.err { background: #fbe9e9; color: #b42318; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } nav.top { flex-wrap: wrap; } table { font-size: 12px; } }

.split { display: grid; grid-template-columns: minmax(280px, 1fr) 1.4fr; gap: 16px; align-items: start; }
.apercu { position: sticky; top: 16px; padding: 8px; }
.apercu img { width: 100%; display: block; border-radius: 4px; }
.apercu iframe { width: 100%; height: 80vh; border: 0; }
input.readonly { background: #f5f6f8; color: #6b7385; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 280px;
  border: 2px dashed #b9c2d3; border-radius: 12px; background: #fff; cursor: pointer; text-align: center; padding: 24px; transition: .15s; }
.drop.over { border-color: #2557d6; background: #eef3ff; }
.drop .big { font-size: 40px; }
.drop.busy { opacity: .8; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } .apercu { position: static; } }
input[hidden] { display: none !important; }

.barre { height: 8px; background: #e8ecf4; border-radius: 4px; overflow: hidden; margin: 8px 0 12px; }
.barre div { height: 100%; background: #2557d6; transition: width .4s; }
form.ignorer { margin-top: 12px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.tabs a { padding: 6px 12px; border-radius: 6px; background: #fff; border: 1px solid #e2e5ea; color: #1d2433; }
.tabs a.actif { background: #1d2433; color: #fff; border-color: #1d2433; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: #b42318; color: #fff; font-size: 11px; text-align: center; }
.barre-outils { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; }
.barre-outils .spacer { flex: 1; }
.barre-outils a.actif { font-weight: 600; }
tr.muted td { color: #9aa1b0; }

.badge.warn { background: #b54708; }
.ecart { margin-top: 4px; padding: 6px 8px; background: #fef6e7; border-radius: 6px; color: #8a4b0f; font-size: 13px; }

table.echeances { margin: 6px 0; width: auto; }
table.echeances td { padding: 4px 6px; }
table.echeances input, table.echeances select { margin-top: 0; }

.drop.compacte { min-height: 90px; padding: 14px; margin-bottom: 10px; }
.attente { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 12px; margin-bottom: 12px; background: #fef6e7; border-radius: 8px; font-size: 13px; }
#modale { position: fixed; inset: 0; z-index: 50; }
.modale-fond { position: absolute; inset: 0; background: rgba(20, 24, 36, .55); }
.modale-boite { position: absolute; inset: 3vh 3vw; background: #f5f6f8; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modale-boite iframe { width: 100%; height: 100%; border: 0; }
.modale-x { position: absolute; top: 6px; right: 10px; z-index: 2; background: #fff; color: #1d2433; font-size: 22px; line-height: 1; padding: 4px 10px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
html.embed nav.top { display: none; }
html.embed main { max-width: none; padding: 16px 20px; }
.squelette div { height: 34px; margin: 10px 0; border-radius: 6px; background: linear-gradient(90deg, #eef0f3 25%, #f7f8fa 50%, #eef0f3 75%); background-size: 200% 100%; animation: sq 1.2s infinite; }
@keyframes sq { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.code { font-size: 18px; letter-spacing: 1px; background: #eef3ff; padding: 2px 8px; border-radius: 4px; }
.flash.recu { background: #eef3ff; color: #1d2433; }
.flash.recu form { margin-left: 8px; }
fieldset.bloc { border: 1px solid #e2e5ea; border-radius: 8px; padding: 8px 16px 4px; margin: 6px 0 14px; }
fieldset.bloc legend { font-weight: 700; font-size: 15px; padding: 0 6px; color: #1d2433; }
fieldset.bloc > .grid { gap: 0 16px; }
label[hidden] { display: none !important; }
.reg-detail[hidden], div[hidden] { display: none !important; }
.warn { color: #b54708; }

.lbl { display: block; font-weight: 500; margin-bottom: 4px; }
.segments { display: inline-flex; border: 1px solid #cfd4dc; border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.seg { margin: 0; cursor: pointer; font-weight: 500; }
.seg input { display: none; }
.seg span { display: block; padding: 8px 16px; background: #fff; color: #1d2433; border-right: 1px solid #cfd4dc; transition: background .15s, color .15s; }
.seg:last-child span { border-right: 0; }
.seg span:hover { background: #f1f3f7; }
.seg-non input:checked + span { background: #b42318; color: #fff; }
.seg-part input:checked + span { background: #b54708; color: #fff; }
.seg-oui input:checked + span { background: #137a3a; color: #fff; }
tr.cliquable { cursor: pointer; transition: background-color .2s ease, box-shadow .2s ease, transform .2s ease; }
tr.cliquable:hover { background: linear-gradient(90deg, #eef3ff, #f5efff); box-shadow: inset 4px 0 0 #6d28d9; }
tr.cliquable:hover td { color: inherit; }

/* ---------- Thème chaleureux ---------- */
:root {
  --fond: #f7f1e8;          /* crème */
  --carte: #fffdf9;         /* blanc cassé chaud */
  --bord: #e6d9c6;          /* sable */
  --entete: #f1e6d6;        /* beige */
  --zebre: #fcf7ef;
  --texte: #3b2f26;         /* brun foncé */
  --doux: #8a7564;          /* taupe */
  --accent: #b5532c;        /* terre cuite */
  --accent-fonce: #96421f;
  --accent-clair: #f6e2d3;
  --nav: #4a3428;           /* brun chocolat */
}
body { background: var(--fond); color: var(--texte); }
nav.top { background: var(--nav); box-shadow: 0 2px 8px rgba(74, 52, 40, .18); }
nav.top a, nav.top button.link { color: #f3e6d8; }
nav.top a:hover { color: #fff; text-decoration: none; }
a { color: var(--accent); }
.muted, .totals span, th { color: var(--doux); }
.card, .totals div, table, .drop, .tabs a { background: var(--carte); border-color: var(--bord); }
.card { box-shadow: 0 1px 3px rgba(74, 52, 40, .06); }
th { background: var(--entete); color: #6b5442; }
th, td { border-bottom-color: #efe5d7; }
input, select, textarea { border-color: #dccbb5; background: #fffdfa; color: var(--texte); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181, 83, 44, .15); }
input.readonly { background: #f4ece1; color: var(--doux); }
button, .btn { background: var(--accent); }
button:hover, .btn:hover { background: var(--accent-fonce); }
button.secondary, .btn.secondary { background: var(--accent-clair); color: #6b3a22; }
button.secondary:hover, .btn.secondary:hover { background: #efd2bd; }
button.link { background: none; color: var(--accent); }
.drop { border-color: #d9bfa3; background: #fffaf2; }
.drop.over { border-color: var(--accent); background: #fbeadb; }
.flash { background: #e9f3e4; }
.flash.recu { background: #f8ecdf; color: var(--texte); }
.attente { background: #fbe9d4; }
fieldset.bloc { border-color: var(--bord); background: #fffcf7; }
fieldset.bloc legend { color: var(--accent-fonce); }
.tabs a.actif { background: var(--nav); color: #fff; border-color: var(--nav); }
.segments { border-color: #dccbb5; }
.seg span { background: #fffdfa; border-right-color: #dccbb5; }
.seg span:hover { background: #f6ecdf; }
.barre { background: #efe3d3; }
.barre div { background: var(--accent); }
.modale-boite { background: var(--fond); }
tr.cliquable:hover { background: linear-gradient(90deg, #fbe4cf, #fdf3e6); box-shadow: inset 4px 0 0 var(--accent); }
.code { background: var(--accent-clair); }
.retour { margin: 0 0 8px; } .retour a { font-weight: 600; }
.badge.auto { background: #137a3a; font-weight: 600; }
.segments.modes { margin: 0; white-space: nowrap; }
.segments.modes button { border: 0; border-right: 1px solid #dccbb5; border-radius: 0; background: #fffdfa; color: #4a3b2a; padding: 4px 8px; font-size: 12px; font-weight: 500; }
.segments.modes button:last-child { border-right: 0; }
.segments.modes button:hover { background: #f6ecdf; }
.segments.modes button.on { background: var(--accent); color: #fff; }
main:has(table.fourn) { max-width: 1560px; }
table.fourn { table-layout: fixed; width: 100%; }
table.fourn th:nth-child(1) { width: 17%; }
table.fourn th:nth-child(2) { width: 8%; }
table.fourn th:nth-child(3) { width: 4%; }
table.fourn th:nth-child(4) { width: 7%; }
table.fourn th:nth-child(5) { width: 7%; }
table.fourn th:nth-child(6) { width: 7%; }
table.fourn th:nth-child(7) { width: 6%; }
table.fourn th:nth-child(8) { width: 41%; }
table.fourn th:nth-child(9) { width: 3%; }
table.fourn td { vertical-align: middle; padding-top: 6px; padding-bottom: 6px; }
table.fourn td.fn strong { display: block; }
table.fourn td.fn small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.fourn td.soc small, table.fourn td.fact small { line-height: 1.3; }
table.fourn td.fact a { text-decoration: none; margin-left: 4px; }
table.fourn .segments.modes { display: flex; width: 100%; }
table.fourn .segments.modes button { flex: 1 1 auto; padding: 4px 3px; font-size: 11px; white-space: nowrap; }
table.fourn a.edit { text-decoration: none; font-size: 15px; }
nav.top .sep { display: inline-block; width: 1px; height: 20px; margin: 0 18px; background: rgba(255,255,255,.45); align-self: center; }
table.fourn td.fact { white-space: nowrap; }
/* Menu latéral */
body:has(> nav.top) { padding-left: 210px; }
nav.top { position: fixed; top: 0; left: 0; bottom: 0; width: 210px; box-sizing: border-box; flex-direction: column; align-items: stretch;
  gap: 2px; padding: 18px 12px; overflow-y: auto; box-shadow: 2px 0 8px rgba(74, 52, 40, .18); }
nav.top a, nav.top button.link { display: block; padding: 7px 10px; border-radius: 6px; text-align: left; }
nav.top a:hover, nav.top button.link:hover { background: rgba(255,255,255,.08); }
nav.top a.actif { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
nav.top .brand { font-size: 18px; margin: 0 0 14px; padding: 4px 10px; }
nav.top .sep { display: block; width: auto; height: 1px; margin: 10px 6px; background: rgba(255,255,255,.3); }
nav.top .spacer { flex: 1; }
nav.top form.inline { display: block; }
nav.top button.link { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; }
@media (max-width: 760px) {
  body:has(> nav.top) { padding-left: 0; }
  nav.top { position: static; width: auto; flex-direction: row; flex-wrap: wrap; }
}
/* Relevés : navigation par société puis compte / carte */
.nav-comptes { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin: 8px 0 18px; }
.nav-soc { background: #fffdfa; border: 1px solid #e8dccb; border-radius: 10px; padding: 10px 12px; }
.nav-soc.courante { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.nav-soc-nom { font-weight: 600; margin-bottom: 8px; color: #4a3b2a; }
.nav-soc-comptes { display: flex; flex-direction: column; gap: 6px; }
.nav-cpt { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "type num" "etat etat"; gap: 2px 8px; padding: 7px 10px;
  border-radius: 7px; border: 1px solid #efe4d6; text-decoration: none; color: inherit; background: #fff; }
.nav-cpt:hover { background: #f6ecdf; }
.nav-cpt.actif { background: #4a3428; color: #fff; border-color: #4a3428; }
.nav-cpt.actif .pos { color: #c9f0d2; }
.nav-cpt-type { grid-area: type; font-weight: 500; }
.nav-cpt-num { grid-area: num; font-variant-numeric: tabular-nums; opacity: .75; }
.nav-cpt-etat { grid-area: etat; font-size: 12px; }
.badge.warn, .nav-cpt .badge.warn { background: #fde7c2; color: #7a4a00; }
table.resultat tr.titre td { font-weight: 600; background: #f6ecdf; color: #4a3b2a; }
table.resultat tr.sous-total td { font-weight: 600; border-top: 1px solid #dccbb5; }
table.resultat tr.resultat-net td { font-weight: 700; font-size: 15px; border-top: 2px solid #4a3428; }
/* Factures de ventes */
.fv-apercu { background: #fff; border: 1px solid #e8dccb; border-radius: 10px; padding: 14mm 0; margin-top: 10px; overflow-x: auto; }
.ligne-fv { display: grid; grid-template-columns: 1fr 160px; gap: 8px; margin-bottom: 6px; }
/* Relevés : couverture mensuelle */
details.couverture { background: #fffdfa; border: 1px solid #e8dccb; border-radius: 10px; padding: 8px 12px; margin: 0 0 16px; }
details.couverture summary { cursor: pointer; }
.couv-scroll { overflow-x: auto; margin-top: 8px; }
table.couv { width: auto; border-collapse: collapse; font-size: 12px; }
table.couv th, table.couv td { padding: 3px 5px; text-align: center; border: 1px solid #efe4d6; white-space: nowrap; }
table.couv th:first-child, table.couv td:first-child { text-align: left; position: sticky; left: 0; background: #fffdfa; }
table.couv th.an { border-left: 2px solid #c9b79f; }
.couv-ok { background: #dff3e4; color: #1e6b37; }
.couv-partiel { background: #fde7c2; color: #7a4a00; }
.couv-manque { background: #fbd9d5; color: #a3261a; font-weight: 600; }
.couv-avant { background: #f4efe8; }
td.statut-rapproche { color: #1e6b37; white-space: nowrap; font-size: 12px; }
td.statut-non_necessaire { color: #8a7a68; font-size: 12px; }
td.statut-a_rapprocher { color: #a3261a; font-weight: 600; white-space: nowrap; font-size: 12px; }
td.origine { white-space: nowrap; color: #6b5a47; cursor: help; }
