/* 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); }
