/* ═══════════════════════════════════════════
   ESTADÍSTICAS DE CAPTURA
   ═══════════════════════════════════════════ */
.stats-container { width: 100%; padding: 30px clamp(14px, 2vw, 40px) 40px; box-sizing: border-box; }

.stats-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.stats-title { margin: 0 0 3px; font-family: var(--font-display); font-weight: 800; font-size: 1.55rem; letter-spacing: -.02em; color: var(--ink); }
.stats-sub { margin: 0; color: var(--ink-soft); font-size: 13.5px; }

.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-soft); font-weight: 600; }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }
.stats-print-btn { white-space: nowrap; }

/* ── Barra de filtros ── */
.stats-filterbar {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.stats-filterbar .form-field { min-width: 150px; }
.stats-filterbar .form-field.ff-grow { flex: 1; min-width: 220px; }
.stats-filterbar .btn { padding: 10px 16px; }

/* ── Chips de filtro activo ── */
.stats-activefilters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.stats-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); color: var(--accent-ink);
  border: 1px solid #c7dbfd; border-radius: var(--pill);
  padding: 5px 6px 5px 12px; font-size: 12.5px; font-weight: 600;
}
.chip-x {
  border: none; background: rgba(37,99,235,.14); color: var(--brand-deep);
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; padding: 0; font-family: var(--font-body);
}
.chip-x:hover { background: var(--brand); color: #fff; }

/* ── KPIs globales ── */
.stats-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stats-kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 18px; box-shadow: var(--shadow-sm);
}
.stats-kpi .k { color: var(--ink-soft); font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: .08em; }
.stats-kpi .v { font-family: var(--font-display); font-weight: 800; font-size: 1.75rem; color: var(--brand); letter-spacing: -.02em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stats-kpi .v small { font-size: .8rem; color: var(--ink-faint); font-weight: 600; }

/* Grid de tarjetas */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 18px; align-items: start; }
.stats-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 20px; }
.stats-card-wide { grid-column: 1 / -1; }
.stats-stack { display: grid; gap: 18px; align-content: start; min-width: 0; }
.stats-card h4 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--ink); letter-spacing: -.01em; }
.stats-card h4 + .card-hint { margin-top: 0; }
.card-hint { margin: 0 0 14px; color: var(--ink-faint); font-size: 12px; }
.stats-card h4:only-child, .stats-card h4:last-child { margin-bottom: 16px; }

/* Barras horizontales */
.hbar { margin-bottom: 15px; }
.hbar:last-child { margin-bottom: 0; }
.hbar-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.nm { font-weight: 700; color: var(--ink); font-size: 13.5px; }
.nm small { display: block; color: var(--ink-faint); font-weight: 500; font-size: 11px; margin-top: 1px; }
.v { font-family: var(--font-display); font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-track { height: 12px; background: var(--surface-3); border-radius: var(--pill); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: var(--pill); transition: width .5s cubic-bezier(.2,.7,.2,1); min-width: 3px; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 176px; height: 176px; border-radius: 50%; position: relative; flex: none; box-shadow: var(--shadow-sm); }
.donut-center {
  position: absolute; inset: 27%; background: var(--surface); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px var(--line);
}
.dc-v { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dc-l { font-size: .72rem; color: var(--ink-soft); }
.donut-legend { flex: 1; min-width: 160px; display: grid; gap: 8px; }
.leg-item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.leg-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.leg-name { color: var(--ink); font-variant-numeric: tabular-nums; }
.leg-val { margin-left: auto; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Tabla de clientes (clickeable) */
.cli-table { width: 100%; border-collapse: collapse; }
.cli-table th, .cli-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; text-align: left; }
.cli-table th { color: var(--ink-soft); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.cli-table td.num, .cli-table th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 12.5px; }
.cli-table tbody tr:last-child td { border-bottom: none; }
.cli-row { cursor: pointer; transition: background .12s; }
.cli-row:hover td { background: var(--surface-2); }
.cli-row-active td { background: var(--brand-soft); }
.cli-row-active td:first-child { box-shadow: inset 3px 0 0 var(--brand); font-weight: 700; color: var(--brand-deep); }

/* Listado de entradas (detalle, paginado) */
.entries-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.entries-table { min-width: 860px; }
.entries-table th { white-space: nowrap; }
.entry-cal {
  display: inline-block; padding: 3px 9px; border-radius: var(--pill);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.entries-pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 14px;
}
.pager-info { color: var(--ink-soft); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pager-info small { color: var(--ink-faint); }
.pager-btns { display: flex; gap: 8px; }
.pager-btns .btn[disabled] { opacity: .45; cursor: default; pointer-events: none; }

@media (max-width: 700px) {
  .stats-container { padding: 16px 12px 32px; }
  .stats-title { font-size: 1.3rem; }
  .stats-kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stats-kpi .v { font-size: 1.4rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .stats-filterbar { padding: 12px; }
  .stats-filterbar .form-field,
  .stats-filterbar .form-field.ff-grow { flex: 1; min-width: 140px; }
  .stats-filterbar .btn { flex: 1; }
  .cli-table th, .cli-table td { padding: 9px 8px; font-size: 12.5px; }
}
@media (max-width: 420px) {
  .donut { width: 140px; height: 140px; }
  .dc-v { font-size: 1.1rem; }
  .stats-kpis { grid-template-columns: 1fr 1fr; }
}
