/* Tableaux de bord : admin (admin.html) et commerçant (compte.html) */
.dash.page { padding-top: 28px; }
.dash h2 { font-size: 1.3rem; margin: 0 0 12px; }
.dash h2 .muted, .dash h3 .muted { font-weight: 500; font-size: .9rem; }
.dash h3 { margin: 0 0 14px; }
.dash section { padding: 0; }
.dash section.card { padding: 24px; }

.dash-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dash-toolbar-right { display: flex; gap: 8px; align-items: center; }
.dash-tabs { background: var(--surface); border: 1px solid var(--border); }
.dash-tabs button { padding: 8px 16px; white-space: nowrap; }
.dash-tabs button.active { background: var(--primary-soft); box-shadow: none; }
.dash-period { margin: 0; }
.dash-period button { padding: 8px 12px; white-space: nowrap; }
.btn-icon { padding: 9px 14px; font-size: 1.1rem; }
.dash-updated { margin: -8px 0 0; font-size: .85rem; }

/* Tuiles KPI */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 2px; align-content: start; }
.kpi .label { color: var(--muted); font-family: var(--font-mono); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.kpi .value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi.hero { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.kpi.hero .label, .kpi.hero .hint, .kpi.hero .delta { color: var(--on-ink); opacity: .9; }
.kpi .hint { color: var(--muted); font-size: .8rem; }
.delta { font-size: .8rem; font-weight: 700; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--muted); }

/* Graphique */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; }
.chart-controls { display: flex; gap: 14px; align-items: center; }
select { font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.chart-total { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.chart { position: relative; width: 100%; height: 240px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--primary); }
.chart .bar.dim { opacity: .45; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--on-ink);
  padding: 8px 12px; border-radius: 10px; font-size: .85rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); white-space: nowrap;
}
.chart-tooltip b { display: block; font-size: 1rem; }
.chart-table-wrap { max-height: 320px; overflow: auto; }

/* Barres horizontales (abonnements, catégories) */
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: .92rem; }
.hbar .track { height: 10px; background: var(--sunken); border-radius: 5px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .n { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.5em; text-align: right; }

.mini-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 12px; margin-top: 18px; }
.mini-kpis div { display: grid; }
.mini-kpis span { color: var(--muted); font-size: .82rem; font-weight: 600; }
.mini-kpis b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.dash-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* Tableaux */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .sub { display: block; color: var(--muted); font-size: .8rem; }
.empty { color: var(--muted); padding: 12px 0; margin: 0; }

.shops-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.shops-filters input { flex: 1 1 260px; padding: 10px 14px; }

/* Mobile : le tableau des commerces devient une liste de fiches */
@media (max-width: 720px) {
  .dash-toolbar, .dash-toolbar-right { width: 100%; }
  .dash-tabs { width: 100%; }
  .dash-period { flex: 1; }
  .dash-period button { flex: 1; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 1.35rem; }
  .dash-grid { grid-template-columns: 1fr; }
  .chart { height: 200px; }
  table.data.shops-table, table.data.shops-table tbody { display: block; }
  table.data.shops-table thead { display: none; }
  table.data.shops-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  table.data.shops-table tr:last-child { border-bottom: 0; }
  table.data.shops-table td { border: 0; padding: 0; white-space: normal; text-align: left; overflow-wrap: anywhere; }
  table.data.shops-table td:first-child { grid-column: 1 / -1; }
  table.data.shops-table td[data-label]::before { content: attr(data-label) ' : '; color: var(--muted); font-size: .8rem; }
}

/* Les éléments de grille ne doivent pas s'élargir à la taille des tableaux */
.dash .stack > *, .dash-grid > *, .kpis > * { min-width: 0; }
.dash .stack { grid-template-columns: minmax(0, 1fr); }
#logout { white-space: nowrap; }
@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi .hint { overflow-wrap: anywhere; }
}

/* Rétention par cohorte : une seule teinte, du clair au foncé */
.cohorts { border-collapse: separate; border-spacing: 2px; font-size: .85rem; width: 100%; }
.cohorts th { color: var(--muted); font-weight: 600; font-size: .78rem; padding: 4px 6px; text-align: center; white-space: nowrap; }
.cohorts th:first-child { text-align: left; }
.cohorts td { padding: 8px 6px; text-align: center; border-radius: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cohorts td.label { text-align: left; background: none; }
.cohorts td.label span { display: block; color: var(--muted); font-size: .75rem; }
.cohorts td.empty-cell { background: none; }
.legend-note { color: var(--muted); font-size: .82rem; margin: 10px 0 0; }

.risk-list { display: grid; gap: 0; }
.risk-list .row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: .92rem; }
.risk-list .row:first-child { border-top: 0; }
.risk-list .sub { display: block; color: var(--muted); font-size: .8rem; }

/* Espace pro : réseaux sociaux */
.social-list { display: grid; }
.social-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.social-row:first-child { border-top: 0; }
.social-row .sub { display: block; color: var(--muted); font-size: .85rem; }
.social-row .warn { color: var(--warning-text); }
@media (max-width: 720px) {
  .dash-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .dash-tabs button { flex: 0 0 auto; }
}

/* Onglet Erreurs : détail technique repliable */
.stack-trace { margin-top: 6px; border: 0; padding: 0; }
.stack-trace summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
.stack-trace pre { margin: 6px 0 0; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: .75rem; background: var(--sunken); border-radius: 8px; padding: 10px; }
