/* Estatísticas da Biblioteca (perfil) */
.stats-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
#statsRoot { min-width: 0; }
.stats-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; }
@media (min-width: 720px) { .stats-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stats-tile { background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 14px 14px 12px; min-width: 0; }
.stats-tile-value { font-family: var(--font-display); font-size: 1.9rem; line-height: 1.1; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stats-tile-label { margin-top: 4px; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.stats-tile-sub { margin-top: 2px; font-size: 0.78rem; color: var(--text-secondary); line-height: 1.35; }

.stats-section { margin-bottom: 26px; min-width: 0; }
.stats-section { container-type: inline-size; }
#statsBody > .stats-section:last-child, .stats-duo:last-child .stats-section:last-child { margin-bottom: 0; }
.stats-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stats-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-secondary); margin: 0 0 10px; }
.stats-section-head .stats-title { margin-bottom: 0; }
.stats-sub { font-size: 0.92rem; color: var(--text-primary); margin: 8px 0 6px; }
.stats-select { min-height: 40px; padding: 4px 28px 4px 12px; background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.stats-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stats-chart-wrap { position: relative; height: 200px; width: 100%; min-width: 0; }
.stats-chart-wrap[hidden] { display: none; }
.stats-chart-wrap canvas { max-width: 100%; }
.stats-empty { font-size: 0.92rem; color: var(--text-secondary); background: var(--bg-tertiary); border: 1px dashed var(--border-strong); border-radius: var(--radius-md); padding: 16px; text-align: center; line-height: 1.5; }
.stats-note { font-size: 0.82rem; color: var(--text-secondary); margin-top: 10px; line-height: 1.45; }
.stats-note-warn { padding-left: 10px; border-left: 3px solid var(--accent); }
.stats-fallback-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.9rem; color: var(--text-primary); }

/* Listas de barras horizontais */
.stats-bars { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.stats-bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 5px; font-size: 0.92rem; }
.stats-bar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.stats-bar-count { flex: none; color: var(--text-secondary); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.stats-bar-track { height: 10px; border-radius: 5px; background: var(--bg-tertiary); overflow: hidden; }
.stats-bar-fill { height: 100%; background: var(--accent); border-radius: 0 5px 5px 0; }
.stats-bar-row.is-other .stats-bar-fill { background: var(--text-secondary); opacity: 0.6; }

/* Estado: barra única empilhada */
.stats-stack { display: flex; gap: 2px; height: 36px; border-radius: var(--radius-sm); overflow: hidden; }
.stats-seg { display: flex; align-items: center; justify-content: center; min-width: 6px; font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats-seg-reading { background: var(--accent-primary); color: #fff; }
.stats-seg-done { background: var(--accent-secondary); color: #fff; }
.stats-seg-pending { background: var(--text-secondary); color: var(--bg-primary); }
.stats-seg-dropped { background: var(--accent-danger); color: #fff; }
html[data-theme="light"] .stats-seg-reading { background: #3a648c; }
html[data-theme="light"] .stats-seg-done { background: #3b7049; }
html:not([data-theme="light"]) .stats-seg-reading { background: #4a7fae; }
html:not([data-theme="light"]) .stats-seg-done { background: #3f8052; }
html:not([data-theme="light"]) .stats-seg-dropped { background: #a14a4a; }
.stats-legend { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin-top: 12px; }
.stats-legend li { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; min-width: 0; }
.stats-legend li.is-zero { opacity: 0.7; }
.stats-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.stats-legend-name { color: var(--text-primary); overflow-wrap: anywhere; }
.stats-legend-n { margin-left: auto; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Notas: colunas */
.stats-ratings { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; align-items: end; }
.stats-rcol { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.stats-rnum { font-size: 0.78rem; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; text-align: center; line-height: 16px; margin-bottom: 2px; }
.stats-rcol.is-zero .stats-rnum { color: var(--text-secondary); font-weight: 400; }
.stats-ratings { --rh: 84px; }
.stats-rbar-wrap { height: calc(var(--rh) + 20px); width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; border-bottom: 1px solid var(--border-strong); }
.stats-rbar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.stats-rcol.is-fav .stats-rbar { background: var(--accent-danger); }
html:not([data-theme="light"]) .stats-rcol.is-fav .stats-rbar { background: #c0605e; }
.stats-rlabel { margin-top: 4px; font-size: 0.72rem; color: var(--text-secondary); white-space: nowrap; }
.stats-rcol.is-fav .stats-rlabel { color: var(--text-primary); font-weight: 700; }
@media (max-width: 400px) { .stats-rlabel { font-size: 0.68rem; } .stats-ratings { gap: 3px; } }

.stats-duo { display: block; }
@media (min-width: 900px) { .stats-duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 36px; } }
@container (max-width: 420px) { .stats-pct { display: none; } }
