/* Budget – feuille de style (inspirée d'Airtable) */
:root {
  --fond: #f7f7f8; --carte: #fff; --texte: #1d1f25; --doux: #616670; --pale: #9aa0a6;
  --ligne: #e3e4e8; --ligne-forte: #cfd2d8; --accent: #2d7ff9; --accent-fonce: #1c64d4; --accent-pale: #e8f1ff;
  --danger: #d63b52; --ok: #1f9d55; --barre: #1f2328; --rayon: 6px;
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 13px/1.4 var(--police); color: var(--texte); background: var(--fond); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- Connexion ---------- */
.connexion { min-height: 100%; display: grid; place-items: center; background: linear-gradient(160deg, #eef1f5, #f9fafb); }
.carte-connexion { width: 340px; background: #fff; border: 1px solid var(--ligne); border-radius: 12px; padding: 32px 28px; box-shadow: 0 10px 30px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 14px; }
.carte-connexion h1 { margin: 0; font-size: 22px; }
.carte-connexion .sous-titre { margin: -10px 0 6px; color: var(--doux); }
.carte-connexion label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 12px; color: var(--doux); }
.carte-connexion input { padding: 9px 10px; border: 1px solid var(--ligne-forte); border-radius: var(--rayon); font-size: 14px; }
.carte-connexion .pied { color: var(--pale); font-size: 11px; text-align: center; margin: 4px 0 0; }
.erreur { color: var(--danger); margin: 0; }
.logo-app { width: 40px; height: 40px; border-radius: 9px; background: var(--barre); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.logo-app.petit { width: 26px; height: 26px; font-size: 14px; border-radius: 6px; background: #fff; color: var(--barre); }

/* ---------- Boutons ---------- */
.btn { border: 1px solid var(--ligne-forte); background: #fff; border-radius: var(--rayon); padding: 6px 12px; font-weight: 500; }
.btn:hover { background: #f2f3f5; }
.btn-primaire { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primaire:hover { background: var(--accent-fonce); }
.btn-danger { color: var(--danger); border-color: #f1c4cc; }
.btn.petit { padding: 3px 8px; font-size: 12px; }

/* ---------- Barre du haut ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
.barre-haut { height: 48px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--barre); color: #fff; }
.marque { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-right: 6px; }
.btn-projet { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: var(--rayon); padding: 6px 12px; font-weight: 600; font-size: 14px; max-width: 320px; }
.btn-projet:hover { background: rgba(255,255,255,.2); }
.btn-projet span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { opacity: .7; }
.onglets { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; }
.onglet { background: transparent; color: rgba(255,255,255,.75); border: 0; padding: 6px 12px; border-radius: var(--rayon); white-space: nowrap; font-weight: 500; }
.onglet:hover { background: rgba(255,255,255,.1); color: #fff; }
.onglet.actif { background: #fff; color: var(--texte); font-weight: 600; }
.espace { flex: 1; }
.etat-sauvegarde { font-size: 12px; color: rgba(255,255,255,.6); min-width: 90px; text-align: right; }
.etat-sauvegarde.en-cours { color: #ffd66e; }
.btn-utilisateur { width: 30px; height: 30px; border-radius: 50%; border: 0; background: #8b46ff; color: #fff; font-weight: 700; font-size: 12px; }

/* ---------- Corps ---------- */
.corps { flex: 1; display: flex; min-height: 0; }
.barre-vues { width: 230px; flex: none; background: #fff; border-right: 1px solid var(--ligne); padding: 10px 8px; overflow-y: auto; }
.barre-vues input { width: 100%; padding: 6px 8px; border: 1px solid var(--ligne); border-radius: var(--rayon); margin-bottom: 8px; background: var(--fond); }
.barre-vues ul { list-style: none; margin: 0; padding: 0; }
.barre-vues li { padding: 6px 8px; border-radius: var(--rayon); cursor: pointer; display: flex; gap: 8px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre-vues li:hover { background: #f2f3f5; }
.barre-vues li.actif { background: var(--accent-pale); color: var(--accent-fonce); font-weight: 600; }
.barre-vues li.separateur { height: 1px; padding: 0; margin: 8px 4px; background: var(--ligne); cursor: default; }
.ico-vue { color: var(--accent); font-size: 12px; width: 14px; text-align: center; }
.corbeille .ico-vue { color: var(--doux); }

.zone-grille { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }
.barre-outils { flex: none; display: flex; align-items: center; gap: 4px; padding: 7px 12px; border-bottom: 1px solid var(--ligne); flex-wrap: nowrap; white-space: nowrap; overflow-x: auto; }
.barre-outils .btn-outil, .barre-outils .btn { flex: none; }
.titre-vue { font-weight: 700; font-size: 14px; margin-right: 8px; }
.puce-outil { font-size: 12px; padding: 4px 8px; border-radius: var(--rayon); white-space: nowrap; }
.puce-outil.filtre { background: #d1f7c4; }
.puce-outil.groupe { background: #ede2fe; }
.puce-outil.tri { background: #ffeab6; }
.btn-outil { border: 0; background: transparent; padding: 5px 8px; border-radius: var(--rayon); color: var(--doux); }
.btn-outil:hover { background: #f2f3f5; color: var(--texte); }
.btn-outil.danger { color: var(--danger); }
.recherche-grille { width: 170px; flex: none; padding: 5px 8px; border: 1px solid var(--ligne); border-radius: var(--rayon); }
.grille { flex: 1; min-height: 0; }
.barre-resume { flex: none; height: 30px; border-top: 1px solid var(--ligne); display: flex; align-items: center; gap: 22px; padding: 0 14px; font-size: 12px; color: var(--doux); background: #fafbfc; }
.barre-resume .total { color: var(--texte); font-weight: 600; }
.barre-resume .total-lib { color: var(--doux); font-weight: 400; margin-right: 4px; }
.chargement, .vide-centre { padding: 40px; text-align: center; color: var(--doux); }

/* ---------- Grille (Tabulator) ---------- */
.tabulator { border: 0; background: #fff; font-size: 13px; }
.tabulator .tabulator-header { background: #f5f6f8; border-bottom: 1px solid var(--ligne-forte); font-weight: 500; }
.tabulator .tabulator-header .tabulator-col { background: #f5f6f8; border-right: 1px solid var(--ligne); }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content { padding: 6px 8px; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-title { font-weight: 500; color: #333; }
.tabulator .tabulator-tableholder .tabulator-table { background: #fff; }
.tabulator-row { min-height: 33px; border-bottom: 1px solid var(--ligne); background: #fff; }
.tabulator-row.tabulator-row-even { background: #fff; }
.tabulator-row:hover { background: #f8f9fb !important; }
.tabulator-row.tabulator-selected { background: var(--accent-pale) !important; }
.tabulator-row.nouvelle { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #fff3c4; } to { background: #fff; } }
.tabulator-row .tabulator-cell { padding: 6px 8px; border-right: 1px solid #edeef1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 33px; }
.tabulator-row .tabulator-cell.a-droite { text-align: right; font-variant-numeric: tabular-nums; }
.tabulator-row .tabulator-cell.primaire { font-weight: 500; border-right: 2px solid var(--ligne-forte); }
.tabulator-row .tabulator-cell.tabulator-editing { border: 2px solid var(--accent); padding: 0; background: #fff; }
.tabulator-row .tabulator-cell.tabulator-editing input, .tabulator-row .tabulator-cell.tabulator-editing textarea { padding: 4px 6px !important; }
.tabulator-row .tabulator-cell.type-formula, .tabulator-row .tabulator-cell.type-lookup, .tabulator-row .tabulator-cell.type-autonumber, .tabulator-row .tabulator-cell.type-created { color: #333; background: #fbfbfc; }
.tabulator-row .tabulator-cell.type-checkbox { text-align: center; cursor: pointer; }
.tabulator-row .tabulator-cell.type-attachments { cursor: pointer; padding: 3px 6px; }
.tabulator .tabulator-frozen.tabulator-frozen-left { border-right: 2px solid var(--ligne-forte); }
.tabulator-row .tabulator-cell.entete-ligne { padding: 0 4px; color: var(--pale); font-size: 11px; text-align: center; position: relative; background: #fff; }
.entete-ligne .case-ligne { display: none; margin: 0; vertical-align: middle; }
.entete-ligne .btn-ouvrir { display: none; border: 0; background: transparent; color: var(--accent); font-size: 14px; padding: 0 2px; vertical-align: middle; }
.tabulator-row:hover .entete-ligne .no-ligne, .tabulator-row.tabulator-selected .entete-ligne .no-ligne { display: none; }
.tabulator-row:hover .entete-ligne .case-ligne, .tabulator-row.tabulator-selected .entete-ligne .case-ligne { display: inline-block; }
.tabulator-row:hover .entete-ligne .btn-ouvrir { display: inline-block; }
.tabulator .tabulator-row .tabulator-cell.entete-ligne { line-height: 20px; }
.ico-champ { color: var(--pale); font-style: italic; margin-right: 2px; }
.tabulator-row.tabulator-group { background: #f1f2f5 !important; border-bottom: 1px solid var(--ligne-forte); padding: 6px 10px; min-height: 34px; font-size: 12.5px; }
.tabulator-row.tabulator-group.tabulator-group-level-1 { background: #f8f8fa !important; padding-left: 26px; }
.tabulator-row.tabulator-group .groupe-champ { color: var(--doux); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.tabulator-row.tabulator-group .groupe-valeur { font-weight: 700; margin: 0 8px 0 4px; }
.tabulator-row.tabulator-group .groupe-nb { color: var(--doux); font-weight: 400; }
.tabulator-row.tabulator-group .groupe-total { margin-left: 18px; color: var(--doux); font-weight: 400; }
.tabulator-row.tabulator-group .groupe-total b { color: #333; }
.tabulator .tabulator-placeholder .tabulator-placeholder-contents { color: var(--pale); font-weight: 400; font-size: 14px; }

.pastille { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; line-height: 18px; white-space: nowrap; margin-right: 3px; }
.lien-puce { display: inline-block; background: #e9eef8; color: #1c3d73; border-radius: 4px; padding: 0 7px; margin-right: 4px; font-size: 12px; line-height: 19px; white-space: nowrap; }
.coche { color: var(--ok); font-weight: 900; font-size: 15px; }
.vignette { height: 26px; width: 26px; object-fit: cover; border-radius: 3px; margin-right: 3px; vertical-align: middle; border: 1px solid var(--ligne); }
.fichier-puce { display: inline-block; height: 26px; min-width: 26px; padding: 0 3px; line-height: 26px; text-align: center; font-size: 9px; font-weight: 700; background: #f1f2f5; border: 1px solid var(--ligne); color: var(--doux); border-radius: 3px; margin-right: 3px; vertical-align: middle; }
.lien-web { color: var(--accent-fonce); }
.editeur-texte { width: 100%; height: 100%; border: 0; outline: 0; padding: 4px 6px; background: #fff; }
.editeur-ancre { height: 100%; }

/* ---------- Sélecteur flottant ---------- */
.selecteur { position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--ligne-forte); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.16); display: flex; flex-direction: column; max-height: 340px; }
.selecteur-recherche { margin: 8px; padding: 6px 8px; border: 1px solid var(--ligne-forte); border-radius: var(--rayon); }
.selecteur-choisis { padding: 8px 8px 0; display: flex; flex-wrap: wrap; gap: 4px; }
.puce-retirable { display: inline-flex; align-items: center; }
.puce-retirable button { border: 0; background: transparent; color: var(--doux); padding: 0 4px; font-size: 14px; }
.selecteur-liste { list-style: none; margin: 0; padding: 0 4px 6px; overflow-y: auto; }
.selecteur-liste li { padding: 5px 8px; border-radius: 5px; cursor: pointer; }
.selecteur-liste li:hover, .selecteur-liste li.actif { background: #f0f3f8; }
.selecteur-liste li.choisi::after { content: "✓"; float: right; color: var(--accent); font-weight: 700; }
.selecteur-liste li.selecteur-creer { color: var(--accent-fonce); font-weight: 600; }
.selecteur-liste li.selecteur-vider { color: var(--doux); font-style: italic; }
.selecteur-liste li.selecteur-vide { color: var(--pale); cursor: default; }

/* ---------- Modales et fiches ---------- */
.modale-fond { position: fixed; inset: 0; background: rgba(20,22,28,.45); z-index: 900; display: grid; place-items: center; padding: 20px; }
.modale { background: #fff; border-radius: 10px; width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modale.large { width: min(1100px, 100%); height: calc(100vh - 40px); }
.modale-tete { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--ligne); gap: 12px; }
.modale-tete h2 { margin: 0; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-fermer { border: 0; background: transparent; font-size: 24px; line-height: 1; color: var(--doux); }
.modale-corps { flex: 1; overflow: auto; padding: 18px; min-height: 0; }
.modale-pied { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--ligne); }
.fiche { display: grid; grid-template-columns: 1fr 300px; gap: 20px; height: 100%; }
.fiche-champs { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding-right: 6px; }
.fiche-champ label { display: block; font-size: 12px; font-weight: 600; color: var(--doux); margin-bottom: 4px; }
.fiche-champ .aide { font-size: 11px; color: var(--pale); margin: -2px 0 4px; }
.fiche-champ input[type=text], .fiche-champ input[type=url], .fiche-champ input[type=date], .fiche-champ textarea, .formulaire input, .formulaire select, .formulaire textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--ligne-forte); border-radius: var(--rayon); background: #fff; }
.fiche-champ input:focus, .fiche-champ textarea:focus, .champ-selecteur:focus { outline: 2px solid var(--accent-pale); border-color: var(--accent); }
.case-grande { width: 18px; height: 18px; accent-color: var(--ok); }
.champ-selecteur { width: 100%; min-height: 34px; text-align: left; background: #fff; border: 1px solid var(--ligne-forte); border-radius: var(--rayon); padding: 5px 8px; }
.valeur-lecture { padding: 7px 9px; background: #f7f8fa; border-radius: var(--rayon); min-height: 33px; }
.vide { color: var(--pale); }
.fiche-historique { border-left: 1px solid var(--ligne); padding-left: 16px; overflow-y: auto; }
.fiche-historique h3 { margin: 0 0 10px; font-size: 13px; }
.liste-historique { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.liste-historique li { padding: 8px 0; border-bottom: 1px solid #f0f1f3; }
.hist-quand { color: var(--pale); font-size: 11px; }
.hist-valeurs { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.hist-valeurs .ancienne { text-decoration: line-through; color: #b23a4c; background: #fdecef; padding: 1px 5px; border-radius: 3px; align-self: flex-start; }
.hist-valeurs .nouvelle { color: #1b6e3a; background: #e6f6ec; padding: 1px 5px; border-radius: 3px; align-self: flex-start; }
.formulaire { display: flex; flex-direction: column; gap: 12px; }
.formulaire label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--doux); }
.formulaire label.ligne { flex-direction: row; align-items: center; }
.liste-masquer { display: flex; flex-direction: column; gap: 6px; columns: 2; }
.liste-masquer label { display: block; break-inside: avoid; }
.table-utilisateurs { width: 100%; border-collapse: collapse; }
.table-utilisateurs th, .table-utilisateurs td { text-align: left; padding: 6px; border-bottom: 1px solid var(--ligne); }

/* ---------- Pièces jointes ---------- */
.pj-grille { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.pj-carte { width: 130px; border: 1px solid var(--ligne); border-radius: 8px; overflow: hidden; background: #fff; position: relative; }
.pj-apercu { display: grid; place-items: center; height: 96px; background: #f4f5f7; }
.pj-apercu img { width: 100%; height: 96px; object-fit: cover; }
.pj-ext { font-weight: 800; color: var(--doux); font-size: 18px; }
.pj-nom { font-size: 11px; padding: 5px 7px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pj-actions { display: flex; justify-content: space-between; padding: 0 6px 5px; }
.pj-actions a, .pj-actions button { border: 0; background: transparent; color: var(--doux); text-decoration: none; font-size: 13px; padding: 2px 4px; }
.pj-depot { border: 2px dashed var(--ligne-forte); border-radius: 8px; padding: 18px; text-align: center; color: var(--accent-fonce); font-weight: 600; cursor: pointer; }
.pj-depot span { color: var(--pale); font-weight: 400; }
.pj-depot.survol { background: var(--accent-pale); border-color: var(--accent); }

/* ---------- Menus et notifications ---------- */
.menu-flottant { position: fixed; z-index: 950; background: #fff; border: 1px solid var(--ligne); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); min-width: 230px; padding: 6px; display: flex; flex-direction: column; }
.menu-flottant button { border: 0; background: transparent; text-align: left; padding: 7px 10px; border-radius: 5px; }
.menu-flottant button:hover, .menu-lien:hover { background: #f2f3f5; }
.menu-lien { padding: 7px 10px; border-radius: 5px; color: var(--accent-fonce); text-decoration: none; }
.menu-info { padding: 6px 10px 10px; border-bottom: 1px solid var(--ligne); margin-bottom: 4px; font-weight: 600; display: flex; flex-direction: column; }
.menu-info small { color: var(--doux); font-weight: 400; }
.menu-version { color: var(--pale); font-size: 11px; padding: 6px 10px 2px; border-top: 1px solid var(--ligne); margin-top: 4px; }
.tabulator-menu { border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); border: 1px solid var(--ligne); font-size: 13px; padding: 4px; }
.tabulator-menu .tabulator-menu-item { padding: 6px 12px; border-radius: 5px; }
#toasts { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2328; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); transition: opacity .4s; display: flex; gap: 14px; align-items: center; }
.toast.erreur { background: var(--danger); }
.toast.ok { background: #1f7a45; }
.toast.sortie { opacity: 0; }
.lien-annuler { border: 0; background: transparent; color: #9cc7ff; font-weight: 700; padding: 0; }

@media (max-width: 800px) {
  .barre-vues { display: none; }
  .onglets { display: none; }
  .fiche { grid-template-columns: 1fr; }
  .fiche-historique { border-left: 0; padding-left: 0; }
}

.btn-maj { border: 0; background: #ffd66e; color: #3d2c00; font-weight: 700; border-radius: var(--rayon); padding: 5px 10px; }
.btn-maj:hover { background: #fcb400; }
.notes-maj { white-space: pre-wrap; background: #f7f8fa; border-radius: var(--rayon); padding: 10px; font-size: 12.5px; }
.formulaire .aide { color: var(--doux); font-size: 12px; }

/* =====================================================================
   Version 1.1 : vues partagées, panneaux, champs, automatisations
   ===================================================================== */
.btn-outil.actif.masquer { background: #cfdfff; color: #1c3d73; }
.btn-outil.actif.filtre { background: #d1f7c4; color: #1e4d14; }
.btn-outil.actif.groupe { background: #ede2fe; color: #4b2a85; }
.btn-outil.actif.tri { background: #fee2d5; color: #7a3315; }
.btn-outil.actif.couleur { background: #ffdaf6; color: #7a1660; }
.titre-vue.bouton { border: 0; background: transparent; padding: 5px 8px; border-radius: var(--rayon); font-weight: 700; font-size: 14px; }
.titre-vue.bouton:hover { background: #f2f3f5; }
.barre-vues li .nom-vue { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.btn-vue-menu { border: 0; background: transparent; color: var(--doux); padding: 0 4px; border-radius: 4px; visibility: hidden; }
.barre-vues li:hover .btn-vue-menu { visibility: visible; }
.btn-vue-menu:hover { background: #e4e6ea; }
.barre-vues li.creer-vue { color: var(--accent-fonce); font-weight: 500; }
.barre-vues li.glisse { opacity: .4; }
.barre-vues li.cible, .liste-champs li.cible { box-shadow: inset 0 2px 0 var(--accent); }

/* Popovers et panneaux */
.popover { position: fixed; z-index: 940; background: #fff; border: 1px solid var(--ligne); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.16); overflow: auto; min-width: 200px; max-width: calc(100vw - 16px); }
.panneau { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.panneau-titre { color: var(--doux); font-size: 12.5px; }
.panneau-pied { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--ligne); padding-top: 10px; }
.panneau select, .panneau input[type=text], .panneau input[type=search], .panneau input[type=date], .panneau input[type=number], .panneau input:not([type]) {
  border: 1px solid var(--ligne-forte); border-radius: 5px; padding: 5px 7px; background: #fff; min-width: 0; }
.recherche-panneau { width: 100%; }
.menu-liste { display: flex; flex-direction: column; padding: 5px; min-width: 200px; }
.menu-liste button { border: 0; background: transparent; text-align: left; padding: 6px 10px; border-radius: 5px; }
.menu-liste button:hover { background: #f2f3f5; }
.menu-liste button.actif { color: var(--accent-fonce); font-weight: 600; }
.menu-liste button.actif::after { content: " ✓"; }
.menu-liste button.danger, .danger { color: var(--danger); }
.menu-liste hr { border: 0; border-top: 1px solid var(--ligne); margin: 4px 0; width: 100%; }
.menu-titre { color: var(--doux); font-size: 11.5px; padding: 4px 10px 6px; }
.popover-enfant { position: fixed; z-index: 960; background: #fff; border: 1px solid var(--ligne); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.btn-lien { border: 0; background: transparent; color: var(--accent-fonce); padding: 4px 0; font-weight: 500; text-align: left; }
.btn-lien:hover { text-decoration: underline; }
.btn-icone { border: 0; background: transparent; color: var(--pale); padding: 2px 6px; border-radius: 4px; }
.btn-icone:hover { background: #f2f3f5; color: var(--danger); }
.btn.actif { background: var(--accent-pale); border-color: var(--accent); color: var(--accent-fonce); }
.aide { color: var(--doux); font-size: 12px; margin: 0; }
.sous-titre { color: var(--doux); font-size: 12px; font-weight: 600; margin-top: 4px; }

/* Masquer des champs */
.liste-champs { list-style: none; margin: 0; padding: 0; max-height: 52vh; overflow-y: auto; }
.liste-champs li { display: flex; align-items: center; gap: 8px; padding: 4px 4px; border-radius: 5px; }
.liste-champs li:hover { background: #f5f6f8; }
.liste-champs .nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poignee { color: var(--pale); cursor: grab; font-size: 12px; }
input.bascule { appearance: none; width: 26px; height: 15px; border-radius: 8px; background: #cfd2d8; position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
input.bascule::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: left .15s; }
input.bascule:checked { background: var(--ok); }
input.bascule:checked::after { left: 13px; }
.ligne-bascule { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }

/* Filtres */
.filtre-groupe { display: flex; flex-direction: column; gap: 6px; }
.filtre-groupe.niveau-1, .filtre-groupe.niveau-2 { background: #f7f8fa; border: 1px solid var(--ligne); border-radius: 6px; padding: 8px; flex: 1; }
.filtre-groupe.niveau-2 { background: #fff; }
.filtre-ligne { display: flex; align-items: center; gap: 6px; }
.filtre-ligne .conj { width: 58px; flex: none; color: var(--doux); font-size: 12px; }
.filtre-ligne select.conj { width: 58px; }
.filtre-ligne select.champ { width: 170px; }
.filtre-ligne select.op { width: 140px; }
.filtre-ligne > input, .filtre-ligne .valeur-choix, .filtre-ligne .valeur-date { flex: 1; min-width: 120px; }
.filtre-ligne .valeur-choix { min-height: 30px; padding: 3px 6px; }
.valeur-date { display: flex; gap: 6px; }
.valeur-date select { flex: 1; }
.petit-nombre { width: 64px; }
.valeur-case { display: inline-flex; align-items: center; gap: 6px; flex: 1; }
.valeur-vide { flex: 1; }
.filtre-actions { display: flex; gap: 18px; padding-top: 2px; }

/* Grouper / trier */
.ligne-tri { display: flex; align-items: center; gap: 8px; }
.ligne-tri .conj { color: var(--doux); font-size: 12px; min-width: 88px; }
.ligne-tri select.champ { flex: 1; }
.ligne-tri select.sens { width: 150px; }
.panneau select.ajout { color: var(--accent-fonce); border-style: dashed; }
.choix-mode { display: flex; gap: 6px; flex-wrap: wrap; }

/* Couleurs */
.pastille-couleur { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--ligne-forte); flex: none; padding: 0; }
.nuancier { display: grid; grid-template-columns: repeat(10, 22px); gap: 4px; padding: 8px; }
.nuancier button { width: 22px; height: 22px; border-radius: 4px; border: 1px solid rgba(0,0,0,.08); padding: 0; }
.nuancier button.choisi { outline: 2px solid var(--texte); outline-offset: 1px; }
.regle-couleur { border: 1px solid var(--ligne); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.regle-tete { display: flex; align-items: center; gap: 8px; }
.regle-tete span { flex: 1; color: var(--doux); }
.apercu-choix { line-height: 24px; }
.tabulator-row.coloree { background: color-mix(in srgb, var(--couleur-ligne) 22%, #fff); }
.tabulator-row.coloree .tabulator-cell.entete-ligne { background: color-mix(in srgb, var(--couleur-ligne) 22%, #fff); }

/* Grille : en-têtes, colonne « + », résumés */
.ico-champ { color: var(--pale); font-style: normal; margin-right: 3px; font-size: 11px; }
.ico-info { color: var(--pale); font-size: 11px; }
.tabulator .tabulator-header .tabulator-col.col-ajout { background: #f5f6f8; cursor: pointer; }
.tabulator .tabulator-header .tabulator-col.col-ajout .tabulator-col-title { text-align: center; font-size: 18px; color: var(--doux); }
.tabulator .tabulator-header .tabulator-col.col-ajout:hover { background: #e8eaee; }
.tabulator-row .tabulator-cell.col-ajout { background: #fafbfc; }
.tabulator .tabulator-col .tabulator-header-popup-button { opacity: 0; padding: 0 4px; color: var(--doux); }
.tabulator .tabulator-col:hover .tabulator-header-popup-button { opacity: 1; }
.tabulator .tabulator-footer { background: #fafbfc; border-top: 1px solid var(--ligne-forte); }
.tabulator .tabulator-footer .tabulator-calcs-holder, .tabulator .tabulator-calcs-holder { background: #fafbfc !important; border-top: 1px solid var(--ligne); }
.tabulator-row.tabulator-calcs { background: #fafbfc !important; }
.tabulator-row.tabulator-calcs .tabulator-cell { font-size: 12px; text-align: right; cursor: pointer; color: var(--texte); font-weight: 600; }
.tabulator-row.tabulator-calcs .tabulator-cell:hover { background: #eef0f3; }
.tabulator-row.tabulator-calcs .tabulator-cell:empty:hover::after { content: "Résumé ▾"; color: var(--pale); font-weight: 400; }
.tabulator-row.tabulator-calcs .tabulator-cell.entete-ligne:hover::after, .tabulator-row.tabulator-calcs .tabulator-cell.col-ajout:hover::after { content: none; }
.tabulator-row.tabulator-calcs-group { background: #fbfbfc !important; border-bottom: 1px solid var(--ligne); }
.resume-lib { color: var(--pale); font-weight: 400; margin-right: 3px; text-transform: none; }
.etoiles { color: #fcb400; letter-spacing: 1px; }
.etoiles .eteintes { color: #e3e4e8; }
.lookup-puce { display: inline-block; background: #f1f2f5; border-radius: 4px; padding: 0 6px; margin-right: 4px; font-size: 12px; line-height: 19px; }
.erreur-formule { color: var(--danger); font-weight: 600; font-size: 12px; }
.tabulator-row .tabulator-cell.type-rollup, .tabulator-row .tabulator-cell.type-modified { color: #333; background: #fbfbfc; }
.fiche-separateur { color: var(--pale); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; border-top: 1px solid var(--ligne); padding-top: 10px; }

/* Éditeur de champ */
.modale-champ { width: min(620px, 100%); }
.editeur-champ select.type-champ:disabled { color: var(--texte); background: #f5f6f8; }
.options-champ { display: flex; flex-direction: column; gap: 10px; }
.editeur-choix { display: flex; flex-direction: column; gap: 6px; }
.ligne-choix { display: flex; align-items: center; gap: 8px; }
.ligne-choix input[type=text] { flex: 1; }
.editeur-formule { display: flex; flex-direction: column; gap: 8px; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.apercu-formule { font-size: 12px; min-height: 18px; }
.apercu-formule.ok { color: var(--ok); }
.apercu-formule.ko { color: var(--danger); }
.puces-insertion { display: flex; flex-wrap: wrap; gap: 4px; max-height: 120px; overflow-y: auto; }
.puce-champ { border: 1px solid var(--ligne); background: #f7f8fa; border-radius: 12px; padding: 2px 9px; font-size: 12px; }
.puce-champ:hover { background: var(--accent-pale); border-color: var(--accent); }

/* Automatisations */
.autos { display: grid; grid-template-columns: 290px 1fr; gap: 18px; height: 100%; }
.autos-liste { display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--ligne); padding-right: 14px; overflow-y: auto; }
.autos-liste hr { border: 0; border-top: 1px solid var(--ligne); width: 100%; }
.auto-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.auto-item:hover { background: #f5f6f8; }
.auto-item.actif { background: var(--accent-pale); border-color: #b9d3fb; }
.auto-item .bascule { margin-top: 3px; }
.auto-nom { font-weight: 600; }
.autos-editeur { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 6px; }
.auto-bloc { border: 1px solid var(--ligne); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.auto-bloc label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--doux); }
.auto-bloc input, .auto-bloc select, .auto-bloc textarea { border: 1px solid var(--ligne-forte); border-radius: 5px; padding: 6px 8px; font-weight: 400; color: var(--texte); }
.auto-bloc-titre { font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.auto-pied { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--ligne); padding-top: 12px; position: sticky; bottom: 0; background: #fff; }
.journal-erreur td { color: var(--danger); }
.journal-test td { color: var(--doux); }

/* Version 1.2 : fiches reliées, listes partagées */
.ouvrir-liens { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 3px; }
.btn-lien.petit { font-size: 12px; padding: 0; }
.fiche-liens { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.liste-liens { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.liste-liens li { font-size: 13px; }
.liste-liens li.inactif .btn-lien { color: var(--pale); text-decoration: line-through; }
.carte-connexion .ok { color: var(--ok); font-size: 13px; margin: 0; }
.carte-connexion .btn-lien { align-self: center; font-size: 13px; }

/* 1.3.0 : connexion Google, import Airtable */
.carte-connexion .btn-google { display: block; text-align: center; text-decoration: none; margin-top: 8px; }
.import-journal { background: #111; color: #ddd; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; padding: 10px 12px; border-radius: 6px; height: 320px; overflow: auto; white-space: pre-wrap; margin: 8px 0 0; }
.import-options { display: grid; gap: 8px; }
.import-options .ligne { display: flex; gap: 8px; align-items: center; }
.import-etat { font-size: 13px; color: #555; }
