/* ─────────────────────────────────────────────────────────────
   Statistiques communautaires ANEF — Styles communs (mobile-first)
   Tailwind CDN handles: body, header, nav, footer, container, loading
   This file handles: components created by JS (pills, cards, tables…)
   ───────────────────────────────────────────────────────────── */

/* ─── CSS Variables (shared with Tailwind config) ──────────── */

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: #334155;
  --primary: #3b82f6;
  --primary-light: #60a5fa;
  --green: #10b981;
  --orange: #f59e0b;
  --violet: #8b5cf6;
  --red: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

html { scroll-behavior: smooth; }

/* ─── Nav active state (desktop top + mobile bottom) ───────── */

.nav-link { text-decoration: none; transition: color 0.15s; }
.nav-link.active {
  color: var(--primary-light) !important;
  border-bottom-color: var(--primary) !important;
}

/* ─── Mobile bottom nav enhancements ──────────────────────── */
@media (max-width: 767px) {
  .mobile-nav-bar { height: 3.5rem; }
  .mobile-nav-bar .nav-link {
    position: relative;
    border-top: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
  }
  .mobile-nav-bar .nav-link.active {
    border-bottom-color: transparent !important;
    border-top-color: var(--primary) !important;
    background: rgba(59,130,246,0.08);
  }
}

/* ─── Filter Bar ─── mobile: stacked ──────────────────────── */

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  margin-bottom: 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-pills { display: flex; gap: 4px; flex-wrap: wrap; }

.pill {
  padding: 0.4rem 0.8rem;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.pill:hover {
  border-color: var(--pill-color, var(--primary));
  color: var(--text);
}
.pill.active {
  background: var(--pill-color, var(--primary));
  border-color: var(--pill-color, var(--primary));
  color: #fff;
}

.sdanf-statut-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.sdanf-pill {
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 26px;
  border-radius: 13px;
  letter-spacing: 0.01em;
}
.sdanf-pill:not(.active) {
  border-color: color-mix(in srgb, var(--pill-color, var(--border)) 50%, transparent);
  color: var(--pill-color, var(--text-muted));
}
.sdanf-pill:not(.active):hover {
  background: color-mix(in srgb, var(--pill-color, var(--primary)) 12%, transparent);
}
.sdanf-pill .pill-short { display: none; }

.filter-bar select,
.filter-group select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.filter-bar select:hover,
.filter-group select:hover { border-color: var(--primary); }

.filter-count {
  align-self: flex-end;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.filter-bar input[type="text"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  width: 100%;
  flex: 1;
}
.filter-bar input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

/* ─── Slider ───────────────────────────────────────────────── */

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  flex: 1;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}
.slider-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 1.5rem;
  text-align: center;
}

/* ─── KPI Cards ─── mobile: 2 columns ─────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.9rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.kpi-card:hover { border-color: var(--primary); }

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--primary-light); }
.kpi-value.green  { color: var(--green); }
.kpi-value.orange { color: var(--orange); }
.kpi-value.violet { color: var(--violet); }
.kpi-value.red    { color: var(--red); }

.kpi-sub { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.25rem; }

/* ─── Data freshness indicator ─── */
.kpi-timer-card { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.kpi-freshness {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.2rem;
}
.freshness-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  transition: background 0.8s, box-shadow 0.8s;
  flex-shrink: 0;
}
.freshness-dot.warn {
  background: var(--orange);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}
.freshness-dot.stale {
  background: var(--red);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}
.freshness-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green);
  transition: color 0.8s;
}
.freshness-text.warn { color: var(--orange); }
.freshness-text.stale { color: var(--red); }

/* Tooltip on timer card */
.kpi-timer-card { position: relative; }
.kpi-timer-card .timer-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  width: max-content;
  max-width: 260px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-muted);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 50;
  pointer-events: none;
}
.kpi-timer-card .timer-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--primary);
}
@media (hover: hover) {
  .kpi-timer-card:hover .timer-tooltip { display: block; }
}
@media (hover: none) {
  .kpi-timer-card .timer-tooltip { display: none !important; }
}

/* ─── Cron history modal ─── */
.cron-run-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.cron-run-item:last-child { border-bottom: none; }
.cron-run-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.cron-run-dot.success { background: var(--green); box-shadow: 0 0 6px rgba(16,185,129,0.4); }
.cron-run-dot.failure { background: var(--red); box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.cron-run-dot.cancelled { background: var(--orange); box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.cron-run-dot.in_progress { background: var(--primary); box-shadow: 0 0 6px rgba(59,130,246,0.4); }
.cron-run-date { color: var(--text); font-weight: 600; min-width: 110px; }
.cron-run-ago { color: var(--text-dim); flex: 1; }
.cron-run-duration { color: var(--text-muted); font-size: 0.75rem; }
.cron-run-trigger { color: var(--text-dim); font-size: 0.72rem; font-style: italic; }

.kpi-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.kpi-bar-item strong {
  color: var(--primary-light);
  font-weight: 700;
  font-size: 0.95rem;
}
.kpi-bar-item strong.green  { color: var(--green); }
.kpi-bar-item strong.orange { color: var(--orange); }
.kpi-bar-item strong.violet { color: var(--violet); }

/* ─── Section ──────────────────────────────────────────────── */

.section { margin-top: 1.5rem; }
.section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}
.chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.chart-stat {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  flex: 1 1 0;
  min-width: 100px;
  text-align: center;
}
.chart-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}
.chart-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

/* ─── Dossier Toolbar ─── mobile: stacked ──────────────────── */

.dossier-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.dossier-count { font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }

.toolbar-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; width: 100%; align-items: center; }
.toolbar-controls select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.toolbar-controls select:hover { border-color: var(--primary); }

.toggle-filter {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  user-select: none;
  flex-shrink: 0;
}
.toggle-filter:hover { border-color: var(--primary); color: var(--text-muted); }
.toggle-filter input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px; height: 14px;
  margin: 0; cursor: pointer;
}
.toggle-filter.active {
  border-color: var(--primary);
  background: rgba(59,130,246,0.12);
  color: var(--primary-light);
}

.pagination { display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.btn-page {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-page:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-page:not(:disabled):hover { border-color: var(--primary); color: var(--text); }
#page-info, .page-info { font-size: 0.8rem; color: var(--text-dim); min-width: 2.5rem; text-align: center; }

/* ─── Dossier History Timeline ──────────────────────────── */

.history-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
  transition: border-color 0.2s;
}
.history-row:hover { border-color: var(--primary); }

.history-row-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  user-select: none;
}
.history-row-header .chevron {
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.history-row.open .history-row-header .chevron { transform: rotate(90deg); }

.history-row-summary {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
}
.history-row-summary .dossier-row-hash { font-size: 0.8rem; }
.history-row-summary .statut-code { font-size: 0.7rem; }
.history-row-summary .history-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.history-snap-count {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  background: rgba(59,130,246,0.15);
  color: var(--primary-light);
  flex-shrink: 0;
}

.history-timeline {
  display: none;
  padding: 0 0.85rem 0.85rem;
}
.history-row.open .history-timeline { display: block; }

.timeline-step {
  display: flex;
  gap: 0.6rem;
  padding: 0.45rem 0;
  position: relative;
}
.timeline-step:not(:last-child) { border-bottom: none; }

.timeline-dot-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 14px;
  flex-shrink: 0;
  padding-top: 0.2rem;
}
.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--bg-card);
}
.timeline-line {
  flex: 1;
  width: 2px;
  background: var(--border);
  margin-top: 0.2rem;
  min-height: 12px;
}

.timeline-content { flex: 1; min-width: 0; }
.timeline-content .ts-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.timeline-content .ts-expl {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.timeline-content .ts-date {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}
.timeline-content .ts-duration {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.08rem 0.4rem;
  border-radius: 4px;
  margin-top: 0.15rem;
}

/* ─── Dossier Cards ─── mobile: 1 column ──────────────────── */

.dossier-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.dossier-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--card-accent, var(--primary));
  box-shadow: var(--shadow);
  transition: border-color 0.2s, transform 0.15s;
}
.dossier-card:hover { border-color: var(--card-accent, var(--primary)); transform: translateY(-2px); }

.dossier-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.65rem; }
.dossier-hash { font-family: monospace; font-size: 0.85rem; color: var(--text-muted); }
.dossier-step-badge { font-size: 0.78rem; font-weight: 700; color: #fff; padding: 0.15rem 0.55rem; border-radius: 10px; }

.badge-percentile {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.3rem;
}
.badge-percentile.fast { color: var(--green); background: rgba(16,185,129,0.15); }
.badge-percentile.normal { color: var(--orange); background: rgba(245,158,11,0.15); }
.badge-percentile.slow { color: var(--red); background: rgba(239,68,68,0.15); }

/* Progress Bar */
.dossier-progress { margin-bottom: 0.65rem; }
.progress-track { display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; margin-bottom: 0.3rem; }
.progress-seg { flex: 1; background: rgba(255,255,255,0.08); transition: background 0.3s; }
.progress-seg.completed { background: var(--seg-color); opacity: 0.7; }
.progress-seg.active { background: var(--seg-color); animation: pulse-seg 2s ease-in-out infinite; }
@keyframes pulse-seg { 0%,100%{opacity:1} 50%{opacity:0.6} }

.progress-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.progress-label code { font-size: 0.78rem; color: var(--text); background: rgba(0,0,0,0.2); padding: 0.1rem 0.35rem; border-radius: 3px; }
.phase-hint { font-size: 0.78rem; color: var(--text-dim); }

/* Durations */
.dossier-durations { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.65rem; padding: 0.45rem 0.7rem; background: rgba(0,0,0,0.15); border-radius: 8px; }
.duration-item { display: flex; flex-direction: column; }
.duration-label { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.duration-value { font-size: 0.92rem; font-weight: 600; color: var(--text); }

/* Info */
.dossier-info { display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 0.45rem; }
.dossier-info-item { display: flex; justify-content: space-between; font-size: 0.82rem; }
.info-label { color: var(--text-dim); }
.info-value { color: var(--text-muted); }

/* Footer / badges */
.dossier-footer { margin-bottom: 0.45rem; }
.badge-complement { font-size: 0.7rem; color: var(--orange); background: rgba(245,158,11,0.15); padding: 0.12rem 0.4rem; border-radius: 4px; }

/* Mini Timeline */
.dossier-mini-timeline { display: flex; gap: 4px; flex-wrap: wrap; }
.step-dot { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; color: #fff; }
.step-dot.current { outline: 2px solid var(--text); outline-offset: 1px; }

/* ─── Global Timeline (metro) ──────────────────────────────── */

.timeline-wrapper {
  overflow-x: auto; padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch; position: relative;
}
.timeline-wrapper::-webkit-scrollbar { height: 6px; }
.timeline-wrapper::-webkit-scrollbar-track { background: var(--bg-card); border-radius: 3px; }
.timeline-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.timeline-wrapper::-webkit-scrollbar-thumb:hover { background: var(--primary); }
.timeline-wrapper { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg-card); }

.global-timeline { display: flex; position: relative; min-width: 900px; padding: 1.5rem 0 0.75rem; gap: 4px; }
.global-timeline::before { content:''; position:absolute; top:calc(1.5rem + 9px); left:20px; right:20px; height:3px; background: linear-gradient(to right, #6b7280 0%, #3b82f6 20%, #8b5cf6 50%, #f59e0b 75%, #10b981 100%); opacity:0.3; z-index:0; border-radius: 2px; }
.timeline-station { flex:1; display:flex; flex-direction:column; align-items:center; position:relative; z-index:1; min-width:68px; padding:0 2px; }
.station-dot { width:18px; height:18px; border-radius:50%; background:var(--bg); border:3px solid var(--border); margin-bottom:0.5rem; transition:all 0.3s; }
.timeline-station.active .station-dot { border-color:var(--dot-color,var(--primary)); background:var(--dot-color,var(--primary)); box-shadow:0 0 10px color-mix(in srgb, var(--dot-color,var(--primary)) 60%, transparent); }
.station-number { font-size:0.7rem; font-weight:700; color:var(--text-dim); }
.timeline-station.active .station-number { color:var(--text); }
.station-name { font-size:0.6rem; color:var(--text-dim); text-align:center; max-width:65px; line-height:1.2; }
.timeline-station.active .station-name { color:var(--text-muted); }
.station-sub-bubbles { display:flex; flex-direction:column; align-items:center; gap:3px; margin-top:0.4rem; }
.station-sub-bubble {
  display:flex; align-items:center; gap:0.3rem;
  font-size:0.62rem; font-weight:600; color:#fff;
  padding:0.2rem 0.5rem; border-radius:10px; cursor:pointer;
  white-space:nowrap;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.station-sub-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  filter: brightness(1.2);
}
.station-sub-bubble:focus { outline: none; }
.station-sub-label { opacity:0.85; font-weight:500; }
.station-sub-count { font-weight:700; }

/* Mobile overrides */
@media (max-width: 767px) {
  .station-sub-bubble { padding: 0.1rem 0.3rem; font-size: 0.55rem; gap: 0.15rem; max-width: 74px; }
  .station-sub-label { max-width: 5em; overflow: hidden; text-overflow: ellipsis; }
  .station-sub-count { font-size: 0.6rem; flex-shrink: 0; }
  .station-sub-bubbles { gap: 2px; }
  .timeline-station { min-width: 74px; padding: 0 4px; }
  .global-timeline { min-width: 950px; gap: 4px; }
  .station-sub-bubble:focus {
    max-width: none; z-index: 10;
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(0,0,0,0.5);
    filter: brightness(1.15);
  }
  .station-sub-bubble:focus .station-sub-label { max-width: none; }
}
@media (min-width: 768px) {
  .global-timeline { min-width: 800px; padding: 2rem 0 1rem; }
  .global-timeline::before { top: calc(2rem + 10px); }
  .station-dot { width: 22px; height: 22px; }
  .station-name { max-width: 80px; font-size: 0.65rem; }
}

/* ─── Charts ───────────────────────────────────────────────── */

.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.chart-container canvas { max-height: 340px; }
.chart-container--tall canvas { max-height: none; }
.chart-container h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.75rem; }
.chart-subtitle { font-size: 0.82rem; color: var(--text-dim); margin: -0.5rem 0 1rem; }

/* ─── Collapsible chart section ──────────────────────────── */

.chart-details { width: 100%; }
.chart-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.chart-details summary::-webkit-details-marker { display: none; }
.chart-details summary::before {
  content: '\25B6';
  font-size: 0.7rem;
  color: var(--text-dim);
  transition: transform 0.2s;
}
.chart-details[open] summary::before { transform: rotate(90deg); }
.chart-details .inline-heading {
  font-size: inherit;
  margin: 0;
  display: inline;
}
.chart-details .details-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.chart-details[open] .details-hint { display: none; }

.chart-container select {
  width: 100%;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.charts-row { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }

/* ─── Tabs ─────────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  padding: 0.75rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text-muted); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Tables ───────────────────────────────────────────────── */

.table-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-container.no-top-radius { border-radius: 0 0 var(--radius) var(--radius); border-top: none; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th { text-align: left; padding: 0.6rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; cursor: default; font-size: 0.8rem; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--primary-light); }
thead th.sort-asc::after { content: ' \25B2'; font-size: 0.7em; }
thead th.sort-desc::after { content: ' \25BC'; font-size: 0.7em; }
tbody td { padding: 0.6rem; border-bottom: 1px solid var(--border); }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
tbody tr:hover { background: var(--bg-card-hover); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Percentile table: compact, evenly-spaced duration columns */
.percentile-table { table-layout: fixed; }
.percentile-table th:nth-child(1) { width: 36%; }
.percentile-table th:nth-child(2),
.percentile-table th:nth-child(3),
.percentile-table th:nth-child(4) { width: 18%; text-align: right; }
.percentile-table th:nth-child(5) { width: 10%; text-align: right; }

/* ─── Summary Cards ────────────────────────────────────────── */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.85rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.summary-card .sc-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.summary-card .sc-value { font-size: 1.4rem; font-weight: 700; margin: 0.2rem 0; }
.summary-card .sc-sub { font-size: 0.78rem; color: var(--text-dim); }

/* ─── Activity Feed ────────────────────────────────────────── */

.activity-feed { list-style: none; padding: 0; }
.activity-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.4rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  grid-row: 1;
  grid-column: 1;
}
.activity-hash { font-family: monospace; color: var(--text-muted); font-size: 0.8rem; grid-row: 1; grid-column: 2; }
.activity-time { font-size: 0.72rem; color: var(--text-dim); white-space: nowrap; grid-row: 1; grid-column: 3; }
.activity-text { color: var(--text-dim); font-size: 0.8rem; grid-row: 2; grid-column: 2 / -1; line-height: 1.35; }
.activity-duration {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--orange);
  background: rgba(245,158,11,0.12);
  padding: 0.08rem 0.4rem;
  border-radius: 4px;
  margin: 0 0.2rem;
}
.activity-time { margin-left: auto; font-size: 0.78rem; color: var(--text-dim); white-space: nowrap; order: 2; }
.badge-type {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.badge-type-new {
  color: #10b981;
  background: rgba(16,185,129,0.15);
}
.badge-type-step {
  color: #3b82f6;
  background: rgba(59,130,246,0.15);
}
.badge-type-progress {
  color: #8b5cf6;
  background: rgba(139,92,246,0.15);
}

/* ─── Statut code (raw API value) ─────────────────────────── */
.statut-code {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: 'Courier New', Courier, monospace;
  background: rgba(255,255,255,0.05);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.06);
}
@media (max-width: 767px) {
  .statut-code { font-size: 0.58rem; padding: 0.05rem 0.25rem; }
}
.statut-code-arrow {
  color: var(--primary-light);
  font-weight: 700;
  padding: 0 0.15rem;
}

/* ─── Mouvements du jour ──────────────────────────────────── */

.mouvements-period { margin-bottom: 0.75rem; }

.mouvements-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mouvement-notif {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
}
.mouvement-notif.mouvement-primary { border-left-color: var(--primary); }
.mouvement-notif.mouvement-green   { border-left-color: var(--green); }
.mouvement-notif.mouvement-violet  { border-left-color: var(--violet); }
.mouvement-notif.mouvement-warning { border-left-color: var(--orange); }

.mouvement-notif-count {
  font-weight: 700;
}
.mouvement-primary .mouvement-notif-count { color: var(--primary-light); }
.mouvement-green .mouvement-notif-count   { color: var(--green); }
.mouvement-violet .mouvement-notif-count  { color: var(--violet); }
.mouvement-warning .mouvement-notif-count { color: var(--orange); }

.mouvement-notif-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.mouvement-clickable {
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  justify-content: space-between;
}
.mouvement-clickable:hover {
  background: rgba(255,255,255,0.06);
  transform: translateX(2px);
}
.mouvement-chevron {
  font-size: 1.2rem;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.mouvement-clickable:hover .mouvement-chevron {
  transform: translateX(3px);
  color: var(--text-muted);
}

.mouvement-dossier-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.mouvement-dossier-item:hover {
  background: rgba(255,255,255,0.05);
}
.mouvement-dossier-item + .mouvement-dossier-item {
  border-top: 1px solid var(--border);
}
.mouvement-dossier-content {
  flex: 1;
  min-width: 0;
}
.mouvement-dossier-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.mouvement-dossier-desc {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.15rem;
}
.mouvement-dossier-detail {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.mouvement-dossier-date {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}
.mouvement-dossier-list {
  display: flex;
  flex-direction: column;
}

.mouvements-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 1rem 0;
}

/* ─── CAE Passages ─────────────────────────────────────────── */

.cae-today-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.88rem;
  font-weight: 600;
}
.cae-today-banner.has-passages {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--green);
}
.cae-today-banner.no-passages {
  background: rgba(100, 116, 139, 0.1);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.cae-today-banner .cae-count { font-size: 1.25rem; font-weight: 700; }

.cae-date-group {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.65rem 0 0.3rem;
  border-bottom: 1px solid var(--border);
  margin-top: 0.5rem;
}
.cae-date-group:first-child { margin-top: 0; }

/* ─── Activity clickable ──────────────────────────────────── */
.activity-clickable { cursor: pointer; }
.activity-clickable:hover { background: rgba(255,255,255,0.04); }

/* ─── Dossier History Modal ──────────────────────────────── */
.history-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.history-modal-overlay.open { display: flex; }

.history-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}
@media (max-width: 767px) {
  .history-modal-overlay { padding: 0.5rem; }
  .history-modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 10px;
  }
  .history-modal-header { padding: 0.7rem 0.85rem; }
  .history-modal-header h3 { font-size: 0.88rem; }
  .modal-history-list { padding: 0.6rem 0.85rem; }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.history-modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}
.history-back {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--primary-light);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.history-back:hover { background: rgba(59,130,246,0.15); border-color: var(--primary); color: var(--primary-light); }
.history-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}
.history-close:hover { color: var(--text); }

.modal-history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

.history-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 0 0.75rem;
  position: relative;
  padding-bottom: 0.75rem;
}
.history-item:last-child { padding-bottom: 0; }
.history-item:last-child .history-connector { display: none; }

.history-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  grid-row: 1;
  grid-column: 1;
  z-index: 1;
}
.history-connector {
  position: absolute;
  left: 4px;
  top: 16px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.history-content {
  grid-row: 1;
  grid-column: 2;
  min-width: 0;
}
.history-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}
.history-date {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-left: auto;
}
.history-duration {
  font-size: 0.7rem;
  color: var(--orange);
  background: rgba(245,158,11,0.12);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
}
.history-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.history-detail {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.history-time-on-status {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}
.history-time-on-status.current {
  color: var(--primary-light);
  background: rgba(59,130,246,0.1);
  border-color: rgba(59,130,246,0.2);
}

/* ─── Dossier Detail Info (in history modal) ──────────────── */

.dossier-detail-info {
  padding: 0.6rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.detail-badge {
  display: inline-block;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  margin-bottom: 0.45rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  padding: 0.15rem 0;
  color: var(--text-muted);
}
.detail-label {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  margin-right: 0.5rem;
}
.detail-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 0.5rem 1rem 0.25rem;
}
.dossier-clickable {
  cursor: pointer;
  transition: background 0.15s;
}
.dossier-clickable:hover {
  background: rgba(59,130,246,0.08);
}

/* ─── Estimator ────────────────────────────────────────────── */

.estimator {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.estimator-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.estimator-field { width: 100%; }
.estimator-field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}
.estimator-field select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  width: 100%;
}

.estimator-result {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.estimate-card {
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 0.85rem;
  text-align: center;
}
.estimate-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.estimate-value { font-size: 1.4rem; font-weight: 700; margin: 0.3rem 0; }
.estimate-sub { font-size: 0.78rem; color: var(--text-dim); }

.confidence-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  margin-top: 0.5rem;
}
.confidence-dot { width: 8px; height: 8px; border-radius: 50%; }
.confidence-high { background: var(--green); }
.confidence-medium { background: var(--orange); }
.confidence-low { background: var(--red); }

/* ─── Heatmap ──────────────────────────────────────────────── */

.heatmap-grid { overflow-x: auto; position: relative; }

.heatmap-table { border-collapse: collapse; font-size: 0.75rem; width: 100%; }
.heatmap-table th { padding: 0.35rem 0.4rem; font-weight: 600; color: var(--text-muted); text-align: center; white-space: nowrap; font-size: 0.75rem; }
.heatmap-table td { padding: 0.3rem 0.4rem; text-align: center; border: 1px solid rgba(255,255,255,0.05); min-width: 38px; font-size: 0.72rem; font-weight: 500; }
.heatmap-table td.hm-cell { transition: opacity 0.2s; }
.heatmap-table td.hm-cell:hover { opacity: 0.8; }
.heatmap-table .hm-label { text-align: left; color: var(--text-muted); font-weight: 500; min-width: 80px; font-size: 0.75rem; }

/* Heatmap popover */
.hm-popover { z-index: 1000; width: 220px; background: #1e2330; border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.7); padding: 0.75rem; animation: modalIn 0.15s ease; position: absolute; }
.hm-popover-header { font-weight: 700; font-size: 0.85rem; color: var(--text-light); margin-bottom: 0.15rem; }
.hm-popover-step { font-size: 0.75rem; color: var(--primary-light); margin-bottom: 0.6rem; }
.hm-popover-stats { display: flex; flex-direction: column; gap: 0.3rem; }
.hm-popover-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; }
.hm-popover-row span { color: var(--text-muted); }
.hm-popover-row strong { color: var(--text-light); font-weight: 600; }
.hm-popover-link { cursor: pointer; border-radius: 4px; padding: 0.2rem 0.3rem; margin: -0.2rem -0.3rem; transition: background 0.15s; }
.hm-popover-link:hover { background: rgba(255,255,255,0.08); }
.hm-hash-link { color: var(--primary-light); font-size: 0.7rem; font-weight: 500; margin-left: 0.3rem; }

/* ─── Distribution Table ──────────────────────────────────── */

.distrib-step-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.distrib-bar {
  display: flex;
  height: 10px;
  border-radius: 4px;
  overflow: hidden;
  min-width: 60px;
}
.distrib-bar-seg { height: 100%; }
.distrib-row { cursor: pointer; }
.distrib-row td:first-child { color: var(--primary-light); }
.distrib-row:hover { background: var(--bg-card-hover) !important; }
.distrib-row-open { background: rgba(59,130,246,0.06); }
.distrib-toggle {
  display: inline-block;
  font-size: 0.55rem;
  color: var(--primary-light);
  width: 1em;
  margin-right: 0.2rem;
  transition: transform 0.15s;
}
.distrib-detail td { background: rgba(255,255,255,0.02); }
.distrib-detail-name {
  padding-left: 1.5rem !important;
  color: var(--text-muted);
}
.distrib-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.distrib-detail-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  min-width: 40px;
}
.distrib-detail-bar > div {
  height: 100%;
  border-radius: 3px;
}
.text-dim { color: var(--text-dim); font-size: 0.72rem; }

/* ─── Funnel ───────────────────────────────────────────────── */

.funnel { margin-bottom: 1.5rem; }

.funnel-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.funnel-bar-wrapper { flex: 1; position: relative; }

.funnel-bar {
  height: 30px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  transition: width 0.5s ease;
}

.funnel-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: auto;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.funnel-pct {
  font-size: 0.75rem;
  color: var(--text-dim);
  min-width: auto;
  text-align: right;
}

.funnel-drop {
  text-align: center;
  font-size: 0.72rem;
  color: var(--red);
  padding: 0.2rem 0;
}

/* ─── Radar controls ───────────────────────────────────────── */

.radar-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.radar-controls select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
}

/* ─── Calendar (GitHub-style) ──────────────────────────────── */

.calendar-grid { overflow-x: auto; padding-bottom: 0.5rem; position: relative; }

.calendar-table { border-collapse: separate; border-spacing: 2px; }
.calendar-table td { width: 12px; height: 12px; border-radius: 2px; border: none; padding: 0; }
.calendar-table .cal-label { font-size: 0.65rem; color: var(--text-dim); text-align: right; padding-right: 4px; width: auto; height: auto; }

.cal-empty { background: rgba(255,255,255,0.03); }
.cal-l1 { background: #0e4429; }
.cal-l2 { background: #006d32; }
.cal-l3 { background: #26a641; }
.cal-l4 { background: #39d353; }

/* ─── Flow Diagram ─────────────────────────────────────────── */

.flow-diagram {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-height: 160px;
  padding: 1rem 0;
  overflow-x: auto;
  position: relative;
}

.flow-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 50px;
}

.flow-node {
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  min-width: 42px;
}

.flow-connector {
  flex: 1;
  width: 100%;
  position: relative;
  min-height: 20px;
}

/* ─── Privacy ──────────────────────────────────────────────── */

.privacy {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--border);
  margin-top: 1.5rem;
}
.privacy h3 { font-size: 0.95rem; margin-bottom: 0.75rem; }
.privacy ul { list-style: none; padding: 0; }
.privacy li { padding: 0.3rem 0; color: var(--text-muted); font-size: 0.85rem; }
.privacy li::before { content: '\1F512 '; }

/* ─── Export button ────────────────────────────────────────── */

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-export:hover { border-color: var(--primary); color: var(--text); }

/* ─── Comparison cards ─────────────────────────────────────── */

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.comparison-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.comparison-card h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.comparison-stat {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.comparison-stat:last-child { border-bottom: none; }
.comparison-stat .cs-label { color: var(--text-dim); }
.comparison-stat .cs-value { font-weight: 600; }

/* ─── Error / No-data ──────────────────────────────────────── */

.error-msg { text-align: center; padding: 2rem; color: var(--red); }
.no-data { text-align: center; padding: 2rem; color: var(--text-dim); font-style: italic; }


/* ─── Table Filters ───────────────────────────────────────── */

.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  padding: 0.7rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.table-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.table-filter-group label {
  font-size: 0.62rem;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.table-filter-group .status-select { min-width: 160px; }
.table-filter-group .status-select-trigger {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  min-height: 32px;
  border-radius: 6px;
}
.table-filter-group select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.15s;
}
.table-filter-group select:hover { border-color: var(--primary); }
.table-filter-group select:focus { outline: none; border-color: var(--primary); }
.table-filter-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  width: 140px;
  transition: border-color 0.15s;
}
.table-filter-input:focus {
  outline: none;
  border-color: var(--primary);
}
.date-range {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.date-sep {
  color: var(--text-dim);
  font-size: 0.7rem;
  flex-shrink: 0;
}
.table-filter-date {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.35rem 0.4rem;
  font-size: 0.75rem;
  width: 120px;
  min-width: 0;
  transition: border-color 0.15s;
}
.table-filter-date:focus {
  outline: none;
  border-color: var(--primary);
}
.table-filter-date::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* Mobile: stack filter groups */
@media (max-width: 767px) {
  .table-filters {
    gap: 0.5rem;
    padding: 0.6rem 0.65rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .table-filter-group {
    min-width: 0;
  }
  .table-filter-group:has(select#dossier-filter-history),
  .table-filter-group:has(.date-range) {
    grid-column: span 2;
  }
  .table-filter-group .status-select { width: 100%; min-width: 0; }
  .table-filter-group select { width: 100%; flex: 1; }
  .table-filter-input {
    flex: 1;
    width: auto;
  }
  .table-filter-date {
    flex: 1;
    width: auto;
  }

  /* Chart stats: 2 columns on mobile */
  .chart-stats {
    gap: 0.35rem;
  }
  .chart-stat {
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 0;
    padding: 0.4rem 0.5rem;
  }
  .chart-stat-value {
    font-size: 0.95rem;
  }

  /* Tall charts on mobile: scrollable with max-height */
  .chart-container--tall {
    max-height: 520px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Dossier toolbar: compact grid layout */
  .dossier-toolbar {
    gap: 0.5rem;
    padding: 0.6rem 0.65rem;
  }
  .toolbar-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .toolbar-controls select {
    width: 100%;
    flex: none;
    padding: 0.35rem 0.4rem;
    font-size: 0.78rem;
  }
  .toolbar-controls .toggle-filter {
    justify-content: center;
  }
  .sdanf-statut-pills {
    gap: 4px;
  }
  .sdanf-pill {
    padding: 0.2rem 0.5rem;
    font-size: 0.68rem;
    min-height: 24px;
    border-radius: 12px;
  }
  .sdanf-pill .pill-full { display: none; }
  .sdanf-pill .pill-short { display: inline; }
  /* Dossier rows: tighter on mobile */
  .dossier-row {
    padding: 0.5rem 0.55rem;
    gap: 0.35rem;
  }
  .dossier-row-status .statut-label {
    font-size: 0.72rem;
  }
  .dossier-row-meta {
    gap: 0.4rem;
    font-size: 0.68rem;
  }

  /* Detail panel: tighter on mobile */
  .dossier-row-detail {
    padding: 0.55rem 0.6rem;
  }
  .dossier-durations {
    padding: 0.4rem 0.55rem;
    gap: 0.35rem;
  }
  .duration-label { font-size: 0.68rem; }
  .duration-value { font-size: 0.85rem; }
  .dossier-info-item { font-size: 0.78rem; }

  /* Timeline in detail: compact on mobile */
  .detail-history-header { font-size: 0.78rem; }
  .timeline-step { gap: 0.5rem; padding: 0.35rem 0; }
  .timeline-content .ts-status { font-size: 0.73rem; }
  .timeline-content .ts-expl { font-size: 0.68rem; }
  .timeline-content .ts-date { font-size: 0.66rem; }
  .timeline-content .ts-duration { font-size: 0.62rem; padding: 0.06rem 0.3rem; }

  /* KPI grid: tighter on small screens */
  .kpi-grid { gap: 0.5rem; }
  .kpi-card { padding: 0.7rem; }
  .kpi-value { font-size: 1.4rem; }
  .kpi-label { font-size: 0.7rem; }
  .kpi-sub { font-size: 0.72rem; }

  /* Dossier card: tighter for grid view on mobile */
  .dossier-card { padding: 0.85rem; }

  /* Section headers */
  .section h2 { font-size: 1rem; }

  /* Tables: compact on mobile, aligned columns */
  .table-container { padding: 0; }
  table { font-size: 0.75rem; }
  thead th { padding: 0.4rem 0.35rem; font-size: 0.7rem; }
  tbody td { padding: 0.4rem 0.35rem; }

  /* Percentile table: let browser auto-size on mobile */
  .percentile-table { table-layout: auto; }
  .percentile-table th:nth-child(1) { width: auto; }
  .percentile-table td.num { white-space: normal; }
}

/* =============================================================
   DESKTOP OVERRIDES (min-width: 768px)
   ============================================================= */

@media (min-width: 768px) {

  html { scroll-padding-top: 60px; }

  /* Filter bar: row layout, align controls at bottom */
  .filter-bar {
    flex-direction: row;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1rem;
  }
  .filter-group { width: auto; }
  .filter-group:has(.filter-label) { align-items: flex-start; }
  .filter-group:has(.status-select) { min-width: 180px; max-width: 280px; }
  .filter-group:has(select:not(.status-select *)) { min-width: 160px; max-width: 260px; }
  .filter-bar select,
  .filter-group select {
    flex: none;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
  }
  .status-select-trigger {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    min-height: auto;
  }
  .filter-bar input[type="text"] {
    width: 100px;
    flex: none;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
  }
  .filter-count { margin-left: auto; align-self: auto; }
  .slider { width: 100px; flex: none; }
  .slider-value { font-size: 0.8rem; }

  /* Pills: compact */
  .pill {
    padding: 0.28rem 0.6rem;
    font-size: 0.8rem;
    min-height: auto;
  }

  /* KPI: auto-fit grid */
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
  }
  .kpi-card { padding: 1.25rem 1.5rem; }
  .kpi-value { font-size: 2rem; }
  .kpi-label { font-size: 0.75rem; }

  /* Section */
  .section { margin-top: 2.5rem; }
  .section h2 { font-size: 1.2rem; }

  /* Dossier toolbar: row */
  .dossier-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
  }
  .toolbar-controls { width: auto; }
  .toolbar-controls select {
    width: auto;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
  }
  .btn-page { padding: 0.28rem 0.55rem; font-size: 0.85rem; }

  /* Dossier grid: multi-column */
  .dossier-grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
  }
  .dossier-card { padding: 1.15rem; }
  .dossier-step-badge { font-size: 0.75rem; padding: 0.12rem 0.5rem; }

  /* Charts */
  .chart-container { padding: 1.5rem; }
  .chart-container canvas { max-height: 400px; }
  .chart-container--tall canvas { max-height: none; }
  .chart-container h3 { font-size: 1rem; }
  .chart-container select { width: auto; margin-bottom: 0; }
  .charts-row { grid-template-columns: 1fr 1fr; }

  /* Tabs: compact */
  .tab { padding: 0.65rem 1.2rem; font-size: 0.82rem; }

  /* Tables */
  .table-container { padding: 1.5rem; }
  table { font-size: 0.88rem; }
  thead th { padding: 0.7rem; font-size: inherit; }
  tbody td { padding: 0.7rem; }

  /* Summary */
  .summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
  }
  .summary-card { padding: 1rem 1.25rem; }
  .summary-card .sc-value { font-size: 1.5rem; }

  /* Activity feed: single row */
  .activity-item { grid-template-columns: 10px auto 1fr auto; grid-template-rows: auto; gap: 0 0.6rem; font-size: 0.85rem; }
  .activity-hash { grid-row: 1; grid-column: 2; font-size: 0.82rem; }
  .activity-text { grid-row: 1; grid-column: 3; font-size: 0.82rem; }
  .activity-time { grid-row: 1; grid-column: 4; font-size: 0.75rem; }

  /* Mouvements: no layout change needed on desktop */

  /* CAE */
  .cae-today-banner { font-size: 0.9rem; padding: 0.85rem 1.1rem; }
  .cae-today-banner .cae-count { font-size: 1.3rem; }
  .cae-date-group { font-size: 0.78rem; }

  /* Estimator */
  .estimator { padding: 1.5rem; }
  .estimator-form { flex-direction: row; gap: 1rem; align-items: end; }
  .estimator-field { width: auto; }
  .estimator-field select { width: auto; padding: 0.4rem 0.6rem; font-size: 0.85rem; }
  .estimator-result { grid-template-columns: repeat(3, 1fr); }
  .estimate-card { padding: 1rem; }
  .estimate-value { font-size: 1.5rem; }

  /* Heatmap */
  .heatmap-table td { min-width: 50px; font-size: 0.75rem; padding: 0.35rem 0.5rem; }
  .heatmap-table .hm-label { min-width: 120px; font-size: 0.78rem; }
  .heatmap-table th { font-size: 0.78rem; padding: 0.4rem 0.5rem; }

  /* Funnel */
  .funnel-step { gap: 0.75rem; margin-bottom: 0.5rem; }
  .funnel-label { min-width: 80px; max-width: none; font-size: 0.78rem; }
  .funnel-pct { min-width: 60px; font-size: 0.75rem; }
  .funnel-bar { height: 36px; font-size: 0.82rem; padding: 0 0.75rem; }

  /* Radar */
  .radar-controls { gap: 0.75rem; }
  .radar-controls select { flex: none; font-size: 0.8rem; padding: 0.3rem 0.5rem; }

  /* Timeline (legacy rules removed — now uses .tl-* classes) */

  /* Calendar */
  .calendar-table { border-spacing: 3px; }
  .calendar-table td { width: 14px; height: 14px; }

  /* Flow */
  .flow-diagram { min-height: 200px; }
  .flow-column { min-width: 60px; }
  .flow-node { font-size: 0.72rem; padding: 0.4rem 0.6rem; min-width: 50px; }

  /* Privacy */
  .privacy { padding: 1.5rem; margin-top: 2.5rem; }
  .privacy h3 { font-size: 1rem; }
  .privacy li { font-size: 0.88rem; }

  /* Comparison */
  .comparison-grid { grid-template-columns: 1fr 1fr; }

  /* Badges */
  .badge-percentile { font-size: 0.65rem; }
  .badge-complement { font-size: 0.65rem; }

  /* View toggle & page size */
  .view-btn { padding: 0.25rem 0.5rem; font-size: 0.95rem; }
  .page-size-select { padding: 0.3rem 0.5rem; font-size: 0.8rem; }

  /* Dossier rows: show more meta */
  .dossier-row { padding: 0.45rem 0.75rem; }
  .dossier-row-status .statut-label { font-size: 0.8rem; }
  .dossier-row-meta { gap: 0.8rem; font-size: 0.75rem; }
  .dossier-row-detail { padding: 1rem 1.15rem; }

  /* Timeline in detail: comfortable on desktop */
  .detail-history-header { font-size: 0.85rem; }
  .timeline-step { gap: 0.85rem; padding: 0.5rem 0; }
  .timeline-dot { width: 12px; height: 12px; }
  .timeline-dot-col { width: 16px; }
  .timeline-content .ts-status { font-size: 0.82rem; }
  .timeline-content .ts-expl { font-size: 0.75rem; }
  .timeline-content .ts-duration { font-size: 0.7rem; padding: 0.1rem 0.45rem; }
}


/* =============================================================
   LARGE DESKTOP OVERRIDES (min-width: 1024px)
   ============================================================= */

@media (min-width: 1024px) {
}


/* ─── Searchable Status Select ─────────────────────────────── */

.status-select { position: relative; width: 100%; }
.status-select-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0.45rem 0.6rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 0.85rem; cursor: pointer;
  text-align: left; min-height: 38px;
}
.status-select-trigger:hover { border-color: var(--primary); }
.status-select-arrow { font-size: 0.7rem; color: var(--text-dim); margin-left: 0.5rem; flex-shrink: 0; }
.status-select-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-select-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  width: min(500px, 90vw);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 100;
  max-height: 350px; display: flex; flex-direction: column;
}
.status-select-search {
  padding: 0.5rem 0.75rem; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); font-size: 0.85rem;
  outline: none; flex-shrink: 0;
}
.status-select-options { overflow-y: auto; flex: 1; }
.status-select-group-label {
  padding: 0.4rem 0.75rem; font-size: 0.75rem; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em;
  background: var(--bg-card); position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--border);
}
.status-select-option {
  padding: 0.45rem 0.75rem 0.45rem 1.25rem;
  font-size: 0.82rem; color: var(--text-muted); cursor: pointer;
  white-space: normal; word-break: break-word; line-height: 1.4;
}
.status-select-option:hover { background: var(--bg-card-hover); color: var(--text); }
.status-select-option.selected { color: var(--primary-light); }
.status-select-no-results {
  padding: 1rem; text-align: center; color: var(--text-dim); font-size: 0.85rem;
}

/* ─── Prefecture Multi-Select ─────────────────────────────── */

.pref-multiselect { position: relative; width: 100%; }
.pref-ms-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0.45rem 0.6rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 0.85rem; cursor: pointer;
  text-align: left; min-height: 38px;
}
.pref-ms-trigger:hover { border-color: var(--primary); }
.pref-ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pref-ms-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  width: min(400px, 90vw);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 100;
  max-height: 350px; display: flex; flex-direction: column;
}
.pref-ms-search {
  display: block; width: 100%; box-sizing: border-box;
  padding: 0.5rem 0.75rem; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); font-size: 0.85rem;
  outline: none; flex-shrink: 0;
}
.pref-ms-options { overflow-y: auto; flex: 1; padding: 0.25rem 0; }
.pref-ms-option {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.75rem; font-size: 0.82rem; color: var(--text-muted);
  cursor: pointer; white-space: nowrap;
}
.pref-ms-option:hover { background: var(--bg-card-hover); color: var(--text); }
.pref-ms-option input[type="checkbox"] {
  accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; cursor: pointer;
}
.pref-ms-all { border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 0.25rem; font-weight: 600; color: var(--text); }

/* ─── Prefecture Searchable Single-Select ────────────────── */
.pref-search-select { position: relative; }
.pref-ss-option {
  padding: 0.4rem 0.75rem; font-size: 0.82rem; color: var(--text-muted);
  cursor: pointer; white-space: nowrap;
}
.pref-ss-option:hover { background: var(--bg-card-hover); color: var(--text); }
.pref-ss-option.selected { color: var(--primary-light); }

/* Filter groups with label: label above, control below */
.filter-group:has(.filter-label) {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}
.filter-group select,
.filter-group .status-select { width: 100%; min-width: 0; }

/* ─── View Toggle ─────────────────────────────────────────── */

.view-toggle { display: inline-flex; gap: 2px; background: var(--bg); border-radius: 6px; padding: 2px; border: 1px solid var(--border); }
.view-btn {
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.55rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.view-btn:hover { color: var(--text-muted); }
.view-btn.active { background: var(--primary); color: #fff; }

/* ─── Page Size Select ────────────────────────────────────── */

.page-size-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.page-size-select:hover { border-color: var(--primary); }

/* ─── Dossier List (compact rows) ─────────────────────────── */

.dossier-list { display: flex; flex-direction: column; gap: 4px; }

.dossier-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--card-accent, var(--primary));
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}
.dossier-row:hover { background: var(--bg-card-hover); border-color: var(--card-accent, var(--primary)); }

.dossier-row-main { flex: 1; min-width: 0; overflow: hidden; }

.dossier-row-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.dossier-row-hash {
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.dossier-row-step {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  padding: 0.08rem 0.4rem;
  border-radius: 8px;
  flex-shrink: 0;
}

.dossier-row-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}
.dossier-row-status .statut-label {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.3;
}

.dossier-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
.dossier-row-meta span { white-space: nowrap; }
.dossier-row-meta span.meta-wrap { white-space: normal; word-break: break-word; }

.dossier-row-expand {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: transform 0.2s;
  flex-shrink: 0;
  line-height: 1;
}
.dossier-row.expanded .dossier-row-expand { transform: rotate(180deg); }

.dossier-row-detail {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 0.65rem 0.75rem;
  margin-top: -4px;
  margin-bottom: 4px;
}
.dossier-row-detail.open { display: block; }

/* Status history inside detail panel */
.detail-history-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border);
}

/* ─── Badge Tri ───────────────────────────────────────────── */

.badge-tri {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #f59e0b;
  background: rgba(245,158,11,0.15);
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
}

/* ─── Badges entretien ────────────────────────────────────── */

.badge-entretien-oui {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16,185,129,0.15);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}
.badge-entretien-non {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #f59e0b;
  background: rgba(245,158,11,0.15);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}
.badge-decision-sans-entretien {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #ef4444;
  background: rgba(239,68,68,0.12);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}

.badge-finished-ok {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16,185,129,0.12);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}
.badge-finished-ko {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #ef4444;
  background: rgba(239,68,68,0.12);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
}

/* ─── Mouvement section header (collapsible) ──────────────── */

.mouv-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.25rem 0;
  user-select: none;
}
.mouv-section-header:hover .mouv-expand-btn {
  background: rgba(59,130,246,0.15);
  color: var(--primary-light);
}
.mouv-section-title { flex: 1; }
.mouv-section-title h2 { margin-bottom: 0.15rem; }
.mouv-section-title .section-subtitle { margin: 0; }
.mouv-expand-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  margin-left: 1rem;
}
.mouv-section-header.open .mouv-expand-btn {
  transform: rotate(180deg);
  background: rgba(59,130,246,0.12);
  color: var(--primary-light);
  border-color: var(--primary);
}
.mouv-chart-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.45s ease, opacity 0.35s ease, margin 0.35s ease;
  margin-top: 0;
}
.mouv-chart-panel.open {
  max-height: 600px;
  opacity: 1;
  margin-top: 1rem;
}

/* ─── Mouvement chart controls ─────────────────────────────── */

.mouv-chart-controls {
  margin-bottom: 1rem;
}
.mouv-chart-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}
.mouv-chart-filters {
  margin-top: 0.75rem;
  gap: 0.75rem;
}
.mouv-filter-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.mouv-filter-group label {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 600;
}
.mouv-date-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s;
}
.mouv-date-input:hover,
.mouv-date-input:focus {
  border-color: var(--primary);
  outline: none;
}
.mouv-granularity-toggles {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.mouv-gran-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.mouv-gran-btn:first-child { border-right: 1px solid var(--border); }
.mouv-gran-btn.active {
  background: var(--primary);
  color: #fff;
}
.mouv-gran-btn:not(.active):hover {
  background: rgba(59,130,246,0.1);
  color: var(--primary-light);
}

/* ─── Chart legend toggles ─────────────────────────────────── */

.chart-legend-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.chart-legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}
.chart-legend-toggle .legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chart-legend-toggle.active {
  border-color: currentColor;
}
.chart-legend-toggle:not(.active) {
  opacity: 0.4;
}
.chart-legend-toggle:hover {
  opacity: 1;
}

/* ─── Badges fraîcheur statut ──────────────────────────────── */

.badge-freshness {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.3rem;
}
.badge-fresh {
  color: #10b981;
  background: rgba(16,185,129,0.15);
}
.badge-moderate {
  color: #f59e0b;
  background: rgba(245,158,11,0.15);
}
.badge-stale {
  color: #ef4444;
  background: rgba(239,68,68,0.15);
}
.badge-status-changed {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  color: #3b82f6;
  background: rgba(59,130,246,0.15);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.3rem;
}

/* ─── Touch / hover safety ─────────────────────────────────── */

@media (hover: none) {
  .dossier-card:hover { transform: none; }
  .kpi-card:hover { border-color: var(--border); }
  .pill:hover { border-color: var(--border); color: var(--text-muted); }
  .pill.active:hover { border-color: var(--pill-color, var(--primary)); color: #fff; }
}

/* ─── Scroll hint gradient ─────────────────────────────────── */

.timeline-wrapper,
.heatmap-grid,
.calendar-grid,
.flow-diagram {
  position: relative;
}

.scroll-hint-right::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(to right, transparent, var(--bg-card));
  pointer-events: none;
  z-index: 2;
}

/* ─── Safe area for notched phones ─────────────────────────── */

@supports (padding: env(safe-area-inset-left)) {
  .filter-bar {
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
  }
}
