#theme-toggle {
  position: fixed; top: 10px; right: 16px; z-index: 1000;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 40px;
  background: var(--theme-sidebar); color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  font-family: 'Inter', sans-serif; font-size: 0.75rem; font-weight: 600;
  cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}
#theme-toggle:hover { transform: translateY(1px); box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
#theme-toggle svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#theme-panel {
  position: fixed; top: 48px; right: 16px; z-index: 999;
  background: #fff; border: 1px solid #e8e8ed;
  border-radius: 16px; padding: 0;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  width: 320px; overflow: hidden;
  display: none; animation: slideUp 0.2s ease;
}
#theme-panel.open { display: block; }
@keyframes slideUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

.tp-head {
  padding: 14px 16px; border-bottom: 1px solid #e8e8ed;
  display: flex; align-items: center; justify-content: space-between;
}
.tp-head h4 { font-family:'Inter',sans-serif; font-size:0.8rem; font-weight:700; color:#0d0f1a; }
.tp-head button { background:none; border:none; cursor:pointer; color:#7c8098; font-size:1rem; padding:2px 6px; border-radius:5px; }
.tp-head button:hover { background:#f8f8f9; }

.tp-themes { padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.theme-card {
  border: 2px solid #e8e8ed; border-radius: 10px;
  overflow: hidden; cursor: pointer; transition: all 0.15s;
}
.theme-card:hover { border-color: #b0b3c6; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.theme-card.active { border-color: var(--theme-accent); box-shadow: 0 0 0 3px var(--theme-accent-light); }

.tc-preview {
  height: 54px; display: flex; overflow: hidden;
}
.tc-sidebar { width: 28%; display: flex; flex-direction:column; padding: 4px; gap: 3px; }
.tc-sidebar-dot { height: 3px; border-radius: 2px; background: rgba(255,255,255,0.25); }
.tc-sidebar-dot.active { background: rgba(255,255,255,0.7); }
.tc-content { flex:1; padding: 4px; display: flex; flex-direction: column; gap: 3px; }
.tc-bar { height: 3px; border-radius: 2px; }
.tc-bar.w-full { width: 100%; }
.tc-bar.w-half { width: 55%; }
.tc-bar.accent { opacity: 0.9; }

.tc-label {
  padding: 6px 8px;
  font-family: 'Inter', sans-serif; font-size: 0.68rem; font-weight: 600;
  color: #3a3d52; background: #f8f8f9; border-top: 1px solid #e8e8ed;
}

.tp-divider { height: 1px; background: #e8e8ed; margin: 0 12px; }
.tp-footer { padding: 10px 12px; display: flex; gap: 8px; }
.tp-footer button {
  flex:1; padding: 7px; border-radius: 8px;
  font-family:'Inter',sans-serif; font-size:0.73rem; font-weight:600;
  cursor:pointer; transition: all 0.15s;
}
.btn-apply { background: var(--theme-accent); color:#fff; border:none; }
.btn-apply:hover { opacity: 0.88; }
.btn-reset { background: #f8f8f9; color:#3a3d52; border:1px solid #e8e8ed; }
.btn-reset:hover { border-color:#d0d0da; }

/* ══════════════════════════════════════════════════════════════════════
   Onglet Statistiques
   ══════════════════════════════════════════════════════════════════════ */

.stats-wrap { padding: 24px 28px 40px; max-width: 1400px; margin: 0 auto; }

.stats-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 22px;
}
.stats-scope-note { font-size: 0.8rem; color: var(--ink3); font-weight: 500; }
.stats-toolbar-right { display: flex; align-items: center; gap: 10px; }
#stats-period, #stats-soc {
  padding: 7px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  font-size: 0.8rem; font-family: inherit; font-weight: 600; color: var(--ink2);
  background: var(--white); cursor: pointer; outline: none;
  transition: border-color .15s;
}
#stats-period:hover, #stats-period:focus,
#stats-soc:hover, #stats-soc:focus { border-color: var(--theme-accent); }

.stats-empty, .stats-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; text-align: center; color: var(--ink3);
}
.stats-empty-icon { font-size: 2.6rem; margin-bottom: 12px; opacity: .6; }
.stats-empty h3 { color: var(--ink2); font-size: 1.05rem; margin-bottom: 6px; }
.stats-empty p { font-size: 0.85rem; max-width: 340px; }

.stats-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--theme-accent-light); border-top-color: var(--theme-accent);
  animation: stats-spin 0.8s linear infinite; margin-bottom: 14px;
}
@keyframes stats-spin { to { transform: rotate(360deg); } }

/* KPI cards */
.stats-kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stats-kpi-card {
  background: var(--white); border-radius: var(--r); padding: 18px 20px;
  border: 1px solid var(--border); position: relative; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: transform .15s, box-shadow .15s;
}
.stats-kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.stats-kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stats-kpi-teal::before   { background: var(--theme-accent); }
.stats-kpi-gold::before   { background: var(--gold); }
.stats-kpi-violet::before { background: var(--violet); }
.stats-kpi-red::before    { background: var(--red); }
.stats-kpi-green::before  { background: var(--green); }

.stats-kpi-icon { font-size: 1.3rem; margin-bottom: 8px; opacity: .85; }
.stats-kpi-value {
  font-family: 'JetBrains Mono', monospace; font-size: 1.65rem; font-weight: 700;
  color: var(--ink); line-height: 1.1; margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.stats-kpi-label { font-size: 0.74rem; color: var(--ink3); font-weight: 600; letter-spacing: .01em; }

/* Charts grid */
.stats-charts-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.stats-chart-card {
  background: var(--white); border-radius: var(--r); padding: 18px 20px;
  border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stats-chart-wide { grid-column: 1 / -1; }
.stats-chart-title {
  font-size: 0.85rem; font-weight: 700; color: var(--ink2); margin-bottom: 14px;
}
.stats-chart-canvas-wrap { position: relative; width: 100%; }

@media (max-width: 900px) {
  .stats-charts-grid { grid-template-columns: 1fr; }
  .stats-chart-wide { grid-column: auto; }
}

/* Bouton suppression de document (visible admin uniquement, voir 05_gemini_save.js) */
.btn-delete-doc {
  padding: 8px 16px; border-radius: var(--r-sm); border: 1.5px solid var(--red);
  background: var(--red-light); color: var(--red); font-size: 0.82rem; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
.btn-delete-doc:hover { background: var(--red); color: #fff; }

/* ══ VUE APERÇUS ══════════════════════════════════════════════ */
.ap-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 14px; margin-bottom: 14px;
  position: sticky; top: 72px; z-index: 5;
}
.ap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-chip {
  border: 1.5px solid var(--border); background: var(--white); color: var(--ink2);
  border-radius: 20px; padding: 5px 12px; font: 600 0.78rem 'Inter', sans-serif; cursor: pointer;
}
.ap-chip span { opacity: .6; font-weight: 500; margin-left: 2px; }
.ap-chip:hover { border-color: var(--theme-accent); }
.ap-chip.active { background: var(--theme-accent); border-color: var(--theme-accent); color: #fff; }
#ap-search {
  flex: 1; min-width: 180px; padding: 7px 12px; border: 1.5px solid var(--border);
  border-radius: 20px; font: 0.82rem 'Inter', sans-serif; outline: none;
}
#ap-search:focus { border-color: var(--theme-accent); box-shadow: 0 0 0 3px var(--teal-light); }
.ap-size { display: inline-flex; border: 1.5px solid var(--border); border-radius: 20px; overflow: hidden; }
.ap-size button { border: none; background: var(--white); padding: 5px 10px; font: 700 0.72rem 'Inter', sans-serif; cursor: pointer; color: var(--ink3); }
.ap-size button.active { background: var(--theme-accent); color: #fff; }
#ap-count { font-size: 0.78rem; color: var(--ink3); white-space: nowrap; }
.ap-grid {
  --ap-w: 210px;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(var(--ap-w), 1fr));
}
.ap-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column;
}
.ap-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); border-color: var(--theme-accent); }
.ap-thumb { position: relative; aspect-ratio: 1 / 1.414; background: #eceae4; overflow: hidden; }
.ap-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; opacity: 0; transition: opacity .25s; }
.ap-thumb img.ok { opacity: 1; }
.ap-ph { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; color: var(--ink3); }
.ap-meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 3px; border-top: 1px solid var(--border); }
.ap-title { font-weight: 700; font-size: 0.8rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-sub { font-size: 0.72rem; color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-badge .badge { font-size: 0.65rem; }
#ap-more { text-align: center; margin: 18px 0 8px; }
.ap-more-btn {
  border: 1.5px solid var(--theme-accent); color: var(--theme-accent); background: var(--white);
  border-radius: 20px; padding: 8px 20px; font: 700 0.8rem 'Inter', sans-serif; cursor: pointer;
}
.ap-more-btn:hover { background: var(--theme-accent); color: #fff; }
