/* Bureau Bellevigroup — inspiré de l'interface GitHub (Primer) : sobre, dense, lisible. */
:root {
  --fg: #1f2328;
  --fg-muted: #59636e;
  --canvas: #ffffff;
  --canvas-subtle: #f6f8fa;
  --canvas-inset: #f6f8fa;
  --border: #d1d9e0;
  --border-muted: #d1d9e0b3;
  --accent: #0969da;
  --accent-subtle: #ddf4ff;
  --success: #1a7f37;
  --success-subtle: #dafbe1;
  --btn-primary: #1f883d;
  --btn-primary-hover: #1c8139;
  --danger: #d1242f;
  --danger-subtle: #ffebe9;
  --attention: #9a6700;
  --attention-subtle: #fff8c5;
  --done: #8250df;
  --done-subtle: #fbefff;
  --shadow: 0 1px 0 #1f23280a;
  --shadow-float: 0 8px 24px #424a5333;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #f0f6fc; --fg-muted: #9198a1; --canvas: #0d1117; --canvas-subtle: #151b23; --canvas-inset: #010409;
    --border: #3d444d; --border-muted: #3d444db3; --accent: #4493f8; --accent-subtle: #388bfd1a;
    --success: #3fb950; --success-subtle: #2ea04326; --btn-primary: #238636; --btn-primary-hover: #29903b;
    --danger: #f85149; --danger-subtle: #f851491a; --attention: #d29922; --attention-subtle: #bb800926;
    --done: #ab7df8; --done-subtle: #ab7df826; --shadow: none; --shadow-float: 0 8px 24px #010409;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--fg); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 600; margin: 0; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
p { margin: 0 0 8px; }
.discret { color: var(--fg-muted); }
.petit { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.aide { color: var(--fg-muted); font-size: 13px; margin: 4px 0 12px; }
.mention { color: var(--fg-muted); font-size: 12px; margin: 16px 0; }
.danger-texte { color: var(--danger) !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------------------------------------------------------------- en-tête façon GitHub */
.entete { background: var(--canvas-subtle); border-bottom: 1px solid var(--border); }
.entete-haut { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px 8px; }
.marque { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 16px; }
.marque:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--fg); color: var(--canvas); font-weight: 700; font-size: 15px; }
.marque-sep { color: var(--fg-muted); }
.marque-app { font-weight: 600; }
.deconnexion { display: flex; align-items: center; gap: 8px; margin: 0; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-subtle); color: var(--accent); font-weight: 600; font-size: 12px; border: 1px solid var(--border); }
.onglets { display: flex; gap: 4px; padding: 0 16px; overflow-x: auto; }
.onglets a { position: relative; padding: 8px 8px 12px; color: var(--fg); border-radius: var(--radius); white-space: nowrap; }
.onglets a:hover { text-decoration: none; background: #818b981a; }
.onglets a[aria-current]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px;
  background: #fd8c73; border-radius: 6px; }
.onglets a[aria-current] { font-weight: 600; }

.page { max-width: 1012px; margin: 0 auto; padding: 24px 16px 64px; }
.page-large { max-width: 1440px; }
.fil { color: var(--fg-muted); margin-bottom: 4px; font-size: 14px; }
.titre-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.boutons { display: flex; flex-wrap: wrap; gap: 8px; }
.barre-outils { margin: 24px 0 4px; }

/* ---------------------------------------------------------------- boutons */
.btn, .bouton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  font: 500 14px/1 var(--font); color: var(--fg); background: var(--canvas-subtle); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover, .bouton:hover { background: #eff2f5; text-decoration: none; }
@media (prefers-color-scheme: dark) { .btn:hover, .bouton:hover { background: #262c36; } }
.btn-primaire, .bouton:not(.secondaire):not(.danger) { background: var(--btn-primary); border-color: #1f232826; color: #fff; }
.btn-primaire:hover, .bouton:not(.secondaire):not(.danger):hover { background: var(--btn-primary-hover); }
.bouton.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-invisible { background: transparent; border-color: transparent; box-shadow: none; color: var(--fg-muted); }
.btn-invisible:hover { background: #818b981a; }
.btn-danger-texte { color: var(--danger); }
.btn-danger-texte:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.copie-ok { background: var(--success-subtle); color: var(--success); border-color: var(--success); }
button.lien { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }

/* ---------------------------------------------------------------- étiquettes */
.label, .pastille { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); border-radius: 2em; color: var(--fg-muted); white-space: nowrap; vertical-align: middle; line-height: 1; }
h1 .label { font-size: 12px; margin-left: 4px; }
.label-envoye { color: var(--accent); border-color: var(--accent); }
.label-vu { color: var(--attention); border-color: var(--attention); }
.label-valide { color: var(--success); border-color: var(--success); background: var(--success-subtle); }
.label-refuse, .label-revoque { color: var(--danger); border-color: var(--danger); }
.label-option { color: var(--done); border-color: var(--done); }
.label-calcul { color: var(--accent); border-color: var(--accent); margin-top: 4px; }
.compteur { display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px; font-size: 12px; font-weight: 500;
  border-radius: 2em; background: #818b981f; color: var(--fg); }

/* ---------------------------------------------------------------- boîtes (Box Primer) */
.boite, .carte { background: var(--canvas); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.carte { padding: 16px; }
.carte.etroite { max-width: 340px; margin: 64px auto; }
.boite-entete { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; background: var(--canvas-subtle);
  border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.boite-corps { padding: 16px; }
.boite.vide { padding: 32px; text-align: center; color: var(--fg-muted); }
.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.carte h2 { margin-bottom: 12px; }
.note { background: var(--attention-subtle); border: 1px solid var(--border); padding: 8px 12px; border-radius: var(--radius); }

/* ---------------------------------------------------------------- lien client */
.lien-client .boite-corps > p:last-child { margin-bottom: 0; }
.copie { display: flex; gap: 8px; margin-bottom: 8px; }
.copie input { flex: 1; min-width: 0; height: 32px; padding: 0 12px; font: 12px var(--mono); color: var(--fg);
  background: var(--canvas-inset); border: 1px solid var(--border); border-radius: var(--radius); }
.en-ligne { display: inline; }

/* ---------------------------------------------------------------- messages */
.flashs { list-style: none; padding: 0; margin: 0 0 16px; }
.flash { padding: 12px 16px; margin-bottom: 8px; border: 1px solid #0969da66; background: var(--accent-subtle); border-radius: var(--radius); }
.flash.success { border-color: #1a7f3766; background: var(--success-subtle); }
.flash.error, .flash.warning { border-color: #d1242f66; background: var(--danger-subtle); }
.annonce { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 8px 16px; border-radius: var(--radius); background: var(--fg); color: var(--canvas); font-weight: 500;
  box-shadow: var(--shadow-float); transition: opacity .15s, transform .15s; z-index: 50; }
.annonce.visible { opacity: 1; transform: translate(-50%, 0); }
.annonce.erreur { background: var(--danger); color: #fff; }
.erreur { color: var(--danger); }

/* ---------------------------------------------------------------- formulaires */
label { display: block; font-weight: 600; margin: 0 0 6px; }
input, select, textarea { font: inherit; color: var(--fg); }
.formulaire input:not([type=checkbox]):not([type=file]), .formulaire select, .formulaire textarea,
.carte input:not([type=checkbox]):not([type=hidden]), .recherche input {
  width: 100%; min-height: 32px; padding: 5px 12px; background: var(--canvas); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: inset 0 1px 0 #d1d9e033; }
.formulaire input:focus, .formulaire select:focus, .formulaire textarea:focus, .carte input:focus, .recherche input:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.formulaire { max-width: 880px; padding: 16px; }
.formulaire .champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.champ { margin: 0 0 16px; }
.formulaire .champs .champ { margin: 0; }
.champ.large { grid-column: 1 / -1; }
.champ small { display: block; color: var(--fg-muted); font-size: 12px; margin-top: 4px; }
.champ.case { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.champ.case label { margin: 0; font-weight: 400; }
.en-erreur input, .en-erreur select, .en-erreur textarea { border-color: var(--danger) !important; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.recherche { display: flex; gap: 8px; margin-bottom: 16px; max-width: 560px; }
.carte label { margin-top: 12px; }
.carte .bouton { margin-top: 16px; width: 100%; }

/* ---------------------------------------------------------------- tableaux */
.tableau-defilant { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-top: 1px solid var(--border-muted); vertical-align: top; }
thead th { border-top: 0; font-size: 12px; font-weight: 600; color: var(--fg-muted); background: var(--canvas-subtle); white-space: nowrap; }
.carte table th { background: none; }
.nombre { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; }
.pagination { display: flex; gap: 16px; align-items: center; }

/* ---------------------------------------------------------------- paramètres et totaux de la grille */
.grille-parametres { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 16px; }
.grille-parametres label { font-size: 12px; font-weight: 500; color: var(--fg-muted); margin: 0; }
.grille-parametres .cellule-unite { margin-top: 4px; }
.grille-parametres .cellule { border-color: var(--border); background: var(--canvas); text-align: right; }

.bandeau-totaux { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(6, 1fr);
  margin: 0 0 8px; background: var(--canvas); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-float); }
.bandeau-totaux > div { padding: 10px 14px; border-left: 1px solid var(--border-muted); min-width: 0; }
.bandeau-totaux > div:first-child { border-left: 0; }
.bandeau-totaux span { display: block; font-size: 12px; color: var(--fg-muted); }
.bandeau-totaux strong { display: block; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bandeau-totaux small { display: block; font-size: 11px; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bandeau-totaux .fort { background: var(--success-subtle); }
.bandeau-totaux .fort strong { color: var(--success); }

/* ---------------------------------------------------------------- lots */
.lot { margin-bottom: 12px; }
.lot > summary { list-style: none; cursor: pointer; flex-wrap: nowrap; }
.lot > summary::-webkit-details-marker { display: none; }
.lot > summary::before { content: "▸"; color: var(--fg-muted); font-size: 12px; transition: transform .1s; order: 1; }
.lot[open] > summary::before { transform: rotate(90deg); }
.lot:not([open]) > summary { border-bottom: 0; border-radius: var(--radius); }
.lot-numero { order: 2; display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 50%;
  background: var(--fg); color: var(--canvas); font-size: 12px; font-weight: 600; }
.lot .poignee { order: 0; }
.cellule-titre { order: 3; flex: 1; min-width: 120px; font-weight: 600 !important; font-size: 14px !important; }
.lot-resume { order: 4; display: flex; align-items: center; gap: 10px; color: var(--fg-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lot-resume strong { color: var(--fg); }
.menu-lot { order: 5; display: flex; gap: 12px; font-size: 12px; white-space: nowrap; }
.description-client { margin: 0; padding: 8px 16px; font-size: 12px; color: var(--fg-muted); border-bottom: 1px solid var(--border-muted); }
.description-client .label { margin-right: 6px; }
.lot.cible-depot { outline: 2px dashed var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- tableur */
.tableur { font-size: 13px; }
.tableur td { padding: 4px 6px; vertical-align: middle; }
.tableur th { padding: 6px; }
.tableur tbody tr:hover { background: var(--canvas-subtle); }
.tableur tr.option { background: var(--done-subtle); }
.tableur tr.informatif td { color: var(--fg-muted); }
.col-poignee { width: 24px; padding-right: 0 !important; }
.col-ref { width: 44px; color: var(--fg-muted); }
.col-inclusion { width: 112px; }
.col-saisie { width: 104px; }
.col-actions { width: 56px; text-align: right; white-space: nowrap; }
.tableur .prix { font-weight: 600; }
.contenu { display: block; color: var(--fg-muted); font-size: 12px; padding: 0 7px; line-height: 1.4; }
.note-interne { display: block; color: var(--attention); font-size: 12px; padding: 2px 7px 0; line-height: 1.4; }
.note-interne::before { content: "Interne · "; font-weight: 600; }
body.notes-masquees .note-interne { display: none; }
.action { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius); color: var(--fg-muted); font-size: 15px; }
.action:hover { background: #818b981a; text-decoration: none; color: var(--fg); }
.tableur tbody tr .action { opacity: 0; }
.tableur tbody tr:hover .action, .tableur tbody tr:focus-within .action { opacity: 1; }
.total-lot td { background: var(--canvas-subtle); font-weight: 600; }
.ajout-rapide td { padding-top: 6px; padding-bottom: 6px; }

/* Cellules modifiables : invisibles au repos, cadre au survol, bleu à l'édition — comme un tableur. */
.cellule { width: 100%; height: 28px; padding: 0 7px; background: transparent; border: 1px solid transparent; border-radius: 4px;
  font: inherit; color: inherit; font-variant-numeric: tabular-nums; }
.cellule:hover { border-color: var(--border); background: var(--canvas); }
.cellule:focus { outline: none; border-color: var(--accent); background: var(--canvas); box-shadow: 0 0 0 3px #0969da33; }
.cellule-nombre { text-align: right; }
.cellule-texte { font-weight: 500; }
.ajout-rapide .cellule-texte { font-weight: 400; color: var(--fg-muted); border: 1px dashed var(--border); }
.ajout-rapide .cellule-texte:focus { color: var(--fg); border-style: solid; }
.cellule::placeholder { color: var(--fg-muted); opacity: .6; }
.cellule.en-cours { background: var(--attention-subtle); }
.cellule.invalide { border-color: var(--danger); background: var(--danger-subtle); }
.cellule-unite { display: flex; align-items: center; gap: 2px; }
.cellule-unite > span { color: var(--fg-muted); font-size: 12px; white-space: nowrap; }
.cellule-choix { appearance: none; -webkit-appearance: none; cursor: pointer; font-size: 12px; font-weight: 500; border-color: var(--border);
  border-radius: 2em; height: 24px; padding: 0 22px 0 10px; width: auto;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2359636e'/%3E%3C/svg%3E") no-repeat right 8px center; }
.choix-inclus { color: var(--success); border-color: #1a7f3766; }
.choix-option { color: var(--done); border-color: #8250df66; }
.choix-informatif { color: var(--fg-muted); }

/* ---------------------------------------------------------------- glisser-déposer */
.poignee { display: inline-grid; place-items: center; width: 20px; height: 24px; color: var(--fg-muted); cursor: grab;
  border-radius: 4px; user-select: none; touch-action: none; font-size: 14px; line-height: 1; }
.poignee:hover { background: #818b981a; color: var(--fg); }
.poignee-exemple { color: var(--fg); font-weight: 600; }
body.glisse-actif, body.glisse-actif * { cursor: grabbing !important; user-select: none; }
.en-deplacement { background: var(--accent-subtle) !important; box-shadow: 0 0 0 2px var(--accent) inset; }
details.en-deplacement { box-shadow: 0 0 0 2px var(--accent); }

/* ---------------------------------------------------------------- import et anciens écrans */
.totaux { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 8px; }
.total { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.total span { display: block; font-size: 12px; color: var(--fg-muted); }
.total strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.total small { color: var(--fg-muted); font-size: 12px; }
.total.fort { background: var(--success-subtle); }
.reperes dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.reperes dt { color: var(--fg-muted); }
.reperes dd { margin: 0; font-weight: 600; }

/* ---------------------------------------------------------------- petits écrans */
@media (max-width: 1100px) {
  .bandeau-totaux { grid-template-columns: repeat(3, 1fr); }
  .bandeau-totaux > div:nth-child(4) { border-left: 0; }
  .bandeau-totaux > div:nth-child(n+4) { border-top: 1px solid var(--border-muted); }
}
@media (max-width: 760px) {
  .page { padding: 16px 16px 48px; }
  .entete-haut { padding: 12px 16px 4px; }
  h1 { font-size: 20px; }
  .bandeau-totaux { position: static; grid-template-columns: repeat(2, 1fr); }
  .bandeau-totaux > div { border-left: 0 !important; border-top: 1px solid var(--border-muted); }
  .bandeau-totaux > div:nth-child(-n+2) { border-top: 0; }
  .bandeau-totaux > div:nth-child(even) { border-left: 1px solid var(--border-muted) !important; }
  .secondaire, .menu-lot, .lot-resume > span:not(.label) { display: none; }
  .lot > summary { flex-wrap: wrap; }
  .tableur tbody tr .action { opacity: 1; }
  .copie { flex-wrap: wrap; }
  .copie input { flex-basis: 100%; }
  .reperes dl { grid-template-columns: 1fr; }
}
.message { padding: 12px 16px; margin-bottom: 12px; border: 1px solid #0969da66; background: var(--accent-subtle); border-radius: var(--radius); }
.message.success { border-color: #1a7f3766; background: var(--success-subtle); }
.message.error { border-color: #d1242f66; background: var(--danger-subtle); }

.label-exemple { margin: 4px 0 0 7px; color: var(--accent); border-color: var(--accent); }
.label-lie { margin: 4px 0 0 7px; color: var(--done); border-color: var(--done); }
