/* ── Cards / KPI ─────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}
.kpi-value {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
}
.kpi-delta.up   { background: rgba(74, 142, 90, 0.12); color: var(--success); }
.kpi-delta.down { background: rgba(176, 74, 62, 0.10); color: var(--danger); }
.kpi-delta.flat { background: var(--bg-elevated); color: var(--text-secondary); }
.kpi-delta::before {
  font-family: var(--font-body); font-size: 10px;
}
.kpi-delta.up::before   { content: '▲'; }
.kpi-delta.down::before { content: '▼'; }
.kpi-delta.flat::before { content: '◆'; }
.kpi-foot {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-style: italic;
}

/* ── Widget / Chart container ───────────────────────────── */
.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}
.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}
.widget-title {
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: 0.01em;
}
.widget-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.widget canvas { max-height: 300px; }

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 24px;
}
.grid-2  { grid-template-columns: 2fr 1fr; }
.grid-eq { grid-template-columns: 1fr 1fr; }
.grid-3  { grid-template-columns: 1fr 1fr 1fr; }
.grid-1  { grid-template-columns: 1fr; }
@media (max-width: 1000px) {
  .grid-2, .grid-eq, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Top list ───────────────────────────────────────────── */
.toplist { list-style: none; padding: 0; margin: 0; }
.toplist li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.toplist li:last-child { border-bottom: none; }
.toplist .tl-name {
  color: var(--text-primary);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-right: 12px;
}
.toplist .tl-bar {
  position: relative; flex: 1; height: 6px;
  background: var(--bg-elevated); border-radius: 3px; overflow: hidden;
  margin: 0 12px;
}
.toplist .tl-bar > span {
  display: block; height: 100%; background: var(--accent);
  border-radius: 3px;
}
.toplist .tl-count {
  font-weight: 600; color: var(--g); font-size: 13px;
  min-width: 50px; text-align: right;
}
.toplist .tl-pct {
  font-size: 11px; color: var(--text-secondary); margin-left: 6px;
}

/* ── Table ──────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead {
  background: var(--bg-elevated);
  text-align: left;
}
.table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 600; color: var(--text-secondary);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.table td {
  padding: 11px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.table tr:hover td { background: var(--bg-elevated); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-fr { background: var(--accent-soft); color: var(--accent); }
.badge-en { background: rgba(34,57,44,.08); color: var(--g); }
.badge-organic { background: rgba(74,142,90,.12); color: var(--success); }
.badge-direct { background: rgba(34,57,44,.08); color: var(--g); }
.badge-social { background: rgba(33,150,243,.12); color: #1976D2; }
.badge-paid { background: rgba(201,168,76,.18); color: var(--accent); }
.badge-referral { background: rgba(147,126,116,.18); color: var(--t); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  background: var(--g);
  color: var(--c);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--g-2); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent;
  color: var(--g);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-elevated); }
.btn-accent { background: var(--go); color: var(--g); }
.btn-accent:hover { background: var(--gl); }

/* Heatmap */
.heatmap {
  display: grid;
  grid-template-columns: 50px repeat(24, 1fr);
  gap: 2px;
  font-size: 10px;
  color: var(--text-secondary);
}
.heatmap .hm-day { padding: 4px 6px; text-align: right; font-weight: 600; }
.heatmap .hm-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--accent-soft);
}
.heatmap .hm-h {
  text-align: center;
  font-size: 9px;
}


/* ── Rapports : grid de cartes PDF + modal viewer ──────────────────── */
.pdf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.pdf-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.pdf-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.pdf-card:active { transform: translateY(1px); }
.pdf-card-icon {
  font-size: 26px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}
.pdf-card-body { min-width: 0; }
.pdf-card-title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-card-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.pdf-card-meta span:not(:last-child)::after {
  content: '·';
  margin-left: 10px;
  opacity: 0.5;
}
.pdf-card-cta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.pdf-empty {
  text-align: center;
  padding: 50px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
}
.pdf-empty-icon { font-size: 38px; opacity: .6; }
.pdf-empty-msg { line-height: 1.7; max-width: 460px; }
.pdf-empty code {
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

/* Modal */
.pdf-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(34, 57, 44, 0.72);
  z-index: 1000;
  display: flex;
  align-items: center; justify-content: center;
  padding: 24px;
  animation: pdf-fade .15s ease-out;
}
@keyframes pdf-fade { from { opacity: 0; } to { opacity: 1; } }

.pdf-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: min(1100px, 96vw);
  height: min(820px, 92vh);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.pdf-modal.is-fullscreen { width: 100vw; height: 100vh; border-radius: 0; }

.pdf-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.pdf-modal-title {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.pdf-modal-icon { font-size: 18px; }
.pdf-modal-name {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pdf-modal-actions { display: flex; gap: 4px; flex-shrink: 0; }

.pdf-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.pdf-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.pdf-btn-close:hover {
  background: rgba(176, 74, 62, 0.10);
  border-color: var(--danger);
  color: var(--danger);
}

.pdf-modal-body {
  flex: 1;
  overflow: hidden;
  background: #2a2a2a;
}
.pdf-modal-frame {
  width: 100%; height: 100%;
  border: 0;
  display: block;
}

@media (max-width: 700px) {
  .pdf-modal-backdrop { padding: 0; }
  .pdf-modal { width: 100vw; height: 100vh; border-radius: 0; }
  .pdf-modal-name { font-size: 14px; }
}
