/* ═══════════════════════════════════════════════════════════════════════
   Dashboard — KPIs, courbe d'acquisition, pipeline, jauge, sources, relances.
   Direction « Linear futuriste » (handoff 02-linear-dark). Tokens uniquement
   (css/index.css), aucun hex en dur hormis les glows portés du prototype.
   ═══════════════════════════════════════════════════════════════════════ */

.dash { display: flex; flex-direction: column; gap: 16px; }

.dash-loading { display: flex; align-items: center; justify-content: center; padding: 80px 0; }

/* ─── Bandeau KPIs (style Tremor / Vercel Analytics, net Linear) ─── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.kpi {
  position: relative; padding: 14px 15px 13px;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border);
  transition: border-color var(--t-base) var(--ease), background var(--t-base) var(--ease);
}
.kpi:hover { border-color: var(--border-hi); }
/* Bordure-énergie (masque dégradé), renforcée au survol */
.kpi::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--grad-soft); opacity: 0.35; pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  transition: opacity var(--t-base) var(--ease);
}
.kpi:hover::before { opacity: 0.75; }
.kpi .k-top { display: flex; align-items: center; gap: 7px; color: var(--text-muted); }
.kpi .k-ic { width: 15px; height: 15px; flex: none; opacity: 0.85; color: var(--accent); }
.kpi .k-ic svg { width: 15px; height: 15px; display: block; }
.kpi .k-label { font-size: 12px; font-weight: 500; letter-spacing: -0.005em; }
.kpi .k-val {
  font-size: 28px; line-height: 1.05; font-weight: 600;
  font-family: var(--font-mono); margin: 11px 0 9px;
  letter-spacing: -0.03em; font-feature-settings: "tnum";
  transition: text-shadow var(--t-base) var(--ease);
}
.kpi:hover .k-val { text-shadow: 0 0 20px color-mix(in srgb, var(--accent) 55%, transparent); }
.kpi .k-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); min-width: 0; }
.kpi .k-foot .ctx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Pill delta */
.delta {
  display: inline-flex; align-items: center; gap: 3px; height: 20px;
  padding: 0 7px 0 5px; border-radius: 5px; font-size: 11.5px; font-weight: 600;
  font-family: var(--font-mono); flex: none; letter-spacing: -0.01em;
}
.delta svg { width: 12px; height: 12px; }
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.down svg { transform: rotate(180deg); }
.delta.flat { color: var(--text-muted); background: var(--bg-hover); }

/* ─── Rangées dashboard ─── */
.dash-row { display: grid; gap: 10px; }
.dash-row.r2 { grid-template-columns: 1.7fr 1fr; }
.dash-row.r3 { grid-template-columns: 1fr 1fr 1.05fr; }

/* ─── Panneaux (verre) ─── */
.dash .panel {
  position: relative; padding: 15px 16px;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; min-width: 0;
}
.dash .panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.dash .panel-h .pt { display: flex; flex-direction: column; gap: 1px; }
.dash .panel-h h3 { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.dash .panel-h .psub { font-size: 11.5px; color: var(--text-dim); }
.panel-link {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
  display: inline-flex; align-items: center; gap: 3px; cursor: pointer;
  transition: color var(--t-fast) var(--ease);
}
.panel-link:hover { color: var(--accent); }
.panel-link svg { width: 13px; height: 13px; }
.panel-empty { color: var(--text-dim); font-size: 13px; padding: 18px 4px; text-align: center; flex: 1; display: flex; align-items: center; justify-content: center; }

/* HUD : bordure-énergie + brackets de coin */
.dash .panel.hud::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--grad-soft); opacity: 0.5; pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.hud .bk { position: absolute; width: 13px; height: 13px; pointer-events: none; opacity: 0.55; z-index: 1; }
.hud .bk.tl { top: 9px; left: 9px; border-top: 1.5px solid var(--accent); border-left: 1.5px solid var(--accent); }
.hud .bk.br { bottom: 9px; right: 9px; border-bottom: 1.5px solid var(--accent2); border-right: 1.5px solid var(--accent2); }

/* ─── Contrôle segmenté (12 / 6 sem.) ─── */
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--bg-hover); border-radius: 7px; border: 1px solid var(--border);
}
.seg button {
  height: 22px; padding: 0 9px; border: none; background: transparent;
  color: var(--text-muted); font-size: 11.5px; font-weight: 500;
  font-family: inherit; border-radius: 5px; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg button.on { background: var(--bg-surface); color: var(--text); box-shadow: var(--shadow); }

/* ─── Courbe d'aire (acquisition) ─── */
.area-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.area-chart { width: 100%; height: auto; display: block; overflow: visible; }
.area-chart .ax { fill: var(--text-dim); font-size: 9.5px; font-family: var(--font-mono); letter-spacing: -0.02em; }
.area-chart .gl { stroke: var(--border); stroke-width: 1; stroke-dasharray: 1 5; stroke-linecap: round; opacity: 0.7; }
.area-chart .ln {
  fill: none; stroke: url(#lnGrad); stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 6px 9px color-mix(in srgb, var(--accent) 18%, transparent));
}
.area-chart .pt-halo { fill: var(--accent); opacity: 0.16; }
.area-chart .pt-last { fill: var(--accent); stroke: var(--bg-surface); stroke-width: 3; }
.area-chart .guide { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 4; opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.area-chart .hdot { fill: var(--accent); stroke: var(--bg-surface); stroke-width: 3; opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.area-chart.show-hover .guide, .area-chart.show-hover .hdot { opacity: 1; }
.area-chart .hit { fill: transparent; cursor: pointer; }
.chart-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 13px));
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 7px 10px; pointer-events: none; opacity: 0;
  transition: opacity var(--t-fast) var(--ease); white-space: nowrap; z-index: 5; line-height: 1.3;
}
.chart-tip .tv { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--text); }
.chart-tip .tl { font-size: 11px; color: var(--text-muted); }
.chart-tip.on { opacity: 1; }

/* ─── Pipeline par étape ─── */
.stage-bar { display: flex; gap: 3px; height: 14px; width: 100%; margin-bottom: 16px; }
.stage-bar i {
  height: 100%; border-radius: 4px;
  background-image: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0));
  box-shadow: var(--shadow);
  transition: transform var(--t-fast) var(--ease-spring), filter var(--t-fast) var(--ease);
}
.stage-bar i:hover { transform: scaleY(1.2); filter: brightness(1.12); }
.stage-list { display: flex; flex-direction: column; gap: 1px; }
.stage-row {
  display: grid; grid-template-columns: 9px 1fr auto auto; align-items: center;
  gap: 9px; padding: 6px 5px; margin: 0 -5px; border-radius: var(--radius-sm);
  font-size: 13px; transition: background var(--t-fast) var(--ease);
}
.stage-row:hover { background: var(--bg-hover); }
.stage-row .sd { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.stage-row .sl { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-row .sc { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); text-align: right; }
.stage-row .sv { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); text-align: right; min-width: 62px; }
.stage-foot {
  margin-top: auto; padding-top: 13px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--text-muted);
}
.stage-foot b { font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }

/* ─── Jauge de conversion (donut) ─── */
.gauge-wrap { display: flex; align-items: center; gap: 16px; }
.gauge { position: relative; width: 108px; height: 108px; flex: none; }
.gauge svg { transform: rotate(-90deg); display: block; }
.gauge .gt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.gauge .gv { font-size: 23px; font-weight: 600; font-family: var(--font-mono); letter-spacing: -0.02em; }
.gauge .gl2 { font-size: 10px; color: var(--text-dim); }
.conv-meta { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 0; }
.conv-line { display: flex; align-items: center; gap: 8px; }
.conv-line .cdot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.conv-line .ct { font-size: 12.5px; color: var(--text-muted); flex: 1; }
.conv-line .cn { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

/* ─── Bar list (sources) ─── */
.barlist { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.barlist-row {
  position: relative; display: flex; align-items: center; height: 31px;
  padding: 0 11px; border-radius: var(--radius-sm); overflow: hidden;
  font-size: 13px; transition: background var(--t-fast) var(--ease);
}
.barlist-row:hover { background: var(--bg-hover); }
.barlist-row .fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 20%, transparent), var(--accent-soft));
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: width var(--t-base) var(--ease);
}
.barlist-row .bl-name { position: relative; z-index: 1; color: var(--text); font-weight: 450; }
.barlist-row .bl-val { position: relative; z-index: 1; margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

/* ─── Relances à venir (aperçu) ─── */
.rel-mini { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rel-mini-row {
  display: flex; align-items: center; gap: 11px; padding: 8px 6px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.rel-mini-row:hover { background: var(--bg-hover); }
.rel-when {
  width: 42px; height: 42px; flex: none; border-radius: var(--radius-sm);
  background: var(--bg-hover); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.rel-when .rw-d { font-size: 15px; font-weight: 600; font-family: var(--font-mono); }
.rel-when .rw-m { font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }
.rel-when.due { background: var(--warning-soft); border-color: transparent; }
.rel-when.due .rw-d, .rel-when.due .rw-m { color: var(--warning); }
.rel-mini-row .rm-main { flex: 1; min-width: 0; }
.rel-mini-row .rm-p { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-mini-row .rm-t { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-mini-row .rm-ch { font-size: 11px; color: var(--text-dim); flex: none; }

/* ─── État vide ─── */
.dash-empty { align-items: center; text-align: center; padding: 56px 24px; gap: 6px; }
.dash-empty-ill {
  width: 52px; height: 52px; margin-bottom: 8px; color: var(--accent);
  display: grid; place-items: center; border-radius: var(--radius-lg);
  background: var(--accent-soft);
}
.dash-empty-ill svg { width: 26px; height: 26px; }
.dash-empty h3 { font-size: 15px; font-weight: 600; }
.dash-empty p { font-size: 13px; color: var(--text-muted); max-width: 320px; }

/* ─── Responsive (3 → 2 → 1) ─── */
@media (max-width: 1100px) {
  .dash-row.r2, .dash-row.r3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row.r2, .dash-row.r3 { grid-template-columns: 1fr; }
  .gauge-wrap { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 460px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi .k-val { font-size: 24px; }
}

/* ─── Mouvement réduit : coupe les animations d'accent du dashboard ─── */
@media (prefers-reduced-motion: reduce) {
  .stage-bar i, .barlist-row .fill { transition: none !important; }
}
