/* Ventana de estadísticas de mazos y sets: mismo aspecto oscuro que los demás diálogos de la aplicación. */
.stats-dialog { width: min(1100px, 94vw); height: min(820px, 92vh); padding: 0; border: 1px solid #55595a; color: #eee7dd; background: #292d30; box-shadow: 0 18px 60px #000b; overflow: hidden; }
.stats-dialog[open] { display: flex; flex-direction: column; }
.stats-dialog::backdrop { background: #111820aa; }
.stats-header { display: flex; align-items: center; gap: 16px; padding: 16px 20px 10px; border-bottom: 1px solid #45494b; }
.stats-header > div { flex: 1; min-width: 0; }
.stats-header h2 { margin: 2px 0 0; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-side { color: #c9b89f; font: 13px 'Segoe UI', sans-serif; white-space: nowrap; cursor: pointer; }
.stats-tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 12px; border-bottom: 1px solid #45494b; background: #25292c; }
.stats-tabs button { border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; color: #c9b89f; background: transparent; font: 13px 'Segoe UI', sans-serif; cursor: pointer; }
.stats-tabs button:hover { color: #fff7ee; }
.stats-tabs button.active { color: #fff7ee; border-bottom-color: #a65032; }
.stats-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 22px; font-family: 'Segoe UI', sans-serif; }

/* Cada pestaña ocupa todo el alto de la ventana. Las secciones con gráfica (curva, roscas) y con barras crecen y se reparten el
   espacio que sobra; lo que no crece (cifras, tablas) queda centrado como un grupo. Si el contenido no cabe, la ventana se desplaza. */
.stats-body { display: flex; flex-direction: column; }
.stat-tab { display: flex; flex: 1 0 auto; flex-direction: column; justify-content: center; gap: 18px; }
.stat-section { display: flex; flex-direction: column; }
.stat-section:has(> .stat-chart, > .stat-donut-box) { flex: 1 1 0; min-height: 170px; }
.stat-section:has(> .stat-hbars) { flex: 1 1 auto; }
.stat-section h3 { margin: 0 0 8px; color: #c98a6d; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }
.stat-figures { display: flex; flex-wrap: wrap; gap: 12px; }
.stat-figure { display: flex; flex: 1 1 105px; flex-direction: column; align-items: center; justify-content: center; padding: 16px 14px; border: 1px solid #45494b; border-radius: 4px; background: #202427; }
.stat-figure strong { font-size: 32px; font-weight: 600; color: #fff7ee; line-height: 1.1; }
.stat-figure span { margin-top: 4px; color: #9a9185; font-size: 13px; }
.stat-note { margin: 6px 0 0; color: #9a9185; font-size: 13px; line-height: 1.45; }
.stat-empty { margin: 4px 0; color: #9a9185; font-size: 13px; }
.stat-error { color: #e2866c; font-size: 13px; }
.stat-field { display: flex; flex-direction: column; gap: 6px; color: #c9b89f; font-size: 13px; max-width: 420px; }
.stat-commander { border: 1px solid #55595a; border-radius: 3px; color: #eee7dd; background: #202427; padding: 8px; font-size: 13px; }

.stat-chart { flex: 1 1 0; min-height: 0; width: 100%; height: auto; }
.stat-grid { stroke: #3a3f42; stroke-width: 1; }
.stat-axis { fill: #9a9185; font-size: 11px; }
.stat-value { fill: #eee7dd; font-size: 11px; font-weight: 600; }
.stat-average { stroke: #e0c46a; stroke-width: 1.5; stroke-dasharray: 4 3; }
.stat-average-label { fill: #e0c46a; font-size: 11px; }
.stat-bar rect:hover { filter: brightness(1.2); }
.stat-keys { display: flex; gap: 16px; margin-top: 4px; font-size: 12px; color: #c9b89f; }
.stat-key::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; background: var(--c); }

/* Las barras se reparten el alto de su sección (con un tope, para que unas pocas no queden separadas como islas). */
.stat-hbars { display: flex; flex: 1 1 auto; flex-direction: column; justify-content: space-evenly; gap: 9px; max-height: 420px; }
.stat-hbar { display: grid; grid-template-columns: 190px 1fr 60px; align-items: center; gap: 12px; font-size: 14px; }
.stat-hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c9b89f; }
.stat-hbar-track { height: 20px; border-radius: 2px; background: #202427; overflow: hidden; }
.stat-hbar-fill { display: block; height: 100%; min-width: 2px; border-radius: 2px; }
.stat-hbar-count { text-align: right; color: #eee7dd; font-variant-numeric: tabular-nums; }

/* La rosca toma el alto que le deja su sección (hasta 300 px) y la leyenda va a su lado, todo centrado. */
.stat-donut-box { display: flex; flex: 1 1 0; min-height: 0; align-items: center; justify-content: center; gap: 44px; }
.stat-donut { height: 100%; max-height: 300px; width: auto; aspect-ratio: 1; flex: none; }
.stat-donut path:hover { filter: brightness(1.2); }
.stat-donut-center { fill: #eee7dd; font-size: 22px; font-weight: 600; }
.stat-legend { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.stat-legend li { display: flex; align-items: center; gap: 8px; }
.stat-swatch { width: 11px; height: 11px; border-radius: 2px; flex: none; }
.stat-legend-label { min-width: 120px; color: #c9b89f; }
.stat-legend-count { color: #eee7dd; font-variant-numeric: tabular-nums; }

.stat-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stat-table th { padding: 6px 8px; text-align: left; color: #9a9185; font-weight: 500; border-bottom: 1px solid #45494b; }
.stat-table td { padding: 6px 8px; border-bottom: 1px solid #34393c; vertical-align: top; }
.stat-legal td:first-child { color: #8cc08f; }
.stat-illegal td:first-child { color: #e2866c; }
.stat-blockers summary { cursor: pointer; color: #e2866c; }
.stat-blockers ul { margin: 6px 0 2px; padding-left: 18px; color: #c9b89f; }
.stat-legal .stat-blockers summary { color: #e0c46a; }
