/* ============================================================
   N-Construction — design system V2
   Source de vérité visuelle : canvas Claude Design « Plateforme BTP »
   (dossier design/, version SaaS · v2.0). Tokens, IBM Plex, composants.
   ============================================================ */

:root {
  /* encre */
  --ink: #1B1D1F;
  --muted: #6B7075;
  --label: #8A8378;
  --label-nav: #6E777F;
  /* surfaces */
  --canvas: #F4F3F0;
  --surface: #FFFFFF;
  --surface-50: #FAF9F7;
  --border: #E2E0DB;
  --border-soft: #EDEBE6;
  --row-line: #F1EFEB;
  /* marque */
  --navy: #16232F;
  --navy-hover: #22384B;
  --ocre: #C67B12;
  --ocre-hover: #D98D1E;
  --ocre-dark: #A45E0A;
  --gold: #F4C67C;
  /* statuts */
  --green: #2E7D5B;
  --amber: #C9871B;
  --red: #B3402F;
  --blue: #2C5F8A;
  /* badges (fond / texte) */
  --b-ok-bg: #DCEAE2; --b-ok-fg: #1F5E43;
  --b-wait-bg: #F1E7D6; --b-wait-fg: #8A5B0B;
  --b-ko-bg: #F6DFDB; --b-ko-fg: #8E3324;
  --b-info-bg: #DFE8F0; --b-info-fg: #25547A;
  --b-mute-bg: #EDEBE6; --b-mute-fg: #5C6469;

  --radius: 5px;
  --radius-sm: 4px;
  --radius-xs: 3px;
  --shadow: 0 2px 6px rgba(27, 29, 31, 0.06);
  --shadow-lg: 0 8px 24px rgba(27, 29, 31, 0.12);
  --sidebar-w: 268px;
  --font: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-wrap: pretty;
}
a { color: var(--ocre-dark); text-decoration: none; }
a:hover { color: var(--ocre); text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
h3 { font-size: 13.5px; font-weight: 600; }
p { margin: 0 0 .8rem; }
small, .muted { color: var(--muted); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D3D0C9; border-radius: 8px; border: 3px solid var(--canvas); }

/* étiquette mono (colonnes, sections, codes) */
.lbl {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--label);
}
.ref { font-family: var(--mono); font-size: 11px; font-weight: 400; }
.num, .mono-num { font-family: var(--mono); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }

@keyframes fadeup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }

/* ---------- Shell application ---------- */
.shell { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy);
  color: #E8E9EA;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.sidebar .brand .logo {
  width: 34px; height: 34px; flex: 0 0 34px;
  background: var(--ocre);
  border-radius: var(--radius-xs);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 13px; font-weight: 600; letter-spacing: -0.5px;
  color: var(--navy);
}
.sidebar .brand .t { font-size: 13.5px; font-weight: 600; letter-spacing: 0.2px; color: #fff; }
.sidebar .brand .s { font-family: var(--mono); font-size: 10px; color: #8A9299; letter-spacing: 0.4px; }

.sidebar .espace {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.sidebar .espace .lbl { color: #79828A; letter-spacing: 0.9px; margin-bottom: 7px; display: block; }
.sidebar .espace .box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: inherit;
}
a.box:hover { background: rgba(255, 255, 255, 0.11); text-decoration: none; color: inherit; }
.sidebar .espace .n { font-size: 12.5px; font-weight: 600; color: #fff; }
.sidebar .espace .p { font-family: var(--mono); font-size: 9.5px; color: #8A9299; }
.sidebar .espace .caret { color: #8A9299; font-size: 10px; }

.sidebar nav {
  flex: 1; overflow-y: auto;
  padding: 12px 10px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.sidebar nav .grp { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav .grp > .lbl { color: var(--label-nav); letter-spacing: 0.9px; padding: 0 8px 6px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: #C3C8CC;
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.07); text-decoration: none; color: #E8E9EA; }
.sidebar nav a.active { background: rgba(198, 123, 18, 0.16); color: var(--gold); }
.sidebar nav a .tok {
  width: 22px; height: 20px; flex: 0 0 22px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.08);
  color: #98A0A7;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 9px; font-weight: 600; letter-spacing: -0.2px;
}
.sidebar nav a.active .tok { background: var(--ocre); color: var(--navy); }
.sidebar nav a .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar nav a .count {
  font-family: var(--mono); font-size: 9.5px;
  padding: 1px 5px; border-radius: 8px;
  background: rgba(198, 123, 18, 0.22); color: #E9A33F;
}
.sidebar nav a .lock { font-size: 10px; color: #5F686F; }

.sidebar .foot {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar .foot .quota-line {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.4px; color: #79828A;
}
.sidebar .foot .bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.sidebar .foot .bar > span { display: block; height: 4px; border-radius: 2px; background: var(--ocre); }
.sidebar .foot .note { font-size: 11px; color: #A3ABB1; line-height: 1.45; }
.sidebar .foot .note a { color: #E9A33F; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(244, 243, 240, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 62px;
  display: flex; align-items: center; gap: 20px;
}
.topbar .burger { display: none; }
.topbar .crumbs { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.topbar .crumb { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.6px; color: #8A8378; text-transform: uppercase; white-space: nowrap; }
.topbar .title { font-size: 15.5px; font-weight: 600; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .tools { display: flex; align-items: center; gap: 10px; }
.topbar form.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 11px; width: 250px;
}
.topbar form.search input { border: none; outline: none; font: inherit; font-size: 12.5px; width: 100%; background: none; color: var(--ink); padding: 0; }
.topbar form.search input::placeholder { color: #9C958C; }
.topbar form.search .k { font-family: var(--mono); font-size: 11px; color: #A9A29A; }
.kbd {
  font-family: var(--mono); font-size: 9.5px; color: #B6AFA6;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 1px 4px; white-space: nowrap;
}
.bell {
  position: relative;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center;
  cursor: pointer; font-size: 13px; color: #5C6469;
}
.bell .dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.userchip { display: flex; align-items: center; gap: 9px; padding-left: 4px; cursor: pointer; }
.userchip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy); color: #E8E9EA;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
}
.userchip .meta { line-height: 1.2; }
.userchip .meta .n { font-size: 12px; font-weight: 600; white-space: nowrap; }
.userchip .meta .r { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.4px; color: var(--label); text-transform: uppercase; white-space: nowrap; }

/* menus déroulants topbar (cloche, utilisateur) */
.pop { position: relative; }
.pop .pop-panel {
  display: none;
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 300px; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  padding: 6px;
}
.pop.open .pop-panel { display: block; animation: fadeup .12s ease; }
.pop-panel .pop-head { padding: 8px 10px 7px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pop-panel a.pop-item, .pop-panel button.pop-item {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none; background: none; font: inherit; text-align: left;
  border-radius: var(--radius-xs);
  color: var(--ink); font-size: 12.5px; cursor: pointer;
}
.pop-panel a.pop-item:hover, .pop-panel button.pop-item:hover { background: var(--surface-50); text-decoration: none; color: var(--ink); }
.pop-item .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: 0 0 7px; }
.pop-item .m { display: block; font-family: var(--mono); font-size: 10px; color: var(--label); margin-top: 1px; }
.pop-empty { padding: 16px 10px; font-size: 12px; color: var(--muted); text-align: center; }

.content { padding: 26px 32px 56px; width: 100%; animation: fadeup .18s ease; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .grow { flex: 1; min-width: 240px; }
.page-head h1 { margin-bottom: 6px; }
.page-head .sub { font-size: 13px; color: var(--muted); max-width: 640px; line-height: 1.5; }
.page-head .actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Composants ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 16px 18px;
}
.card > .card-pad, .card.pad { padding: 0; }
/* tables et en-têtes en pleine largeur dans la carte (design canvas) */
.card > .table-wrap, .card > .card-pad > .table-wrap { margin: 0 -18px; }
.card > .table-wrap:first-child { margin-top: -16px; }
.card > .table-wrap:last-child { margin-bottom: -16px; }
.card-head {
  margin: -16px -18px 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head + .table-wrap { margin-top: -14px !important; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .lbl { display: block; }
.card-head .sub, .card-sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.card > .pagination { margin-top: 12px; }
.table + .pagination, .table-wrap + .pagination { margin-top: 12px; }

.grid { display: grid; gap: 16px; }
.grid.tight { gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.grid.panel { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.grid.panel-l { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid.tree { grid-template-columns: 238px minmax(0, 1fr); align-items: start; }
.stack > .card:last-child { margin-bottom: 0; }

/* KPI — barre d'accent verticale */
.stat {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 17px;
  display: flex; flex-direction: column; gap: 11px;
  margin: 0;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--navy));
}
.stat.flat::before { display: none; }
.stat.acc-navy { --accent: var(--navy); }
.stat.acc-ocre { --accent: var(--ocre); }
.stat.acc-blue { --accent: var(--blue); }
.stat.acc-red { --accent: var(--red); }
.stat.acc-green { --accent: var(--green); }
.stat .label { font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.8px; text-transform: uppercase; color: var(--label); }
.stat .vrow { display: flex; align-items: baseline; gap: 7px; }
.stat .value { font-size: 27px; font-weight: 600; letter-spacing: -1px; line-height: 1; color: var(--ink); }
.stat .unit { font-family: var(--mono); font-size: 11px; color: var(--label); }
.stat .sub { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
/* KPI compact (fiche projet) : valeur mono 19px */
.stat.compact { padding: 14px 15px; gap: 8px; }
.stat.compact .value { font-family: var(--mono); font-size: 19px; letter-spacing: -0.5px; }
.stat.compact .sub { font-size: 11px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--navy); color: #fff;
  border: 1px solid var(--navy);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: var(--navy-hover); border-color: var(--navy-hover); text-decoration: none; color: #fff; }
.btn.accent { background: var(--ocre); border-color: var(--ocre); color: var(--navy); font-weight: 600; }
.btn.accent:hover { background: var(--ocre-hover); border-color: var(--ocre-hover); color: var(--navy); }
.btn.secondary { background: var(--surface); color: #4A5157; border-color: var(--border); font-weight: 500; }
.btn.secondary:hover { background: var(--surface); border-color: #C9C5BD; color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--red); border-color: #E8C4BC; }
.btn.danger:hover { background: #FDFAF9; border-color: #E8C4BC; color: #8E3324; }
.btn.outline-accent { background: var(--surface); color: var(--ocre-dark); border-color: var(--ocre); font-weight: 600; }
.btn.outline-accent:hover { background: #FDF6EA; color: var(--ocre-dark); }
.btn.ghost { background: transparent; color: var(--ocre-dark); border-color: transparent; }
.btn.ghost:hover { background: transparent; color: var(--ocre); border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { background: var(--b-mute-bg); border-color: var(--b-mute-bg); color: #B6AFA6; cursor: not-allowed; }

/* contrôle segmenté (Pipeline / Liste / …) */
.seg {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.seg a, .seg button {
  border: none; background: none; font: inherit;
  font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: var(--radius-xs);
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg a:hover, .seg button:hover { background: var(--canvas); color: var(--muted); text-decoration: none; }
.seg a.active, .seg button.active { background: var(--navy); color: #fff; }
.seg a.active:hover, .seg button.active:hover { background: var(--navy); color: #fff; }

/* puce de filtre (menus ▾) */
.fchip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 12px; color: #4A5157; cursor: pointer;
  font-family: var(--font);
}
.fchip:hover { border-color: #C9C5BD; text-decoration: none; color: #4A5157; }
.fchip .caret { color: #A9A29A; font-size: 10px; }
.fchip.mono { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
.fchip.alerte { background: #F6DFDB; border-color: #E8C4BC; color: #8E3324; cursor: default; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters .spacer { flex: 1; }
.filters form { display: contents; }

.field { margin-bottom: 13px; }
.field label { display: block; font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.8px; text-transform: uppercase; color: var(--label); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="file"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 12.5px; color: var(--ink);
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(198, 123, 18, 0.3);
  border-color: var(--ocre);
}
input.err, select.err, textarea.err { border-color: var(--red); background: #FDFAF9; color: #8E3324; }
textarea { min-height: 90px; resize: vertical; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.checkline input { width: auto; }
.checkline label { margin: 0; font-family: var(--font); font-size: 12.5px; letter-spacing: 0; text-transform: none; color: var(--ink); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--label);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  background: var(--surface-50);
}
.table td { padding: 13px 12px; border-bottom: 1px solid var(--row-line); vertical-align: middle; font-weight: 500; }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table td small, .table td .muted { font-weight: 400; }
.table tbody tr:hover td { background: var(--surface-50); }
.table td.num, .table th.num { text-align: right; }
.table td.num { font-family: var(--mono); font-size: 11.5px; }
.table .empty td { text-align: center; color: var(--muted); padding: 24px; background: none; font-weight: 400; }
.table tfoot td, .table tr.total td {
  background: var(--navy); color: #fff;
  font-weight: 600; border-bottom: none;
  padding-top: 13px; padding-bottom: 13px;
}
.table tfoot td.num, .table tr.total td.num { font-family: var(--mono); font-size: 12px; }
.table tfoot td .dim, .table tr.total td .dim { opacity: .75; font-weight: 400; }
.rowtitle { font-size: 12.5px; font-weight: 600; }
a.rowtitle { color: var(--ink); }
a.rowtitle:hover { color: var(--ink); }
.rowmeta { font-family: var(--mono); font-size: 10px; color: var(--label); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-gray { background: var(--b-mute-bg); color: var(--b-mute-fg); }
.badge-blue { background: var(--b-info-bg); color: var(--b-info-fg); }
.badge-indigo { background: var(--b-info-bg); color: var(--b-info-fg); }
.badge-purple { background: var(--b-info-bg); color: var(--b-info-fg); }
.badge-amber { background: var(--b-wait-bg); color: var(--b-wait-fg); }
.badge-green { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.badge-red { background: var(--b-ko-bg); color: var(--b-ko-fg); }
.badge-orange { background: var(--b-wait-bg); color: var(--b-wait-fg); }
.badge-ia { background: var(--navy); color: var(--gold); font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.6px; }
.badge.mono, .badge-mono { font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 0.2px; }
.badge-plan {
  display: inline-block;
  background: var(--ocre); color: var(--navy);
  border-radius: 8px; padding: 1px 7px;
  font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0.3px;
}
/* étiquette de règle / moteur (RÈGLES MÉTIER, IA · P2, …) */
.tag-rule { font-family: var(--mono); font-size: 9.5px; padding: 2px 6px; border-radius: var(--radius-xs); background: var(--b-wait-bg); color: var(--b-wait-fg); white-space: nowrap; }
.tag-rule.ia { background: var(--navy); color: var(--gold); }

.alert {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  border: 1px solid transparent;
}
.alert.ok { background: var(--b-ok-bg); color: var(--b-ok-fg); border-color: #C4DCCE; }
.alert.err { background: var(--b-ko-bg); color: var(--b-ko-fg); border-color: #E8C4BC; }
.alert.warn { background: var(--b-wait-bg); color: var(--b-wait-fg); border-color: #E5CFA6; }
.alert ul { margin: .2rem 0 0; padding-left: 1.1rem; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button, .tabs a {
  background: none; border: none; font: inherit;
  padding: 11px 14px;
  font-size: 12.5px; font-weight: 500; color: #8A8378;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button:hover, .tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs button.active, .tabs a.active { color: var(--ink); border-bottom-color: var(--ocre); }
.tabs.in-card { border-bottom: none; margin: 0 -20px -1px; padding: 0 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeup .15s ease; }

/* ---------- États d'interface (design system V2) ---------- */
.empty-state {
  border: 1px dashed #D7D3CB;
  border-radius: var(--radius-sm);
  padding: 34px 24px 38px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
  background: var(--surface-50);
}
.empty-state .tok {
  width: 34px; height: 34px; border-radius: var(--radius-xs);
  background: var(--b-mute-bg); color: var(--label);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
}
.empty-state .t { font-size: 13.5px; font-weight: 600; }
.empty-state .d { font-size: 12px; color: var(--muted); line-height: 1.5; max-width: 340px; }
.empty-state .btn { margin-top: 4px; }
.empty-state.in-table { border: none; background: none; }

.error-state {
  border: 1px solid #E8C4BC; background: #FDFAF9;
  border-radius: var(--radius-sm);
  padding: 18px;
  display: flex; flex-direction: column; gap: 9px;
}
.error-state .t { font-size: 13px; font-weight: 600; color: #8E3324; }
.error-state .d { font-size: 12px; color: #6B5A52; line-height: 1.5; max-width: 460px; }
.error-state .code { font-family: var(--mono); font-size: 9.5px; color: #A9A29A; }

.skeleton {
  height: 13px; border-radius: var(--radius-xs);
  background: linear-gradient(90deg, #EDEBE6 0%, #F6F5F2 50%, #EDEBE6 100%);
  background-size: 400px 100%;
  animation: shimmer 1.4s linear infinite;
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--ocre);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block; vertical-align: middle;
}

/* zone verrouillée (IA hors Premium Dédié) */
.locked-zone {
  border: 1px dashed #D7D3CB;
  border-radius: var(--radius);
  padding: 34px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: repeating-linear-gradient(135deg, #FAF9F7 0 7px, #F4F3F0 7px 14px);
  text-align: center;
}
.locked-zone .l1 { font-family: var(--mono); font-size: 10.5px; color: var(--label); letter-spacing: 0.8px; }
.locked-zone .l2 { font-family: var(--mono); font-size: 9.5px; color: #A9A29A; letter-spacing: 0.4px; }

/* Pipeline / stepper */
.stepper { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 16px; }
.step {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 9.5px; font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--muted);
  padding: 4px 9px 4px 5px;
  border-radius: var(--radius-xs);
  background: var(--b-mute-bg);
  border: 1px solid transparent;
}
.step .n {
  min-width: 17px; height: 17px; border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.08);
  display: grid; place-items: center;
  font-size: 9px; padding: 0 2px;
}
.step.done { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.step.done .n { background: var(--green); color: #fff; }
.step.current { background: var(--navy); color: var(--gold); }
.step.current .n { background: var(--ocre); color: var(--navy); }

/* Chaîne d'achat V2 — cartes reliées par des flèches */
.chain { display: flex; align-items: stretch; margin-bottom: 0; }
.chain .seg-link { flex: 1; min-width: 0; display: flex; align-items: stretch; }
.chain .link {
  flex: 1; min-width: 0;
  border: 1px solid #E7E4DE;
  background: var(--surface-50);
  border-radius: var(--radius-sm);
  padding: 13px 13px 14px;
  display: flex; flex-direction: column; gap: 8px;
  color: inherit;
}
a.chain-link:hover { text-decoration: none; }
.chain .link .code {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--navy);
}
.chain .link .code .c { font-family: var(--mono); font-size: 9.5px; font-weight: 400; color: var(--label); }
.chain .link .what { font-size: 12px; font-weight: 500; line-height: 1.35; color: var(--ink); }
.chain .link .who { font-family: var(--mono); font-size: 9px; letter-spacing: 0.4px; color: var(--label); text-transform: uppercase; }
.chain .link.warm { background: #FDF9F1; border-color: #E5CFA6; }
.chain .link.warm .code { color: #8A5B0B; }
.chain .link.cool { background: #F2F7F4; border-color: #CFE0D7; }
.chain .link.cool .code { color: #1F5E43; }
.chain .arrow { width: 22px; flex: 0 0 22px; display: grid; place-items: center; color: #C9C5BD; font-size: 12px; }

.checklist { list-style: none; margin: 6px 0 14px; padding: 0; }
.checklist li { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: 12px; line-height: 1.45; color: #4A5157; }
.checklist .okmark, .checklist .komark, .checklist .waitmark {
  width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px;
  border-radius: var(--radius-xs);
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700;
}
.checklist .okmark { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.checklist .komark { background: var(--b-ko-bg); color: var(--b-ko-fg); }
.checklist .waitmark { background: var(--b-mute-bg); color: #8A8378; }

/* Visas (pastilles rondes DAF / DG / ASS.) */
.visas { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.visas .visa {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 8.5px; font-weight: 600;
  background: var(--b-mute-bg); color: #A9A29A;
}
.visas .visa.ok { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.visas form { display: contents; }
.visas button.visa { border: none; cursor: pointer; padding: 0; font: inherit; font-family: var(--mono); font-size: 8.5px; font-weight: 600; }
.visas button.visa:hover { outline: 1px solid var(--ocre); }

dialog.modal {
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: min(560px, 94vw);
  color: var(--ink);
}
dialog.modal::backdrop { background: rgba(22, 35, 47, 0.5); }
dialog.modal .modal-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
}
dialog.modal .modal-head h3 { margin: 0; }
dialog.modal .modal-body { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }
dialog.modal .close { background: none; border: none; font-size: 15px; cursor: pointer; color: var(--muted); }

.progressbar { background: var(--b-mute-bg); border-radius: 3px; height: 5px; overflow: hidden; position: relative; }
.progressbar.thin { height: 3px; border-radius: 2px; }
.progressbar > span { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.progressbar > span.warn { background: var(--amber); }
.progressbar > span.over { background: var(--red); }
.progressbar .seuil { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--red); }

.pagination { display: flex; gap: 4px; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface);
  color: var(--ink);
}
.pagination .current { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination .disabled { opacity: .5; }

/* Kanban pipeline V2 (écran Appels d'offres) */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: start; }
.kcol { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kcol-head {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 9px;
  border-bottom: 2px solid var(--kcol, var(--navy));
}
.kcol-head .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kcol-head .t { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.kcol-head .n { font-family: var(--mono); font-size: 10.5px; color: var(--label); }
.kcol-head .who { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.6px; color: var(--label); text-transform: uppercase; }
.kcard {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
  color: var(--ink);
}
.kcard:hover { text-decoration: none; color: var(--ink); border-color: var(--ocre); box-shadow: var(--shadow); }
.kcard .ref { font-size: 10px; color: var(--ocre-dark); }
.kcard .t { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.kcard .c { font-size: 11px; color: var(--muted); }
.kcard .hr { height: 1px; background: var(--row-line); }
.kcard .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kcard .amount { font-family: var(--mono); font-size: 11px; font-weight: 500; }
.kcard .sla { font-family: var(--mono); font-size: 9.5px; border-radius: var(--radius-xs); padding: 2px 6px; white-space: nowrap; }
.kcard .docs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.kcard .docs span {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.2px;
  border: 1px solid var(--border-soft); border-radius: 2px;
  padding: 2px 5px; color: var(--muted); background: var(--canvas);
}
.kcard .docs span.ok { border-color: #CFE0D7; background: var(--b-ok-bg); color: var(--b-ok-fg); }
.kadd {
  border: 1px dashed #D7D3CB; border-radius: var(--radius);
  padding: 10px; text-align: center;
  font-size: 11.5px; color: #9C958C; cursor: pointer; display: block;
}
.kadd:hover { border-color: var(--ocre); color: var(--ocre-dark); text-decoration: none; }

/* Circuit de validation (cartes par direction, barre de couleur) */
.circuit { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.circuit .dir {
  border: 1px solid #E7E4DE; border-radius: var(--radius-sm);
  background: var(--surface-50);
  padding: 13px 12px;
  display: flex; flex-direction: column; gap: 9px;
  color: inherit;
}
a.dir:hover { text-decoration: none; border-color: #C9C5BD; }
.circuit .dir .d { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--navy); letter-spacing: 0.5px; }
.circuit .dir .n { font-size: 22px; font-weight: 600; letter-spacing: -0.8px; line-height: 1; }
.circuit .dir .l { font-size: 11px; color: var(--muted); line-height: 1.35; }
.circuit .dir .bar { height: 3px; border-radius: 2px; width: 100%; }

/* Écriture d'audit / activité */
.audit-row { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 0 0 11px; margin-bottom: 11px; border-bottom: 1px solid var(--row-line); font-size: 12.5px; align-items: start; }
.audit-row:last-child { border-bottom: none; margin-bottom: 0; }
.audit-row .time { font-family: var(--mono); font-size: 10.5px; color: var(--label); padding-top: 1px; }
.audit-row .what { min-width: 0; line-height: 1.4; }
.audit-row .ref { display: block; font-size: 10px; color: var(--ocre-dark); margin-top: 3px; }

/* Alertes règles métier (contrôle de complétude) */
.rule-alert { display: flex; gap: 11px; padding-bottom: 13px; margin-bottom: 13px; border-bottom: 1px solid var(--row-line); align-items: flex-start; }
.rule-alert:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.rule-alert .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: 0 0 7px; }
.rule-alert .t { font-size: 12.5px; font-weight: 500; line-height: 1.35; }
.rule-alert .m { font-family: var(--mono); font-size: 10px; color: var(--label); margin-top: 3px; }

/* Phases de chantier (liste avec n° rond, jauge, tag) */
.phase-row {
  display: grid; grid-template-columns: 30px 1fr 128px 116px; gap: 14px;
  align-items: center;
  padding: 13px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: inherit;
}
.phase-row:hover { background: var(--surface-50); text-decoration: none; color: inherit; }
.phase-row.hl { background: #FDF9F1; border-color: #E5CFA6; }
.phase-row .n {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  background: var(--b-mute-bg); color: var(--label);
}
.phase-row.done .n { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.phase-row.wait .n { background: var(--ocre); color: var(--navy); }
.phase-row.run .n { background: var(--b-wait-bg); color: var(--b-wait-fg); }
.phase-row.late .n { background: var(--b-ko-bg); color: var(--b-ko-fg); }
.phase-row .t { font-size: 13px; font-weight: 600; }
.phase-row .m { font-family: var(--mono); font-size: 10px; color: var(--label); margin-top: 3px; }
.phase-row .p { font-family: var(--mono); font-size: 10px; color: var(--label); margin-top: 5px; }

/* Gantt (planning) */
.gantt { display: flex; flex-direction: column; }
.gantt .g-head { display: grid; grid-template-columns: var(--gcol, 250px) 1fr; border-top: 1px solid var(--border-soft); }
.gantt .g-head .l { padding: 8px 12px 8px 0; font-family: var(--mono); font-size: 9.5px; color: var(--label); letter-spacing: 0.6px; text-transform: uppercase; }
.gantt .g-weeks { display: grid; grid-template-columns: repeat(10, 1fr); border-left: 1px solid var(--border-soft); }
.gantt .g-weeks span { padding: 8px 0 8px 6px; font-family: var(--mono); font-size: 9px; color: var(--label); border-right: 1px solid var(--canvas); }
.gantt .g-row { display: grid; grid-template-columns: var(--gcol, 250px) 1fr; align-items: center; border-top: 1px solid var(--canvas); }
.gantt .g-row .l { padding: 10px 14px 10px 0; }
.gantt .g-row .l .t { font-size: 12.5px; font-weight: 500; }
.gantt .g-row .l .m { font-family: var(--mono); font-size: 9.5px; color: var(--label); margin-top: 2px; }
.gantt .g-track {
  position: relative; height: 38px;
  border-left: 1px solid var(--border-soft);
  background: repeating-linear-gradient(to right, transparent 0 calc(10% - 1px), var(--canvas) calc(10% - 1px), var(--canvas) 10%);
}
.gantt .g-bar {
  position: absolute; top: 12px; height: 14px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; padding-left: 7px;
}
.gantt .g-bar .pct { font-family: var(--mono); font-size: 9px; font-weight: 600; white-space: nowrap; }
.gantt .g-today { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--red); }
.gantt-legend { display: flex; align-items: center; gap: 14px; font-family: var(--mono); font-size: 9.5px; color: var(--label); text-transform: uppercase; flex-wrap: wrap; }
.gantt-legend .sw { width: 10px; height: 6px; border-radius: 2px; display: inline-block; }
.gantt-legend .today { width: 1px; height: 10px; background: var(--red); display: inline-block; }
.gantt-legend > span { display: inline-flex; align-items: center; gap: 5px; }

/* Cartes rapport de chantier (photo hachurée + méta) */
.report-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  margin: 0;
}
.report-card .photo {
  height: 148px; position: relative;
  background: repeating-linear-gradient(135deg, #ECEAE5 0 8px, #E3E0DA 8px 16px);
  display: grid; place-items: center;
  border-bottom: 1px solid var(--border);
}
.report-card .photo .cap { font-family: var(--mono); font-size: 10px; color: var(--label); letter-spacing: 0.7px; text-align: center; padding: 0 20px; line-height: 1.5; text-transform: uppercase; }
.report-card .photo .count {
  position: absolute; bottom: 9px; right: 9px;
  font-family: var(--mono); font-size: 9px;
  background: rgba(22, 35, 47, 0.85); color: #fff;
  padding: 3px 6px; border-radius: var(--radius-xs);
}
.report-card .body { padding: 14px 15px 16px; display: flex; flex-direction: column; gap: 10px; }
.report-card .rowhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.report-card .t { font-size: 13px; font-weight: 600; line-height: 1.35; }
.report-card .d { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.report-card .meta { display: flex; align-items: center; gap: 12px; padding-top: 3px; font-family: var(--mono); font-size: 9.5px; color: var(--label); text-transform: uppercase; flex-wrap: wrap; }

/* Pointage main d'œuvre (cellules jour) */
.pcell {
  width: 34px; height: 26px; border-radius: var(--radius-xs);
  display: inline-grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  background: var(--b-mute-bg); color: #A9A29A;
  border: none; cursor: default;
}
button.pcell { cursor: pointer; }
button.pcell:hover { outline: 1px solid var(--ocre); }
.pcell.p { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.pcell.s { background: var(--b-wait-bg); color: var(--b-wait-fg); }
.pcell.a { background: var(--b-ko-bg); color: var(--b-ko-fg); }
.legend { display: flex; align-items: center; gap: 18px; font-family: var(--mono); font-size: 9.5px; color: var(--label); text-transform: uppercase; flex-wrap: wrap; }
.legend .sw { width: 16px; height: 12px; border-radius: 2px; display: inline-block; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* Matrice RBAC (cellules carrées) */
.rbac-cell {
  min-width: 22px; height: 22px; border-radius: var(--radius-xs);
  display: inline-grid; place-items: center;
  padding: 0 4px;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  margin: 0 auto;
  white-space: nowrap;
}
.rbac-cell.rw { background: #DCEAE2; color: #1F5E43; }
.rbac-cell.r { background: #EAF0EC; color: #3F6B57; }
.rbac-cell.v { background: #F1E7D6; color: #8A5B0B; }
.rbac-cell.n { background: #EDEBE6; color: #B6AFA6; }

/* Bandeau navy (back-office, rapport hebdo trésorerie) */
.navy-card {
  background: var(--navy); color: #E8E9EA;
  border-radius: var(--radius);
  padding: 17px 18px;
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 16px;
}
.navy-card .lbl { color: #8A9299; }
.navy-card .t { font-size: 14px; font-weight: 600; color: #fff; }
.navy-card .d { font-size: 12px; color: #A3ABB1; line-height: 1.55; }
.navy-hero {
  background: var(--navy); border-radius: var(--radius);
  padding: 20px 22px;
  display: flex; align-items: center; gap: 30px; flex-wrap: wrap;
  margin-bottom: 18px; color: #E8E9EA;
}
.navy-hero .grow { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 5px; }
.navy-hero .lbl { color: #8A9299; }
.navy-hero .t { font-size: 19px; font-weight: 600; color: #fff; }
.navy-hero .d { font-size: 12px; color: #A3ABB1; line-height: 1.55; max-width: 560px; }
.navy-hero .kpi { display: flex; flex-direction: column; gap: 5px; }
.navy-hero .kpi .v { font-family: var(--mono); font-size: 24px; font-weight: 600; color: #fff; }
.navy-hero .kpi .v.gold { color: var(--gold); }
.navy-hero .kpi .n { font-size: 11px; color: #A3ABB1; }

/* Arborescence documentaire */
.doc-tree { display: flex; flex-direction: column; gap: 2px; }
.doc-tree a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: var(--radius-xs);
  color: var(--ink); font-size: 12px;
}
.doc-tree a:hover { background: var(--surface-50); text-decoration: none; }
.doc-tree a.active { background: rgba(198, 123, 18, 0.12); font-weight: 600; }
.doc-tree a.root { background: var(--canvas); font-weight: 600; }
.doc-tree a.root.active { background: rgba(198, 123, 18, 0.12); }
.doc-tree .dot { width: 6px; height: 6px; border-radius: 1px; background: #C9C5BD; flex: 0 0 6px; }
.doc-tree a.active .dot { background: var(--ocre); }
.doc-tree a.root .dot { background: var(--navy); }
.doc-tree .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tree .n { font-family: var(--mono); font-size: 9.5px; color: var(--label); }
.doc-tree .child { margin-left: 12px; }
.file-ico {
  width: 24px; height: 28px; flex: 0 0 24px;
  border: 1px solid var(--border); border-radius: 2px;
  background: var(--surface-50);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 7.5px; color: var(--label);
}
.file-ico.lg { width: 26px; height: 30px; flex-basis: 26px; font-size: 8px; }

/* Code projet en jeton navy/gold */
.code-token {
  display: inline-block;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  background: var(--navy); color: var(--gold);
  padding: 8px 12px; border-radius: var(--radius-sm);
  letter-spacing: 0.5px; white-space: nowrap;
}

/* ---------- Chat IA V2 ---------- */
.chat-shell { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 18px; align-items: start; }
.chat-card { display: flex; flex-direction: column; min-height: 620px; padding: 0; }
.chat-head { padding: 15px 18px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 12px; }
.chat-head .ico {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--navy); color: var(--gold);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
}
.chat-head .t { font-size: 13.5px; font-weight: 600; }
.chat-head .m { font-family: var(--mono); font-size: 9.5px; color: var(--label); letter-spacing: 0.3px; text-transform: uppercase; }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 20px; max-height: 58vh; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 76%;
  background: var(--navy); color: #fff;
  border-radius: 6px 6px 2px 6px;
  padding: 12px 15px;
  font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg-ai { display: flex; flex-direction: column; gap: 12px; max-width: 84%; }
.msg-ai .bubble {
  background: var(--surface-50);
  border: 1px solid var(--border-soft);
  border-radius: 6px 6px 6px 2px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
  font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg-ai .hr { height: 1px; background: var(--border-soft); }
.msg-ai .src-label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.7px; color: var(--label); text-transform: uppercase; }
.msg-ai .src {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #E7E4DE; border-radius: var(--radius-xs);
  padding: 8px 10px; background: var(--surface);
  white-space: normal;
}
.msg-ai .src:hover { border-color: var(--ocre); }
.msg-ai .src .ext { font-family: var(--mono); font-size: 8px; color: var(--label); border: 1px solid var(--border); border-radius: 2px; padding: 2px 4px; }
.msg-ai .src .n { font-size: 11.5px; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-ai .src .loc { font-family: var(--mono); font-size: 9.5px; color: var(--ocre-dark); white-space: nowrap; }
.msg-ai .nosrc { display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: var(--muted); white-space: normal; }
.chat-foot { padding: 15px 18px; border-top: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 11px; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-chips button {
  font: inherit; font-size: 11.5px; color: #4A5157;
  background: none; border: 1px solid var(--border);
  border-radius: 14px; padding: 5px 11px; cursor: pointer;
}
.chat-chips button:hover { border-color: var(--ocre); color: var(--ocre-dark); }
.chat-form { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 8px 8px 13px; }
.chat-form textarea { flex: 1; min-height: 24px; max-height: 120px; border: none; outline: none; padding: 0; background: none; resize: none; font-size: 13px; }
.chat-form textarea:focus { outline: none; }
.chat-note { font-size: 11px; color: var(--label); line-height: 1.5; }
.rag-step { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 13px; }
.rag-step:last-child { margin-bottom: 0; }
.rag-step .n {
  width: 20px; height: 20px; flex: 0 0 20px;
  border-radius: var(--radius-xs);
  background: var(--canvas); color: #4A5157;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 9px; font-weight: 600;
}
.rag-step .t { font-size: 12px; font-weight: 500; }
.rag-step .d { font-size: 11px; color: var(--muted); line-height: 1.45; margin-top: 3px; }
.rag-steps.dim .rag-step { opacity: .55; }
.qlog-row { display: flex; align-items: center; gap: 10px; padding-bottom: 9px; margin-bottom: 9px; border-bottom: 1px solid var(--row-line); }
.qlog-row:last-child { border-bottom: none; margin-bottom: 0; }
.qlog-row .time { font-family: var(--mono); font-size: 9.5px; color: var(--label); width: 38px; flex: 0 0 38px; }
.qlog-row .q { font-size: 11.5px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qlog-row .who { font-family: var(--mono); font-size: 9px; color: var(--ocre-dark); text-transform: uppercase; }
.rbac-note {
  border: 1px solid #E5CFA6; background: #FDF9F1;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 12px;
}
.rbac-note .ico { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; background: var(--b-wait-bg); color: var(--b-wait-fg); display: grid; place-items: center; font-size: 11px; }
.rbac-note .t { font-size: 12.5px; font-weight: 600; color: #8A5B0B; }
.rbac-note .d { font-size: 12px; color: #6B5A3E; line-height: 1.5; margin-top: 4px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ocre); opacity: .4; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.premium-bullet {
  border: 1px solid #E7E4DE; border-radius: var(--radius-sm);
  padding: 13px 14px;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface-50);
}
.premium-bullet .tag { font-family: var(--mono); font-size: 9px; letter-spacing: 0.6px; color: #8A5B0B; text-transform: uppercase; }
.premium-bullet .t { font-size: 12px; font-weight: 500; line-height: 1.4; }
.premium-bullet .d { font-size: 11px; color: var(--muted); line-height: 1.45; }

/* Suggestions IA (assistance au chiffrage) */
.ai-suggest {
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 10px 11px;
  display: flex; flex-direction: column; gap: 5px;
  background: var(--surface-50);
  margin-bottom: 10px;
}
.ai-suggest .t { font-size: 11.5px; font-weight: 500; }
.ai-suggest .row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ai-suggest .pu { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.ai-suggest .delta { font-family: var(--mono); font-size: 9.5px; }
.ai-suggest .src { font-family: var(--mono); font-size: 9px; color: var(--label); }
.ai-banner {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.5px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.ai-banner.on { background: var(--b-ok-bg); color: var(--b-ok-fg); }
.ai-banner.off { background: var(--b-wait-bg); color: var(--b-wait-fg); }

/* ---------- Pages publiques ---------- */
.pub-nav {
  display: flex; align-items: center; gap: 22px;
  padding: 13px 5vw;
  background: rgba(244, 243, 240, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.pub-nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); font-size: 14px; }
.pub-nav .brand .logo {
  width: 30px; height: 30px; border-radius: var(--radius-xs);
  background: var(--ocre); color: var(--navy);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
}
.pub-nav .links { flex: 1; display: flex; gap: 20px; font-size: 12.5px; }
.pub-nav .links a { color: var(--muted); font-weight: 500; }
.pub-nav .links a:hover { color: var(--ink); text-decoration: none; }

.hero { background: var(--navy); color: #E8E9EA; padding: 72px 5vw 64px; }
.hero .wrap { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: 1.15fr .85fr; gap: 44px; align-items: center; }
.hero .kicker { font-family: var(--mono); font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); margin-bottom: 14px; }
.hero h1 { color: #fff; font-size: 34px; font-weight: 600; letter-spacing: -0.8px; line-height: 1.15; margin-bottom: 14px; }
.hero h1 em { color: var(--gold); font-style: normal; }
.hero p.lead { font-size: 14.5px; color: #B7BEC4; line-height: 1.6; margin-bottom: 24px; max-width: 54ch; }
.hero .cta-row { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .free-note { font-family: var(--mono); font-size: 10px; letter-spacing: 0.4px; color: #8A9299; margin-top: 12px; }
.hero-visual {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  padding: 14px;
}
.hero-visual .row {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 11px; margin-bottom: 7px;
  font-family: var(--mono); font-size: 10.5px;
}
.hero-visual .row:last-child { margin-bottom: 0; }
.hero-visual .row .dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }

.section { padding: 56px 5vw; }
.section .wrap { max-width: 1100px; margin: 0 auto; }
.section.alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section .kicker { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--ocre-dark); text-align: center; margin-bottom: 8px; }
.section h2.title { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; text-align: center; margin-bottom: 6px; }
.section p.sub { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 32px; font-size: 13px; }

.feature { padding: 17px 18px; margin: 0; }
.feature .tok {
  width: 34px; height: 30px; border-radius: var(--radius-xs);
  background: var(--navy); color: var(--gold);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  margin-bottom: 11px;
}
.feature h3 { margin-bottom: 5px; font-size: 13.5px; }
.feature p { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }

.plan { display: flex; flex-direction: column; padding: 20px; margin: 0; }
.plan .name { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--label); }
.plan .price { font-size: 26px; font-weight: 600; letter-spacing: -0.8px; color: var(--ink); margin: 8px 0 4px; }
.plan .price small { font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.plan ul { list-style: none; padding: 0; margin: 10px 0 18px; flex: 1; }
.plan ul li { padding: 4px 0; font-size: 12.5px; display: flex; gap: 8px; }
.plan ul li::before { content: "✓"; color: var(--green); font-weight: 600; }
.plan ul li.no { color: var(--muted); }
.plan ul li.no::before { content: "—"; color: #C9C5BD; }
.plan.highlight { border: 1.5px solid var(--ocre); position: relative; }
.plan.highlight .tag {
  position: absolute; top: -10px; right: 14px;
  background: var(--navy); color: var(--gold);
  font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 0.6px;
  padding: 3px 8px; border-radius: 8px;
}

.pub-footer { background: var(--navy); color: #A3ABB1; padding: 36px 5vw; font-size: 12.5px; }
.pub-footer .wrap { max-width: 1100px; margin: 0 auto; display: flex; gap: 32px; flex-wrap: wrap; justify-content: space-between; }
.pub-footer a { color: #E8E9EA; }
.pub-footer b { color: #fff; }

/* Docs */
.docs-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; max-width: 1100px; margin: 0 auto; padding: 28px 5vw 48px; align-items: start; }
.docs-nav { position: sticky; top: 70px; }
.docs-nav a { display: block; padding: 7px 11px; border-radius: var(--radius-sm); color: var(--muted); font-size: 12.5px; font-weight: 500; margin-bottom: 2px; }
.docs-nav a:hover { color: var(--ink); text-decoration: none; background: rgba(198, 123, 18, 0.07); }
.docs-nav a.active { background: rgba(198, 123, 18, 0.13); color: var(--ocre-dark); font-weight: 600; }
.docs-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 38px; font-size: 13px; }
.docs-content h1 { font-size: 22px; }
.docs-content h2 { margin-top: 26px; font-size: 15px; }
.docs-content h3 { margin-top: 18px; font-size: 13.5px; }
.docs-content li { margin-bottom: 3px; }
.docs-content code { font-family: var(--mono); background: var(--surface-50); border: 1px solid var(--border-soft); border-radius: 3px; padding: 1px 5px; font-size: 11px; }
.docs-content pre { background: var(--navy); color: #DCE3E9; padding: 13px 16px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 11.5px; }
.docs-content pre code { background: none; border: none; padding: 0; color: inherit; }
.docs-content table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 12.5px; }
.docs-content table th { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.7px; text-transform: uppercase; color: #79828A; background: var(--surface-50); }
.docs-content table th, .docs-content table td { border: 1px solid var(--border); padding: 8px 11px; text-align: left; }
.docs-content blockquote { border-left: 3px solid var(--ocre); margin: 12px 0; padding: 4px 16px; color: var(--muted); background: var(--surface-50); border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--navy); color: #E8E9EA; padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.auth-side .kicker { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); margin-bottom: 12px; }
.auth-side h2 { color: #fff; font-size: 24px; letter-spacing: -0.5px; }
.auth-side p { color: #B7BEC4; font-size: 13px; }
.auth-side ul { list-style: none; padding: 0; }
.auth-side li { padding: 5px 0; font-size: 12.5px; color: #C3C8CC; }
.auth-side li::before { content: "✓ "; color: var(--gold); font-weight: 600; }
.auth-side a { color: var(--gold); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--canvas); }
.auth-card { width: min(430px, 100%); }

/* Design system (page Tokens & composants) */
.swatch { display: flex; flex-direction: column; gap: 8px; }
.swatch .c { height: 56px; border-radius: var(--radius-sm); border: 1px solid rgba(27, 29, 31, 0.09); }
.swatch .n { font-family: var(--mono); font-size: 10px; font-weight: 500; }
.swatch .h { font-family: var(--mono); font-size: 9.5px; color: var(--label); }
.swatch .u { font-size: 10.5px; color: var(--muted); line-height: 1.4; }
.type-row { display: grid; grid-template-columns: 1fr 168px; gap: 14px; align-items: baseline; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--row-line); }
.type-row .spec { font-family: var(--mono); font-size: 9.5px; color: var(--label); line-height: 1.6; white-space: pre-line; }
.space-demo { display: flex; align-items: flex-end; gap: 12px; }
.space-demo .u { display: flex; flex-direction: column; align-items: center; gap: 6px; font-family: var(--mono); font-size: 9px; color: var(--label); }
.space-demo .b { background: var(--ocre); border-radius: 2px; }
.icon-tok {
  width: 30px; height: 26px; border-radius: var(--radius-xs);
  background: var(--canvas); border: 1px solid #E7E4DE;
  display: inline-grid; place-items: center;
  font-family: var(--mono); font-size: 9px; font-weight: 600; color: #4A5157;
}

/* ---------- Responsive (breakpoints du design) ---------- */
@media (max-width: 1439px) {
  .grid.side, .grid.panel, .grid.panel-l { grid-template-columns: 1fr; }
  .chat-shell { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(5, 232px); overflow-x: auto; padding-bottom: 8px; }
}
@media (max-width: 1023px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.tree { grid-template-columns: 1fr; }
  .circuit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero .wrap { grid-template-columns: 1fr; }
  .docs-shell { grid-template-columns: 1fr; }
  .docs-nav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .topbar form.search { display: none; }
  .content { padding: 20px 22px 44px; }
  .topbar { padding: 0 22px; }
}
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .topbar { height: auto; padding: 10px 14px; gap: 10px; }
  .topbar .burger {
    display: inline-flex; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-xs); padding: 6px 10px; font-size: 14px; cursor: pointer; color: var(--ink);
  }
  .topbar .userchip .meta { display: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .circuit { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .pub-nav .links { display: none; }
  .btn { padding: 10px 16px; } /* cibles tactiles 44 px */
  .chain { flex-direction: column; gap: 6px; }
  .chain .arrow { display: none; }
  .phase-row { grid-template-columns: 30px 1fr; }
  .phase-row > :nth-child(3) { grid-column: 2; }
  .phase-row > :nth-child(4) { grid-column: 2; justify-self: start; }
}

@media print {
  .sidebar, .topbar, .btn, .tabs, .chat-form, .pub-nav, .pub-footer { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
  .card { border: 1px solid #ccc; }
}
