/* ERP Will Create — style */
:root {
  --jaune: #FFD700;
  --noir: #262620;
  --fond: #f6f5f0;
  --carte: #ffffff;
  --texte: #262620;
  --doux: #6b6a62;
  --bord: #e3e1d8;
  --rouge: #c0392b;
  --orange: #d97706;
  --vert: #2e7d4f;
  --mariage: #e7769d;
  --entreprise: #3b7dd8;
  --reseaux: #8b5cf6;
  --association: #14a39a;
  --evenementiel: #f08a24;
  --rayon: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: inherit; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
h2 a { font-size: .8rem; font-weight: 400; color: var(--doux); margin-left: auto; }
h2 small, h3 small { color: var(--doux); font-weight: 400; }
small { color: var(--doux); }
.chargement { padding: 2rem; color: var(--doux); }

/* Barre du haut */
.barre {
  position: sticky; top: 0; z-index: 10; background: var(--noir); color: #fff;
  display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem;
}
.logo { font-weight: 800; text-decoration: none; white-space: nowrap; color: #fff; }
.logo span { background: var(--jaune); color: var(--noir); border-radius: 4px; padding: 0 .35rem; margin-left: .2rem; font-size: .8em; }
.barre nav { display: flex; gap: .15rem; overflow-x: auto; flex: 1; scrollbar-width: thin; }
.barre nav a {
  text-decoration: none; padding: .35rem .6rem; border-radius: 6px; white-space: nowrap;
  color: #d8d6cc; font-size: .9rem;
}
.barre nav a:hover { color: #fff; background: #3a3a33; }
.barre nav a.actif { background: var(--jaune); color: var(--noir); font-weight: 600; }
.barre nav b:not(:empty) {
  background: var(--rouge); color: #fff; border-radius: 9px; font-size: .7rem; padding: 0 .4rem; margin-left: .3rem;
}
.barre .lien { color: #d8d6cc; }

main { max-width: 1400px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* Boutons */
button, .bouton {
  font: inherit; cursor: pointer; border: 1px solid var(--noir); background: var(--jaune); color: var(--noir);
  border-radius: 8px; padding: .4rem .85rem; text-decoration: none; display: inline-block; font-weight: 600; font-size: .9rem;
}
button:hover, .bouton:hover { filter: brightness(.95); }
button.secondaire, .bouton.secondaire { background: #fff; border-color: var(--bord); font-weight: 500; }
button.danger { background: #fff; color: var(--rouge); border-color: var(--rouge); margin-left: auto; }
button.lien { background: none; border: 0; padding: 0; text-decoration: underline; font-weight: 400; }
h1 .bouton { font-size: .85rem; }

/* Champs */
input, select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid var(--bord); border-radius: 8px; padding: .45rem .6rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--jaune); border-color: var(--noir); }
input[type="checkbox"] { width: auto; accent-color: var(--noir); }
input:disabled, select:disabled, textarea:disabled { background: var(--fond); color: var(--doux); }

/* Cartes, KPI */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem; }
.grille2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpis > div { background: var(--carte); border: 1px solid var(--bord); border-left: 4px solid var(--jaune); border-radius: var(--rayon); padding: .75rem 1rem; display: flex; flex-direction: column; }
.kpis span { color: var(--doux); font-size: .85rem; }
.kpis b { font-size: 1.5rem; }
.kpis .alerte { border-left-color: var(--rouge); }
.kpis .alerte b { color: var(--rouge); }
.ligne { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .45rem 0; border-top: 1px solid var(--bord); }
.ligne:first-of-type { border-top: 0; }
.ligne .actions, .droite { margin-left: auto; }
.actions { display: flex; gap: .35rem; }
.actions button { padding: .2rem .6rem; font-size: .8rem; }
.vide { color: var(--doux); font-style: italic; }
.aide { color: var(--doux); max-width: 70ch; }
.pastille { background: var(--noir); color: var(--jaune); border-radius: 20px; padding: .05rem .55rem; font-size: .78rem; font-weight: 600; }
.retard { color: var(--rouge); font-weight: 600; }
.bientot { color: var(--orange); font-weight: 600; }

/* Couleurs des prestations */
.p-mariage { --p: var(--mariage); }
.p-entreprise { --p: var(--entreprise); }
.p-reseaux { --p: var(--reseaux); }
.p-association { --p: var(--association); }
.p-evenementiel { --p: var(--evenementiel); }
.kpis > div[class^="p-"] { border-left-color: var(--p); }

/* Puces de filtre */
.puces { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.puces a { text-decoration: none; border: 1px solid var(--bord); background: #fff; border-radius: 20px; padding: .2rem .75rem; font-size: .85rem; border-left: 4px solid var(--p, var(--noir)); }
.puces a.actif { background: var(--noir); color: #fff; }

/* Pipeline */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: 1rem; align-items: start; }
.kanban section { background: #ecebe4; border-radius: var(--rayon); padding: .6rem; min-height: 120px; }
.kanban h3 { font-size: .85rem; margin: 0 0 .5rem; text-transform: uppercase; letter-spacing: .03em; }
.ticket {
  display: flex; flex-direction: column; gap: .15rem; background: #fff; border-radius: 8px; padding: .55rem .65rem; margin-bottom: .5rem;
  text-decoration: none; border-left: 4px solid var(--p, var(--noir)); box-shadow: 0 1px 2px rgba(0,0,0,.06); font-size: .85rem;
}
.ticket:hover { box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.ticket b { font-size: .9rem; }
.ticket span { color: var(--doux); }
.ticket .action { color: var(--texte); font-style: italic; }
.ticket .retard { color: var(--rouge); }
.ticket .bientot { color: var(--orange); }

/* Listes */
.outils { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.outils input[type="search"] { max-width: 280px; }
.outils select { width: auto; }
.outils label { display: flex; gap: .35rem; align-items: center; }
.compte { color: var(--doux); margin-left: auto; font-size: .85rem; }
.tableau { overflow-x: auto; background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--doux); background: #faf9f5; white-space: nowrap; }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover { background: #fffbe0; }
tbody tr:last-child td { border-bottom: 0; }
tr.agent { background: #f7f4ff; }
td.detail { font-size: .8rem; color: var(--doux); max-width: 520px; word-break: break-word; }
.tableau .vide { padding: 1rem; }
.petit { font-size: .8rem; }

/* Étiquettes de statut */
.etiquette { display: inline-block; border-radius: 20px; padding: .05rem .55rem; font-size: .78rem; background: #eeede6; white-space: nowrap; }
.e-valide, .e-paye, .e-solde_paye, .e-publie, .e-signe, .e-converti, .e-fait, .e-traitee { background: #dcf2e3; color: var(--vert); }
.e-refuse, .e-perdu, .e-en_retard, .e-exclu, .e-annule { background: #fbe1de; color: var(--rouge); }
.e-en_attente, .e-nouvelle, .e-nouveau, .e-devis_envoye, .e-relance, .e-emis, .e-a_contacter { background: #fff4bf; color: #6b5800; }
.e-abonnement, .e-forfait_mensuel { background: #ece6fe; color: #5b3cc4; }

/* Fiche */
.fiche { background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1.25rem; max-width: 760px;
  display: grid; grid-template-columns: 200px 1fr; gap: .6rem 1rem; align-items: center; }
.fiche > label { font-size: .9rem; color: var(--doux); }
.fiche > label.case { grid-column: 2; color: var(--texte); display: flex; align-items: center; gap: .4rem; }
.fiche .groupe { grid-column: 1 / -1; margin: .8rem 0 0; padding-top: .8rem; border-top: 1px solid var(--bord); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
.fiche textarea { resize: vertical; }
.fiche .boutons, .fiche #cle-affichee { grid-column: 1 / -1; }
.boutons { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; align-items: center; }
.retour { margin: 0 0 .5rem; font-size: .9rem; }
.retour a { color: var(--doux); }
.meta { color: var(--doux); font-size: .8rem; }
.cle { background: #fffbe0; border: 1px solid var(--jaune); border-radius: 8px; padding: .75rem; margin-top: .75rem; }
.cle code { display: inline-block; word-break: break-all; background: #fff; padding: .3rem .5rem; border-radius: 6px; font-size: .85rem; }

/* À valider */
.proposition { margin-bottom: 1rem; }
.proposition pre { white-space: pre-wrap; font: inherit; background: var(--fond); padding: .75rem; border-radius: 8px; margin: .5rem 0; }
.proposition textarea { margin-top: .5rem; }

/* Calendrier */
.mois { min-width: 9rem; text-align: center; text-transform: capitalize; }
.legende { display: flex; gap: .7rem; flex-wrap: wrap; font-size: .8rem; color: var(--doux); margin-left: auto; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .25rem; background: var(--s); }
.s-idee { --s: #b9b7ad; }
.s-en_creation { --s: var(--orange); }
.s-pret { --s: var(--entreprise); }
.s-programme { --s: var(--reseaux); }
.s-publie { --s: var(--vert); }
.calendrier { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendrier .entete { text-align: center; font-size: .78rem; color: var(--doux); text-transform: uppercase; padding: .25rem 0; }
.jour { background: #fff; border: 1px solid var(--bord); border-radius: 8px; min-height: 110px; padding: .3rem; position: relative; display: flex; flex-direction: column; gap: 3px; }
.jour.vide { background: transparent; border: 0; }
.jour.auj { border: 2px solid var(--jaune); }
.jour .num { font-size: .8rem; color: var(--doux); }
.jour .plus { position: absolute; top: .2rem; right: .35rem; text-decoration: none; color: var(--doux); font-weight: 700; opacity: 0; }
.jour:hover .plus { opacity: 1; }
.contenu { display: block; text-decoration: none; font-size: .75rem; line-height: 1.25; padding: .2rem .35rem; border-radius: 5px; background: #f3f2ec; border-left: 3px solid var(--s); overflow: hidden; }
.contenu small { display: block; font-size: .7rem; }

/* Temps */
.saisie { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.saisie > select, .saisie > input { width: auto; flex: 1 1 160px; }
.rapides { display: flex; gap: .3rem; }
.rapides button { padding: .3rem .55rem; font-size: .8rem; }

/* Document (devis / facture) */
.document { background: #fff; max-width: 820px; margin: 1rem auto; padding: 2.5rem; border: 1px solid var(--bord); border-radius: 4px; }
.document header { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.document header .droite { text-align: right; }
.document h1 { display: block; margin: 0 0 .5rem; font-size: 1.5rem; }
.destinataire { margin: 0 0 1.5rem auto; width: 50%; padding: .75rem; border: 1px solid var(--bord); border-radius: 6px; min-height: 4rem; }
.document th { background: var(--noir); color: #fff; }
.document td:not(:first-child), .document th:not(:first-child) { text-align: right; }
.document tfoot td { border: 0; }
.mentions { margin-top: 2rem; font-size: .85rem; color: var(--doux); }

/* Connexion */
.connexion { max-width: 360px; margin: 12vh auto; background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); padding: 2rem; display: flex; flex-direction: column; gap: .5rem; }
.connexion .logo { color: var(--noir); font-size: 1.4rem; text-align: center; margin-bottom: 1rem; }
.connexion label { font-size: .9rem; color: var(--doux); }
.connexion button { margin-top: 1rem; padding: .6rem; }

/* Messages */
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--noir); color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,.2); max-width: 90vw; }
.toast.erreur { background: var(--rouge); }

/* Téléphone */
@media (max-width: 720px) {
  .barre { flex-wrap: wrap; gap: .4rem; }
  .barre nav { order: 3; flex-basis: 100%; }
  .barre .lien { margin-left: auto; }
  main { padding: 1rem .75rem 3rem; }
  .fiche { grid-template-columns: 1fr; }
  .fiche > label.case { grid-column: 1; }
  .calendrier { grid-template-columns: 1fr; }
  .calendrier .entete, .jour.vide { display: none; }
  .jour { min-height: 0; }
  .jour .plus { opacity: 1; }
  .document { padding: 1.25rem; }
  .document header { flex-direction: column; }
  .destinataire { width: 100%; }
}

/* Impression : seul le document sort */
@media print {
  body { background: #fff; }
  .barre, .noprint, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .document { border: 0; margin: 0; padding: 0; max-width: none; }
  .document th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
