:root {
  --bg: #fbfaf7; --tint: #f3f1ea; --card: #ffffff; --ink: #14140f; --muted: #66655d; --line: #e2dfd5;
  --accent: #2f4bff; --accent-soft: #e6eaff; --good: #14693a; --good-soft: #d6f1df; --warn: #8a5a00; --warn-soft: #ffe9b8;
  --bad: #a3271b; --bad-soft: #fad4cf; --violet: #5b33b8; --violet-soft: #e6dcff;
  --ease: cubic-bezier(.2, .8, .2, 1); --radius: 18px;
  --serif: "Instrument Serif", Georgia, serif; --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { display: grid; grid-template-columns: 252px 1fr; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Barre latérale */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--ink); color: #fff; padding: 22px 16px 18px; overflow: hidden; }
.side::after { content: ""; position: absolute; left: -40%; bottom: -30%; width: 150%; aspect-ratio: 1; border-radius: 50%; background: var(--accent); filter: blur(110px); opacity: .28; pointer-events: none; }
.brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand svg { width: 36px; height: 36px; flex: none; transition: transform .5s var(--ease); }
.brand:hover svg { transform: rotate(-8deg) scale(1.06); }
.brand rect { fill: var(--bg); } .brand path { fill: none; stroke: var(--ink); stroke-width: 8; stroke-linecap: round; } .brand circle { fill: var(--accent); }
.brand span { display: grid; line-height: 1.05; }
.brand em { font-family: var(--serif); font-weight: 400; font-size: 19px; color: #a9b6ff; }
.nav { position: relative; z-index: 1; display: grid; gap: 2px; }
.nav__label { padding: 16px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #77766c; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #c9c8be; font-weight: 500; transition: background .25s, color .25s, transform .35s var(--ease); }
.nav a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(3px); }
.nav a.is-active { background: #fff; color: var(--ink); }
.nav b { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 12px; text-align: center; }
.side__foot { position: relative; z-index: 1; margin-top: auto; display: grid; gap: 12px; }
.side__foot p { font-size: 12px; color: #8b8a80; text-align: center; }

/* Zone principale */
.main { min-width: 0; padding: 34px clamp(20px, 3.4vw, 52px) 64px; }
.view { max-width: 1280px; margin: 0 auto; animation: viewIn .55s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(36px, 4vw, 52px); line-height: 1; letter-spacing: -.01em; }
h1 em { color: var(--accent); }
h2 { font-size: 17px; font-weight: 700; }
.sub { color: var(--muted); margin-top: 8px; max-width: 62ch; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.grow { flex: 1; }

/* Boutons */
.btn { position: relative; overflow: hidden; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border: 1px solid transparent; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; transition: color .25s, border-color .25s, box-shadow .3s; }
.btn::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--accent); transform: translateY(101%); transition: transform .4s var(--ease); }
.btn:hover::before { transform: none; }
.btn--accent { background: var(--accent); } .btn--accent::before { background: #fff; } .btn--accent:hover { color: var(--ink); }
.btn--ghost { background: var(--card); color: var(--ink); border-color: var(--line); } .btn--ghost:hover { color: #fff; border-color: var(--accent); }
.btn--danger { background: none; color: var(--bad); border-color: var(--bad-soft); } .btn--danger::before { background: var(--bad); } .btn--danger:hover { color: #fff; }
.btn--sm { padding: 7px 14px; font-size: 13px; }
.btn--full { width: 100%; padding: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Cartes et indicateurs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; transition: transform .45s var(--ease), box-shadow .45s var(--ease), border-color .3s; animation: viewIn .6s var(--ease) both; animation-delay: calc(var(--i) * 55ms); }
.kpi:hover { transform: translateY(-4px); box-shadow: 0 24px 40px -28px rgba(20, 20, 15, .45); border-color: #cfccc0; }
.kpi span { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kpi strong { display: block; font-family: var(--serif); font-weight: 400; font-size: 46px; line-height: 1.05; margin: 6px 0 2px; }
.kpi small { color: var(--muted); font-size: 13px; }
.kpi--dark { background: var(--ink); border-color: var(--ink); color: #fff; } .kpi--dark span, .kpi--dark small { color: #a3a297; }
.kpi--accent strong { color: var(--accent); } .kpi--good strong { color: var(--good); } .kpi--bad strong { color: var(--bad); } .kpi--warn strong { color: var(--warn); }
.cols { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; align-items: start; }
.cols--even { grid-template-columns: 1fr 1fr; }

.bars { display: grid; gap: 12px; }
.bar { display: grid; grid-template-columns: 150px 1fr 34px; align-items: center; gap: 12px; font-size: 14px; }
.bar__track { height: 10px; border-radius: 999px; background: var(--tint); overflow: hidden; }
.bar__fill { height: 100%; border-radius: inherit; background: var(--accent); width: var(--w); transform-origin: left; animation: grow 1s var(--ease) both; animation-delay: calc(var(--i) * 70ms + 150ms); }
@keyframes grow { from { transform: scaleX(0); } }
.bar b { text-align: right; }

/* Pastilles de statut */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: var(--tint); color: var(--muted); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag--1 { background: var(--accent-soft); color: #1f36c7; } .tag--2 { background: #cdd6ff; color: #1f36c7; }
.tag--3 { background: var(--violet-soft); color: var(--violet); } .tag--4 { background: var(--warn-soft); color: var(--warn); }
.tag--5 { background: var(--good-soft); color: var(--good); } .tag--6 { background: var(--bad-soft); color: var(--bad); }
.tag--late { background: var(--bad-soft); color: var(--bad); } .tag--today { background: var(--warn-soft); color: var(--warn); } .tag--soon { background: var(--good-soft); color: var(--good); }
.tag--plain::before { display: none; }

/* Tableaux */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 13px 16px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: var(--tint); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; transition: background .2s; }
tbody tr:hover { background: #f8f7f2; }
td strong { font-weight: 600; } td small { display: block; color: var(--muted); font-size: 13px; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; font-family: var(--serif); font-weight: 400; font-size: 30px; color: var(--ink); margin-bottom: 6px; }
.empty .row { justify-content: center; margin-top: 18px; }

/* Champs */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.input, select, textarea { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); transition: border-color .2s, box-shadow .2s; }
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(47, 75, 255, .14); }
.toolbar .input { max-width: 320px; } .toolbar select { width: auto; }
textarea { resize: vertical; line-height: 1.55; }
label.f { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .wide { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .25s, color .25s, border-color .25s, transform .3s var(--ease); }
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Pipeline */
.board { display: grid; grid-template-columns: repeat(7, minmax(138px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 12px; }
.col { background: var(--tint); border-radius: 16px; padding: 9px; min-height: 420px; min-width: 0; transition: background .25s, box-shadow .25s; }
.col.is-over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.col__head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; font-size: 13px; font-weight: 700; }
.col__head b { color: var(--muted); font-weight: 600; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 13px; margin-bottom: 9px; cursor: grab; transition: transform .35s var(--ease), box-shadow .35s var(--ease), opacity .2s; animation: viewIn .5s var(--ease) both; animation-delay: calc(var(--i) * 40ms); }
.pcard:hover { transform: translateY(-3px); box-shadow: 0 18px 30px -22px rgba(20, 20, 15, .5); }
.pcard.is-drag { opacity: .35; }
.pcard strong { display: block; font-weight: 600; line-height: 1.3; }
.pcard small { display: block; color: var(--muted); font-size: 12.5px; margin: 2px 0 9px; }
.pcard .row { gap: 6px; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.pcard .tag { white-space: normal; font-size: 11.5px; padding: 3px 9px; }

/* Listes d'actions */
.items { display: grid; gap: 10px; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; transition: transform .35s var(--ease), border-color .25s; animation: viewIn .5s var(--ease) both; animation-delay: calc(var(--i) * 45ms); }
.item:hover { transform: translateX(4px); border-color: #cfccc0; }
.item__main { flex: 1; min-width: 200px; cursor: pointer; }
.item__main strong { font-weight: 600; } .item__main small { display: block; color: var(--muted); font-size: 13px; }
.group { margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.group:first-of-type { margin-top: 0; }

/* Fiche prospect (panneau latéral) */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(20, 20, 15, .42); opacity: 0; pointer-events: none; transition: opacity .35s; backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; z-index: 50; width: min(560px, 100%); height: 100%; background: var(--bg); box-shadow: -30px 0 60px -30px rgba(20, 20, 15, .5); transform: translateX(104%); visibility: hidden; transition: transform .5s var(--ease), visibility 0s .5s; display: flex; flex-direction: column; }
body.fiche-ouverte .overlay { opacity: 1; pointer-events: auto; }
body.fiche-ouverte .drawer { transform: none; visibility: visible; transition-delay: 0s; }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 26px 28px 18px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.05; }
.drawer__body { flex: 1; overflow-y: auto; padding: 22px 28px 28px; display: grid; gap: 22px; align-content: start; }
.drawer__foot { display: flex; gap: 10px; padding: 16px 28px; border-top: 1px solid var(--line); background: var(--card); }
.x { width: 38px; height: 38px; flex: none; border: 1px solid var(--line); border-radius: 50%; background: var(--card); font-size: 20px; line-height: 1; cursor: pointer; transition: transform .4s var(--ease), background .2s; }
.x:hover { transform: rotate(90deg); background: var(--tint); }
.sec { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.histo { display: grid; gap: 10px; }
.histo li { display: grid; grid-template-columns: 84px 1fr; gap: 12px; font-size: 13.5px; }
.histo time { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Messages */
.msg { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
.msg textarea { min-height: 380px; }
.msg__list { display: grid; gap: 8px; }
.modele { text-align: left; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--card); cursor: pointer; transition: border-color .25s, background .25s, transform .3s var(--ease); }
.modele:hover { border-color: var(--accent); transform: translateX(3px); }
.modele.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.modele strong { display: block; font-weight: 600; } .modele small { opacity: .7; font-size: 12.5px; }

/* Devis */
.sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(28px, 4vw, 56px); max-width: 880px; box-shadow: 0 40px 70px -50px rgba(20, 20, 15, .5); }
.sheet__top { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 28px; border-bottom: 2px solid var(--ink); }
.sheet__brand { font-weight: 700; font-size: 22px; letter-spacing: -.02em; } .sheet__brand em { font-family: var(--serif); font-weight: 400; color: var(--accent); margin-left: 3px; }
.sheet__top p { color: var(--muted); font-size: 13.5px; }
.sheet__title { font-family: var(--serif); font-size: 44px; line-height: 1; text-align: right; }
.sheet__parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 28px 0; }
.sheet__parties strong { display: block; font-size: 16px; }
.sheet table { margin-top: 6px; } .sheet th { background: none; border-bottom: 1px solid var(--ink); padding-inline: 8px; } .sheet td { padding: 10px 8px; }
.sheet tbody tr { cursor: default; } .sheet tbody tr:hover { background: none; }
.sheet input { width: 100%; padding: 7px 9px; border: 1px solid transparent; border-radius: 8px; background: none; }
.sheet input:hover { border-color: var(--line); } .sheet input:focus { outline: none; border-color: var(--accent); background: #fff; }
.sheet input.num { text-align: right; }
.sheet__total { margin-left: auto; width: min(340px, 100%); margin-top: 18px; }
.sheet__total div { display: flex; justify-content: space-between; padding: 8px; }
.sheet__total .big { border-top: 2px solid var(--ink); font-weight: 700; font-size: 19px; margin-top: 4px; }
.sheet__note { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; white-space: pre-line; }

.spin { width: 38px; height: 38px; margin: 0 auto 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

.avis { max-width: 54ch; margin: 18px auto 0; padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; font-weight: 500; }

/* Écran de connexion (version en ligne) */
.auth { display: none; position: fixed; inset: 0; z-index: 90; place-items: center; padding: 24px; background: var(--ink); overflow: auto; }
.auth::before { content: ""; position: absolute; left: -10%; bottom: -40%; width: 70%; aspect-ratio: 1; border-radius: 50%; background: var(--accent); filter: blur(140px); opacity: .4; pointer-events: none; }
body.verrou .auth { display: grid; }
body.verrou .side, body.verrou .main { visibility: hidden; }
.auth__card { position: relative; width: min(440px, 100%); display: grid; gap: 16px; background: var(--bg); border-radius: 26px; padding: clamp(28px, 5vw, 44px); box-shadow: 0 50px 90px -40px rgba(0, 0, 0, .8); animation: viewIn .6s var(--ease) both; }
.auth__card svg { width: 46px; height: 46px; }
.auth__card rect { fill: var(--ink); } .auth__card path { fill: none; stroke: var(--bg); stroke-width: 8; stroke-linecap: round; } .auth__card circle { fill: #8fa0ff; }
.auth__card h1 { font-size: 40px; }
.auth__card .sub { margin-top: -6px; font-size: 14.5px; }
.auth__err { min-height: 1.4em; color: var(--bad); font-size: 14px; font-weight: 600; text-align: center; }
.btn:disabled { opacity: .6; cursor: progress; }

/* Notifications */
.toasts { position: fixed; left: 50%; bottom: 26px; z-index: 80; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: 0 20px 40px -18px rgba(0, 0, 0, .6); animation: toast 2.8s var(--ease) both; }
@keyframes toast { 0% { opacity: 0; transform: translateY(16px) scale(.96); } 10%, 86% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .cols, .cols--even, .msg { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 14px; }
  .nav { grid-template-columns: repeat(3, 1fr); } .nav__label, .side__foot p { display: none; } .nav a { padding: 8px 10px; font-size: 13px; }
  .side__foot { margin-top: 12px; }
  .form { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media print {
  body { display: block; background: #fff; }
  .no-print { display: none !important; }
  .main { padding: 0; } .view { animation: none; max-width: none; }
  .sheet { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .sheet input { border: 0 !important; padding: 0; }
  @page { size: A4; margin: 18mm; }
}
