/* Portail Augury — feuille de style unique (aucune dépendance externe).
   Palette : bleu marine, bleu pétrole, turquoise, blanc. */
:root {
  --navy: #0b1f3a;
  --navy-2: #13325c;
  --navy-3: #1c4373;
  --petrol: #0e5a6e;
  --link: #0e5a6e;
  --turquoise: #19c3b1;
  --turquoise-dark: #0b7f74;
  --turquoise-soft: #e3f8f5;
  --bg: #f3f6f9;
  --surface: #ffffff;
  --text: #17202e;
  --muted: #5a6a7e;
  --border: #dbe2ea;
  --border-strong: #c3cdd8;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warning: #9a5b00;
  --warning-soft: #fff4dc;
  --success: #17794a;
  --success-soft: #e5f6ec;
  --info: #1f5f99;
  --info-soft: #e7f0fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 2px 8px rgba(11, 31, 58, .05);
  --sidebar: 252px;
  --heading: #0b1f3a;
  --surface-2: #f7f9fb;
  --hover: #f4f7fa;
  --chip: #eef2f6;
  --chip-text: #3a4a5e;
  --chip-navy: #e4ebf5;
  --chip-navy-text: #13325c;
  --faint: #b5c0cc;
  --accent-btn: #0b7f74;
  --accent-btn-hover: #096a61;
  --btn-bg: #0b1f3a;
  --btn-bg-hover: #13325c;
  color-scheme: light;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--heading); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--turquoise); outline-offset: 2px; }

/* ---------- Structure ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy);
  color: #cfdbe9;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.15rem 1.1rem 1rem; color: #fff; }
.brand img { width: 38px; height: 38px; }
.brand-name { font-weight: 750; letter-spacing: .08em; font-size: .98rem; }
.brand-sub { font-size: .7rem; letter-spacing: .14em; color: var(--turquoise); text-transform: uppercase; }
.nav-group { padding: .4rem .7rem .2rem; }
.nav-group-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #7f93ad; padding: .6rem .5rem .3rem; }
.nav-link {
  display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: 8px;
  color: #dbe6f2; font-size: .92rem; font-weight: 500;
}
.nav-link:hover { background: var(--navy-2); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--turquoise); }
.nav-link svg { width: 18px; height: 18px; flex: none; stroke: currentColor; }
.nav-upcoming { padding: .35rem .6rem; font-size: .82rem; color: #6f84a0; display: flex; justify-content: space-between; gap: .5rem; }
.nav-upcoming span:last-child { font-size: .7rem; border: 1px solid #2b4466; border-radius: 99px; padding: 0 .45rem; white-space: nowrap; }
.sidebar-foot { margin-top: auto; padding: 1rem 1.1rem; font-size: .75rem; color: #7f93ad; border-top: 1px solid #18355d; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .7rem 1.6rem;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar form.search { flex: 1; max-width: 520px; position: relative; }
.topbar form.search input { width: 100%; padding-left: 2.2rem; }
.topbar form.search svg { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--muted); }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: .6rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--petrol); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; letter-spacing: .02em;
}
.user-chip .who, .user-link .who { line-height: 1.15; display: flex; flex-direction: column; }
.user-chip .who strong, .user-link .who strong { display: block; font-size: .88rem; color: var(--heading); }
.user-chip .who span, .user-link .who span { font-size: .75rem; color: var(--muted); }
.content { padding: 1.6rem; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head p { color: var(--muted); margin: .2rem 0 0; }
.breadcrumb { font-size: .82rem; color: var(--muted); margin-bottom: .35rem; }
.breadcrumb a { color: var(--muted); }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-overlay { display: none; }
.nav-toggle-label { display: none; cursor: pointer; padding: .35rem; border-radius: 8px; }
.nav-toggle-label svg { width: 22px; height: 22px; stroke: var(--heading); }

/* ---------- Bandeaux ---------- */
.env-banner { background: var(--warning-soft); color: var(--warning); text-align: center; font-size: .8rem; font-weight: 600; padding: .3rem; border-bottom: 1px solid #f1d8a6; }
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.flash-success { background: var(--success-soft); color: var(--success); border-color: #bfe5cf; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #f5c6c0; }
.flash-warning { background: var(--warning-soft); color: var(--warning); border-color: #f1d8a6; }
.flash-info { background: var(--info-soft); color: var(--info); border-color: #c5dbf1; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem 1.25rem; margin-bottom: 1.2rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .2rem; position: relative; }
.kpi::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--turquoise); }
.kpi-title { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.9rem; font-weight: 750; color: var(--heading); font-variant-numeric: tabular-nums; }
.kpi-def { font-size: .78rem; color: var(--muted); }
.kpi-meta { font-size: .72rem; color: var(--muted); display: flex; justify-content: space-between; gap: .5rem; margin-top: .3rem; }
.kpi a.kpi-link { font-size: .8rem; font-weight: 600; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .62rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-weight: 650; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 220px; }
.pagination { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; margin-top: .8rem; font-size: .88rem; }
.pagination a, .pagination span { padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.pagination span.current { background: var(--navy); color: #fff; border-color: var(--heading); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 99px; font-size: .74rem; font-weight: 650; background: var(--chip); color: var(--chip-text); white-space: nowrap; }
.badge-turquoise { background: var(--turquoise-soft); color: var(--turquoise-dark); }
.badge-navy { background: var(--chip-navy); color: var(--chip-navy-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-demo { background: #fff0f6; color: #a3195b; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .3rem; }
label, .label { font-weight: 600; font-size: .88rem; color: var(--heading); }
.req { color: var(--danger); }
.hint { font-size: .8rem; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=file], input[type=search], input[type=url], input[type=tel], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: .55rem .7rem; width: 100%; min-height: 40px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--turquoise); outline: none; box-shadow: 0 0 0 3px rgba(25, 195, 177, .22); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .82rem; font-weight: 600; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .7rem; }
.choice-card { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: .8rem .9rem; display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; background: var(--surface); font-weight: 500; }
.choice-card:has(input:checked) { border-color: var(--turquoise); background: var(--turquoise-soft); box-shadow: 0 0 0 1px var(--turquoise); }
.choice-card input { margin-top: .25rem; accent-color: var(--turquoise-dark); }
.choice-card strong { display: block; color: var(--heading); }
.checkline { display: flex; gap: .55rem; align-items: flex-start; font-weight: 500; }
.checkline input { margin-top: .3rem; accent-color: var(--turquoise-dark); width: 16px; height: 16px; flex: none; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .4rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem .2rem; margin: 0 0 1rem; }
legend { font-weight: 650; color: var(--heading); padding: 0 .35rem; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 650; font-size: .9rem;
  padding: .55rem 1rem; min-height: 40px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  background: var(--btn-bg); color: #fff; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--btn-bg-hover); text-decoration: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; }
.btn-accent { background: var(--accent-btn); }
.btn-accent:hover { background: var(--accent-btn-hover); }
.btn-ghost { background: var(--surface); color: var(--heading); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #efb4ad; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: .3rem .65rem; min-height: 32px; font-size: .82rem; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: wait; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; font-weight: 600; }

/* ---------- Fiches ---------- */
.dl { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: .45rem 1.2rem; margin: 0; font-size: .92rem; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.record-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.record-id { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95rem; background: var(--chip); padding: .15rem .5rem; border-radius: 6px; color: var(--heading); letter-spacing: .03em; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; }
.tab { padding: .6rem .9rem; font-weight: 600; font-size: .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--heading); text-decoration: none; }
.tab.active { color: var(--heading); border-bottom-color: var(--turquoise); }
.tab.disabled { color: var(--faint); cursor: not-allowed; }
.tab.disabled small { font-weight: 500; font-size: .7rem; }
.message-box { background: var(--surface-2); border: 1px dashed var(--turquoise); border-radius: var(--radius); padding: .9rem 1rem; white-space: pre-wrap; font-size: .92rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 130px 1fr; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: .8rem; }
.diff { font-size: .8rem; color: var(--muted); margin-top: .2rem; overflow-wrap: anywhere; }
.callout { border-left: 4px solid var(--turquoise); background: var(--turquoise-soft); padding: .8rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1rem; font-size: .9rem; }
.callout-warning { border-color: #e0a100; background: var(--warning-soft); }
.callout-danger { border-color: var(--danger); background: var(--danger-soft); }
.roadmap { list-style: none; padding: 0; margin: 0; }
.roadmap li { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.roadmap li:last-child { border-bottom: 0; }

/* Matrice des permissions */
.matrix th.role { text-align: center; }
.matrix td.cell { text-align: center; }
.matrix .yes { color: var(--turquoise-dark); font-weight: 800; }
.matrix .no { color: var(--faint); }
.matrix tr.module td { background: var(--surface-2); font-weight: 700; color: var(--heading); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.lock { font-size: .7rem; color: var(--warning); font-weight: 700; }
.perm-list { columns: 2; column-gap: 2rem; }
.perm-item { break-inside: avoid; padding: .45rem 0; border-bottom: 1px solid var(--border); }

/* ---------- Pages d'accès ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, var(--petrol) 100%); color: #dbe7f3; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-brand .brand { padding: 0; }
.auth-brand h1 { color: #fff; font-size: 2rem; max-width: 420px; }
.auth-brand p { max-width: 420px; color: #b7c8dc; }
.auth-panel { display: grid; place-items: center; padding: 2rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.45rem; }
.accent-bar { width: 48px; height: 4px; background: var(--turquoise); border-radius: 4px; margin-bottom: 1rem; }
.rules { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-height: 320px; overflow-y: auto; font-size: .9rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  .nav-toggle:checked ~ .layout .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(11, 31, 58, .45); z-index: 40; }
  .nav-toggle-label { display: inline-flex; }
  .topbar { padding: .6rem 1rem; gap: .6rem; }
  .user-chip .who, .user-link .who { display: none; }
  .content { padding: 1rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { padding: 1.5rem; }
  .auth-brand h1, .auth-brand p.lead { display: none; }
  .perm-list { columns: 1; }
  .timeline li { grid-template-columns: 1fr; gap: .1rem; }
  .dl { grid-template-columns: 1fr; gap: .1rem; }
  .dl dd { margin-bottom: .5rem; }
  .hide-mobile { display: none; }
  h1 { font-size: 1.3rem; }
}
@media print {
  .sidebar, .topbar, .env-banner, .form-actions, .btn { display: none !important; }
  .layout { display: block; }
}

/* Utilitaires (la politique CSP interdit les attributs style="" en ligne) */
.w-full { width: 100%; }
.mw-640 { max-width: 640px; }
.mw-780 { max-width: 780px; }
.mt-1 { margin-top: 1rem; }
.mt-05 { margin-top: .5rem; }
.mb-0 { margin-bottom: 0; }
.center-page { margin: 3rem auto; }
.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.row-gap { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Correctifs de mise en page */
.grid > *, .main, .content { min-width: 0; }
@media (min-width: 901px) {
  .layout { background: linear-gradient(to right, var(--navy) var(--sidebar), transparent var(--sidebar)); }
}
.diff-list { list-style: none; margin: .25rem 0 0; padding: 0; font-size: .8rem; color: var(--muted); }
.diff-list li { display: block; padding: .05rem 0; border: 0; }
.diff-list .k { font-weight: 600; color: var(--text); }
.diff-list .old { text-decoration: line-through; color: var(--danger); }

/* Assurance */
tfoot th { background: var(--surface-2); color: var(--heading); font-size: .85rem; text-transform: none; letter-spacing: 0; }
th.total, td.total { font-size: 1.05rem; font-weight: 800; color: var(--heading); }
.amount-hero { font-size: 2rem; font-weight: 800; color: var(--heading); font-variant-numeric: tabular-nums; line-height: 1.1; }
.amount-sub { color: var(--muted); font-size: .85rem; }
.steps { display: flex; gap: .3rem; flex-wrap: wrap; margin: .4rem 0 1rem; padding: 0; list-style: none; }
.steps li { font-size: .78rem; padding: .25rem .65rem; border-radius: 99px; background: var(--chip); color: var(--muted); font-weight: 600; }
.steps li.done { background: var(--success-soft); color: var(--success); }
.steps li.current { background: var(--navy); color: #fff; }
.steps li.ko { background: var(--danger-soft); color: var(--danger); }
.sticky-side { position: sticky; top: 76px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .5rem; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.textdoc { white-space: pre-wrap; font-size: .9rem; line-height: 1.6; max-height: 70vh; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; }
.diffcell { background: var(--warning-soft); font-weight: 700; }
@media (max-width: 900px) { .sticky-side { position: static; } }
.matrix-box { width: 18px; height: 18px; accent-color: var(--turquoise-dark); cursor: pointer; }
.matrix-box:disabled { cursor: not-allowed; opacity: .55; }
.field.grow { flex: 1; min-width: 220px; }


/* ---------- Mode sombre ---------- */
:root[data-theme="sombre"] {
  --bg: #0b1322;
  --surface: #121d31;
  --surface-2: #17243b;
  --hover: #1a2944;
  --text: #e3eaf3;
  --heading: #f2f6fb;
  --muted: #9aabbf;
  --border: #243552;
  --border-strong: #34496b;
  --chip: #1d2c46;
  --chip-text: #c9d5e3;
  --chip-navy: #1f3557;
  --chip-navy-text: #cfe0f5;
  --faint: #4d6080;
  --turquoise-soft: #0f3434;
  --turquoise-dark: #45d6c5;
  --success: #5fd39a; --success-soft: #10301f;
  --warning: #f0b955; --warning-soft: #33280f;
  --danger: #f5877d; --danger-soft: #3a1918;
  --info: #84b8ef; --info-soft: #14263e;
  --accent-btn: #0f9a8b;
  --accent-btn-hover: #12ae9d;
  --btn-bg: #2a4c80;
  --btn-bg-hover: #345c97;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --link: #5cc8d8;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
  --bg: #0b1322;
    --surface: #121d31;
    --surface-2: #17243b;
    --hover: #1a2944;
    --text: #e3eaf3;
    --heading: #f2f6fb;
    --muted: #9aabbf;
    --border: #243552;
    --border-strong: #34496b;
    --chip: #1d2c46;
    --chip-text: #c9d5e3;
    --chip-navy: #1f3557;
    --chip-navy-text: #cfe0f5;
    --faint: #4d6080;
    --turquoise-soft: #0f3434;
    --turquoise-dark: #45d6c5;
    --success: #5fd39a; --success-soft: #10301f;
    --warning: #f0b955; --warning-soft: #33280f;
    --danger: #f5877d; --danger-soft: #3a1918;
    --info: #84b8ef; --info-soft: #14263e;
    --accent-btn: #0f9a8b;
    --accent-btn-hover: #12ae9d;
    --btn-bg: #2a4c80;
    --btn-bg-hover: #345c97;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --link: #5cc8d8;
    color-scheme: dark;
  }
}
:root[data-theme="sombre"] .sidebar, :root[data-theme="sombre"] .auth-brand { background: #08101d; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .sidebar, :root[data-theme="auto"] .auth-brand { background: #08101d; } }
:root[data-theme="sombre"] .badge-demo { background: #3a1730; color: #f4a6cf; }
@media (min-width: 901px) { :root[data-theme="sombre"] .layout { background: linear-gradient(to right, #08101d var(--sidebar), transparent var(--sidebar)); } }
@media (prefers-color-scheme: dark) and (min-width: 901px) { :root[data-theme="auto"] .layout { background: linear-gradient(to right, #08101d var(--sidebar), transparent var(--sidebar)); } }

/* Barre du haut : actions à droite */
.topbar .top-actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--heading); cursor: pointer; }
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.user-link { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; border-radius: 99px; padding: 2px 10px 2px 2px; }
.user-link:hover { background: var(--hover); text-decoration: none; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.8rem; }
.avatar-md { width: 56px; height: 56px; font-size: 1.1rem; }
.mb-1 { margin-bottom: 1rem; }
input[type=file] { font: inherit; font-size: .85rem; color: var(--text); }
.is-off { opacity: .55; }
.is-off .compat-hint { display: inline; }
.compat-hint { display: none; font-size: .78rem; color: var(--warning); font-weight: 600; margin-left: .3rem; }
.branch-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.branch-switch a { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: .9rem 1rem; background: var(--surface); color: var(--text); text-decoration: none; display: block; }
.branch-switch a strong { display: block; color: var(--heading); font-size: 1.02rem; }
.branch-switch a.active { border-color: var(--turquoise); background: var(--turquoise-soft); box-shadow: 0 0 0 1px var(--turquoise); }
.branch-switch a:hover { text-decoration: none; border-color: var(--turquoise); }
.roster-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1.4fr auto auto; gap: .4rem; align-items: center; }
.roster-row input, .roster-row select { min-height: 34px; height: 34px; padding: .3rem .5rem; font-size: .88rem; }
@media (max-width: 900px) { .roster-row { grid-template-columns: 1fr 1fr; } }

/* Organigramme */
.org { display: flex; flex-direction: column; align-items: center; }
.org-branch { font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--turquoise-dark); background: var(--turquoise-soft); padding: .3rem .9rem; border-radius: 99px; margin: .4rem 0; }
.org-link { width: 2px; height: 26px; background: var(--border-strong); }
.org-level { width: 100%; text-align: center; }
.org-level-title { font-size: .95rem; margin: .2rem 0 .7rem; }
.org-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.org-card { display: flex; gap: .8rem; align-items: flex-start; text-align: left; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--turquoise); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); width: 290px; }
.org-card-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.org-card-body strong { color: var(--heading); }
.org-contact { margin: .4rem 0 0; font-size: .82rem; }
.org-contact div { display: flex; gap: .4rem; }
.org-contact dt { color: var(--muted); min-width: 78px; }
.org-contact dd { margin: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }

/* ---------- Contrats (étape 5) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; padding: .3rem .75rem; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: .84rem; font-weight: 600; text-decoration: none; }
.chip:hover { background: var(--hover); text-decoration: none; }
.chip.active { background: var(--btn-bg); border-color: var(--btn-bg); color: #fff; }
.checklist { list-style: none; margin: 0 0 .8rem; padding: 0; }
.checklist li { display: flex; gap: .55rem; align-items: flex-start; padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { flex: 0 0 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.checklist .ok { background: var(--success-soft); color: var(--success); }
.checklist .ko { background: var(--danger-soft); color: var(--danger); }
.checklist .warn { background: var(--warning-soft); color: var(--warning); }
.stepper { list-style: none; margin: 0; padding: 0; counter-reset: st; }
.stepper > li { position: relative; padding: 0 0 1rem 2.4rem; counter-increment: st; }
.stepper > li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--chip); color: var(--muted); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .85rem; }
.stepper > li.done::before { content: "✓"; background: var(--success-soft); color: var(--success); }
.stepper > li.current::before { background: var(--btn-bg); color: #fff; }
.stepper > li h3 { margin: .15rem 0 .4rem; font-size: 1rem; color: var(--heading); }
.change-table td:nth-child(2) { color: var(--muted); text-decoration: line-through; }
.request-block { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: .8rem; }
.request-block .card-head { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .4rem; }
.mb-05 { margin-bottom: .5rem; }

/* ---------- Planning commun ---------- */
.planning { table-layout: fixed; min-width: 980px; }
.planning th:first-child { width: 150px; }
.planning td { vertical-align: top; padding: .35rem; }
.planning .is-today { background: var(--surface-2); }
.slot { display: block; border-radius: 6px; padding: .3rem .4rem; margin-bottom: .3rem; font-size: .76rem; line-height: 1.25; border-left: 3px solid var(--turquoise); background: var(--chip); color: var(--text); text-decoration: none; }
a.slot:hover { background: var(--hover); text-decoration: none; }
.slot-time { display: block; font-weight: 700; color: var(--heading); }
.slot-title { display: block; }
.slot-meta { display: block; color: var(--muted); font-size: .7rem; }
.slot-audience { border-left-color: #c2410c; }
.slot-reunion { border-left-color: #6d28d9; }
.slot-indisponible { border-left-color: var(--muted); background: repeating-linear-gradient(135deg, var(--chip), var(--chip) 6px, var(--surface-2) 6px, var(--surface-2) 12px); }
.slot-masked { font-style: italic; }
.slot-free { color: var(--muted); font-size: .72rem; opacity: .6; }
.text-warning { color: var(--warning); }
.pdf-text { max-height: 520px; overflow: auto; background: var(--surface-2); padding: .6rem; border-radius: 6px; }
.planning tbody th { text-transform: none; letter-spacing: 0; white-space: normal; font-size: .84rem; color: var(--text); overflow-wrap: anywhere; }

/* Tableau de bord CFO : les trois chiffres essentiels (demande du 18/11/2026) */
.essentials { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin: 1rem 0; }
.essential { display: flex; flex-direction: column; gap: .35rem; padding: 1.2rem 1.3rem; border-radius: var(--radius); border: 1px solid var(--border);
  border-top: 5px solid var(--accent-btn); background: var(--surface); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
.essential:hover { border-color: var(--accent-btn); }
.essential-title { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.essential-value { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.essential-sub { font-size: .88rem; font-weight: 600; }
.essential-def { font-size: .78rem; color: var(--muted); }
.essential-wait { border-top-color: var(--warning); }
.essential-wait .essential-value { color: var(--warning); }
.essential-paid { border-top-color: var(--success); }
.essential-paid .essential-value { color: var(--success); }
.essential-late { border-top-color: var(--danger); }
.essential-late .essential-value { color: var(--danger); }
.all-kpis > summary { cursor: pointer; font-weight: 700; padding: .2rem 0; }
.all-kpis[open] > summary { margin-bottom: .6rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }

/* Accueil épuré (retour du CFO, 18/11/2026) */
.kpis-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.home-row { margin-bottom: 1rem; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li + li { border-top: 1px solid var(--border); }
.todo-list a { display: grid; grid-template-columns: 3rem 1fr auto; gap: .8rem; align-items: center; padding: .6rem .2rem; color: inherit; text-decoration: none; }
.todo-list a:hover { background: var(--turquoise-soft); }
.todo-count { font-size: 1.35rem; font-weight: 800; text-align: center; color: var(--turquoise-dark); }
.todo-go { color: var(--muted); }
.donut-wrap { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.donut { width: 170px; height: 170px; flex: none; }
.donut-total { font-size: 8px; font-weight: 800; fill: var(--text); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 180px; }
.legend li { display: grid; grid-template-columns: 14px 1fr auto 3rem; gap: .5rem; align-items: center; padding: .3rem 0; }
.legend .dot { width: 10px; height: 10px; }
.legend .small { text-align: right; }
.bars { width: 100%; max-height: 260px; }
.bar-label { font-size: 8px; fill: var(--muted); }
.bar-value { font-size: 7px; font-weight: 700; fill: var(--text); }

/* Logo officiel (fond clair pour garder le gris lisible sur le thème sombre) */
.brand-logo { display: inline-flex; align-items: center; background: #fff; border-radius: 10px; padding: .45rem .7rem; }
.brand-logo img { display: block; width: 150px; max-width: 100%; height: auto; }
