[hidden] { display: none !important; }   /* l'attribut hidden l'emporte sur les règles display */
:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --ink: #28251f;
  --muted: #8a8577;
  --line: #e6e3da;
  --accent: #7c6fde;
  --accent-ink: #ffffff;
  --green: #2f9e8f;
  --red: #c0504d;
  --orange: #d97742;
  --radius: 10px;
  font-size: 15px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
header {
  display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap;
  padding: 10px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
nav { flex-wrap: wrap; }
.brand { background: none; border: none; cursor: pointer; padding: 0; display: flex; align-items: center; }
.brand img { height: 30px; display: block; }
.brand:hover { opacity: .8; }
.tab-gear { font-size: 1.15rem; padding: 5px 9px; line-height: 1; }
nav { display: flex; gap: 4px; }
.tab {
  border: none; background: none; padding: 8px 14px; border-radius: 8px;
  font: inherit; color: var(--muted); cursor: pointer;
}
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.active { background: var(--accent); color: var(--accent-ink); }
.badge {
  background: var(--orange); color: #fff; border-radius: 9px;
  font-size: .72rem; padding: 1px 7px; margin-left: 4px; vertical-align: 1px;
}
.tab.active .badge { background: #fff; color: var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 22px; }
.view > * + * { margin-top: 18px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; }
.panel h3 { font-size: .95rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.hint { color: var(--muted); font-size: .88rem; margin-top: 0; }

/* cartes projets */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.total-banner {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 8px; padding: 4px 6px 14px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.total-banner .tb-label { font-size: 1rem; font-weight: 600; color: var(--muted); }
.total-banner .tb-figs { display: flex; align-items: baseline; gap: 14px; }
.total-banner .tb-reel { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-banner .tb-prevu { font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; border-top: 3px solid var(--accent);
}
.card .name { font-weight: 600; font-size: .9rem; margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.card .row { display: flex; justify-content: space-between; font-size: .88rem; padding: 2px 0; }
.card .row .lbl { color: var(--muted); }
.amount.pos { color: var(--green); }
.amount.neg { color: var(--red); }

/* filtres */
.filters { display: flex; gap: 8px; align-items: center; }
.filters.wrap { flex-wrap: wrap; margin-bottom: 12px; }
input, select, button { font: inherit; }
input[type="search"], input[type="text"], input[type="number"], input[type="date"], select, textarea {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { font: inherit; width: 100%; resize: vertical; }
input[type="search"] { min-width: 200px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }

button.primary {
  background: var(--accent); color: var(--accent-ink); border: none;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }
button.danger { background: var(--red); color: #fff; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; }
button.link { background: none; border: none; color: var(--accent); cursor: pointer; text-decoration: underline; padding: 0; }
button.icon { background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 6px; }
button.icon:hover { background: var(--bg); color: var(--ink); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 7px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th.num, td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #faf9f5; }
.table-foot { color: var(--muted); font-size: .85rem; padding-top: 10px; }
.pill {
  display: inline-block; font-size: .73rem; border-radius: 9px; padding: 1px 8px;
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.pill.projet { color: #fff; }
.pill.prevu { background: #f3eedd; color: #9a7b1e; }
.pill.atraiter { background: var(--orange); color: #fff; }
.pill.ok { background: #e3f1ee; color: var(--green); }
.pill.dup { background: #f4e3e3; color: var(--red); }
.pill.hors-banque { background: #ededf0; color: #8a8a96; font-style: italic; }

/* sélecteur de justificatif Drive dans la fiche transaction */
.justif-row { display: flex; gap: 6px; align-items: center; }
.justif-row input { flex: 1; }
.justif-link { font-size: .82rem; margin: 4px 0 0; }
.justif-link .ok { color: var(--green); font-weight: 600; }
.justif-pending { color: var(--muted); }

/* popup de sélection (#justif-picker) */
#justif-picker { width: min(560px, 92vw); max-width: 560px; padding: 22px 24px; }
#justif-picker[open] { display: flex; flex-direction: column; gap: 10px; }   /* flex SEULEMENT quand ouvert (sinon il s'affichait en bas de page) */
.picker-head h2 { margin: 0 0 8px; }
#picker-search { width: 100%; margin-bottom: 4px; }
.picker-list { margin-top: 8px; max-height: 50vh; overflow-y: auto; border: 1px solid var(--border, #e3e0d8); border-radius: 8px; background: #fff; }
.justif-hit { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 12px; background: none; border: none; border-bottom: 1px solid #f0eee8; cursor: pointer; font-size: .88rem; color: var(--ink, #1a1830); }
.justif-hit:last-child { border-bottom: none; }
.justif-hit:hover { background: #f3f1fb; }
.justif-hit .jh-icon { flex-shrink: 0; }
.justif-hit .jh-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.justif-hit .jh-date { color: var(--muted); font-size: .78rem; flex-shrink: 0; }

/* écritures liées entre elles (salaire, virement interne, lien manuel) : groupe matérialisé par un bord coloré à gauche */
tbody tr.grouped { background: #fcfcff; }
tbody tr.grouped:hover { background: #f6f5fb; }
.pill.linked { background: #eceaf7; color: #6b5fc0; }

/* journal : table principale + panneau prévu */
.journal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; margin-top: 18px; }
.journal-layout > .panel { min-width: 0; }
.side-panel { position: sticky; top: 70px; }
.side-panel table { font-size: .82rem; }
@media (max-width: 1000px) { .journal-layout { grid-template-columns: 1fr; } .side-panel { position: static; } }

a.justif { color: var(--accent); text-decoration: none; }
a.justif:hover { text-decoration: underline; }

/* états financiers */
.pnl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .pnl-grid { grid-template-columns: 1fr; } }
.fin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.fin-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.fin-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-table .rub td { color: var(--muted); }
.fin-table .sec td { font-weight: 700; color: var(--ink); padding-top: 14px; text-transform: uppercase; font-size: .78rem; letter-spacing: .04em; }
.fin-table .sub td { font-weight: 700; border-top: 1.5px solid var(--line); }
.fin-table .grand td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
/* budgets */
.bud-table td { vertical-align: middle; }
.bud-cat-row.over td { color: var(--red); }
.bud-bar { display: inline-block; width: 120px; height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.bud-bar-fill { height: 100%; background: var(--green); border-radius: 5px; }
.bud-bar-fill.over { background: var(--red); }
.bud-pct { font-size: .82rem; color: var(--muted); }
.bud-expand { background: none; border: none; cursor: pointer; color: var(--muted); padding: 0 4px 0 0; }
.bud-detail-row td { background: #faf9f5; padding: 4px 10px 8px; }
.bud-postes-detail { display: flex; flex-direction: column; gap: 2px; }
.bud-poste-line { display: flex; justify-content: space-between; font-size: .84rem; color: var(--muted); padding: 1px 0; }
.bud-poste-line em { font-style: italic; opacity: .8; }
#bud-detail .fin-table input, #bud-detail .fin-table select { border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; background: transparent; font: inherit; }
#bud-detail .fin-table input:hover, #bud-detail .fin-table select:hover { border-color: var(--line); }
#bud-detail .fin-table input:focus, #bud-detail .fin-table select:focus { border-color: var(--accent); background: #fff; outline: none; }

.print-only { display: none; }
@media print {
  header, .no-print, nav, .tab { display: none !important; }
  .view[hidden] { display: none; }
  .print-only { display: block; margin-bottom: 12px; }
  .panel { border: none; padding: 0 0 18px; }
  .pnl-grid { gap: 30px; }
  main { max-width: none; padding: 0; }
}

/* compte de résultat */
.pnl { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.pnl-result { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 4px; padding: 12px 8px 2px; border-top: 2px solid var(--ink); font-weight: 700; }
.pnl-result .amount { font-size: 1.1rem; }
.pnl table tbody tr { cursor: default; }
.pnl .total td { font-weight: 700; border-top: 2px solid var(--line); }
@media (max-width: 800px) { .pnl { grid-template-columns: 1fr; } }

/* import */
#drop-zone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px;
  text-align: center; color: var(--muted); margin: 14px 0; transition: border-color .15s;
}
#drop-zone.over { border-color: var(--accent); color: var(--accent); }
#mapping-zone, #preview-zone, #import-result { margin-top: 16px; }
#import-result, #sal-result { padding: 12px; border-radius: 8px; background: #e3f1ee; color: var(--green); margin-top: 16px; }

/* salaires */
.salary-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .salary-layout { grid-template-columns: 1fr; } }
.salary-form { display: flex; flex-direction: column; gap: 12px; }
.salary-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.salary-form input, .salary-form select { width: 100%; }
#sal-breakdown table tbody tr { cursor: default; }
#sal-breakdown .total td { font-weight: 700; border-top: 2px solid var(--line); }

/* réglages */
.settings-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.settings-item .grow { flex: 1; }
.subprojects { margin: 4px 0 10px 26px; }
.subprojects .settings-item { border-bottom: none; padding: 3px 4px; color: var(--muted); }
.inline-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

/* notification éphémère */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: all .2s; z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* modal */
dialog {
  border: none; border-radius: 14px; padding: 0; width: min(620px, 94vw);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(40, 37, 31, .45); }
#tx-form, #emp-form, #subv-form, #facpaid-form, #cli-form, #transfer-form { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
#tx-form h2, #emp-form h2, #subv-form h2, #facpaid-form h2, #cli-form h2, #transfer-form h2 { margin: 0 0 4px; }
#tx-form label, #emp-form label, #subv-form label, #facpaid-form label, #cli-form label, #transfer-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
#tx-form input, #tx-form select, #emp-form input, #emp-form select, #subv-form input, #subv-form select, #facpaid-form input, #facpaid-form select, #cli-form input, #transfer-form input, #transfer-form select { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
.modal-actions .spacer { flex: 1; }
.modal-actions button { padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.modal-actions button.primary { border: none; background: var(--accent); color: var(--accent-ink); }
.modal-actions button.danger { border: none; background: var(--red); color: #fff; }

/* ===== authentification ===== */
.user-chip { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: .85rem; color: var(--muted); }
.user-chip #user-name { font-weight: 600; color: var(--ink, #1a1830); }
.role-badge { background: #eceaf7; color: #6b5fc0; border-radius: 8px; padding: 1px 8px; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }

#login-screen { position: fixed; inset: 0; z-index: 1000; background: var(--bg, #f4f2ea); display: flex; align-items: center; justify-content: center; padding: 20px; }
#login-form { background: var(--panel, #fff); padding: 30px 32px; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.18); width: min(360px, 94vw); display: flex; flex-direction: column; gap: 12px; }
#login-form .brand { font-size: 1.3rem; }
#login-form h2 { margin: 4px 0 6px; }
#login-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
#login-form input { width: 100%; }
#login-form .primary { margin-top: 6px; }
.login-error { color: var(--red, #c0392b); font-size: .85rem; min-height: 1em; }

/* rôle lecture : on masque les actions d'écriture (le serveur les refuse de toute façon) */
body[data-role="lecture"] #btn-new,
body[data-role="lecture"] #btn-transfer,
body[data-role="lecture"] #btn-add-project,
body[data-role="lecture"] #btn-add-cat,
body[data-role="lecture"] #btn-fac-save,
body[data-role="lecture"] #btn-add-user { display: none; }

/* changement de mot de passe obligatoire (1ʳᵉ connexion) */
#force-pw { width: min(380px, 94vw); padding: 28px 30px; }
#force-pw-form { display: flex; flex-direction: column; gap: 12px; }
#force-pw-form h2 { margin: 0; }
#force-pw-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
#force-pw-form input[type="password"], #force-pw-form input[type="text"] { width: 100%; }
#force-pw-form .primary { margin-top: 4px; }

/* rapprochement bancaire (panneau de suggestions dans le journal) */
.reconcile-panel { border-left: 3px solid var(--accent); background: #faf9ff; margin-top: 14px; }
.reconcile-panel h3 { margin: 0 0 6px; }
.reconcile-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.rc-pair { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; min-width: 0; }
.rc-arrow { color: var(--muted); }
.rc-bank { color: var(--muted); }
.rc-do { flex-shrink: 0; }

/* emoji plats Twemoji */
img.emoji { height: 1.05em; width: 1.05em; margin: 0 .05em 0 .1em; vertical-align: -0.15em; }
