/* XCompta — feuille de style */
:root {
  --fond: #f4f6fa;
  --carte: #ffffff;
  --encre: #1c2433;
  --encre-2: #55607a;
  --encre-3: #8791a8;
  --trait: #dfe4ee;
  --trait-fort: #c5ccdb;
  --marine: #172033;
  --marine-2: #222e47;
  --accent: #2457d6;
  --accent-fonce: #1a44ad;
  --accent-pale: #e8effd;
  --ok: #157a4c;
  --ok-pale: #e3f5ec;
  --alerte: #a15c07;
  --alerte-pale: #fdf1dc;
  --erreur: #b3261e;
  --erreur-pale: #fce9e7;
  --info: #0e6c8c;
  --info-pale: #e1f2f8;
  --rayon: 8px;
  --ombre: 0 1px 2px rgba(23, 32, 51, .06), 0 2px 8px rgba(23, 32, 51, .05);
  --police: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; font-family: var(--police); color: var(--encre); background: var(--fond); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; font-weight: 650; }
h3 { font-size: .95rem; margin: 0 0 .5rem; font-weight: 650; }
p { margin: .3rem 0 .7rem; }
small, .petit { font-size: .86rem; }
.discret { color: var(--encre-2); }
.tres-discret { color: var(--encre-3); }
.mono { font-family: var(--mono); font-size: .93em; }
.droite { text-align: right; }
.centre { text-align: center; }
.gras { font-weight: 650; }
.nowrap { white-space: nowrap; }

/* --- structure ------------------------------------------------------------ */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.barre-laterale { background: var(--marine); color: #cfd6e6; display: flex; flex-direction: column; position: sticky;
  top: 0; height: 100vh; overflow-y: auto; }
.marque { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem .9rem; color: #fff; font-weight: 700;
  font-size: 1.15rem; letter-spacing: -.01em; }
.marque:hover { text-decoration: none; }
.marque .logo { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, #3b74f2, #1a44ad);
  display: grid; place-items: center; font-size: .95rem; font-weight: 800; }
.nav-section { padding: .55rem 1.1rem .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: #7f8aa5; font-weight: 600; }
.nav a { display: block; padding: .38rem 1.1rem; color: #cfd6e6; border-left: 3px solid transparent; font-size: .95rem; }
.nav a:hover { background: var(--marine-2); text-decoration: none; color: #fff; }
.nav a.actif { background: var(--marine-2); border-left-color: #4f86ff; color: #fff; font-weight: 600; }
.nav .pastille { float: right; background: #c9781a; color: #fff; border-radius: 9px; padding: 0 .45rem; font-size: .75rem;
  font-weight: 700; line-height: 1.35rem; }
.pied-nav { margin-top: auto; padding: .8rem 1.1rem; font-size: .8rem; color: #7f8aa5; border-top: 1px solid #2a3654; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.entete { background: var(--carte); border-bottom: 1px solid var(--trait); padding: .55rem 1.4rem; display: flex;
  align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 20; }
.entete form { margin: 0; }
.entete select { border: 1px solid var(--trait-fort); border-radius: 6px; padding: .3rem .5rem; font: inherit;
  background: #fff; max-width: 300px; font-weight: 600; }
.entete .espace { flex: 1; }
.entete .utilisateur { color: var(--encre-2); font-size: .92rem; }
.badge-role { background: var(--accent-pale); color: var(--accent-fonce); border-radius: 10px; padding: .1rem .55rem;
  font-size: .78rem; font-weight: 600; }
.contenu { padding: 1.2rem 1.4rem 3rem; max-width: 1500px; width: 100%; }
.contenu.large { max-width: none; }
.titre-page { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.titre-page .sous-titre { color: var(--encre-2); font-size: .93rem; margin-top: .15rem; }
.titre-page .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* --- cartes, grilles -------------------------------------------------------- */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre);
  padding: 1rem 1.1rem; margin-bottom: 1rem; }
.carte.sans-marge { padding: 0; overflow: clip; }  /* clip (et non hidden) : les en-tetes collants restent relatifs a la page */
.carte > h2:first-child { margin-top: 0; }
.grille { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-lateral { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-lateral { grid-template-columns: 1fr; } }
.indicateur { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .85rem 1rem;
  box-shadow: var(--ombre); }
.indicateur .libelle { color: var(--encre-2); font-size: .85rem; }
.indicateur .valeur { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem;
  letter-spacing: -.01em; }
.indicateur .valeur.positif { color: var(--ok); }
.indicateur .valeur.negatif { color: var(--erreur); }
.indicateur .note { color: var(--encre-3); font-size: .82rem; }

/* --- boutons ---------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--trait-fort); background: #fff;
  color: var(--encre); border-radius: 6px; padding: .4rem .8rem; font: inherit; font-weight: 600; cursor: pointer;
  line-height: 1.2; white-space: nowrap; }
.btn:hover { background: #f1f4fa; text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #7aa2ff;
  outline-offset: 1px; }
.btn.principal-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.principal-btn:hover { background: var(--accent-fonce); }
.btn.succes { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--erreur); border-color: #e5b5b1; }
.btn.danger:hover { background: var(--erreur-pale); }
.btn.petit-btn { padding: .2rem .5rem; font-size: .85rem; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-lien { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.btn-lien:hover { text-decoration: underline; }
kbd { background: #eef1f7; border: 1px solid var(--trait-fort); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 .3rem; font-family: var(--mono); font-size: .8rem; color: var(--encre-2); }

/* --- formulaires ------------------------------------------------------------ */
label { font-weight: 600; font-size: .88rem; color: var(--encre-2); display: block; margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=file],
select, textarea { font: inherit; border: 1px solid var(--trait-fort); border-radius: 6px; padding: .38rem .55rem;
  background: #fff; color: var(--encre); width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input[readonly] { background: #f3f5f9; color: var(--encre-2); }
.champ { margin-bottom: .75rem; }
.champs { display: grid; gap: .75rem 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
.champs .champ { margin: 0; }
.case { display: flex; align-items: center; gap: .4rem; font-weight: 500; color: var(--encre); }
.case input { width: auto; }
.filtres { display: flex; gap: .6rem .8rem; flex-wrap: wrap; align-items: flex-end; }
.filtres .champ { margin: 0; }
.filtres input[type=text], .filtres input[type=date], .filtres select { width: auto; min-width: 110px; }
.aide { color: var(--encre-3); font-size: .84rem; font-weight: 400; }

/* --- tableaux --------------------------------------------------------------- */
.tableau { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tableau th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--encre-2);
  background: #f3f5f9; padding: .5rem .65rem; border-bottom: 1px solid var(--trait-fort); position: sticky; top: 50px;
  z-index: 5; white-space: nowrap; font-weight: 650; }
.tableau td { padding: .32rem .65rem; border-bottom: 1px solid #eceff5; vertical-align: top; }
.tableau tbody tr:hover td { background: #f7f9fd; }
.tableau .num { text-align: right; white-space: nowrap; font-family: var(--mono); font-size: .92em; }
.tableau th.num { font-family: var(--police); }
.tableau tr.sous-total td { font-weight: 650; background: #f6f8fc; border-top: 1px solid var(--trait-fort); }
.tableau tr.total td { font-weight: 700; background: #eef2fa; border-top: 2px solid var(--trait-fort); font-size: 1.02em; }
.tableau tr.titre-groupe td { font-weight: 700; background: #eef2fa; padding-top: .55rem; }
.tableau tr.report td { color: var(--encre-2); font-style: italic; }
.tableau tr.inactif td { color: var(--encre-3); }
.tableau td.vide { color: var(--encre-3); text-align: center; padding: 1.6rem; }
.tableau.compact td { padding: .22rem .55rem; }
.tableau a.ligne { color: inherit; }
.debiteur { color: var(--encre); }
.crediteur { color: #7a3aa8; }
.ecart-nonzero { color: var(--erreur); font-weight: 700; }

/* --- etiquettes, messages ---------------------------------------------------- */
.etiquette { display: inline-block; border-radius: 10px; padding: .05rem .55rem; font-size: .78rem; font-weight: 650;
  white-space: nowrap; }
.e-brouillon { background: var(--alerte-pale); color: var(--alerte); }
.e-validee { background: var(--ok-pale); color: var(--ok); }
.e-cloture, .e-neutre { background: #e9edf5; color: var(--encre-2); }
.e-ouvert { background: var(--info-pale); color: var(--info); }
.e-erreur, .e-a_corriger { background: var(--erreur-pale); color: var(--erreur); }
.e-visee { background: var(--ok-pale); color: var(--ok); }
.e-non_revue { background: #e9edf5; color: var(--encre-2); }
.e-lettre { background: var(--accent-pale); color: var(--accent-fonce); font-family: var(--mono); }
.messages { margin-bottom: 1rem; }
.message { border-radius: var(--rayon); padding: .6rem .9rem; margin-bottom: .5rem; border: 1px solid; font-weight: 500; }
.message.ok { background: var(--ok-pale); border-color: #b6e2cb; color: #0f5c39; }
.message.erreur { background: var(--erreur-pale); border-color: #f1c0bb; color: #8a1c15; }
.message.alerte { background: var(--alerte-pale); border-color: #f0d49c; color: #7a4504; }
.message.info { background: var(--info-pale); border-color: #b5dcea; color: #0a5670; }
.encart { border-left: 4px solid var(--accent); background: var(--accent-pale); padding: .6rem .9rem;
  border-radius: 0 var(--rayon) var(--rayon) 0; margin-bottom: 1rem; }
.encart.alerte { border-left-color: #d08a17; background: var(--alerte-pale); }
.encart.erreur { border-left-color: var(--erreur); background: var(--erreur-pale); }
.encart.ok { border-left-color: var(--ok); background: var(--ok-pale); }

.onglets { display: flex; gap: .25rem; border-bottom: 1px solid var(--trait-fort); margin-bottom: 1rem; }
.onglets a { padding: .45rem .9rem; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0;
  color: var(--encre-2); font-weight: 600; margin-bottom: -1px; }
.onglets a.actif { background: var(--carte); border-color: var(--trait-fort); color: var(--encre); }
.onglets a:hover { text-decoration: none; color: var(--encre); }

/* --- connexion ---------------------------------------------------------------- */
.page-connexion { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 20% 0%, #24365f 0%, var(--marine) 60%); padding: 1rem; }
.boite-connexion { width: 100%; max-width: 380px; background: #fff; border-radius: 12px; padding: 2rem 1.8rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.boite-connexion .marque { color: var(--encre); padding: 0 0 1.2rem; }

/* --- saisie ------------------------------------------------------------------- */
.saisie-entete { display: grid; grid-template-columns: 150px 110px 170px 1fr; gap: .7rem; margin-bottom: .8rem; }
.grille-saisie { width: 100%; border-collapse: collapse; }
.grille-saisie th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--encre-2); padding: .3rem .4rem; border-bottom: 2px solid var(--trait-fort); }
.grille-saisie td { padding: 2px 3px; border-bottom: 1px solid #eceff5; vertical-align: middle; position: relative; }
.grille-saisie input { border: 1px solid transparent; border-radius: 4px; padding: .32rem .45rem; width: 100%;
  background: transparent; font: inherit; }
.grille-saisie input:hover { border-color: var(--trait); }
.grille-saisie input:focus { border-color: var(--accent); background: #fff; outline: none;
  box-shadow: 0 0 0 2px rgba(36, 87, 214, .15); }
.grille-saisie input.montant { text-align: right; font-family: var(--mono); font-size: .95em; }
.grille-saisie input.compte { font-family: var(--mono); font-size: .95em; }
.grille-saisie input.invalide { border-color: var(--erreur); background: var(--erreur-pale); }
.grille-saisie .col-n { width: 34px; color: var(--encre-3); text-align: center; font-size: .82rem; }
.grille-saisie .col-compte { width: 150px; }
.grille-saisie .col-intitule { width: 22%; color: var(--encre-2); font-size: .9rem; padding-left: .5rem; }
.grille-saisie .col-montant { width: 150px; }
.grille-saisie .col-suppr { width: 30px; }
.grille-saisie tfoot td { padding: .45rem .5rem; font-weight: 700; border-top: 2px solid var(--trait-fort);
  border-bottom: none; }
.grille-saisie tfoot .num { text-align: right; font-family: var(--mono); }
.suppr-ligne { border: none; background: none; color: var(--encre-3); cursor: pointer; font-size: 1.05rem; line-height: 1;
  padding: .2rem .35rem; border-radius: 4px; }
.suppr-ligne:hover { color: var(--erreur); background: var(--erreur-pale); }
.liste-comptes { position: absolute; z-index: 40; background: #fff; border: 1px solid var(--trait-fort); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(23, 32, 51, .18); max-height: 290px; overflow-y: auto; min-width: 420px; left: 3px; top: 100%; }
.liste-comptes div { padding: .3rem .6rem; cursor: pointer; display: flex; gap: .7rem; white-space: nowrap; }
.liste-comptes div .n { font-family: var(--mono); color: var(--accent-fonce); min-width: 92px; }
.liste-comptes div.sel, .liste-comptes div:hover { background: var(--accent-pale); }
.liste-comptes .creer { border-top: 1px solid var(--trait); color: var(--ok); font-weight: 600; }
.etat-piece { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .8rem; }
.equilibre { font-weight: 700; padding: .25rem .7rem; border-radius: 6px; }
.equilibre.ok { background: var(--ok-pale); color: var(--ok); }
.equilibre.ko { background: var(--erreur-pale); color: var(--erreur); }
.raccourcis { color: var(--encre-3); font-size: .82rem; margin-top: .7rem; display: flex; gap: 1rem; flex-wrap: wrap; }

/* --- graphiques --------------------------------------------------------------- */
.histogramme { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: .5rem; }
.histogramme .mois { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.histogramme .barres { flex: 1; display: flex; align-items: flex-end; gap: 2px; width: 100%; justify-content: center; }
.histogramme .barre { width: 42%; max-width: 20px; border-radius: 3px 3px 0 0; min-height: 1px; }
.histogramme .barre.produits { background: #2f9e6b; }
.histogramme .barre.charges { background: #d9793b; }
.histogramme .etq { font-size: .74rem; color: var(--encre-3); margin-top: .25rem; }
.legende { display: flex; gap: 1rem; font-size: .82rem; color: var(--encre-2); }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; }

/* --- controles ----------------------------------------------------------------- */
.controle { border-left: 4px solid var(--trait-fort); }
.controle.g-bloquant { border-left-color: var(--erreur); }
.controle.g-alerte { border-left-color: #d08a17; }
.controle.g-info { border-left-color: var(--info); }
.controle.g-ok { border-left-color: var(--ok); }
.controle summary { cursor: pointer; display: flex; gap: .7rem; align-items: baseline; list-style: none; }
.controle summary::-webkit-details-marker { display: none; }
.controle summary .t { font-weight: 650; }
.controle ul { margin: .6rem 0 0; padding-left: 1.2rem; }
.controle li { margin-bottom: .15rem; }
.pastille-g { display: inline-block; min-width: 68px; text-align: center; border-radius: 10px; font-size: .75rem;
  font-weight: 700; padding: .05rem .5rem; }
.pastille-g.bloquant { background: var(--erreur); color: #fff; }
.pastille-g.alerte { background: #d08a17; color: #fff; }
.pastille-g.info { background: var(--info-pale); color: var(--info); }
.pastille-g.ok { background: var(--ok-pale); color: var(--ok); }

.liste-def { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
.liste-def dt { color: var(--encre-2); }
.liste-def dd { margin: 0; font-weight: 500; }
.fil { border-left: 2px solid var(--trait); margin: 0; padding: 0 0 0 .9rem; list-style: none; }
.fil li { margin-bottom: .6rem; position: relative; }
.fil li::before { content: ""; position: absolute; left: -1.22rem; top: .45rem; width: 8px; height: 8px;
  border-radius: 50%; background: var(--trait-fort); }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; background: var(--marine); color: #fff; padding: .7rem 1rem;
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); z-index: 100; max-width: 420px; }
.toast.erreur { background: var(--erreur); }
dialog { border: none; border-radius: 10px; padding: 1.2rem 1.3rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  max-width: 460px; width: 92%; }
dialog::backdrop { background: rgba(23, 32, 51, .45); }
.actions-dialog { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.pagination { display: flex; gap: .4rem; align-items: center; margin-top: .8rem; }

/* --- impression ----------------------------------------------------------------- */
@media print {
  html { font-size: 11px; }
  body { background: #fff; }
  .barre-laterale, .entete, .no-print, .messages, .titre-page .actions { display: none !important; }
  .app { display: block; }
  .contenu { padding: 0; max-width: none; }
  .carte { border: none; box-shadow: none; padding: 0; }
  .tableau th { position: static; background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tableau tr { page-break-inside: avoid; }
  a { color: inherit; }
  .en-tete-impression { display: block !important; margin-bottom: .6rem; }
}
.en-tete-impression { display: none; }
