/* ==========================================================================
   Budget Com' · Ingenium animalis — prototype UI
   Charte : Bleu Ingenium #0D1245 · Ardoise #303366 · Or #DDB670
            Orange d'appel #F0822D (boutons / alertes) · Crème #FEF7E2
   ========================================================================== */

:root {
  --bleu: #0D1245;
  --ardoise: #303366;
  --or: #DDB670;
  --or-fonce: #B8862E;
  --orange: #F0822D;
  --orange-fonce: #D96A16;
  --creme: #FEF7E2;
  --blanc: #FFFFFF;

  --fond: #F7F6F2;
  --surface: #FFFFFF;
  --ligne: #E7E3D8;
  --ligne-douce: #F0EDE4;
  --texte: #0D1245;
  --texte-2: #4A4E72;
  --texte-3: #7C7F99;

  /* Étapes (rampe séquentielle bleue, ordonnée) */
  --st-devis: #C5CAEA;
  --st-engage: #7F89C9;
  --st-facture: #3D4A9E;
  --st-paye: #1F2766;
  --n1: #A3A7B8;

  /* Statuts réservés */
  --ok: #2E7D5B;
  --ok-bg: #E6F3EC;
  --warn: #B25E00;
  --warn-bg: #FFF0E0;
  --crit: #B3261E;
  --crit-bg: #FCE8E6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(13, 18, 69, .06), 0 4px 16px rgba(13, 18, 69, .04);

  --f-titre: "IvyPresto Display", "Playfair Display", Georgia, "Times New Roman", serif;
  --f-texte: "HK Grotesk", "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--f-texte);
  font-size: 14px;
  line-height: 1.45;
  color: var(--texte);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--texte-3); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Typo charte ---------- */
h1, h2, h3 { font-family: var(--f-titre); font-weight: 600; margin: 0; color: var(--bleu); }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 17px; color: var(--ardoise); }
.h4 {
  font-family: var(--f-texte);
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--or-fonce);
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.h4::before {
  content: ""; width: 14px; height: 3px; border-radius: 2px; background: var(--or);
}

/* ---------- Boutons (rayon 30px, capitales) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 30px; border: 2px solid var(--orange);
  padding: 7px 18px; min-height: 36px;
  font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  background: var(--orange); color: #fff; cursor: pointer;
  transition: background .3s, color .3s, border-color .3s;
  white-space: nowrap;
}
.btn:hover { background: #fff; color: var(--orange-fonce); }
.btn-outline { background: #fff; color: var(--orange-fonce); }
.btn-outline:hover { background: var(--orange); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--ligne); color: var(--texte-2); }
.btn-ghost:hover { background: var(--creme); color: var(--bleu); border-color: var(--or); }
.btn-danger { background: #fff; border-color: var(--crit); color: var(--crit); }
.btn-danger:hover { background: var(--crit); color: #fff; }
.btn-sm { min-height: 28px; padding: 3px 12px; font-size: 11px; }
.btn-icon {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid transparent;
  background: transparent; cursor: pointer; display: inline-grid; place-items: center;
  color: var(--texte-2);
}
.btn-icon:hover { background: var(--creme); border-color: var(--or); color: var(--bleu); }
.btn:focus-visible, .btn-icon:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(240, 130, 45, .35); outline-offset: 1px;
}

/* ---------- Connexion ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 80% -10%, #303366 0%, transparent 60%), var(--bleu);
  padding: 24px 16px;
}
.login-card {
  width: 100%; max-width: 440px; background: #fff; border-radius: 18px; padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { display: block; height: 46px; margin: 0 auto 28px; }
.login h1 { text-align: center; font-size: 26px; }
.login .sub { text-align: center; color: var(--texte-2); margin: 6px 0 24px; }
.demo-accounts { margin-top: 22px; border-top: 1px solid var(--ligne); padding-top: 16px; }
.demo-accounts button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--ligne); border-radius: 10px;
  padding: 8px 12px; margin-bottom: 6px; cursor: pointer; text-align: left;
}
.demo-accounts button:hover { border-color: var(--or); background: var(--creme); }
.login-foot { color: rgba(255,255,255,.55); text-align: center; font-size: 12px; margin-top: 18px; }

/* ---------- Coque applicative ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bleu); color: #fff; padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
}
.sidebar .logo { height: 38px; margin: 2px 8px 6px; align-self: flex-start; }
.sidebar .app-name {
  margin: 0 10px 22px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--or); font-weight: 700;
}
.nav-group { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.45); margin: 18px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: rgba(255,255,255,.82); font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(221,182,112,.16); color: #fff; box-shadow: inset 3px 0 0 var(--or); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: 12px; font-size: 11px; color: rgba(255,255,255,.45); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 28px; background: rgba(255,255,255,.85); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--ligne); position: sticky; top: 0; z-index: 20;
}
.topbar .burger { display: none; }
.topbar .ctx { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.ctx label { font-size: 11px; color: var(--texte-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.ctx .field { display: flex; align-items: center; gap: 6px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--ligne); border-radius: 30px;
  padding: 4px 6px 4px 4px; background: #fff; cursor: pointer; position: relative;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--creme); color: var(--bleu);
  display: grid; place-items: center; font-weight: 800; font-size: 11px; border: 1px solid var(--or);
}
.user-menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--ligne);
  border-radius: 12px; box-shadow: var(--shadow); min-width: 240px; padding: 6px; z-index: 30; text-align: left;
}
.user-menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.user-menu button:hover { background: var(--creme); }

.page { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--texte-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cartes & grilles ---------- */
.card { background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card.creme { background: var(--creme); border-color: #F1E3BB; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .h4 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: 1.3fr repeat(5, 1fr); }
.g-2 { grid-template-columns: 1.6fr 1fr; }
.g-2-eq { grid-template-columns: 1fr 1fr; }
.stack > * + * { margin-top: 16px; }

/* ---------- Tuiles KPI ---------- */
.kpi .label { font-size: 12px; color: var(--texte-2); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.kpi .sub { font-size: 12px; color: var(--texte-3); margin-top: 2px; }
.kpi .key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.kpi.hero { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.kpi.hero .label { color: var(--or); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 700; }
.kpi.hero .value { font-size: 40px; color: #fff; }
.kpi.hero .sub { color: rgba(255,255,255,.7); }

/* Barre de consommation empilée */
.conso-bar { display: flex; gap: 2px; height: 22px; border-radius: 6px; overflow: hidden; background: var(--ligne-douce); margin: 10px 0 10px; }
.conso-bar span { display: block; height: 100%; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--texte-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 3px; width: 16px; border-radius: 2px; vertical-align: 3px; }

/* Jauge */
.meter { position: relative; height: 8px; background: #E3E6F4; border-radius: 4px; overflow: hidden; min-width: 80px; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--st-facture); border-radius: 4px; }
.meter.warn > span { background: var(--orange); }
.meter.crit > span { background: var(--crit); }
.meter-wrap { display: flex; align-items: center; gap: 8px; }
.meter-wrap .pct { width: 44px; text-align: right; font-size: 12px; font-weight: 600; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--texte-3); padding: 8px 10px; border-bottom: 1px solid var(--ligne); white-space: nowrap; background: var(--surface);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--ligne-douce); vertical-align: middle; }
.tbl tbody tr:hover td { background: #FCFBF7; }
.tbl th.right, .tbl td.right { text-align: right; }
.tbl tr.fam td { background: #FBF8EF; font-weight: 700; border-bottom-color: var(--ligne); cursor: pointer; }
.tbl tr.fam:hover td { background: var(--creme); }
.tbl tr.poste td:first-child { padding-left: 34px; color: var(--texte-2); }
.tbl tfoot td { font-weight: 800; border-top: 2px solid var(--bleu); border-bottom: 0; padding-top: 11px; }
.tbl .code { font-size: 11px; color: var(--texte-3); font-weight: 600; margin-right: 6px; }
.chev { display: inline-block; width: 14px; transition: transform .2s; color: var(--or-fonce); }
.open .chev { transform: rotate(90deg); }
.tbl .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.tbl td.lib strong { display: block; font-weight: 600; }
.tbl td.lib span { font-size: 12px; color: var(--texte-3); }
.empty { padding: 32px; text-align: center; color: var(--texte-3); }

/* Pastilles de statut */
.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 30px; padding: 2px 10px 2px 8px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; border: 1px solid transparent;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pill.devis { background: #F1F2FA; color: var(--ardoise); border-color: #D9DCF0; }
.pill.devis .dot { background: #fff; border: 2px solid var(--st-engage); }
.pill.engage { background: #ECEEF8; color: var(--ardoise); }
.pill.engage .dot { background: var(--st-engage); }
.pill.facture { background: #E3E6F4; color: var(--bleu); }
.pill.facture .dot { background: var(--st-facture); }
.pill.paye { background: var(--bleu); color: #fff; }
.pill.paye .dot { background: var(--or); }
.steps { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.steps i { width: 14px; height: 4px; border-radius: 2px; background: #E3E6F4; }
.steps i.on { background: var(--st-facture); }

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--ligne-douce); color: var(--texte-2); }
.tag.admin { background: var(--bleu); color: #fff; }
.tag.contrib { background: var(--creme); color: var(--or-fonce); border: 1px solid #F1E3BB; }
.tag.lecteur { background: #EEF0F6; color: var(--ardoise); }
.tag.off { background: #F3F3F3; color: #999; }

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.crit { color: var(--crit); }
.status svg { width: 14px; height: 14px; }

/* ---------- Alertes ---------- */
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--ligne-douce); }
.alerts li:last-child { border-bottom: 0; }
.alerts .ic { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.alerts .ic svg { width: 16px; height: 16px; }
.alerts .ic.warn { background: var(--warn-bg); color: var(--warn); }
.alerts .ic.crit { background: var(--crit-bg); color: var(--crit); }
.alerts .ic.info { background: #ECEEF8; color: var(--ardoise); }
.alerts strong { display: block; font-size: 13px; }
.alerts span { font-size: 12px; color: var(--texte-2); }

/* ---------- Filtres & formulaires ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.input, select.input, textarea.input {
  border: 1px solid var(--ligne); background: #fff; border-radius: 10px; padding: 7px 10px; min-height: 36px; min-width: 0;
}
.input:hover { border-color: #D6CFBB; }
.input:focus { border-color: var(--or); outline: none; box-shadow: 0 0 0 3px rgba(221,182,112,.25); }
.input.search { min-width: 280px; padding-left: 32px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237C7F99' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center; }
.seg { display: inline-flex; border: 1px solid var(--ligne); border-radius: 30px; padding: 3px; background: #fff; }
.seg button { border: 0; background: transparent; padding: 5px 14px; border-radius: 30px; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--texte-2); }
.seg button.on { background: var(--bleu); color: #fff; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.fld label { display: block; font-size: 12px; font-weight: 700; color: var(--texte-2); margin-bottom: 4px; }
.fld .input { width: 100%; }
.fld .hint { font-size: 11px; color: var(--texte-3); margin-top: 3px; }
.req::after { content: " *"; color: var(--orange); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--bleu); }

.stage-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stage {
  border: 1px solid var(--ligne); border-radius: 12px; padding: 10px; background: #FCFBF7; position: relative;
}
.stage.on { background: #fff; border-color: var(--st-engage); box-shadow: inset 0 3px 0 var(--st-facture); }
.stage .check { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stage .fld { margin-bottom: 6px; }
.stage .fld label { font-size: 11px; font-weight: 600; }
.stage .input { min-height: 32px; padding: 5px 8px; font-size: 13px; }
.stage.disabled .fld { opacity: .45; pointer-events: none; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--creme); border: 1px solid #F1E3BB; border-radius: 8px; padding: 3px 8px; }

/* ---------- Modale ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(13, 18, 69, .45); z-index: 100;
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 640px; max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.3);
}
.modal.lg { max-width: 920px; }
.modal-head { padding: 18px 22px 12px; border-bottom: 1px solid var(--ligne); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head p { margin: 4px 0 0; color: var(--texte-2); font-size: 13px; }
.modal-body { padding: 18px 22px; overflow: auto; }
.modal-foot { padding: 12px 22px; border-top: 1px solid var(--ligne); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: #FCFBF7; border-radius: 0 0 16px 16px; }
.modal-foot .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bleu); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; border-left: 4px solid var(--or); animation: fade .2s; max-width: 360px; }

/* ---------- Graphiques ---------- */
.chart-box { position: relative; height: 290px; }
.chart-box.tall { height: 360px; }

/* ---------- Bandeau démo ---------- */
.demo-banner { background: var(--creme); border-bottom: 1px solid #F1E3BB; color: var(--ardoise); font-size: 12px; padding: 6px 28px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.demo-banner b { color: var(--or-fonce); }

/* ---------- Administration ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ligne); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 700; color: var(--texte-2); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--bleu); border-bottom-color: var(--or); }
.nomen-fam { border: 1px solid var(--ligne); border-radius: 12px; margin-bottom: 12px; background: #fff; overflow: hidden; }
.nomen-fam > header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #FBF8EF; border-bottom: 1px solid var(--ligne); flex-wrap: wrap; }
.nomen-fam > header h3 { font-size: 16px; }
.nomen-fam .postes { list-style: none; margin: 0; padding: 0; }
.nomen-fam .postes li { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 34px; border-bottom: 1px solid var(--ligne-douce); flex-wrap: wrap; }
.nomen-fam .postes li:last-child { border-bottom: 0; }
.nomen-fam .grow { flex: 1; min-width: 160px; }
.inactive { opacity: .5; }

/* ---------- Aperçu e-mail ---------- */
.mail-meta { font-size: 12.5px; border: 1px solid var(--ligne); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; background: #FCFBF7; }
.mail-meta div { display: flex; gap: 10px; padding: 2px 0; }
.mail-meta span { width: 50px; flex: none; color: var(--texte-3); font-weight: 700; }
.mail-frame { max-width: 600px; margin: 0 auto; border: 1px solid var(--ligne); border-radius: 12px; overflow: hidden; background: #fff; }
.mail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 24px; border-bottom: 3px solid var(--or); }
.mail-head img { height: 32px; }
.mail-head span { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--or-fonce); font-weight: 800; }
.mail-body { padding: 22px 24px 26px; font-size: 14px; line-height: 1.55; }
.mail-body h2 { font-size: 22px; margin-bottom: 12px; }
.mail-body p { margin: 0 0 10px; }
.mail-small { font-size: 12px; color: var(--texte-3); }
.mail-kv { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13.5px; }
.mail-kv th { text-align: left; font-weight: 600; color: var(--texte-3); padding: 7px 12px 7px 0; width: 34%; vertical-align: top; border-bottom: 1px solid var(--ligne-douce); }
.mail-kv td { padding: 7px 0; border-bottom: 1px solid var(--ligne-douce); }
.mail-list { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.mail-list th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-3); padding: 6px 8px 6px 0; border-bottom: 1px solid var(--ligne); }
.mail-list td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--ligne-douce); vertical-align: top; }
.mail-list td span { font-size: 12px; color: var(--texte-3); }
.mail-box { background: var(--creme); border-left: 3px solid var(--or); border-radius: 0 8px 8px 0; padding: 10px 14px; margin: 14px 0 4px; }
.mail-box-t { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--or-fonce); }
.mail-box-v { font-size: 13px; }
.mail-alert { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.mail-alert.warn { background: var(--warn-bg); color: #6B3900; }
.mail-alert.crit { background: var(--crit-bg); color: #7A1A14; }
.mail-alert svg { flex: none; margin-top: 2px; }
.mail-btn { display: inline-block; background: var(--orange); color: #fff !important; border-radius: 30px; padding: 10px 24px; font-weight: 800; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.mail-btn:hover { background: var(--orange-fonce); }
.mail-foot { background: var(--bleu); color: rgba(255,255,255,.65); font-size: 11px; padding: 14px 24px; line-height: 1.5; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- Rapport DG ---------- */
.report-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.report-params { position: sticky; top: 84px; }
.report-scroll { overflow-x: auto; }
.report {
  width: 794px; min-height: 1123px; margin: 0 auto; background: #fff; box-shadow: 0 4px 30px rgba(13,18,69,.12);
  padding: 40px 48px 64px; color: var(--bleu); font-size: 12px; position: relative;
}
.report + .report { margin-top: 20px; }
.rp-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--bleu); padding-bottom: 14px; margin-bottom: 18px; }
.rp-head img { height: 40px; }
.rp-head .t { text-align: right; }
.rp-head .t h1 { font-size: 22px; text-transform: uppercase; letter-spacing: .01em; }
.rp-head .t p { margin: 4px 0 0; font-size: 11px; color: var(--texte-2); }
.rp-sec { margin-bottom: 14px; break-inside: avoid; }
.report .alerts li { padding: 6px 0; }
.rp-sec h2 { font-size: 15px; text-transform: uppercase; display: flex; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--or); padding-bottom: 4px; margin-bottom: 10px; }
.rp-sec h2 small { font-family: var(--f-texte); color: var(--or-fonce); font-size: 11px; font-weight: 800; }
.rp-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rp-kpi { border: 1px solid var(--ligne); border-radius: 8px; padding: 8px 10px; }
.rp-kpi b { display: block; font-size: 16px; }
.rp-kpi span { font-size: 10px; color: var(--texte-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.rp-kpi.hero { background: var(--bleu); color: #fff; border-color: var(--bleu); }
.rp-kpi.hero span { color: var(--or); }
.rp-comment { background: var(--creme); border-left: 3px solid var(--or); padding: 10px 14px; font-size: 12.5px; white-space: pre-wrap; border-radius: 0 8px 8px 0; }
.report .tbl { font-size: 11px; }
.report .tbl th { font-size: 9.5px; padding: 5px 6px; }
.report .tbl td { padding: 4px 6px; }
.report .tbl tr.fam td { cursor: default; }
.report .tbl.compact td { padding: 2px 6px; line-height: 1.3; }
.report .tbl.compact tr.poste td:first-child { padding-left: 16px; }
.report .tbl.compact .status svg { width: 12px; height: 12px; }
.report .tbl.compact .status { font-size: 10.5px; }
.rp-foot { position: absolute; left: 48px; right: 48px; bottom: 24px; display: flex; justify-content: space-between; font-size: 9.5px; color: var(--texte-3); border-top: 1px solid var(--ligne); padding-top: 6px; }
.rp-chart { height: 170px; position: relative; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .g-kpi { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
  .g-2, .g-2-eq, .report-layout { grid-template-columns: 1fr; }
  .report-params { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .25s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(13,18,69,.4); }
  .topbar { padding: 10px 16px; }
  .topbar .burger { display: inline-grid; }
  .topbar { flex-wrap: nowrap; gap: 8px; }
  .topbar .ctx { flex-wrap: nowrap; gap: 6px; }
  .ctx label, .user-chip > .small { display: none; }
  .ctx .input { padding: 5px 6px; min-height: 34px; font-size: 13px; }
  .user-chip { padding: 3px; }
  .page { padding: 18px 16px 40px; }
  .demo-banner { padding: 6px 16px; }
  .g-kpi { grid-template-columns: repeat(2, 1fr); }
  .kpi.hero { grid-column: 1 / -1; }
  .stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .input.search { min-width: 0; flex: 1 1 100%; }
  h1 { font-size: 23px; }
}
@media (max-width: 480px) {
  .stage-grid { grid-template-columns: 1fr; }
  .kpi.hero .value { font-size: 32px; }
}

/* ---------- Impression : uniquement le rapport ---------- */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .demo-banner, .report-params, .page-head, #toast-root, #modal-root { display: none !important; }
  .shell { display: block; }
  .page { padding: 0; max-width: none; }
  .report-layout { display: block; }
  .report { box-shadow: none; margin: 0; width: 210mm; min-height: 297mm; page-break-after: always; }
  .report:last-child { page-break-after: auto; }
  .report + .report { margin-top: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
