/* La déclaration de TVA – feuille de style commune à tous les niveaux
   Structure du modèle co-int ; couleurs reprises de miseenforme-orange.css */

:root {
	--pourpre: #C45911;        /* couleur principale : orange */
	--pourpre-fonce: #9A4409;
	--pourpre-clair: #FBEADB;
	--rouge: #C02539;
	--rouge-vif: #DC143C;
	--jaune: #FCC419;
	--jaune-clair: #FFF6D6;
	--vert: #187C09;           /* ce qu'on te donne */
	--vert-fonce: #125E07;
	--menthe: #E4F1E1;
	--menthe-clair: #F3F9F1;
	--brun: #6D3109;
	--gris: #F2F2F2;
	--gris-ligne: #E2DEDA;
	--fond: #F5F4F3;
	--texte: #2E2A27;
	--texte-doux: #6A625C;
	--ok: #187C09;
	--ok-fond: #E4F1E1;
	--ko: #C02539;
	--ko-fond: #FBE6E9;
	--rayon: 10px;
	--largeur-score: 118px;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--fond);
	color: var(--texte);
	font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
}
button, select, input { font-family: inherit; }
.cache { display: none !important; }
[hidden] { display: none !important; }   /* l'attribut hidden l'emporte sur les display des composants */

/* ===== Barre du haut ===== */
.topbar {
	position: sticky; top: 0; z-index: 20;
	background: var(--pourpre); color: #fff;
	display: flex; align-items: center; gap: 16px;
	padding: 10px 24px;
}
.topbar .logo { height: 46px; width: 46px; background: #fff; border-radius: 8px; padding: 3px; object-fit: contain; }
.topbar .titres { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 600; line-height: 1.25; }
.topbar .sous-titre { font-size: 13px; opacity: .9; }
.badge-niveau {
	display: inline-block; background: var(--jaune); color: var(--brun);
	font-weight: 700; font-size: 12px; padding: 2px 10px; border-radius: 20px;
	margin-left: 8px; vertical-align: middle;
}
.puce-eleve {
	display: flex; align-items: center; gap: 8px;
	background: rgba(255, 255, 255, .16); border-radius: 30px;
	padding: 6px 14px; font-size: 14px; white-space: nowrap;
}
.puce-eleve button {
	display: inline-flex; background: transparent; color: #fff; border: 0; padding: 2px; cursor: pointer; opacity: .85;
}
.puce-eleve button:hover { opacity: 1; }
.puce-eleve button:disabled { opacity: .35; cursor: default; }
.chrono { font-variant-numeric: tabular-nums; }

/* ===== Mise en page ===== */
main { max-width: 1440px; margin: 22px auto 0; padding: 0 calc(var(--largeur-score) + 30px) 0 24px; }

.carte {
	background: #fff; border-radius: var(--rayon);
	border: 1px solid var(--gris-ligne);
	margin-bottom: 18px; overflow: hidden;
}
.carte-titre {
	display: flex; align-items: center; gap: 10px; width: 100%;
	background: var(--pourpre); color: #fff;
	padding: 10px 16px; font-weight: 600; font-size: 16px; border: 0; text-align: left;
}
.carte-titre.vert { background: var(--vert); }
.carte-titre.jaune { background: var(--jaune); color: var(--brun); }
.carte-titre svg { flex: none; }
.carte-corps { padding: 14px 18px; }

.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grille.simple { grid-template-columns: 1fr; }
.grille > .carte { margin-bottom: 18px; }

/* ----- Consigne repliable ----- */
.consigne { display: flex; gap: 14px; }
.consigne .ico {
	flex: none; width: 40px; height: 40px; border-radius: 50%;
	background: var(--pourpre-clair); color: var(--pourpre);
	display: flex; align-items: center; justify-content: center;
}
.consigne-texte { flex: 1; min-width: 0; }
.consigne-texte h2 { margin: 0; font-size: 16px; }
.consigne-bascule {
	display: flex; align-items: center; gap: 8px; width: 100%;
	background: none; border: 0; padding: 8px 0; cursor: pointer;
	font-size: 16px; font-weight: 600; color: var(--pourpre); text-align: left;
}
.chevron { transition: transform .25s; }
.repliee .chevron { transform: rotate(-90deg); }
.consigne-contenu, .pliable { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .25s; }
.consigne-contenu > div, .pliable > div { overflow: hidden; }
.repliee .consigne-contenu, .repliee .pliable { grid-template-rows: 0fr; }
#listeConsignes { margin: 4px 0 10px; padding-left: 20px; }
#listeConsignes li { margin: 3px 0; }
.legende { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--texte-doux); padding-bottom: 6px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.pastille { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }

/* ----- Encadrés d'information (vert = ce qu'on te donne) ----- */
.bascule-carte { cursor: pointer; }
.bascule-carte span { flex: 1; }
.info { background: var(--menthe-clair); color: var(--texte); }
.info ul { margin: 0; padding-left: 20px; }
.info li { margin: 3px 0; }
.info p { margin: 0 0 6px; }

/* ----- Mémo partie double ----- */
.memo { background: var(--jaune-clair); color: var(--brun); }
.memo p { margin: 0 0 6px; }
.memo .regle { display: flex; gap: 10px; align-items: baseline; margin: 4px 0; }
.memo .ordre { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #E8CF8A; }

/* ===== Tableaux de saisie ===== */
.defile { overflow-x: auto; }
table.saisie { width: auto; border-collapse: collapse; font-size: 13.5px; }
table.saisie th {
	background: var(--jaune); color: var(--rouge);
	font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
	padding: 6px 6px; text-align: center; border: 1px solid #F1D57A; line-height: 1.25;
}
table.saisie td { padding: 4px 5px; border: 1px solid var(--gris-ligne); vertical-align: middle; text-align: center; }
table.saisie td.donnee { color: var(--texte); white-space: nowrap; }
table.saisie td.donnee.num { text-align: right; font-variant-numeric: tabular-nums; }
table.saisie td:first-child.donnee:not(.num):not(.date) { text-align: left; white-space: normal; }
table.saisie td.sans-objet { background: #FAF9F8; }
table.saisie td.etat, table.saisie th.th-etat { width: 34px; border-left: 2px solid var(--gris-ligne); }
table.saisie tr.ligne-total td { border-top: 2px solid var(--pourpre); background: var(--pourpre-clair); font-weight: 600; }
.carte-donnees table.saisie th { background: var(--menthe); color: var(--vert-fonce); border-color: #CFE5CA; }

.champ {
	width: 100%; min-width: 54px; height: 32px; padding: 0 6px;
	border: 1.5px solid #D9CFC7; border-radius: 6px; background: var(--jaune-clair);
	color: var(--texte); font-size: 13.5px; text-align: right; font-variant-numeric: tabular-nums;
}
.champ:focus { outline: none; border-color: var(--pourpre); box-shadow: 0 0 0 3px var(--pourpre-clair); background: #fff; }
.champ-date { min-width: 64px; text-align: center; }
.champ-doc { min-width: 100px; text-align: left; }
.champ-op { width: 38px; min-width: 38px; text-align: center; font-weight: 700; font-size: 16px; }
.champ-prix { min-width: 64px; }
.champ-mt { min-width: 84px; }
select.champ { text-align: left; cursor: pointer; min-width: 180px; }
td.ok .champ, .cellule.ok .champ { border-color: var(--ok); background: var(--ok-fond); }
td.ko .champ, .cellule.ko .champ { border-color: var(--ko); background: var(--ko-fond); }

/* Oui / Non */
.bascule { display: inline-flex; border: 1.5px solid #D9CFC7; border-radius: 6px; overflow: hidden; }
.bascule button { border: 0; background: #fff; color: var(--texte-doux); padding: 5px 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.bascule button + button { border-left: 1.5px solid #D9CFC7; }
.bascule button.actif { background: var(--pourpre); color: #fff; }
td.ok .bascule { border-color: var(--ok); } td.ok .bascule button.actif { background: var(--ok); }
td.ko .bascule { border-color: var(--ko); } td.ko .bascule button.actif { background: var(--ko); }

.etat-ico svg { display: none; }
.ligne-ok > .etat .i-ok, .ligne-ok .etat-ico .i-ok { display: inline; color: var(--ok); }
.ligne-ko > .etat .i-ko, .ligne-ko .etat-ico .i-ko { display: inline; color: var(--ko); }

.corr { display: none; margin-top: 3px; font-size: 11.5px; color: var(--rouge); font-weight: 600; white-space: nowrap; }
body.corrige .corr { display: block; }
.note { margin: 0; padding: 8px 16px 12px; font-size: 13px; color: var(--texte-doux); font-style: italic; }

/* ----- Informations données ----- */
.info-ligne { margin: 3px 0; }

/* ----- Documents des mouvements ----- */
.mouvements { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; background: var(--menthe-clair); }
.mvt { background: #fff; border: 1px solid #CFE5CA; border-left: 4px solid var(--vert); border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.mvt.mvt-out { border-left-color: var(--rouge); }
.mvt-haut { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; }
.mvt-doc { color: var(--texte); }
.mvt-date { color: var(--texte-doux); font-weight: 600; }
.mvt-ref { font-size: 12px; color: var(--texte-doux); margin-top: 2px; }
.mvt-des { font-size: 12.5px; }
.mvt-qte { margin-top: 3px; }
.mvt-in .mvt-qte strong { color: var(--vert); }
.mvt-out .mvt-qte strong { color: var(--rouge); }
.mvt-pu { color: var(--texte-doux); }

/* ----- Lignes de calcul ----- */
.calculs { display: flex; flex-direction: column; gap: 10px; }
.calcul { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--gris-ligne); border-radius: 8px; }
.calcul-titre { min-width: 150px; font-weight: 600; color: var(--pourpre); }
.calcul-formule { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
.calcul-formule .cellule { display: inline-flex; flex-direction: column; align-items: center; position: relative; }
.calcul-formule .cellule .champ { width: 92px; }
.calcul-formule .cellule .champ-op { width: 38px; }
.calcul-formule .cellule select.champ { width: auto; }
.calcul-formule .aide { position: absolute; top: -8px; right: -8px; }
.jeton-txt { font-size: 18px; font-weight: 600; color: var(--texte-doux); }
.calcul > .etat { width: 24px; text-align: center; }

/* ----- Infobulles d'aide ----- */
.aide { display: inline-flex; color: var(--pourpre); cursor: help; vertical-align: middle; position: relative; }
.aide .bulle {
	display: none; position: fixed; z-index: 60; max-width: 260px;
	background: var(--texte); color: #fff; font-size: 12.5px; font-weight: 400; text-transform: none; letter-spacing: 0;
	line-height: 1.4; padding: 8px 10px; border-radius: 6px; text-align: left; white-space: normal;
}
.aide:hover .bulle.placee, .aide:focus .bulle.placee { display: block; }

/* ----- Vérification d'un tableau ----- */
.verif-cas {
	display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
	margin: -8px 0 22px; padding: 0 2px;
}
.verif-cas-info { font-size: 13px; color: var(--texte-doux); }

/* ===== Boutons ===== */
.btn {
	display: inline-flex; align-items: center; gap: 8px;
	border: 0; border-radius: 8px; cursor: pointer;
	font-size: 15px; font-weight: 600; padding: 10px 18px;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-principal { background: var(--rouge-vif); color: #fff; }
.btn-principal:hover:not(:disabled) { background: var(--jaune); color: var(--rouge); }
.btn-second { background: #fff; color: var(--pourpre); border: 1.5px solid var(--pourpre); }
.btn-second:hover:not(:disabled) { background: var(--pourpre-clair); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 18px; }

.bandeau-cloture {
	display: flex; align-items: center; gap: 10px;
	background: var(--pourpre-clair); color: var(--pourpre-fonce);
	border-radius: var(--rayon); padding: 12px 16px; margin-bottom: 18px; font-weight: 600;
}
body.cloture select.champ { pointer-events: none; }

/* ===== Jauge de réussite (à droite de l'écran) ===== */
.score {
	position: fixed; right: 18px; top: 92px; z-index: 15;
	width: var(--largeur-score);
	background: #fff; border: 1px solid var(--gris-ligne); border-radius: var(--rayon);
	padding: 12px 10px; text-align: center;
}
.score-titre { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--pourpre); letter-spacing: .03em; }
.score-valeur { font-size: 26px; font-weight: 700; color: var(--texte); margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.jauge {
	position: relative; width: 26px; height: 180px; margin: 0 auto 10px;
	background: var(--gris); border-radius: 14px; overflow: hidden;
}
.jauge div { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--pourpre); transition: height .5s, width .5s; }
.jauge.parfait div { background: var(--vert); }
.score-texte { margin: 0 0 4px; font-size: 12px; color: var(--texte); }
.penalite { margin: 0; font-size: 11.5px; color: var(--texte-doux); }

footer { text-align: center; color: var(--texte-doux); font-size: 13px; padding: 18px 0 26px; }

/* ===== Fenêtres ===== */
.voile {
	position: fixed; inset: 0; z-index: 100;
	background: rgba(46, 42, 39, .55);
	display: flex; align-items: center; justify-content: center; padding: 20px;
}
.fenetre { background: #fff; border-radius: 12px; width: 100%; max-width: 440px; overflow: hidden; }
.fenetre.alerte .carte-titre { background: var(--rouge); }
.fenetre form, .dialogue-corps { padding: 18px; }
.fenetre label { display: block; font-weight: 600; margin-bottom: 8px; }
.fenetre input {
	width: 100%; height: 42px; padding: 0 12px; font-size: 15px; margin-bottom: 16px;
	border: 1.5px solid #D9CFC7; border-radius: 8px;
}
.fenetre input:focus { outline: none; border-color: var(--pourpre); box-shadow: 0 0 0 3px var(--pourpre-clair); }
.fenetre form .btn { width: 100%; justify-content: center; }
.dialogue-corps p { margin: 0 0 16px; }
.dialogue-boutons { display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Impression ===== */
.entete-impression { display: none; }

@media (max-width: 860px) {
	main { padding: 0 14px; }
	.grille { grid-template-columns: 1fr; }
	.score {
		position: sticky; top: auto; bottom: 0; right: auto; width: auto;
		display: flex; align-items: center; gap: 12px; border-radius: 0; border-width: 1px 0 0;
		text-align: left;
	}
	.score-valeur { margin: 0; font-size: 20px; }
	.jauge { flex: 1; width: auto; height: 12px; margin: 0; }
	.jauge div { top: 0; bottom: 0; right: auto; height: auto; width: 0; }
	.score-texte, .penalite { display: none; }
}

@media print {
	@page { size: A4 landscape; margin: 8mm; }
	.defile { overflow: visible !important; }
	body { background: #fff; font-size: 9.5pt; color: #000; }
	.topbar, .score, .voile, .actions, .verif-cas, footer, #carteConsignes, .bandeau-cloture, .section-mouvements { display: none !important; }
	main { max-width: none; margin: 0; padding: 0; }
	.entete-impression { display: block; margin-bottom: 3mm; }
	.entete-impression h1 { font-size: 12pt; margin: 0 0 2mm; }
	.entete-impression table { width: 100%; border-collapse: collapse; font-size: 9.5pt; border-bottom: 1px solid #000; }
	.entete-impression td { padding: 1mm 0; }
	.grille { display: block; }
	.carte { border: 1px solid #999; border-radius: 0; margin-bottom: 3mm; break-inside: auto; }
	.carte-titre, .carte-titre.vert, .carte-titre.jaune { background: none !important; color: #000; border-bottom: 1px solid #999; padding: 1mm 2mm; font-size: 10pt; }
	.carte-titre .chevron { display: none; }
	.carte-corps { padding: 1.5mm 2mm; }
	.pliable { display: block; }
	.info, .memo { background: none; color: #000; }
	table.saisie { font-size: 8pt; }
	table.saisie th { background: none !important; color: #000; border: 1px solid #999; padding: .8mm 1mm; font-size: 7pt; }
	table.saisie td { padding: .6mm 1mm; border: 1px solid #bbb; background: none !important; }
	table.saisie tr { break-inside: avoid; }
	.champ, td.ok .champ, td.ko .champ, .cellule.ok .champ, .cellule.ko .champ { -webkit-appearance: none; appearance: none; border: 0; background: none; height: auto; padding: 0; min-width: 0; font-size: 8pt; color: #000; }
	.bascule { border: 0; } .bascule button { display: none; padding: 0; } .bascule button.actif { display: inline; background: none !important; color: #000; }
	.mouvements, .info-carte { display: none !important; }
	.calcul { border: 0; padding: 1mm 0; } .calcul-formule .cellule .champ { width: auto; }
	.aide { display: none; }
	.ligne-ok .etat-ico .i-ok, .ligne-ko .etat-ico .i-ko { color: #000; }
	.corr { display: none !important; }
}

/* Formule à reconstituer : listes plus étroites pour tenir sur une ligne */
.section-selection .calcul-formule .cellule select.champ { min-width: 150px; max-width: 210px; }

/* ===== Largeur des colonnes adaptée au contenu ===== */
/* Le tableau prend la largeur de son contenu ; chaque case a la largeur de la donnée attendue. */
table.saisie .champ { width: 64px; min-width: 0; }
table.saisie .champ-qte { width: 64px; }
table.saisie .champ-prix { width: 68px; }
table.saisie .champ-mt { width: 92px; }
table.saisie .champ-date { width: 66px; }
table.saisie .champ-doc { width: 112px; }
table.saisie th { min-width: 0; }
table.saisie td.donnee { white-space: nowrap; }
table.saisie td:first-child.donnee:not(.num):not(.date) { white-space: normal; }
/* chaque colonne prend la largeur minimale de son contenu ; les en-têtes passent à la ligne */
table.saisie th, table.saisie td { width: 1px; }
table.saisie td.donnee.long { white-space: normal; min-width: 190px; }
.carte > .defile { padding: 0; }

.calcul-formule .cellule .champ-op { width: 38px; }

/* ===== Tableaux côte à côte quand la place le permet ===== */
#contenu { display: flex; flex-wrap: wrap; gap: 0 22px; align-items: flex-start; }
#contenu > .section { flex: 0 1 auto; min-width: 0; max-width: 100%; }
#contenu > .section-mouvements { flex-basis: 100%; }
#contenu > .section > .carte { width: max-content; max-width: 100%; }
#contenu > .section-mouvements > .carte { width: auto; }
.section .note { max-width: 640px; }
@media print { #contenu { display: block; } #contenu > .section > .carte { width: auto; } }
#contenu > .section > .carte table.saisie { min-width: 100%; }
table.saisie td.donnee.long { text-align: left; }
/* Calculs : se placent à côté de la fiche s'il reste au moins 300 px, sinon dessous */
#contenu > .section-calculs { flex: 1 1 300px; min-width: 300px; }
#contenu > .section-calculs > .carte { width: auto; }
.calcul { flex-wrap: wrap; row-gap: 6px; }
.calcul-titre { min-width: 0; flex: 0 0 auto; margin-right: 6px; }
.calcul-formule { flex: 1 1 260px; }
.calcul-formule .cellule .champ { width: 76px; }
.calcul-formule .cellule .champ-op { width: 38px; }
#contenu > .section-selection { flex: 1 1 300px; min-width: 300px; }
#contenu > .section-selection > .carte { width: auto; }

/* ===== Alignement selon la nature de la donnée ===== */
table.saisie td.donnee.num { text-align: right; }
table.saisie td.donnee.date { text-align: center; }
table.saisie td.donnee.texte, table.saisie td.donnee.code, table.saisie td.donnee.long { text-align: left; }
table.saisie tr.ligne-total td.donnee.texte { text-align: left; }
table.saisie td[class^="saisie-"] { text-align: center; }
.champ-date, .champ-op { text-align: center; }
.champ-doc, select.champ { text-align: left; }

/* ===== Justification des calculs ===== */
.calcul { position: relative; align-items: flex-start; padding: 10px 40px 10px 12px; }
.calcul-titre { flex-basis: 100%; margin: 0; }
.calcul > .etat { position: absolute; right: 12px; top: 10px; }
.cellule { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.legende-case { font-size: 11px; line-height: 1.2; color: var(--texte-doux); text-align: center; max-width: 100px; }
.calcul-formule { align-items: flex-start; gap: 8px; }
.calcul-formule .jeton-txt, .frac-resultat .jeton-txt { padding-top: 4px; }
.calcul-cmup { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.fraction { display: inline-flex; flex-direction: column; align-items: stretch; }
.frac-ligne { display: flex; justify-content: center; align-items: flex-start; gap: 6px; }
.frac-barre { height: 2px; background: var(--texte); margin: 6px 0; border-radius: 1px; }
.frac-resultat { display: flex; align-items: flex-start; gap: 8px; }
.calculs .cellule .champ { width: 82px; }
.calculs .cellule .champ-mt { width: 90px; }
.calculs .cellule .champ-op { width: 38px; }
.calculs .cellule select.champ { width: 175px; min-width: 0; }
.section-calculs .calculs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 10px; }
.section-calculs .aide { display: none; }
@media print { .legende-case { font-size: 7pt; } .frac-barre { background: #000; } }

/* ===== Déclaration de TVA ===== */
table.saisie tr.ligne-groupe td { background: var(--orange-clair, #FBEADB); color: var(--pourpre-fonce); font-weight: 700; text-align: left; text-transform: uppercase; font-size: 12.5px; letter-spacing: .02em; }
table.saisie tr.ligne-total td.donnee { font-weight: 700; }
table.saisie td.donnee.code { font-weight: 600; color: var(--texte-doux); }
table.saisie td.donnee.ligne-cerfa { font-weight: 700; color: var(--pourpre); text-align: center; }
table.saisie.formulaire .champ { width: 96px; }
table.saisie tr.ligne-cadre td { background: var(--pourpre); color: #fff; font-weight: 700; text-align: left; font-size: 13.5px; }
table.saisie.formulaire td.donnee.texte { white-space: normal; min-width: 220px; }

/* ----- Documents support (balance) : déclinaisons de vert ----- */
.carte-donnees { border-color: #CFE5CA; }
.carte-donnees table.saisie td { border-color: #DCEBD8; }
.carte-donnees table.saisie tbody tr:nth-child(even):not(.ligne-total):not(.ligne-groupe) td { background: var(--menthe-clair); }
.carte-donnees table.saisie td.donnee.code { color: var(--vert); font-weight: 700; }
.carte-donnees table.saisie tr.ligne-total td { border-top: 2px solid var(--vert); background: var(--menthe); color: var(--vert-fonce); }
.carte-donnees table.saisie tr.ligne-groupe td { background: var(--menthe); color: var(--vert-fonce); }
.carte-donnees table.saisie th { border-color: #CFE5CA; }
.info-carte { border-color: #CFE5CA; }
.info-carte .info strong { color: var(--vert-fonce); }

/* ----- Écriture comptable ----- */
table.saisie.ecriture .choix { width: 330px; text-align: left; }
table.saisie.ecriture .champ-mt { width: 100px; }
table.saisie.ecriture td.donnee.date { color: var(--texte-doux); font-weight: 600; }
@media print { table.saisie.ecriture .choix { text-align: left; } }

/* ----- « Pour aller plus loin » : déclinaisons de bleu ----- */
:root { --bleu: #1F5FA8; --bleu-fonce: #17457A; --bleu-clair: #E3EDF9; --bleu-pale: #F3F7FC; }
.carte-bleue { border-color: #C7D9EF; }
.carte-titre.bleu { background: var(--bleu); color: #fff; }
.carte-bleue table.saisie th { background: var(--bleu-clair); color: var(--bleu-fonce); border-color: #C7D9EF; }
.carte-bleue table.saisie td { border-color: #D6E3F3; }
.carte-bleue table.saisie td.donnee.date { color: var(--bleu-fonce); }
.carte-bleue .champ { background: var(--bleu-pale); border-color: #BFD3EC; }
.carte-bleue .champ:focus { border-color: var(--bleu); box-shadow: 0 0 0 3px var(--bleu-clair); background: #fff; }
.section-ecriture .btn-verif-cas { background: var(--bleu); color: #fff; }
.section-ecriture .btn-verif-cas:hover:not(:disabled) { background: var(--bleu-fonce); color: #fff; }

/* ===== Contrôle des documents commerciaux ===== */
/* En-tête des documents reconstitués (émetteur, références, destinataire) */
.doc-entete { display: grid; grid-template-columns: repeat(3, minmax(0, auto)); gap: 10px 22px; justify-content: space-between;
	padding: 12px 14px 10px; font-size: 12.5px; line-height: 1.45; color: var(--texte); }
.doc-bloc { min-width: 0; }
.doc-cadre { border: 1px solid #CFE5CA; border-radius: 6px; padding: 6px 10px; background: var(--menthe-clair); align-self: start; }
.carte:not(.carte-donnees) .doc-cadre { border-color: var(--gris-ligne); background: var(--gris); }
.doc-logo { display: block; max-height: 44px; max-width: 90px; margin-bottom: 4px; }
/* Repères L1, L2… */
span.repere, table.saisie td.donnee.repere { font-weight: 700; color: var(--pourpre); }
span.repere { display: inline-block; padding: 0 6px; margin-left: 4px; border-radius: 4px; background: var(--jaune); color: var(--brun); font-size: 11.5px; }
table.saisie td.donnee.repere { text-align: center; }
/* Documents en image */
.images-docs { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.doc-image { margin: 0; flex: 0 1 460px; min-width: 260px; }
.doc-image img { display: block; width: 100%; height: auto; border: 1px solid var(--gris-ligne); border-radius: 6px; cursor: zoom-in; background: #fff; }
.doc-image figcaption { margin-top: 5px; font-size: 12.5px; font-weight: 600; color: var(--vert-fonce); text-align: center; }
/* Listes de choix */
table.saisie.analyse td:nth-child(2) .choix { width: 260px; }
table.saisie.analyse td:nth-child(3) .choix { width: 380px; }
table.saisie.analyse td.donnee.texte { white-space: nowrap; }
table.saisie.facture .choix { width: 250px; }
table.saisie.facture td.donnee.texte { white-space: normal; min-width: 200px; }
@media print {
	.doc-image { flex: 0 1 48%; } .doc-image img { cursor: default; }
	.images-docs { gap: 6mm; } .note { font-size: 8pt; }
	table.saisie .choix { width: auto !important; }
}
/* Ajustements de mise en page */
.doc-logo { float: left; margin: 0 10px 4px 0; }
.doc-bloc::after { content: ''; display: block; clear: both; }
.carte-donnees:has(.doc-entete) table.saisie td, .carte-donnees:has(.doc-entete) table.saisie th { font-size: 12.5px; padding: 3px 5px; }
.images-colonne { flex-direction: column; }
.images-colonne .doc-image { flex: none; width: 420px; min-width: 0; }
table.saisie.facture .choix { width: 275px; }
#contenu > .section > .carte:has(.doc-entete) { width: min-content; }
.doc-entete { grid-template-columns: auto auto auto; }
.doc-bloc { white-space: normal; }
table.saisie.facture td.donnee.texte { min-width: 160px; }
table.saisie.analyse td:nth-child(3) .choix { width: 420px; }
@media print { .images-colonne { flex-direction: row; } .images-colonne .doc-image, .doc-image { width: 31%; flex: 0 0 31%; } #contenu > .section > .carte:has(.doc-entete) { width: auto; } }

/* ===== Organisation de la page : documents à gauche (fixes), travail à droite ===== */
#contenu.avec-panneau { display: grid; grid-template-columns: var(--larg-panneau, 460px) minmax(0, 1fr); gap: 0 20px; align-items: start; }
.panneau-docs { position: sticky; top: 80px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; margin: 0 0 18px; width: auto; }
.panneau-docs > .carte-titre { flex: none; }
.onglets { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; border-bottom: 1px solid #CFE5CA; background: var(--menthe-clair); flex: none; }
.onglet { border: 1px solid #CFE5CA; border-bottom: 0; background: #fff; color: var(--vert-fonce); font-weight: 600; font-size: 13px;
	padding: 6px 12px; border-radius: 8px 8px 0 0; cursor: pointer; margin-bottom: -1px; }
.onglet:hover { background: var(--menthe); }
.onglet.actif { background: var(--vert); border-color: var(--vert); color: #fff; }
.onglet-corps { overflow: auto; padding: 12px; flex: 1 1 auto; min-height: 0; }
.panneau-docs .onglet-corps > .carte { border: 0; box-shadow: none; margin: 0; width: auto; }
.panneau-docs .onglet-corps > .carte > .carte-titre { display: none; }
.panneau-docs .doc-image { width: 100%; flex: none; min-width: 0; margin: 0; }
.doc-zoom { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.doc-zoom img { display: block; width: 100%; height: auto; border: 1px solid var(--gris-ligne); border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.08); background: #fff; }
.doc-zoom:hover img, .doc-zoom:focus-visible img { outline: 3px solid var(--menthe); }
.colonne-taches { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.colonne-taches > .section { max-width: 100%; }
.colonne-taches > .section > .carte { width: max-content; max-width: 100%; }
.avec-panneau table.saisie.analyse td:nth-child(2) .choix { width: 225px; }
.avec-panneau table.saisie.analyse td:nth-child(3) .choix { width: 310px; }
.avec-panneau table.saisie.analyse td.donnee.texte { white-space: normal; min-width: 150px; max-width: 200px; }
@media (max-width: 1180px) {
	#contenu.avec-panneau { display: block; }
	.panneau-docs { position: static; max-height: none; }
}

/* ===== Présentation des documents (en-tête façon document commercial) ===== */
.doc-entete { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 18px; padding: 12px 14px; font-size: 12.5px; line-height: 1.45;
	border-bottom: 2px solid #CFE5CA; margin-bottom: 2px; }
.carte:not(.carte-donnees) .doc-entete { border-bottom-color: var(--pourpre-clair); }
.doc-emetteur { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.doc-emetteur strong { font-size: 13.5px; color: var(--texte); }
.doc-logo { float: none; margin: 0; max-height: 52px; max-width: 64px; object-fit: contain; flex: none; }
.doc-titre { text-align: right; white-space: nowrap; color: var(--texte-doux); }
.doc-nom { font-size: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--vert-fonce); margin-bottom: 2px; }
.carte:not(.carte-donnees) .doc-nom { color: var(--pourpre); }
.doc-infos { color: var(--texte-doux); align-self: end; }
.doc-dest { justify-self: end; align-self: start; min-width: 170px; border: 1px solid #CFE5CA; border-radius: 6px; padding: 6px 10px; background: var(--menthe-clair); }
.carte:not(.carte-donnees) .doc-dest { border-color: var(--gris-ligne); background: var(--gris); }
.doc-bloc::after { display: none; }

/* ===== Visionneuse ===== */
#visionneuse { position: fixed; inset: 0; z-index: 200; background: rgba(25, 22, 20, .86); display: flex; flex-direction: column; }
#visionneuse[hidden] { display: none; }
.visionneuse-barre { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; color: #fff; font-weight: 600; }
#visionneuseFermer { background: #fff; color: var(--texte); border: 0; border-radius: 6px; padding: 6px 12px; font-weight: 600; cursor: pointer; }
.visionneuse-image { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 0 18px 18px; }
.visionneuse-image img { max-width: min(1250px, 100%); height: auto; background: #fff; border-radius: 6px; box-shadow: 0 6px 30px rgba(0,0,0,.4); }
body.sans-defilement { overflow: hidden; }

@media print {
	#contenu.avec-panneau { display: block; }
	.panneau-docs { position: static; max-height: none; display: block; }
	.onglets, #visionneuse { display: none !important; }
	.onglet-corps[hidden] { display: block !important; }
	.panneau-docs .onglet-corps { overflow: visible; padding: 2mm; }
	.panneau-docs .onglet-corps:has(.doc-image) { display: inline-block !important; width: 32%; vertical-align: top; }
	.doc-image figcaption { font-size: 7pt; }
	.colonne-taches > .section > .carte { width: auto; }
}
.panneau-docs .onglet-corps table.saisie { width: 100%; }
.panneau-docs .onglet-corps .note { padding: 6px 4px 0; }
/* Repères : même étiquette jaune partout (documents, tableau d'analyse) */
span.repere { display: inline-block; min-width: 30px; padding: 1px 7px; border-radius: 4px; background: var(--jaune); color: var(--brun);
	font-weight: 700; font-size: 12px; line-height: 1.5; text-align: center; box-shadow: inset 0 -1px 0 rgba(0,0,0,.12); }
td.donnee.repere span.repere { margin-left: 0; }
@media print { span.repere { background: #FFE08A !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
table.saisie td.donnee.repere { text-align: center !important; width: 1px; }
.avec-panneau table.saisie.analyse td:nth-child(2) .choix { width: 215px; }
.avec-panneau table.saisie.analyse td:nth-child(3) .choix { width: 295px; }
/* En-tête : émetteur | type de document, destinataire sous le titre, conditions sur toute la largeur */
.doc-entete { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "em ti" "em de" "in in"; }
.doc-emetteur { grid-area: em; }
.doc-titre { grid-area: ti; white-space: normal; max-width: 260px; }
.doc-nom { font-size: 15px; line-height: 1.25; }
.doc-dest { grid-area: de; }
.doc-infos { grid-area: in; align-self: start; padding-top: 6px; border-top: 1px dashed #CFE5CA; display: block; }
.carte:not(.carte-donnees) .doc-infos { border-top-color: var(--pourpre-clair); }
/* Tableaux des documents dans le panneau : plus compacts */
.panneau-docs table.saisie th, .panneau-docs table.saisie td { font-size: 12px !important; padding: 3px 4px !important; }
.panneau-docs table.saisie th { font-size: 10.5px !important; }
.avec-panneau table.saisie.analyse td:nth-child(2) .choix { width: 205px; }
.avec-panneau table.saisie.analyse td:nth-child(3) .choix { width: 285px; }
.avec-panneau table.saisie.analyse td.donnee.texte { max-width: 160px; }
.doc-emetteur > div { white-space: nowrap; } .doc-titre { max-width: 200px; }
.mentions-legales { display: inline-block; margin-top: 4px; font-style: normal; font-size: 11px; color: var(--texte-doux); letter-spacing: .01em; }
