@font-face { font-family: 'Inter'; src: url('vendor/inter.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --brand: #146d88; --brand-600: #0f5a71; --brand-50: #e8f4f8; --brand-100: #cfe8f0;
  --sky: #35b7eb; --lime: #cbd400; --lime-50: #f6f7d9;
  --page: #f4f6f7; --surface: #ffffff; --surface-2: #f9fafa;
  --ink: #0f1d24; --ink-2: #4a5a62; --muted: #8a979d; --line: #e4e9eb; --line-2: #eef1f2;
  --grid: #e9edee; --axis: #c9d1d4;
  --good: #0a7a2f; --good-bg: #e7f6ec; --bad: #b42318; --bad-bg: #fdecea; --warn: #9a6700; --warn-bg: #fff4d6; --crit: #d03b3b;
  --s1: #1a84a6; --s2: #eb6834; --s3: #6250d6; --s4: #a8b000; --s5: #d55181; --s6: #35b7eb; --prev: #b9c2c6;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 29, 36, .04), 0 2px 8px rgba(15, 29, 36, .04);
  --shadow-lg: 0 12px 40px rgba(15, 29, 36, .16);
  --sidebar: 236px;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--page);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-weight: 750; font-size: 17px; color: var(--brand); letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.nav-group { margin-top: 14px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; text-decoration: none; }
.nav a svg { width: 18px; height: 18px; stroke: currentColor; flex: none; opacity: .85; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.nav a .pill { margin-left: auto; font-size: 11px; background: var(--brand); color: #fff; border-radius: 99px; padding: 1px 7px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: 1px; }
.demo-badge { display: inline-block; background: var(--lime-50); color: #5c6100; border: 1px solid #e3e79a; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 600; margin-top: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(244, 246, 247, .88); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); padding: 12px 28px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 60px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 13px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--axis); background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.ai { background: linear-gradient(135deg, #146d88, #1a84a6 60%, #35b7eb); color: #fff; border: 0; box-shadow: 0 2px 10px rgba(20, 109, 136, .3); }
.btn.ai:hover { filter: brightness(1.06); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface); border-color: var(--line); }
.select, .input { height: 36px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 0 10px; }
.input:focus, .select:focus { outline: 2px solid var(--brand-100); border-color: var(--brand); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; height: 28px; padding: 0 10px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: 13px; }
.seg button.on { background: var(--brand-50); color: var(--brand); font-weight: 600; }

.dropdown { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; display: none; }
.menu.right { left: auto; right: 0; }
.dropdown.open .menu { display: block; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .check { width: 16px; font-weight: 700; color: var(--brand); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-foot { padding: 8px 10px 4px; display: grid; gap: 8px; }
.menu-foot .row { display: flex; gap: 6px; align-items: center; }
.menu-scroll { max-height: 300px; overflow-y: auto; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; border-radius: 99px; background: var(--brand-50); color: var(--brand); font-weight: 500; font-size: 12.5px; border: 1px solid var(--brand-100); }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; width: 18px; height: 18px; border-radius: 50%; line-height: 1; }
.chip button:hover { background: var(--brand-100); }

.search-trigger { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; min-width: 240px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); cursor: pointer; }
.search-trigger kbd { margin-left: auto; font: 11px/1 inherit; border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px; color: var(--muted); }
.search-trigger svg { width: 16px; height: 16px; stroke: currentColor; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
@media (max-width: 1180px) { .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-21, .g-12 { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; } .sidebar { display: none; } .g-2, .g-3 { grid-template-columns: 1fr; } .content, .topbar { padding-left: 14px; padding-right: 14px; } .search-trigger { min-width: 0; } }
.mt { margin-top: 16px; } .mt-l { margin-top: 24px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card.flush { padding: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card.flush .card-head { padding: 18px 20px 0; }
.card-title { font-size: 14.5px; font-weight: 650; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-actions { display: flex; gap: 6px; align-items: center; }

/* KPI */
.kpi { position: relative; padding: 16px 18px 14px; overflow: hidden; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-label .src { font-size: 10.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); min-height: 20px; }
.kpi canvas.spark { position: absolute; right: 14px; top: 14px; width: 84px !important; height: 30px !important; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; border-radius: 6px; padding: 2px 6px; }
.delta.up { color: var(--good); background: var(--good-bg); }
.delta.down { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--ink-2); background: var(--surface-2); }

.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 220px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.dash { height: 0; border-top: 2px dashed var(--prev); border-radius: 0; width: 14px; vertical-align: 3px; }

/* Bars list */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; cursor: default; }
.bar-row.link { cursor: pointer; }
.bar-row.link:hover .bar-label { color: var(--brand); }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.bar-val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.bar-val small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.bar-track { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--s1); }

/* Tables */
.table-wrap { overflow: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.t th.n, .t td.n { text-align: right; }
.t th .arr { color: var(--brand); margin-left: 3px; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.link { cursor: pointer; }
.t tbody tr:hover td { background: #f7fafb; }
.t td .main-cell { font-weight: 550; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.t td .sub-cell { color: var(--muted); font-size: 12px; }
.t td.muted { color: var(--muted); }
.cell-bar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.cell-bar .mini { width: 54px; height: 5px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.cell-bar .mini span { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.table-tools { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.table-tools .input { width: 280px; }
.table-foot { padding: 10px 20px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line-2); display: flex; justify-content: space-between; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); white-space: nowrap; }
.badge .sw { width: 7px; height: 7px; border-radius: 50%; }
.seg-Champion { background: #e6f3f7; color: #0f5a71; border-color: #cfe8f0; }
.seg-Fidèle { background: #eef0ff; color: #4636a8; border-color: #dcdcfb; }
.seg-Nouveau { background: var(--lime-50); color: #5c6100; border-color: #e3e79a; }
.seg-Occasionnel { background: var(--surface-2); color: var(--ink-2); }
.seg-À.relancer, .seg-relancer { background: var(--warn-bg); color: var(--warn); border-color: #f5e0a3; }
.seg-Perdu { background: var(--bad-bg); color: var(--bad); border-color: #f7cfca; }

/* Alerts */
.alerts { display: grid; gap: 10px; }
.alert { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.alert .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; font-weight: 700; }
.alert.critical .ico { background: #fde8e8; color: var(--crit); }
.alert.serious .ico { background: #fdece3; color: #b5491c; }
.alert.warning .ico { background: var(--warn-bg); color: var(--warn); }
.alert.good .ico { background: var(--good-bg); color: var(--good); }
.alert-title { font-weight: 600; }
.alert-detail { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.alert-kind { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Report hero */
.hero { background: linear-gradient(135deg, #0f5a71 0%, #146d88 45%, #1a84a6 100%); color: #fff; border: 0; padding: 24px 26px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(203, 212, 0, .35), rgba(203, 212, 0, 0) 70%); }
.hero .eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .8; font-weight: 600; }
.hero .big { font-size: 40px; font-weight: 750; letter-spacing: -0.03em; margin-top: 4px; }
.hero .row { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 14px; position: relative; z-index: 1; }
.hero .stat .v { font-size: 20px; font-weight: 700; }
.hero .stat .l { font-size: 12px; opacity: .8; }
.hero .delta.up { background: rgba(255, 255, 255, .16); color: #e9f9c2; }
.hero .delta.down { background: rgba(255, 255, 255, .16); color: #ffd2cc; }
.hero .delta.flat { background: rgba(255, 255, 255, .12); color: #fff; }
.brief { font-size: 14px; line-height: 1.6; }
.brief ul { margin: 0; padding-left: 18px; }
.brief li { margin: 4px 0; }

/* Misc */
.empty { padding: 28px; text-align: center; color: var(--muted); }
.error-box { padding: 12px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.note { font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.funnel { display: grid; gap: 10px; }
.funnel-step { display: grid; grid-template-columns: 130px 1fr 80px; gap: 10px; align-items: center; }
.funnel-step .track { height: 26px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.funnel-step .track span { display: flex; align-items: center; height: 100%; background: var(--s1); border-radius: 6px; color: #fff; font-size: 12px; font-weight: 600; padding-left: 8px; min-width: 32px; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.skeleton { background: linear-gradient(90deg, var(--line-2), #f6f8f9, var(--line-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.loading-page { display: grid; gap: 16px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 100; font-weight: 500; }
.tag-src { font-size: 11px; color: var(--muted); }
.conn-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.conn-row:last-child { border-bottom: 0; }
.conn-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; }
.ok-pill { color: var(--good); background: var(--good-bg); }
.ko-pill { color: var(--bad); background: var(--bad-bg); }

/* ---------- Command palette ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 29, 36, .35); z-index: 60; display: none; }
.overlay.open { display: block; }
.palette { position: fixed; top: 12vh; left: 50%; transform: translateX(-50%); width: min(640px, 92vw); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 61; display: none; overflow: hidden; }
.palette.open { display: block; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 16px 18px; font-size: 16px; outline: none; }
.palette .results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette .grp { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--muted); padding: 10px 12px 4px; letter-spacing: .05em; }
.palette .res { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.palette .res.sel, .palette .res:hover { background: var(--brand-50); }
.palette .res small { color: var(--muted); }

/* ---------- Assistant drawer ---------- */
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); z-index: 70; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .22s ease; }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head .t { font-weight: 700; font-size: 15px; }
.drawer-head .s { font-size: 12px; color: var(--muted); }
.ai-orb { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #146d88, #35b7eb); display: grid; place-items: center; color: #fff; }
.chat { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--surface-2); }
.msg { max-width: 92%; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; padding: 10px 14px; border-radius: 14px 14px 4px 14px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); padding: 12px 16px; border-radius: 14px 14px 14px 4px; box-shadow: var(--shadow); width: 92%; }
.msg.bot p { margin: 0 0 8px; } .msg.bot p:last-child { margin-bottom: 0; }
.msg.bot ul, .msg.bot ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.bot table { border-collapse: collapse; margin: 8px 0; font-size: 12.5px; width: 100%; }
.msg.bot th, .msg.bot td { border-bottom: 1px solid var(--line-2); padding: 5px 8px; text-align: left; }
.msg.bot th { font-weight: 600; color: var(--ink-2); }
.msg.bot h3, .msg.bot h4 { font-size: 14px; margin: 8px 0 4px; }
.msg.bot code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.msg .steps { margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.msg .chart-box { height: 220px; margin-top: 10px; }
.typing { display: inline-flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); opacity: .4; animation: tp 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes tp { 50% { opacity: 1; transform: translateY(-3px); } }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 12px; cursor: pointer; font-size: 13px; text-align: left; }
.suggest button:hover { border-color: var(--brand); color: var(--brand); }
.composer { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; max-height: 160px; font: inherit; outline: none; }
.composer textarea:focus { border-color: var(--brand); }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #dff1f7, transparent 50%), radial-gradient(circle at 90% 90%, #f3f5c9, transparent 45%), var(--page); }
.login-card { width: min(380px, 92vw); padding: 30px; }
