/* EcomPilot — Dashboard. Grille 8 px, mêmes rayons que la landing (8/16/24). */
button,input,select{font:inherit;color:inherit}
button{background:none;border:0;cursor:pointer}
a{color:inherit;text-decoration:none}
:focus-visible{outline:3px solid var(--laterite);outline-offset:2px;border-radius:8px}

.app{display:grid;grid-template-columns:264px 1fr;min-height:100vh}

/* ---------- Menu latéral ---------- */
.side{position:sticky;top:0;height:100vh;display:flex;flex-direction:column;gap:24px;padding:24px 16px;background:var(--fleuve);color:#C5D6D1}
:root[data-theme="dark"] .side{background:#06201E;border-right:1px solid var(--line)}
.logo{display:flex;align-items:center;gap:8px;padding:0 8px;font:600 24px/1 var(--f-title);color:var(--sable)}
.logo b{font-weight:600;color:#E3876F}
.menu{display:flex;flex-direction:column;gap:2px;flex:1;overflow:auto}
.menu-title{font:700 11px var(--f-text);letter-spacing:.14em;text-transform:uppercase;color:#8FB0A9;padding:16px 12px 8px}
.menu a,.menu button{display:flex;align-items:center;gap:12px;height:40px;padding:0 12px;border-radius:var(--r-sm);font-size:15px;font-weight:500;text-align:left;transition:background .15s,color .15s;position:relative}
.menu a:hover,.menu button:hover{background:rgba(244,237,225,.08);color:var(--sable)}
.menu .active{background:var(--sable);color:var(--fleuve);font-weight:700}
.menu .active::before{content:"";position:absolute;left:-16px;top:8px;bottom:8px;width:4px;border-radius:0 4px 4px 0;background:var(--laterite)}
:root[data-theme="dark"] .menu .active{background:#14524D;color:var(--sable)}
.count{margin-left:auto;min-width:24px;height:20px;padding:0 6px;border-radius:10px;background:var(--laterite-btn);color:#fff;font-size:11px;display:grid;place-items:center}
.count.route{background:rgba(244,237,225,.14);color:var(--sable)}
.side-card{padding:16px;border-radius:var(--r-md);background:rgba(244,237,225,.06);border:1px solid rgba(244,237,225,.12)}
.side-route{width:100%;height:40px;margin-bottom:8px}
.side-route path{fill:none;stroke:#E3876F;stroke-width:2;stroke-dasharray:2 6;stroke-linecap:round}
.side-route circle{fill:#E3876F}.side-route circle+circle{fill:var(--sable)}
.side-card p{color:var(--sable);font-size:15px}.side-card b{font-size:18px}
.side-card small{font-size:12px;color:#A8C1BA}
.profile{display:flex;align-items:center;gap:12px;padding:12px 8px 0;border-top:1px solid rgba(244,237,225,.12)}
.avatar{display:grid;place-items:center;width:40px;height:40px;flex:none;border-radius:50%;background:var(--laterite-100);color:var(--laterite-ink);font:600 15px var(--f-title)}
.who{flex:1;min-width:0}.who b{display:block;color:var(--sable);font-size:14px}.who small{font-size:12px;color:#A8C1BA}
.side .icon-btn{color:#C5D6D1;box-shadow:none}

/* ---------- Zone principale ---------- */
.main{padding:32px 40px 40px;display:flex;flex-direction:column;gap:24px;min-width:0}
.top{display:flex;justify-content:space-between;align-items:flex-end;gap:24px}
.crumb{font-size:14px;color:var(--muted)}
h1{font:600 32px/1.15 var(--f-title);letter-spacing:-.01em;color:var(--brand);margin-top:4px}
.top-tools{display:flex;align-items:center;gap:8px}
.search{display:flex;align-items:center;gap:8px;width:304px;height:44px;padding:0 8px 0 16px;border-radius:var(--r-pill);background:var(--surface);box-shadow:inset 0 0 0 1px var(--line);color:var(--muted);transition:box-shadow .15s}
.search:focus-within{box-shadow:inset 0 0 0 2px var(--laterite)}
.search input{flex:1;min-width:0;border:0;outline:0;background:none;color:var(--text);font-size:15px}
.search input::placeholder{color:var(--muted)}
kbd{font:500 12px var(--f-num);padding:2px 8px;border-radius:6px;background:var(--surface-2);box-shadow:inset 0 0 0 1px var(--line);color:var(--muted)}
.icon-btn{position:relative;display:grid;place-items:center;width:44px;height:44px;border-radius:50%;background:var(--surface);box-shadow:inset 0 0 0 1px var(--line);color:var(--text);transition:background .15s}
.icon-btn:hover{background:var(--surface-2)}
.icon-btn.sm{width:32px;height:32px;background:none;box-shadow:none;color:var(--muted)}
.icon-btn.sm:hover{background:var(--surface-2);color:var(--text)}
.i-sun{display:none}:root[data-theme="dark"] .i-sun{display:block}:root[data-theme="dark"] .i-moon{display:none}
.badge{position:absolute;top:6px;right:6px;min-width:18px;height:18px;padding:0 4px;border-radius:9px;background:var(--laterite-btn);color:#fff;font-size:10px;display:grid;place-items:center;box-shadow:0 0 0 2px var(--surface)}
.btn-primary{display:inline-flex;align-items:center;gap:8px;height:44px;padding:0 20px 0 16px;border-radius:var(--r-pill);background:var(--laterite-btn);color:#fff;font-weight:700;font-size:15px;box-shadow:0 8px 20px rgba(176,74,49,.28);transition:background .15s,transform .15s}
.btn-primary:hover{background:#9A3F29;transform:translateY(-1px)}
.ghost-btn{display:inline-flex;align-items:center;gap:8px;height:40px;padding:0 16px;border-radius:var(--r-pill);box-shadow:inset 0 0 0 1px var(--line);background:var(--surface);font-size:14px;font-weight:500}
.ghost-btn:hover{box-shadow:inset 0 0 0 1px var(--brand)}
.link{display:inline-flex;align-items:center;gap:4px;color:var(--accent);font-weight:700;font-size:14px}
.link:hover{text-decoration:underline}
.link .ico{width:16px;height:16px}

/* Notifications */
.notif-wrap{position:relative}
.notif{position:absolute;right:0;top:56px;z-index:20;width:368px;background:var(--surface);border-radius:var(--r-md);box-shadow:var(--shadow-2),inset 0 0 0 1px var(--line);overflow:hidden}
.notif header{display:flex;justify-content:space-between;align-items:center;padding:16px;border-bottom:1px solid var(--line)}
.notif ul{list-style:none;padding:8px}
.notif li{display:flex;gap:12px;padding:12px 8px;border-radius:var(--r-sm);position:relative;font-size:14px}
.notif li:hover{background:var(--surface-2)}
.notif li.new::after{content:"";position:absolute;right:12px;top:18px;width:8px;height:8px;border-radius:50%;background:var(--laterite)}
.notif p{padding-right:16px}.notif small{display:block;color:var(--muted);font-size:12px;margin-top:2px}
.n-ico{display:grid;place-items:center;width:36px;height:36px;flex:none;border-radius:10px}
.n-ico .ico{width:18px;height:18px}
.n-ico.momo{background:var(--momo);color:#1B1B1B;font:700 10px var(--f-text)}
.n-ico.lat{background:var(--laterite-100);color:var(--laterite-ink)}
.n-ico.fl{background:var(--fleuve);color:var(--sable);--ico-fill:var(--fleuve)}
.n-ico.warn{background:var(--wait-bg);color:var(--wait)}

/* Période */
.period{display:flex;align-items:center;gap:16px}
.seg{display:flex;padding:4px;border-radius:var(--r-pill);background:var(--surface);box-shadow:inset 0 0 0 1px var(--line)}
.seg button{height:32px;padding:0 16px;border-radius:var(--r-pill);font-size:14px;font-weight:500;color:var(--muted)}
.seg button.on{background:var(--brand);color:var(--surface);font-weight:700}
:root[data-theme="dark"] .seg button.on{background:var(--sable);color:var(--fleuve)}
.range{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500}
.range .ico{width:18px;height:18px;color:var(--accent)}
.range em{font-style:normal;color:var(--muted);font-weight:400}
.period .ghost-btn{margin-left:auto}

/* ---------- Cartes ---------- */
.card{background:var(--surface);border-radius:var(--r-lg);box-shadow:var(--shadow-1);padding:24px}
:root[data-theme="dark"] .card,:root[data-theme="dark"] .kpi{box-shadow:inset 0 0 0 1px var(--line)}
.card-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:16px}
h2{font:600 20px/1.2 var(--f-title);color:var(--brand)}
.sub{font-size:14px;color:var(--muted);margin-top:4px}
.sub b{color:var(--text)}

/* KPI */
.kpis{display:grid;grid-template-columns:1.35fr 1fr 1fr 1fr;gap:16px}
.kpi{position:relative;overflow:hidden;background:var(--surface);border-radius:var(--r-lg);padding:24px;box-shadow:var(--shadow-1);display:flex;flex-direction:column;gap:16px;transition:transform .2s,box-shadow .2s}
.kpi:hover{transform:translateY(-2px);box-shadow:var(--shadow-2)}
.k-label{display:flex;align-items:center;gap:12px;font-size:15px;font-weight:500;color:var(--muted)}
.k-ico{display:grid;place-items:center;width:36px;height:36px;border-radius:10px;background:var(--laterite-100);color:var(--laterite-ink)}
.k-ico .ico{width:18px;height:18px}
.k-ico.ok{background:var(--ok-bg);color:var(--ok)}.k-ico.wait{background:var(--wait-bg);color:var(--wait)}
:root[data-theme="dark"] .k-ico:not(.ok):not(.wait){background:#3A1D15;color:#E3876F}
.k-val{font-size:40px;line-height:1;font-weight:700;color:var(--text)}
.k-val small{font-size:16px;font-weight:500;color:var(--muted)}
.k-foot{font-size:13px;color:var(--muted);display:flex;align-items:center;gap:8px}
.trend{display:inline-flex;align-items:center;gap:2px;height:24px;padding:0 8px 0 4px;border-radius:var(--r-pill);font:700 13px var(--f-num)}
.trend .ico{width:14px;height:14px;stroke-width:2.5}
.trend.up,.trend.good-down{background:var(--ok-bg);color:var(--ok)}
.trend.neutral{background:var(--route-bg);color:var(--route)}
.trend.sm{height:20px;font-size:12px}
.hero-kpi{background:var(--fleuve);color:var(--sable)}
:root[data-theme="dark"] .hero-kpi{background:#14524D}
.kpi-motif{position:absolute;right:-40px;top:-40px;width:240px;height:240px;opacity:.16;-webkit-mask:radial-gradient(closest-side,#000 30%,transparent);mask:radial-gradient(closest-side,#000 30%,transparent)}
.hero-kpi .k-label,.hero-kpi .k-foot,.hero-kpi .k-val small{color:#C5D6D1;position:relative}
.hero-kpi .k-val{color:#fff;position:relative}
.hero-kpi .k-ico{background:rgba(244,237,225,.12);color:#E3876F}
.hero-kpi .trend{background:rgba(95,211,154,.16);color:#7FE0AE}

/* Pipeline */
.pipeline{padding:24px}
.pipe-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}
.pipe-stats{display:flex;gap:40px}
.pipe-stats p{display:flex;align-items:baseline;gap:8px}
.pipe-stats small{font-size:13px;color:var(--muted)}
.pipe-stats b{font-size:20px;color:var(--text)}
.pipe-bar{display:flex;gap:4px;height:16px;border-radius:8px;overflow:hidden}
.pipe-bar span{border-radius:4px}
.seg-ok{background:var(--ok)}.seg-route{background:var(--route)}.seg-wait{background:#D9A23B}
.pipe-legend{list-style:none;padding:0;margin-top:16px;display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
.pipe-legend li{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.pipe-legend b{font-size:18px;color:var(--text)}
.pipe-legend small{font-size:13px;color:var(--muted)}
.pipe-legend .total{justify-content:flex-end;color:var(--muted);font-size:14px;padding-left:16px;border-left:1px solid var(--line)}

/* Graphique */
.row{display:grid;grid-template-columns:1fr 352px;gap:16px}
.legend{display:flex;gap:16px;font-size:13px;color:var(--muted)}
.legend span{display:flex;align-items:center;gap:8px}
.legend span::before{content:"";width:16px;height:3px;border-radius:2px;background:var(--laterite)}
.legend .lg-prev::before{background:repeating-linear-gradient(90deg,var(--muted) 0 4px,transparent 4px 7px)}
.chart{position:relative;height:296px}
.chart svg{display:block;width:100%;height:100%}
.chart .g{stroke:var(--line);stroke-dasharray:2 4}
.chart .ax{font:500 11px var(--f-num);fill:var(--muted)}
.chart .cur{fill:none;stroke:var(--laterite);stroke-width:3;stroke-linecap:round}
.chart .prev{fill:none;stroke:var(--muted);stroke-width:1.5;stroke-dasharray:4 4;opacity:.6}
.chart .hair{stroke:var(--brand);stroke-width:1;stroke-dasharray:3 3}
.chart .dot{fill:var(--surface);stroke:var(--laterite);stroke-width:3}
.tip{position:absolute;pointer-events:none;z-index:5;min-width:192px;padding:12px 16px;border-radius:12px;background:var(--fleuve-900);color:var(--sable);box-shadow:var(--shadow-2);display:flex;flex-direction:column;gap:2px;font-size:13px}
:root[data-theme="dark"] .tip{background:var(--sable);color:var(--encre)}
.tip small{color:#A8C1BA;font-size:12px}:root[data-theme="dark"] .tip small{color:var(--gris)}
.tip b{font-size:17px}
.tip em{font-style:normal;font-size:12px;font-weight:700;margin-top:4px}
.tip em.up{color:#7FE0AE}.tip em.dn{color:#F2A58F}
:root[data-theme="dark"] .tip em.up{color:#1E7A4F}:root[data-theme="dark"] .tip em.dn{color:#A9432C}

/* Encaissements */
.pay-card{display:flex;flex-direction:column}
.donut-wrap{position:relative;width:160px;height:160px;margin:0 auto 16px}
.donut{width:100%;height:100%;transform:rotate(-90deg)}
.donut circle{fill:none;stroke-width:14}
.d-bg{stroke:var(--surface-2)}.d-momo{stroke:var(--momo)}.d-airtel{stroke:var(--airtel)}.d-cash{stroke:var(--brand)}
.donut-c{position:absolute;inset:0;display:grid;place-content:center;text-align:center}
.donut-c b{font-size:28px;line-height:1}.donut-c small{font-size:12px;color:var(--muted)}
.pay-list{list-style:none;padding:0;display:flex;flex-direction:column;gap:4px}
.pay-list li{display:grid;grid-template-columns:1fr auto 48px;align-items:center;gap:8px;height:40px;font-size:14px}
.pay-list b{font-size:14px}.pay-list small{text-align:right;color:var(--muted);font-size:13px}
.pay-total{display:flex;justify-content:space-between;margin-top:auto;padding-top:16px;border-top:1px solid var(--line);font-size:14px;color:var(--muted)}
.pay-total b{color:var(--text)}

/* Tableau */
.filters{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.chip{display:inline-flex;align-items:center;gap:8px;height:36px;padding:0 14px;border-radius:var(--r-pill);font-size:14px;font-weight:500;box-shadow:inset 0 0 0 1px var(--line);transition:background .15s}
.chip span{font-size:12px;color:var(--muted)}
.chip:hover{background:var(--surface-2)}
.chip.on{background:var(--brand);color:var(--surface);box-shadow:none}
.chip.on span{color:inherit;opacity:.75}
:root[data-theme="dark"] .chip.on{background:var(--sable);color:var(--fleuve)}
.select{position:relative;display:inline-flex;align-items:center;gap:8px;height:36px;padding:0 12px;border-radius:var(--r-pill);box-shadow:inset 0 0 0 1px var(--line);color:var(--muted)}
.select .ico{width:16px;height:16px;color:var(--accent)}
.select select{border:0;background:none;outline:0;font-size:14px;font-weight:500;color:var(--text);cursor:pointer}
.select option{background:var(--surface);color:var(--text)}
.table-wrap{overflow-x:auto;margin:0 -24px}
table{width:100%;border-collapse:collapse;font-size:14px}
thead th{height:40px;padding:0 16px;text-align:left;font:700 12px var(--f-text);letter-spacing:.08em;text-transform:uppercase;color:var(--muted);background:var(--surface-2);border-block:1px solid var(--line);white-space:nowrap}
th:first-child,td:first-child{padding-left:24px}th:last-child,td:last-child{padding-right:16px}
tbody td{height:64px;padding:0 16px;border-bottom:1px solid var(--line);white-space:nowrap}
tbody tr{transition:background .15s}
tbody tr:hover{background:var(--surface-2)}
tbody tr:hover .id{color:var(--accent)}
.r{text-align:right}
.id{font-weight:700;color:var(--brand)}
.cust{display:flex;align-items:center;gap:12px;font-weight:500}
.av{display:grid;place-items:center;width:32px;height:32px;border-radius:50%;background:var(--sable-200);color:var(--fleuve);font:600 12px var(--f-title)}
:root[data-theme="dark"] .av{background:#1B403C;color:var(--sable)}
.city,.date{color:var(--muted)}
.amt{font-weight:700}
.amt::after{content:" FCFA";font-weight:400;color:var(--muted);font-size:12px}
table.is-empty{display:none}
.empty{display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px;padding:48px 24px 40px}
.empty-ico{width:64px;height:64px;color:var(--accent);stroke:currentColor;fill:none;margin-bottom:8px}
.empty b{font:600 18px var(--f-title);color:var(--brand)}
.empty p{color:var(--muted);font-size:14px;max-width:320px;margin-bottom:8px}
.t-foot{display:flex;justify-content:space-between;align-items:center;padding-top:16px;font-size:13px;color:var(--muted)}
.foot-note{text-align:center;font-size:12px;color:var(--muted)}

/* Bulle « version complète » */
.toast{position:absolute;z-index:50;display:flex;align-items:center;gap:8px;height:36px;padding:0 14px 0 10px;border-radius:var(--r-pill);background:var(--encre);color:var(--sable);font-size:13px;font-weight:500;box-shadow:var(--shadow-2);opacity:0;transform:translateY(-4px);transition:opacity .18s,transform .18s;pointer-events:none;white-space:nowrap}
.toast .ico{width:16px;height:16px;color:#E3876F}
.toast.show{opacity:1;transform:none}
:root[data-theme="dark"] .toast{background:var(--sable);color:var(--encre)}

/* ---------- Téléphone 390 px ---------- */
@media (max-width:900px){
  .app{grid-template-columns:1fr}
  .side{position:sticky;top:0;z-index:10;height:auto;flex-direction:row;align-items:center;padding:12px 16px;gap:8px}
  .side .logo{font-size:20px;padding:0}.side .logo svg{width:32px;height:32px}
  .menu,.side-card,.profile .who,.profile .icon-btn{display:none}
  .profile{margin-left:auto;padding:0;border:0}.profile .avatar{width:36px;height:36px}
  .main{padding:24px 16px 32px;gap:16px}
  .top{flex-direction:column;align-items:stretch}
  h1{font-size:26px}
  .top-tools{flex-wrap:wrap}
  .search{width:auto;flex:1;order:-1;flex-basis:100%}
  .btn-primary{flex:1;justify-content:center}
  .period{flex-wrap:wrap;gap:8px}
  .range em{display:none}
  .period .ghost-btn{display:none}
  .kpis{grid-template-columns:1fr 1fr;gap:8px}
  .hero-kpi{grid-column:1/-1}
  .kpi{padding:16px;gap:8px}
  .k-label{font-size:13px;gap:8px}.k-ico{width:28px;height:28px}
  .k-val{font-size:28px}
  .k-foot span+*,.k-foot{font-size:11px}
  .pipe-head{flex-direction:column;align-items:flex-start;gap:12px}
  .pipe-stats{gap:16px;flex-direction:column}
  .pipe-legend{grid-template-columns:1fr 1fr}
  .pipe-legend .total{justify-content:flex-start;border:0;padding:0}
  .row{grid-template-columns:1fr}
  .card{padding:16px;border-radius:var(--r-md)}
  .card-head{flex-direction:column}
  .chart{height:240px}
  .filters{justify-content:flex-start}
  .table-wrap{margin:0 -16px}
  th:first-child,td:first-child{padding-left:16px}
  .notif{width:calc(100vw - 32px);right:-104px}
}
/* Correctifs v2 */
.app{background:linear-gradient(90deg,var(--fleuve) 264px,transparent 264px)}
:root[data-theme="dark"] .app{background:linear-gradient(90deg,#06201E 264px,transparent 264px)}
.side{--mark-bg:#14524D}
.trend,.k-foot,h1,.btn-primary,.pipe-legend li{white-space:nowrap}
.search{width:280px}
.kpis{grid-template-columns:1.3fr 1fr 1fr 1fr}
.k-label{min-height:36px;white-space:nowrap}
.pipe-legend{grid-template-columns:auto auto auto 1fr;gap:32px}
.pipe-legend li{flex-wrap:nowrap}
@media (max-width:900px){.app{background:none}h1{white-space:normal}.pipe-legend{grid-template-columns:1fr;gap:12px}.k-label{white-space:normal}.k-foot{white-space:normal;flex-wrap:wrap;gap:4px}}
.pay i{width:32px}
:root[data-theme="dark"] .side{border-right:0}
/* Téléphone : corrections finales (après les règles v2) */
@media (max-width:900px){
  .main{overflow:hidden}
  .kpis{grid-template-columns:1fr 1fr}
  .kpis .kpi:last-child{grid-column:1/-1}
  .k-label{white-space:normal;min-height:0;align-items:flex-start}
  .pipe-legend li{flex-wrap:wrap}
  .pipe-stats p{flex-wrap:wrap}
  .t-foot{gap:16px}.t-foot .link{white-space:nowrap}
  .table-wrap{margin:0;overflow:visible}
  table thead{display:none}
  table,tbody{display:block}
  tbody tr{display:grid;grid-template-columns:1fr auto;gap:8px 12px;padding:16px 0;border-bottom:1px solid var(--line)}
  tbody td{display:block;height:auto;padding:0!important;border:0;white-space:normal}
  tbody tr:hover{background:none}
  td.id{grid-column:1}td:nth-child(6){grid-column:2;grid-row:1;justify-self:end}
  td:nth-child(2){grid-column:1/-1}
  td.city{grid-column:1}td.amt{grid-column:2;grid-row:3;text-align:right}
  td:nth-child(5){grid-column:1}td.date{grid-column:2;grid-row:4;text-align:right;font-size:13px}
  td:last-child{display:none}
}
