/* PlanComptable – feuille de style commune à tous les niveaux et aux tests
   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: 1120px; margin: 22px auto 0; padding: 0 calc(var(--largeur-score) + 30px) 0 24px; }
@media (min-width: 1400px) { main { padding-left: 0; } }

.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; }

/* ===== Tableau des opérations ===== */
.defile { overflow-x: auto; }
table.comptes { width: 100%; border-collapse: collapse; }
table.comptes th {
	background: var(--jaune); color: var(--rouge);
	font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
	padding: 8px 10px; text-align: left;
}
table.comptes th.centre { text-align: center; }
table.comptes td { padding: 7px 10px; border-bottom: 1px solid var(--gris-ligne); vertical-align: middle; }
table.comptes tr.fin-op td { border-bottom: 2px solid #E9D3C2; }
table.comptes tbody tr:last-child td { border-bottom: 0; }
table.comptes td.num { width: 46px; text-align: center; font-weight: 700; color: var(--rouge); background: var(--jaune-clair); }
table.comptes td.col-sens { width: 92px; text-align: center; }
table.comptes.mode-intitule .col-choix { width: 380px; }
table.comptes.mode-intitule .col-affiche { width: 140px; }
table.comptes.mode-numero .col-choix { width: 170px; }
table.comptes.mode-numero .col-affiche { width: 350px; }
table.comptes td.etat, table.comptes th.th-etat { width: 40px; text-align: center; }

.sens {
	display: inline-block; min-width: 70px; text-align: center;
	font-size: 12px; font-weight: 700; border-radius: 4px; padding: 2px 8px; color: #fff;
}
.sens.debit { background: var(--vert); }
.sens.credit { background: var(--pourpre); }

.champ {
	width: 100%; height: 34px; padding: 0 8px;
	border: 1.5px solid #D9CFC7; border-radius: 6px; background: #fff;
	color: var(--texte); font-size: 14px;
}
select.champ { cursor: pointer; }
.champ:focus { outline: none; border-color: var(--pourpre); box-shadow: 0 0 0 3px var(--pourpre-clair); }
select.champ.vide { color: var(--texte-doux); }
.affiche {
	display: block; min-height: 34px; line-height: 20px; padding: 7px 10px;
	border-radius: 6px; background: var(--gris); font-size: 14px; font-variant-numeric: tabular-nums;
}
.affiche:empty::before { content: '–'; color: #B5ACA5; }

td.ok .champ { border-color: var(--ok); background: var(--ok-fond); }
td.ko .champ { border-color: var(--ko); background: var(--ko-fond); }

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

.corr { display: none; margin-top: 4px; font-size: 12px; color: var(--rouge); font-weight: 600; }
body.corrige .corr { 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; }
	table.comptes.mode-intitule .col-choix, table.comptes.mode-numero .col-choix { width: auto; }
	table.comptes .col-affiche, table.comptes.mode-numero .col-affiche { width: 140px; }
	.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 portrait; margin: 10mm; }
	body { background: #fff; font-size: 9.5pt; color: #000; }
	.topbar, .score, .voile, .actions, .verif-cas, footer, #carteConsignes, .bandeau-cloture, .section-memo { 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.comptes th { background: none; color: #000; border-bottom: 1px solid #999; padding: 1mm 1.5mm; font-size: 8pt; }
	table.comptes td { padding: .8mm 1.5mm; border-bottom: 1px solid #ccc; }
	table.comptes td.num { background: none; color: #000; }
	table.comptes tr { break-inside: avoid; }
	.sens { background: none !important; color: #000; border: 1px solid #000; padding: 0 2mm; min-width: 0; }
	.champ, td.ok .champ, td.ko .champ { -webkit-appearance: none; appearance: none; border: 0; background: none; height: auto; padding: 0; font-size: 9pt; color: #000; }
	.affiche { background: none; padding: 0; min-height: 0; font-size: 9pt; }
	.ligne-ok .etat-ico .i-ok, .ligne-ko .etat-ico .i-ko { color: #000; }
	.corr { display: none !important; }
}
