:root {
  --navy: #14275c;
  --navy-600: #1d3478;
  --navy-50: #eef1f8;
  --ink: #0f1a3a;
  --text: #3b4560;
  --muted: #7a8299;
  --line: #e4e7ef;
  --bg: #f5f6fa;
  --gold: #b89a5e;
  --red: #c2413b;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { color: var(--navy); margin: 0; letter-spacing: -.015em; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin: 22px 0 12px; }
.is-hidden { display: none !important; }
.small { font-size: 12.5px; color: var(--muted); }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
code { font-size: 12.5px; background: var(--navy-50); padding: 4px 8px; border-radius: 6px; color: var(--navy); word-break: break-all; }

.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--navy); }
.logo__mark { font-weight: 800; font-size: 22px; letter-spacing: -.035em; line-height: 1; }
.logo__mark sup { font-size: .5em; color: #b89a5e; margin-left: 1px; letter-spacing: 0; }
.logo__text { font-size: 10.5px; font-weight: 600; line-height: 1.15; max-width: 70px; padding-left: 8px; border-left: 1px solid currentColor; opacity: .85; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14px/1 var(--font);
  border: 0; border-radius: 6px; padding: 11px 16px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, color .15s;
}
.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-600); }
.btn--ghost { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn--ghost:hover { box-shadow: inset 0 0 0 1.5px var(--navy); }
.btn--danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1.5px #f0c9c6; }
.btn--danger:hover { background: #fdf1f0; }
.btn--sm { padding: 8px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.link { background: none; border: 0; padding: 0; font: 600 13px var(--font); color: var(--navy); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--navy-50); color: var(--navy); cursor: pointer; font-size: 14px; }

/* --------------------------------------------------------------- Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #eef1f8, #f9fafc); }
.login__card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 36px 32px; box-shadow: 0 30px 60px -30px rgba(20, 39, 92, .35); }
.login__card h1 { font-size: 22px; margin: 22px 0 22px; }
.login__error { color: var(--red); font-weight: 600; font-size: 14px; margin: 0 0 12px; }

/* ----------------------------------------------------------------- Bar */
.bar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.bar__inner { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab { background: none; border: 0; font: 600 14px var(--font); color: var(--muted); padding: 22px 12px 19px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--navy); }
.tab.is-active { color: var(--navy); border-bottom-color: var(--navy); }
.count { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11.5px; margin-left: 4px; }
.count:empty { display: none; }
@media (max-width: 640px) {
  .bar__inner { gap: 8px; padding-top: 10px; }
  .tabs { order: 3; flex-basis: 100%; }
}

.page { max-width: 1280px; margin: 0 auto; padding: 28px 16px 60px; }
.view { display: none; }
.view.is-active { display: block; }
.view__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 2px; }
.kpi__label { font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi__value { font-size: 30px; color: var(--navy); font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: 12.5px; color: var(--muted); }
.kpi--alert { border-color: #f0c9c6; }
.kpi--alert .kpi__value { color: var(--red); }
.kpi--gold { border-color: #e6d8b8; background: #fdfaf3; }
.kpi--gold .kpi__value { color: #8a6f36; }

/* ---------------------------------------------------------------- Table */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.panel__head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 12px 16px; background: #fafbfd; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .due { color: #8a6f36; font-weight: 700; }
.table--click tbody tr { cursor: pointer; }
.table--click tbody tr:hover td { background: #f8f9fc; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 32px; margin: 0; }
.tag { font-size: 11px; font-weight: 600; background: #eee; color: #777; padding: 2px 7px; border-radius: 6px; vertical-align: middle; }

.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 800px) { .filters { grid-template-columns: 1fr 1fr; } .filters input { grid-column: 1 / -1; } }
.filters input, .filters select, .field input, .field select, .field textarea {
  font: 14.5px var(--font); color: var(--ink); padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; width: 100%;
}
.filters input:focus, .filters select:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--navy); }

.status, .proj { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status--nouveau { background: #fdecea; color: #b3261e; }
.status--contacte { background: #fff4e0; color: #9a5b00; }
.status--qualifie { background: #e6effd; color: #1f4fa8; }
.status--en_cours { background: #efe8fb; color: #5b34a8; }
.status--vente_validee { background: #e3f4e8; color: #1d7a3d; }
.status--perdu { background: #eef0f3; color: #6b7280; }
.proj--achat { background: var(--navy-50); color: var(--navy); }
.proj--vente { background: #f6efe0; color: #8a6f36; }

/* ------------------------------------------------------------- Partners */
.partners { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.partner { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; grid-template-columns: 120px 1fr; gap: 18px; }
.partner.is-inactive { opacity: .6; }
.partner__qr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; align-self: start; }
.partner__qr img { width: 100%; display: block; }
.partner__top { display: flex; justify-content: space-between; gap: 10px; }
.partner__top h3 { margin: 0; font-size: 17px; }
.partner__top p { margin: 2px 0 0; }
.partner__url { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.partner__stats { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.partner__stats strong { color: var(--navy); font-size: 15px; }
.partner__actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 520px) { .partner { grid-template-columns: 1fr; } .partner__qr { width: 140px; } }

/* --------------------------------------------------------------- Drawer */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer[hidden] { display: none; }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(15, 26, 58, .45); }
.drawer__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: #fff; display: flex; flex-direction: column; animation: slide .25s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-size: 20px; }
.drawer__body { padding: 20px 22px 40px; overflow-y: auto; }
.drawer__badges { display: flex; gap: 8px; margin-bottom: 16px; }
.contact-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

.dl { margin: 0 0 8px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dl__row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.dl__row:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--ink); white-space: pre-wrap; word-break: break-word; }

.form .field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 13px; font-weight: 600; color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; margin: 6px 0 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }
.sale { background: #fdfaf3; border: 1px solid #efe4cb; border-radius: 12px; padding: 4px 16px 6px; margin-top: 8px; transition: opacity .2s; }
.sale h3 { color: #8a6f36; }
.sale.is-muted { opacity: .55; }
.form__actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.mailbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: #e9f5ee; border: 1px solid #c6e6d2; color: #1d5c34; border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.mailbar--off { background: #fdf3e6; border-color: #f1d9b5; color: #8a5a12; }
.partner__mail { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.partner__mail.is-warn { color: #9a5b00; font-weight: 600; }

.mareco-box { background: var(--navy-50); border-radius: 12px; padding: 4px 14px 2px; margin-bottom: 16px; }
.mareco-box__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mareco-box__head h3 { margin: 12px 0; }
.mareco-box .dl { background: #fff; }
.mareco-ok { margin-top: 4px; font-size: 11.5px; font-weight: 700; color: #1d7a3d; }

.logo-field { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center; margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.logo-field__preview { width: 96px; height: 96px; border-radius: 12px; background: #fafbfd; border: 1px dashed var(--line); display: grid; place-items: center; overflow: hidden; }
.logo-field__preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-field__preview span { font-size: 12px; color: var(--muted); }
.logo-field__label { font-size: 13px; font-weight: 600; color: var(--ink); }
.logo-field .small { margin: 2px 0 10px; }
.logo-field .link { margin-left: 10px; }
.partner__top h3 { display: flex; align-items: center; gap: 8px; }
.partner__logo { width: 32px; height: 32px; object-fit: contain; }

.bar__actions { display: flex; align-items: center; gap: 18px; }
@media (max-width: 640px) { .bar__actions { margin-left: auto; } }

.mailbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.howto { background: var(--navy-50); border-radius: 10px; padding: 12px 14px; margin: 12px 0 16px; font-size: 14px; }
.howto ol { margin: 6px 0 6px; padding-left: 20px; }
.howto li { margin: 2px 0; }
