/* MonMagasin – feuille de style commune (logiciel du commerçant, console, connexion) */
:root {
  --fond: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --bord: #e2e5ea;
  --texte: #1c2330;
  --texte-2: #5b6576;
  --primaire: #1f5fd6;
  --primaire-fonce: #174bab;
  --primaire-pale: #e8f0fd;
  --succes: #157a4a;
  --succes-pale: #e3f4ea;
  --alerte: #a15c00;
  --alerte-pale: #fdf1dc;
  --danger: #c0352b;
  --danger-pale: #fbe7e5;
  --ombre: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --ombre-haute: 0 12px 32px rgba(16, 24, 40, .18);
  --rayon: 10px;
  --menu: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #11151c; --surface: #1a2029; --surface-2: #222a35; --bord: #2e3846; --texte: #e6e9ee; --texte-2: #9aa5b5;
    --primaire: #5b8ff0; --primaire-fonce: #7aa5f5; --primaire-pale: #1d2d4a;
    --succes: #4cc38a; --succes-pale: #16322a; --alerte: #f0b35a; --alerte-pale: #3a2c14; --danger: #f07a70; --danger-pale: #3d1f1d;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4); --ombre-haute: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fond); color: var(--texte); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--primaire); text-decoration: none; } a:hover { text-decoration: underline; }
p { margin: 0 0 1em; }
.discret { color: var(--texte-2); }
.petit { font-size: .85rem; }
.cache { display: none !important; }

/* ---------- Boutons et champs ---------- */
button, .bouton {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; border: 1px solid var(--bord);
  background: var(--surface); color: var(--texte); padding: .5rem .95rem; display: inline-flex; align-items: center; gap: .45rem;
  text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
button:hover, .bouton:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
button.primaire, .bouton.primaire { background: var(--primaire); border-color: var(--primaire); color: #fff; }
button.primaire:hover { background: var(--primaire-fonce); border-color: var(--primaire-fonce); }
button.danger { color: var(--danger); }
button.lien { border: none; background: none; color: var(--primaire); padding: 0; font-weight: 500; }
button.lien:hover { text-decoration: underline; background: none; }
button.large { width: 100%; justify-content: center; padding: .7rem 1rem; }
:focus-visible { outline: 2px solid var(--primaire); outline-offset: 2px; }

label.champ { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--texte-2); }
label.champ .aide { font-weight: 400; font-size: .8rem; }
input, select, textarea {
  font: inherit; color: var(--texte); background: var(--surface); border: 1px solid var(--bord); border-radius: 8px;
  padding: .55rem .7rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primaire); box-shadow: 0 0 0 3px var(--primaire-pale); }
textarea { min-height: 90px; resize: vertical; }
label.case { display: flex; align-items: center; gap: .55rem; font-size: .92rem; font-weight: 500; color: var(--texte); cursor: pointer; }
label.case input { width: auto; }
.grille-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.grille-form .pleine { grid-column: 1 / -1; }
.avec-bouton { display: flex; gap: .5rem; }
.avec-bouton input { flex: 1; }

/* ---------- Page seule (connexion, erreurs) ---------- */
.page-seule { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.carte-seule { background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; box-shadow: var(--ombre); padding: 32px; width: 100%; max-width: 420px; }
.marque { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; margin-bottom: 1.4rem; }
.marque .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--primaire); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .95rem; flex: none; }
.pile { display: flex; flex-direction: column; gap: 1rem; }
.separateur { display: flex; align-items: center; gap: .8rem; color: var(--texte-2); font-size: .85rem; }
.separateur::before, .separateur::after { content: ""; flex: 1; height: 1px; background: var(--bord); }
.message { border-radius: 8px; padding: .65rem .85rem; font-size: .9rem; }
.message.erreur { background: var(--danger-pale); color: var(--danger); }
.message.ok { background: var(--succes-pale); color: var(--succes); }
.message.info { background: var(--primaire-pale); color: var(--primaire-fonce); }

/* ---------- Structure de l'application ---------- */
.appli { display: grid; grid-template-columns: var(--menu) minmax(0, 1fr); min-height: 100vh; }
.menu { background: var(--surface); border-right: 1px solid var(--bord); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.menu .marque { padding: 0 8px; margin-bottom: 1rem; }
.menu .marque span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .titre-section { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--texte-2); padding: 14px 10px 6px; }
.menu a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .7rem; border-radius: 8px; color: var(--texte); font-weight: 500; }
.menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu a.actif { background: var(--primaire-pale); color: var(--primaire-fonce); font-weight: 600; }
.menu a.indispo { color: var(--texte-2); }
.menu .bas { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--bord); }
.menu .moi { padding: 8px 10px; font-size: .85rem; }
.menu .moi strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.contenu { padding: 28px 32px 48px; max-width: 1180px; width: 100%; }
.barre-mobile { display: none; }

.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.entete h1 { margin: 0; }
.entete p { margin: .25rem 0 0; }
.outils { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.outils input[type=search] { max-width: 320px; }
.onglets { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.onglets button { border: none; background: none; padding: .38rem .8rem; font-weight: 500; color: var(--texte-2); }
.onglets button.actif { background: var(--surface); color: var(--texte); box-shadow: var(--ombre); font-weight: 600; }

.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 20px; }
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 1.5rem; }
.chiffre { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.carte a.couvrante { color: inherit; display: block; }
.carte a.couvrante:hover { text-decoration: none; }

/* ---------- Tableaux ---------- */
.tableau { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--bord); vertical-align: middle; }
th { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-2); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.cliquable { cursor: pointer; }
tbody tr.cliquable:hover { background: var(--surface-2); }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.inactif td { color: var(--texte-2); }
.vide { padding: 40px 20px; text-align: center; color: var(--texte-2); }

.pastille { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--texte-2); white-space: nowrap; }
.pastille.bleu { background: var(--primaire-pale); color: var(--primaire-fonce); }
.pastille.vert { background: var(--succes-pale); color: var(--succes); }
.pastille.orange { background: var(--alerte-pale); color: var(--alerte); }
.pastille.rouge { background: var(--danger-pale); color: var(--danger); }
.pastilles { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Modules ---------- */
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.module { display: flex; flex-direction: column; gap: .5rem; }
.module .haut { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.module .prix { font-weight: 700; font-size: 1.05rem; margin-top: auto; }
.module.actif { border-color: var(--primaire); }
.total { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

/* ---------- Fenêtres ---------- */
.voile { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.fenetre { background: var(--surface); border-radius: 14px; box-shadow: var(--ombre-haute); width: 100%; max-width: 640px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.fenetre.etroite { max-width: 460px; }
.fenetre header { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.fenetre header h2 { margin: 0; }
.fenetre header button { border: none; font-size: 1.4rem; line-height: 1; padding: .2rem .5rem; color: var(--texte-2); }
.fenetre .corps { padding: 18px 22px; overflow-y: auto; }
.fenetre footer { padding: 14px 22px; border-top: 1px solid var(--bord); display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }
.fenetre footer .gauche { margin-right: auto; }
.copie { display: flex; gap: .5rem; }
.copie input { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }

.notes { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.note { background: var(--texte); color: var(--surface); padding: .7rem 1rem; border-radius: 9px; box-shadow: var(--ombre-haute); font-size: .92rem; max-width: 360px; }
.note.erreur { background: var(--danger); color: #fff; }

/* ---------- Téléphone ---------- */
@media (max-width: 820px) {
  .appli { grid-template-columns: 1fr; }
  .menu { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--ombre-haute); }
  .appli.menu-ouvert .menu { transform: none; }
  .barre-mobile { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--bord); position: sticky; top: 0; z-index: 30; }
  .barre-mobile .marque { margin: 0; }
  .contenu { padding: 20px 16px 40px; }
  .grille-form { grid-template-columns: 1fr; }
  .outils input[type=search] { max-width: none; flex: 1 1 100%; }
  .colonne-large { display: none; }
  .carte-seule { padding: 24px 20px; }
}

/* ---------- Ventes ---------- */
.chiffre.rouge { color: var(--danger); }
.titre-bloc { margin: 1.5rem 0 .6rem; }
.bloc { margin-bottom: 1rem; }
.deux-colonnes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 14px; margin: 14px 0; align-items: start; }
.deux-colonnes > div { display: flex; flex-direction: column; gap: 14px; }
.totaux { display: flex; flex-direction: column; gap: .35rem; }
.ligne-total { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.ligne-total.grand { font-size: 1.15rem; font-weight: 700; border-top: 1px solid var(--bord); padding-top: .55rem; margin-top: .3rem; }
.editeur-lignes td { padding: .45rem .4rem; vertical-align: top; }
.editeur-lignes th { padding: .55rem .4rem; }
.editeur-lignes .col-desc { min-width: 260px; display: flex; flex-direction: column; gap: 4px; }
.editeur-lignes textarea { min-height: 38px; resize: vertical; }
.editeur-lignes td:nth-child(2) input { width: 70px; }
.editeur-lignes td:nth-child(3) input { width: 74px; }
.editeur-lignes td:nth-child(4) input { width: 96px; }
.editeur-lignes td:nth-child(5) input { width: 60px; }
.editeur-lignes td:nth-child(6) select { width: 76px; }
.editeur-lignes .total-ligne { padding-top: .95rem; }
.actions-ligne { white-space: nowrap; }
button.mini { padding: .25rem .5rem; font-size: .9rem; line-height: 1.2; }
.barre-actions { position: sticky; bottom: 0; display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; padding: 12px 0; margin-top: 8px; background: var(--fond); border-top: 1px solid var(--bord); }
.barre-actions .espace { flex: 1; }
.grille-infos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem 1rem; }
.info { display: flex; flex-direction: column; gap: 2px; }
.info strong { font-weight: 600; overflow-wrap: anywhere; }
.carte h3 { margin-bottom: .6rem; }
.carte table td { padding: .45rem .3rem; }
fieldset.section { border: none; padding: 0; margin: 0; }
fieldset.section legend { font-weight: 700; font-size: 1.05rem; margin-bottom: .6rem; }
@media (max-width: 820px) {
  .deux-colonnes { grid-template-columns: 1fr; }
}
.nowrap { white-space: nowrap; }

/* ---------- Temps et interventions ---------- */
.chrono { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chrono.actif { border-color: var(--danger); background: var(--danger-pale); }
.compteur { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.carte .entete { margin-bottom: .6rem; align-items: center; }
.carte .entete h3 { margin: 0; }
.carte + .carte, .chrono + .carte { margin-top: 14px; }
input.court { width: 80px; }
.texte-libre { white-space: pre-wrap; margin: 0; }
canvas.signature { display: block; width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 1px dashed var(--bord); border-radius: 8px; touch-action: none; cursor: crosshair; margin-top: .4rem; }
table.materiel td { padding: .35rem .3rem; }
table.materiel td:nth-child(3) { width: 100%; }
.outils select { width: auto; max-width: 100%; }

/* ---------- Catalogue, panier, stock ---------- */
.ariane { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .88rem; color: var(--texte-2); margin-bottom: .3rem; }
.grille-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 1.5rem; }
.carte-choix { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; box-shadow: var(--ombre); padding: 20px; min-height: 150px;
  display: flex; flex-direction: column; gap: .3rem; color: var(--texte); transition: border-color .12s; }
.carte-choix:hover { border-color: var(--primaire); text-decoration: none; }
.carte-choix strong { font-size: 1.1rem; margin-top: .5rem; }
.carte-choix.discrete { background: var(--surface-2); box-shadow: none; }
.carte-choix .initiale { width: 48px; height: 48px; border-radius: 12px; background: var(--primaire-pale); color: var(--primaire-fonce); display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; }
.carte-choix .initiale.ronde { border-radius: 50%; font-size: 1rem; }
.deux-choix { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 780px; }
.carte-choix.grande { min-height: 190px; align-items: center; justify-content: center; text-align: center; }
.carte-choix.grande strong { font-size: 1.4rem; margin: 0; }
.filtres { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; margin-bottom: 1rem; align-items: end; }
.quantite { display: inline-flex; align-items: center; gap: .55rem; }
.quantite button { width: 38px; height: 38px; padding: 0; justify-content: center; font-size: 1.1rem; }
.quantite strong { min-width: 1.6rem; text-align: center; }
.ajout { display: inline-flex; justify-content: flex-end; }
.ajout > button { min-height: 38px; }
.rouge { color: var(--danger); }
.vert { color: var(--succes); }
.panier { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 20px; align-items: start; }
.panier .totaux { margin-top: 14px; }
.panier h3 { font-size: .92rem; color: var(--texte-2); }
.pile-serree { display: flex; flex-direction: column; gap: .5rem; }
.ligne-espacee { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
input.loupe { padding-left: 2.1rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6576' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: .7rem center; min-height: 44px; }
.resultats { display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; }
.resultats:not(:empty) { border: 1px solid var(--bord); }
button.resultat { border: none; border-bottom: 1px solid var(--bord); border-radius: 0; flex-direction: column; align-items: flex-start; gap: 0; white-space: normal; text-align: left; font-weight: 500; }
button.resultat:last-child { border-bottom: none; }
.client-choisi { display: flex; justify-content: space-between; align-items: center; gap: .8rem; background: var(--primaire-pale); color: var(--primaire-fonce); border-radius: 10px; padding: .75rem .9rem; }
.moyens { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.moyens button { min-height: 56px; justify-content: center; font-size: 1rem; }
.moyens button.choisi { background: var(--succes-pale); border: 2px solid var(--succes); color: var(--succes); }
.moyens button.choisi::before { content: "✓"; }
button.grand { width: 100%; min-height: 58px; justify-content: center; font-size: 1.1rem; }
.grand-message { font-size: 1.05rem; padding: 1rem 1.2rem; }
.deux-egales { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.deux-egales .titre-bloc { margin-top: .5rem; }
.outils input.large { max-width: 520px; }
@media (max-width: 1000px) {
  .panier, .deux-egales { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .deux-choix, .filtres { grid-template-columns: 1fr; }
}
.bandeau-demo { background: var(--alerte-pale); color: var(--alerte); font-size: .88rem; font-weight: 500; padding: .55rem 32px; border-bottom: 1px solid var(--bord); }
