:root {
  --encre: #17211F;
  --papier: #F3F6FA;
  --sapin: #164B7E;
  --sapin-fonce: #0B2E52;
  --laiton: #E8892B;
  --entree: #1B7A50;
  --sortie: #B0362F;
  --ligne: #D8E0DD;
  --doux: #5A6763;
  --bs-body-font-family: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
body { background: var(--papier); color: var(--encre); }
h1, .h1, h2, .h2, h3, .h3, h4, .h4 { font-weight: 700; letter-spacing: -0.01em; }

.num, .montant, .solde { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; white-space: nowrap; }
.entree { color: var(--entree) !important; }
.sortie { color: var(--sortie) !important; }

/* Mise en page : menu latéral */
:root { --larg-menu: 268px; --haut-barre: 52px; --bas-barre: 60px; }
.contenu { min-width: 0; }
.contenu main { min-width: 0; }
main h1, main .h1, main h2, main .h2, main h3, main .h3, .panneau-tete h2, .ticket .nom { overflow-wrap: anywhere; min-width: 0; }
main h1, main .h1 { font-size: clamp(1.35rem, 1rem + 1.2vw, 1.75rem); }
.panneau, .ticket, .bandeau { min-width: 0; }
.panneau-corps { overflow-wrap: anywhere; }
.panneau-corps .table-responsive, .panneau > .table-responsive { margin: 0; }

.marque-lien { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; text-decoration: none; min-width: 0; }
.marque-lien:hover { color: #fff; }

/* Barre du haut (téléphone et tablette) */
.haut { position: sticky; top: 0; z-index: 1020; height: var(--haut-barre); background: var(--sapin); color: #fff; display: flex; align-items: center; gap: .6rem; padding: 0 .75rem; }
.haut .btn-menu { background: transparent; border: 0; color: #fff; font-size: 1.7rem; line-height: 1; padding: .1rem .35rem; border-radius: 6px; }
.haut .haut-nom { margin-left: auto; font-size: .85rem; opacity: .8; max-width: 38%; }

/* Menu latéral */
.lateral { --bs-offcanvas-width: 292px; --bs-offcanvas-bg: var(--sapin); --bs-offcanvas-color: #fff; background: var(--sapin); color: #fff; }
.lateral-tete { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .85rem 1rem; min-height: var(--haut-barre); border-bottom: 1px solid rgba(255,255,255,.12); }
.lateral-profil { padding: .7rem 1rem; border-bottom: 1px solid rgba(255,255,255,.12); font-size: .9rem; min-width: 0; }
.lateral-corps { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: .5rem 0 1rem; }
.lateral ul { margin: 0; padding: 0; }
.lien, .groupe-titre { display: flex; align-items: center; gap: .7rem; width: calc(100% - 16px); margin: 2px 8px; padding: .55rem .8rem; border-radius: 8px; color: rgba(255,255,255,.82); text-decoration: none; background: transparent; border: 0; text-align: left; position: relative; min-width: 0; }
.lien .lib, .groupe-titre .lib:not(.badge):not(.fleche) { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lien:hover, .groupe-titre:hover { background: rgba(255,255,255,.08); color: #fff; }
.lien > .bi, .groupe-titre > .bi:first-child { font-size: 1.1rem; width: 1.3rem; text-align: center; flex: 0 0 1.3rem; }
.groupe-titre { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.62); margin-top: .5rem; }
.groupe.ouvert > .groupe-titre { color: #fff; }
.groupe-titre .fleche { font-size: .75rem; transition: transform .2s; flex: 0 0 auto; margin-left: auto; }
.groupe-titre:not(.collapsed) .fleche { transform: rotate(180deg); }
.groupe .collapse ul, .groupe .collapsing ul { padding-left: .35rem; }
.lien.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--laiton); }
.groupe-simple { margin-top: .25rem; }
.btn-reduire { background: rgba(255,255,255,.1); border: 0; color: #fff; width: 2rem; height: 2rem; border-radius: 6px; align-items: center; justify-content: center; flex: 0 0 auto; }
.btn-reduire:hover { background: rgba(255,255,255,.2); }
.btn-reduire .bi { transition: transform .2s; }

@media (min-width: 992px) {
  .lateral.offcanvas-lg { position: fixed !important; top: 0; bottom: 0; left: 0; width: var(--larg-menu) !important; height: 100vh !important; z-index: 1030; display: flex; flex-direction: column; background: var(--sapin) !important; color: #fff !important; transition: width .18s ease !important; }
  .contenu { margin-left: var(--larg-menu); transition: margin-left .18s ease; }
  .haut { display: none; }
  html.menu-reduit { --larg-menu: 68px; }
  html.menu-reduit .lateral-tete { flex-direction: column; justify-content: center; padding: .6rem 0; gap: .5rem; }
  html.menu-reduit .lateral .lib:not(.badge) { display: none !important; }
  html.menu-reduit .lateral-profil { display: none; }
  html.menu-reduit .btn-reduire .bi { transform: rotate(180deg); }
  html.menu-reduit .groupe-titre { display: none; }
  html.menu-reduit .groupe .collapse { display: block !important; height: auto !important; }
  html.menu-reduit .groupe { border-top: 1px solid rgba(255,255,255,.12); padding-top: .3rem; margin-top: .3rem; }
  html.menu-reduit .groupe-simple { border-top: 1px solid rgba(255,255,255,.12); padding-top: .3rem; }
  html.menu-reduit .groupe .collapse ul { padding-left: 0; }
  html.menu-reduit .lien { justify-content: center; padding: .6rem 0; }
  html.menu-reduit .lien .badge.lib { position: absolute; top: 1px; right: 5px; font-size: .6rem; padding: .2em .4em; }
}

@media (max-width: 991.98px) {
  body.avec-menu .contenu { padding-bottom: calc(var(--bas-barre) + env(safe-area-inset-bottom, 0px) + .5rem); }
}

/* Barre fixe du bas (téléphone et tablette) */
.barre-bas { display: none; }
@media (max-width: 991.98px) {
  .barre-bas { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1025; height: calc(var(--bas-barre) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: #fff; border-top: 1px solid var(--ligne); box-shadow: 0 -2px 8px rgba(0,0,0,.06); }
  .barre-bas a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; color: var(--doux); text-decoration: none; font-size: .7rem; font-weight: 600; min-width: 0; padding: 0 .1rem; }
  .barre-bas a span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .barre-bas a .bi { font-size: 1.35rem; line-height: 1.1; }
  .barre-bas a.active { color: var(--sapin); box-shadow: inset 0 3px 0 var(--laiton); background: #F1F6F4; }
}
@media print { .lateral, .haut, .barre-bas { display: none !important; } .contenu { margin-left: 0 !important; padding: 0 !important; } }

/* Boutons */
.btn-primary {
  --bs-btn-bg: var(--sapin); --bs-btn-border-color: var(--sapin);
  --bs-btn-hover-bg: var(--sapin-fonce); --bs-btn-hover-border-color: var(--sapin-fonce);
  --bs-btn-active-bg: var(--sapin-fonce); --bs-btn-active-border-color: var(--sapin-fonce);
  --bs-btn-disabled-bg: var(--sapin); --bs-btn-disabled-border-color: var(--sapin);
}
.btn-entree { --bs-btn-bg: var(--entree); --bs-btn-border-color: var(--entree); --bs-btn-color: #fff; --bs-btn-hover-bg: #146040; --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: #146040; }
.btn-sortie { --bs-btn-bg: var(--sortie); --bs-btn-border-color: var(--sortie); --bs-btn-color: #fff; --bs-btn-hover-bg: #8e2a24; --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: #8e2a24; }

/* Panneaux */
.panneau { background: #fff; border: 1px solid var(--ligne); border-radius: 10px; }
.panneau + .panneau { margin-top: 1.25rem; }
.panneau-tete { padding: .8rem 1rem; border-bottom: 1px solid var(--ligne); display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.panneau-tete h2 { font-size: 1rem; margin: 0; font-weight: 600; }
.panneau-corps { padding: 1rem; }

/* Cartes de solde par méthode : bande latérale à la couleur de l'opérateur */
.ticket { background: #fff; border: 1px solid var(--ligne); border-left: 6px solid var(--c, #6c757d); border-radius: 8px; padding: .8rem 1rem; color: inherit; text-decoration: none; display: block; }
a.ticket:hover { border-color: var(--c); color: inherit; }
.ticket .nom { font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.ticket .solde { font-size: 1.4rem; font-weight: 700; margin: .15rem 0 .45rem; }
.ticket dl { display: grid; grid-template-columns: auto 1fr; gap: .1rem .75rem; margin: 0; font-size: .82rem; color: var(--doux); }
.ticket dt { font-weight: 400; }
.ticket dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* Bandeau des totaux */
.bandeau { background: var(--sapin); color: #fff; border-radius: 10px; overflow: hidden; }
.bandeau > div { padding: .85rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0; box-shadow: inset 0 1px 0 rgba(255,255,255,.14), inset 1px 0 0 rgba(255,255,255,.14); }
.bandeau span { font-size: .8rem; color: rgba(255,255,255,.72); }
.bandeau strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bandeau .bandeau-principal strong { font-size: 1.6rem; }
.bandeau .entree { color: #9EE2BF !important; }
.bandeau .sortie { color: #F7B3AD !important; }

/* Tableaux */
.table { --bs-table-bg: transparent; }
.table thead th { font-size: .8rem; font-weight: 600; color: var(--doux); background: #EEF2F0; border-bottom-color: var(--ligne); white-space: nowrap; }
.table tfoot td { border-top: 2px solid var(--encre); }
.table-ops tr.annulee td { opacity: .55; }
.table-ops tr.annulee td.num { text-decoration: line-through; }
.badge-entree { background: #E1F2E9; color: var(--entree); font-weight: 600; }
.badge-sortie { background: #F7E3E1; color: var(--sortie); font-weight: 600; }
.puce { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--c); margin-right: .4rem; vertical-align: .05em; }

/* Choix entrée / sortie */
.bascule { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.bascule a { border: 2px solid var(--ligne); border-radius: 8px; padding: .7rem; text-align: center; text-decoration: none; color: var(--doux); font-weight: 600; background: #fff; }
.bascule a.actif-entree { border-color: var(--entree); color: var(--entree); background: #F1FAF5; }
.bascule a.actif-sortie { border-color: var(--sortie); color: var(--sortie); background: #FCF3F2; }
.saisie-montant { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.dispo { font-size: .9rem; }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; background: var(--sapin); padding: 1rem; }
.connexion .carte { background: #fff; border-radius: 12px; padding: 2rem; width: min(390px, 100%); }
.connexion h1 { font-size: 1.35rem; }

/* Reçu */
.recu { max-width: 400px; margin: 0 auto; background: #fff; border: 1px dashed #97A39F; padding: 1.4rem; }
.recu .montant { font-size: 2rem; font-weight: 700; }
.recu dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.recu dt { font-weight: 400; color: var(--doux); }
.recu dd { margin: 0; text-align: right; font-weight: 500; }

:focus-visible { outline: 3px solid var(--laiton); outline-offset: 2px; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { padding: 0 !important; max-width: none !important; }
  .panneau { border: 0; }
  .panneau-tete { padding-left: 0; padding-right: 0; }
  .bandeau { background: #fff; color: #000; border: 1px solid #000; }
  .bandeau span { color: #333; }
  .bandeau .entree, .bandeau .sortie { color: #000 !important; }
  .recu { border: 0; }
  a { text-decoration: none; color: inherit; }
}


/* Billetage */
.billetage { border: 1px dashed var(--laiton); background: #FFFBF1; border-radius: 8px; padding: .75rem; margin-bottom: 1rem; }
.billetage-tete { font-weight: 600; margin-bottom: .5rem; }
.billetage-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .35rem .9rem; }
.coupure { display: grid; grid-template-columns: 5.2rem 1rem 4.2rem 1fr; align-items: center; gap: .3rem; margin: 0; }
.coupure-nom { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.coupure-x { color: var(--doux); text-align: center; }
.coupure-st { color: var(--doux); font-size: .85rem; text-align: right; font-variant-numeric: tabular-nums; }
.billetage-total { margin-top: .6rem; padding-top: .5rem; border-top: 1px solid #EADFC4; }
.billetage-total strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
input[readonly].saisie-montant { background: #F4F1E8; }
.coupure-groupe { grid-column: 1 / -1; font-size: .8rem; font-weight: 600; color: var(--doux); margin-top: .35rem; }
.releves { border: 1px dashed var(--ligne); background: #F7FAF9; border-radius: 8px; padding: .75rem; }
.billetage-lecture { background: #FFFDF6; }
.billetage-lecture .coupure { grid-template-columns: 6.5rem 1rem 3rem 1fr; }

/* Double authentification */
.connexion .carte-large { width: min(460px, 100%); }
.qr-activation { width: 220px; max-width: 100%; margin: .5rem auto 1rem; padding: .5rem; background: #fff; border: 1px solid var(--ligne); border-radius: 8px; }
.qr-activation svg { display: block; width: 100%; height: auto; }
.code-otp { font-size: 1.8rem; letter-spacing: .35em; font-variant-numeric: tabular-nums; }
.cle-secrete { display: block; font-size: 1rem; letter-spacing: .08em; padding: .5rem; background: #F3F6FA; border-radius: 6px; word-break: break-all; color: var(--encre); }
.bascule-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Les libellés .visually-hidden (position absolue) des tableaux ne doivent pas élargir la page */
.table-responsive { position: relative; }
/* Les contenus longs ne doivent jamais forcer la largeur d'une colonne Bootstrap */
.row > * { min-width: 0; }

/* Formules d'abonnement (affiches BBTEK) */
.formule-carte { border: 1px solid var(--ligne, #dde3df); border-radius: 10px; padding: 1rem; background: #fff; }
.formule-carte.formule-actuelle { border-color: #1b7a4f; box-shadow: 0 0 0 2px rgba(27, 122, 79, .25); }
.formule-carte h3 { margin: 0; }

/* BBTEK Commerce : logo de l'application */
.marque { display: inline-block; flex: none; width: 30px; height: 30px; border-radius: 8px; background: url('logo-commerce-96.png') center / cover no-repeat; }
