/* ClinData Portal — Statistiche (4.19) */

.stats-modes { display: flex; gap: 0.4rem; margin-bottom: 0.9rem; }
.stats-filters { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: flex-end; margin-bottom: 1rem; }
.stats-filters label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.stats-filters select { min-width: 220px; }
.stats-patient { min-width: 280px; position: relative; }
.stats-period { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: flex-end; }
.stats-period input[type=date] { width: 165px; }
.stats-presets { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.stats-caption { margin: 0 0 0.8rem; }
.stats-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.7rem; margin-bottom: 1.2rem; }
.stats-kpi { border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 0.65rem 0.8rem; display: flex; flex-direction: column; gap: 0.15rem; background: var(--bg-surface); min-width: 0; }
.stats-kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 600; }
.stats-kpi-value { font-size: 1.35rem; color: var(--text-main); }
.stats-kpi-prev { font-size: 0.78rem; color: var(--text-muted); }
.stats-delta { font-size: 0.8rem; font-weight: 600; }
.stats-up { color: #15803d; }
.stats-down { color: #b91c1c; }
.stats-flat { color: var(--text-muted); font-weight: 500; }

.stats-h { margin: 1.1rem 0 0.5rem; font-size: 0.98rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.stats-legend { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.35rem; }
.stats-legend .stats-bar { display: inline-block; width: 14px; height: 8px; }
.stats-table .num { text-align: right; white-space: nowrap; }
.stats-col-bar { width: 22%; min-width: 90px; }
.stats-bars { display: flex; flex-direction: column; gap: 2px; }
.stats-bar { display: block; height: 7px; border-radius: 3px; background: var(--primary); }
.stats-bar-prev { background: #cbd5e1; }
.stats-cancelled td { color: var(--text-muted); text-decoration: line-through; }
.stats-cancelled td:last-child { text-decoration: none; }

@media (max-width: 700px) {
  .stats-filters { flex-direction: column; align-items: stretch; }
  .stats-filters select, .stats-patient { min-width: 0; width: 100%; }
  .stats-period label { flex: 1 1 calc(50% - 0.4rem); }
  .stats-period input[type=date] { width: 100%; }
  .stats-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .stats-kpi-value { font-size: 1.1rem; }
  .stats-col-bar { display: none; }
  /* elenchi del paziente: una scheda per riga invece di colonne strette */
  .stats-list thead { display: none; }
  .stats-list, .stats-list tbody, .stats-list tr, .stats-list td { display: block; width: 100%; }
  .stats-list tr { border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 0.4rem 0.6rem; margin-bottom: 0.5rem; }
  .stats-list td { display: flex; justify-content: space-between; gap: 0.8rem; border: 0; padding: 0.15rem 0; text-align: right; }
  .stats-list td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-size: 0.78rem; text-align: left; flex: none; }
  .stats-list td.num { text-align: right; }
  .stats-list td.doc-actions-cell { justify-content: flex-end; padding-top: 0.3rem; }
}
