#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; }


/* ══ GALERIE ═══════════════════════════════════════════════ */
#view-galerie { padding: 16px 20px 40px; }
.gal-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 0 14px; background: var(--paper);
}
.gal-select, .gal-search {
  border: 1.5px solid var(--border); border-radius: var(--r-sm); padding: 7px 10px;
  font-family: 'Inter', sans-serif; font-size: 0.85rem; background: var(--white); color: var(--ink); outline: none;
}
.gal-search { flex: 1; min-width: 220px; max-width: 420px; }
.gal-select:focus, .gal-search:focus { border-color: var(--theme-accent); }
.gal-nb { font-size: 0.8rem; color: var(--ink3); font-weight: 600; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.gal-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  transition: transform .12s, box-shadow .12s, border-color .12s; outline: none;
}
.gal-card:hover, .gal-card:focus { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); border-color: var(--theme-accent); }
.gal-thumb {
  aspect-ratio: 1 / 1.414; background: #eceae4; display: flex; align-items: center; justify-content: center;
  overflow: hidden; border-bottom: 1px solid var(--border);
}
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.gal-load { width: 22px; height: 22px; border: 2px solid rgba(0,0,0,0.12); border-top-color: var(--theme-accent); border-radius: 50%; animation: spin .8s linear infinite; }
.gal-noimg { font-size: 0.75rem; color: var(--ink3); text-align: center; padding: 10px; }
.gal-info { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.gal-fourn { font-size: 0.8rem; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-meta { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--ink3); }
.gal-meta strong { color: var(--ink); }
.gal-statut .badge { font-size: 0.66rem; }
.gal-vide { grid-column: 1 / -1; text-align: center; color: var(--ink3); padding: 40px; font-size: 0.9rem; }
#gal-sentinel { grid-column: 1 / -1; height: 1px; }
