/* ============================================================
   Bilan EESH — feuille de style de l'application.
   Thème clair/sombre par tokens. Palette « nature » : vert pin
   en accent, neutres gris-vert, ocre/terre cuite pour les états.
   ============================================================ */

:root {
  --bg: #F4F6F1;
  --surface: #FFFFFF;
  --surface-2: #EDF1EA;
  --border: #DBE0D5;
  --border-strong: #C7CFC0;
  --text: #1A211C;
  --text-muted: #57615A;
  --text-faint: #8A938B;
  --accent: #2F6049;
  --accent-strong: #244B3A;
  --accent-contrast: #FFFFFF;
  --accent-soft: #DEE9E0;
  --good: #2E7D4F;  --good-soft: #DCEBDE;
  --warn: #8F6111;  --warn-soft: #F0E7CE;
  --crit: #9E4429;  --crit-soft: #F1DFD8;
  --axe1: #6F7E76; --axe2: #3F7A9B; --axe3: #2F6049; --axe4: #A76F30;
  --shadow: 0 1px 2px rgba(20,30,24,.05), 0 2px 10px rgba(20,30,24,.05);
  --r: 12px; --r-sm: 8px;
  --maxw: 1080px;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F130E; --surface: #171C16; --surface-2: #1F251E; --border: #2C332B;
    --border-strong: #3A423A; --text: #E7ECE4; --text-muted: #9BA69C; --text-faint: #6E786F;
    --accent: #79BF96; --accent-strong: #98D3B0; --accent-contrast: #0E1410; --accent-soft: #1E2C22;
    --good: #74C08F; --good-soft: #1B291F; --warn: #D6A64C; --warn-soft: #2B2615;
    --crit: #DA8368; --crit-soft: #2E1E18;
    --axe1: #8A978F; --axe2: #5E9AB9; --axe3: #79BF96; --axe4: #C79355;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 2px 12px rgba(0,0,0,.28);
  }
}
:root[data-theme="light"] {
  --bg: #F4F6F1; --surface: #FFFFFF; --surface-2: #EDF1EA; --border: #DBE0D5;
  --border-strong: #C7CFC0; --text: #1A211C; --text-muted: #57615A; --text-faint: #8A938B;
  --accent: #2F6049; --accent-strong: #244B3A; --accent-contrast: #FFFFFF; --accent-soft: #DEE9E0;
  --good: #2E7D4F; --good-soft: #DCEBDE; --warn: #8F6111; --warn-soft: #F0E7CE;
  --crit: #9E4429; --crit-soft: #F1DFD8;
  --axe1: #6F7E76; --axe2: #3F7A9B; --axe3: #2F6049; --axe4: #A76F30;
  --shadow: 0 1px 2px rgba(20,30,24,.05), 0 2px 10px rgba(20,30,24,.05);
}
:root[data-theme="dark"] {
  --bg: #0F130E; --surface: #171C16; --surface-2: #1F251E; --border: #2C332B;
  --border-strong: #3A423A; --text: #E7ECE4; --text-muted: #9BA69C; --text-faint: #6E786F;
  --accent: #79BF96; --accent-strong: #98D3B0; --accent-contrast: #0E1410; --accent-soft: #1E2C22;
  --good: #74C08F; --good-soft: #1B291F; --warn: #D6A64C; --warn-soft: #2B2615;
  --crit: #DA8368; --crit-soft: #2E1E18;
  --axe1: #8A978F; --axe2: #5E9AB9; --axe3: #79BF96; --axe4: #C79355;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 2px 12px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body.app {
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); }
.topbar-accent { height: 3px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--axe2))); }
.topbar-inner { max-width: var(--maxw); margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; text-decoration: none; }
.brand svg { width: 26px; height: 26px; display: block; }
.brand b { font-family: var(--serif); font-weight: 600; font-size: 1.12rem; letter-spacing: .01em; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { padding: 7px 12px; border-radius: var(--r-sm); color: var(--text-muted); text-decoration: none; font-size: .9rem; font-weight: 500; }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav a:hover { color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.dept-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong); font-size: .83rem; font-weight: 600; }
.dept-chip .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--accent); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--accent); color: var(--accent-contrast);
  display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.logout-form { display: inline-flex; margin: 0; }

/* ---------- Layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 32px 24px 72px; }
.eyebrow { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--text-faint); }
.muted { color: var(--text-muted); }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 1.85rem; letter-spacing: -.005em; margin: 0 0 5px; text-wrap: balance; }
.head .sub { color: var(--text-muted); font-size: .95rem; }
.head .sub b { color: var(--text); font-weight: 600; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--r-sm);
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn svg { width: 16px; height: 16px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 30px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 16px 15px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 11px; }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.axe-tag { display: inline-flex; align-items: center; gap: 6px; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--text-faint); }
.axe-tag .dot { width: 7px; height: 7px; border-radius: 999px; }
.tile .label { font-size: .9rem; color: var(--text-muted); font-weight: 500; line-height: 1.3; }
.tile .value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.tile .value .of { font-size: 1rem; font-weight: 600; color: var(--text-faint); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.fill-good { background: var(--good); } .fill-warn { background: var(--warn); } .fill-crit { background: var(--crit); }

/* ---------- Card + table ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 1.02rem; font-weight: 650; letter-spacing: -.005em; }
.link { color: var(--accent); font-size: .86rem; font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
thead th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); font-weight: 700; padding: 11px 18px; border-bottom: 1px solid var(--border); }
tbody td { padding: 13px 18px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td .title { font-weight: 550; }
td.num { text-align: right; }
.type-chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .78rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.type-chip .dot { width: 7px; height: 7px; border-radius: 999px; }

/* ---------- Messages ---------- */
.messages-wrap { max-width: var(--maxw); margin: 16px auto 0; padding: 0 24px; }
.messages { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 11px 14px; border-radius: var(--r-sm); font-size: .9rem; font-weight: 500; border: 1px solid transparent; }
.msg-success { background: var(--good-soft); color: var(--good); }
.msg-error { background: var(--crit-soft); color: var(--crit); }
.msg-info, .msg-warning { background: var(--warn-soft); color: var(--warn); }

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; padding: 22px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.col-2 { grid-column: 1 / -1; }
label.lbl { font-size: .82rem; font-weight: 600; color: var(--text); }
label.lbl .req { color: var(--crit); }
.hint { font-size: .78rem; color: var(--text-faint); }
.err { font-size: .78rem; color: var(--crit); font-weight: 600; }
.input, .textarea, input[type="text"], input[type="number"], input[type="date"], input[type="password"] {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--r-sm); padding: 10px 12px; font: inherit; font-size: .92rem; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .textarea:focus, input:focus, .btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus, .textarea:focus, input:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 108px; line-height: 1.55; }

/* Segmented / multi-choice controls (radios & checkboxes rendus en pastilles) */
.seg { display: flex; flex-wrap: wrap; gap: 7px; }
.seg-opt { position: relative; display: inline-flex; }
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg-opt span { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); padding: 8px 13px; border-radius: 999px; font-size: .85rem; font-weight: 600; cursor: pointer; }
.seg-opt span::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--text-faint); }
.seg-opt:hover span { border-color: var(--border-strong); color: var(--text); }
.seg-opt:has(input:checked) span { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); color: var(--accent-strong); }
.seg-opt:has(input:checked) span::before { background: var(--accent); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.feeds { grid-column: 1 / -1; display: flex; align-items: center; gap: 11px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-strong); font-size: .85rem; }
.feeds svg { width: 17px; height: 17px; flex-shrink: 0; }
.feeds b { font-weight: 700; }

.dropzone { grid-column: 1 / -1; display: block; border: 1.5px dashed var(--border-strong); border-radius: var(--r-sm);
  padding: 20px; text-align: center; color: var(--text-muted); font-size: .88rem; background: var(--surface-2); cursor: pointer; }
.dropzone b { color: var(--accent); font-weight: 650; }

.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px;
  border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 40%, transparent);
  border-bottom-left-radius: var(--r); border-bottom-right-radius: var(--r); flex-wrap: wrap; }
.form-foot .saved { font-size: .82rem; color: var(--text-faint); }
.form-foot .actions { display: flex; gap: 10px; margin-left: auto; }
.form-alert { max-width: 640px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--crit-soft); color: var(--crit);
  font-size: .88rem; font-weight: 500; margin-bottom: 16px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 62vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 30px 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 1.5rem; margin: 0; }
.auth-card .field { gap: 6px; }
.auth-sep { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: .8rem; }
.auth-sep::before, .auth-sep::after { content: ""; height: 1px; background: var(--border); flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .nav { display: none; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  main { padding: 24px 16px 60px; }
  .topbar-inner { padding: 10px 16px; gap: 12px; }
  h1 { font-size: 1.55rem; }
  .dept-chip { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .icon-btn, .nav a, .tile, .seg-opt span { transition: background .15s ease, border-color .15s ease, color .15s ease; }
  .meter > span { transition: width .5s cubic-bezier(.4,0,.2,1); }
}

/* ---------- Menus déroulants (select) ---------- */
.select {
  appearance: none; width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--r-sm); padding: 10px 34px 10px 12px; font: inherit; font-size: .92rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.select:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

/* ---------- Tuiles métriques + indicateurs par axe ---------- */
.tile.metric { justify-content: space-between; }
.tile.metric .value { font-size: 2rem; }
.axes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 30px; }
.axe-dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; margin-right: 8px; vertical-align: middle; }
.stat-list { display: flex; flex-direction: column; }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.stat-row:last-child { border-bottom: 0; }
.stat-row .lab { color: var(--text-muted); }
.stat-row .val { font-weight: 700; }
@media (max-width: 700px) { .axes-grid { grid-template-columns: 1fr; } }
