/* ═══════════════════════════════════════════════════════════════
   css-views-layout.css
   Masonry, cards, tabla, vista galeria, renombrar estante, drag & drop de estantes, scrubbers (galeria y crono), boton volver arriba.
   (Parte de styles.css — el orden de <link> respeta la cascada original)
   ═══════════════════════════════════════════════════════════════ */

    /* ── MASONRY LAYOUT ── */
    #masonry-layout {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    width: 100%;
    }

    .masonry-column {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1;
    min-width: 260px;
    max-width: 100%;
    }

    /* ── CARDS ── */
    .country-card, .group-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    width: 100%;
    break-inside: avoid;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    box-shadow: var(--shadow-card);
    }

    .country-card:hover, .group-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    }

    .country-header, .group-header {
    background: linear-gradient(135deg, rgba(255,255,255,0.028) 0%, transparent 100%);
    padding: 0.6rem 0.95rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Outfit', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    }

    .country-header span:last-child:not(.card-badge):not(.badge-car):not(.badge-moto):not(.shelf-rename-btn):not(.badge-emoji),
    .group-header span:last-child:not(.card-badge):not(.badge-car):not(.badge-moto):not(.badge-emoji) {
    font-family: 'Space Mono', monospace;
    font-size: 0.62rem;
    font-weight: 400;
    color: var(--text-dim);
    letter-spacing: 0.03em;
    background: var(--bg-element);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    }
    /* El card-badge y sus hijos no deben heredar el estilo del pill de conteo */
    .country-header .card-badge,
    .group-header .card-badge {
    background: transparent; border: none; padding: 0;
    color: inherit; font-size: inherit; font-family: inherit;
    font-weight: inherit; letter-spacing: 0; border-radius: 0;
    }

    .brand-section { padding: 0.65rem 0.95rem; border-bottom: 1px solid var(--border-color); }
    .brand-section:last-child { border-bottom: none; }

    .category { margin-bottom: 0.45rem; }
    .category:last-child { margin-bottom: 0; }

    .category-title {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    }

    .category-title::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 2px;
    border-radius: 2px;
    flex-shrink: 0;
    }

    .category-title.car { color: var(--accent-car); }
    .category-title.car::before { background: var(--accent-car); box-shadow: 0 0 6px var(--accent-car-glow); }
    .category-title.moto { color: var(--accent-moto); }
    .category-title.moto::before { background: var(--accent-moto); box-shadow: 0 0 6px var(--accent-moto-glow); }

    ul {
    list-style: none;
    padding-left: 0.45rem;
    border-left: 1px solid var(--border-color);
    }

    li {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0.2rem 0.35rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    transition: background var(--transition), color var(--transition);
    cursor: default;
    }
    /* Los <li> con data-country son interactivos (abre ficha) */
    li[data-country] { cursor: pointer; }

    li:hover { background: var(--bg-hover); color: var(--text-primary); }
    li .model-text { flex: 1; min-width: 0; }
    li.brand-start {
    margin-top: 0.45rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.2rem;
    }
    li.brand-start:first-child { margin-top: 0; border-top: none; padding-top: 0; }

    /* dots de nota y estante: inline en el HTML, no pseudo-elementos */
    .dot-nota, .dot-estante {
    display: inline-block;
    width: 4px; height: 4px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: box-shadow var(--transition);
    }
    .dot-nota {
    background: var(--accent-gold);
    box-shadow: 0 0 6px rgba(240,180,41,0.5);
    }
    li:hover .dot-nota { box-shadow: 0 0 10px rgba(240,180,41,0.75); }
    .dot-estante {
    background: #f97316;
    box-shadow: 0 0 6px rgba(249,115,22,0.45);
    }
    li:hover .dot-estante { box-shadow: 0 0 10px rgba(249,115,22,0.7); }
    .form-group textarea {
    width: 100%;
    font-family: 'Outfit', inherit;
    font-size: 0.82rem;
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.42rem 0.7rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    resize: vertical;
    min-height: 58px;
    max-height: 120px;
    line-height: 1.45;
    }
    .form-group textarea:focus { border-color: var(--accent-car); box-shadow: 0 0 0 3px rgba(77,159,255,0.12); }

    li .action-btns {
    display: none;
    align-items: center;
    gap: 0.15rem;
    flex-shrink: 0;
    }
    li:hover .action-btns { display: flex; }
    li .right-side {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    flex-shrink: 0;
    }

    li .price-text {
    font-family: 'Space Mono', monospace;
    color: var(--text-dim);
    font-size: 0.68rem;
    transition: color var(--transition);
    }
    li:hover .price-text { color: var(--accent-gold); }

    li .delete-btn, li .edit-btn {
    cursor: pointer;
    font-size: 0.95rem;
    opacity: 0.6;
    transition: opacity var(--transition), color var(--transition);
    }
    li .edit-btn { color: var(--accent-car); }
    li .delete-btn { color: var(--accent-red); }
    li .delete-btn:hover, li .edit-btn:hover { opacity: 1; }
    body.prices-hidden .price-text { display: none; }
    body.prices-hidden #table-view th.col-money,
    body.prices-hidden #table-view td.col-money { display: none; }
    body.prices-hidden .stats-investment-section { display: none; }

    /* ── FICHA TITLE COLOR BARS ── */

    button.active {
    background: var(--bg-hover);
    border-color: var(--border-bright);
    color: var(--text-primary);
    }

    /* ── TABLE ── */
    #table-view { width:100%; border-collapse:collapse; font-size:0.8rem; }
    #table-view th {
    font-family:'Space Mono',monospace;
    font-size:0.6rem;
    text-transform:uppercase;
    letter-spacing:.08em;
    color:var(--text-dim);
    padding:0.5rem 0.8rem;
    border-bottom:1px solid var(--border-color);
    text-align:left;
    cursor:pointer;
    user-select:none;
    white-space:nowrap;
    background: var(--bg-element);
    }
    #table-view th:hover { color:var(--text-secondary); }
    #table-view th.sort-asc::after { content:' ↑'; color:var(--accent-car); }
    #table-view th.sort-desc::after { content:' ↓'; color:var(--accent-car); }
    #table-view td { padding:0.32rem 0.8rem; border-bottom:1px solid var(--border-color); color:var(--text-secondary); vertical-align:middle; }
    #table-view tr:hover td { background:var(--bg-element); color:var(--text-primary); }
    #table-view tr:hover .price-text { color:var(--accent-gold); }
    #table-view .tbl-edit, #table-view .tbl-del { display:inline; cursor:pointer; font-size:0.9rem; margin-left:3px; opacity:0; transition:opacity var(--transition); }
    #table-view tr:hover .tbl-edit, #table-view tr:hover .tbl-del { opacity:0.45; }
    #table-view tr:hover .tbl-edit:hover { opacity:1; }
    #table-view tr:hover .tbl-del:hover  { opacity:1; }
    #table-view .tbl-edit { color:var(--accent-car); }
    #table-view .tbl-del  { color:var(--accent-red); }
    #table-view .type-car  { color:var(--accent-car); font-size:0.65rem; font-weight:700; font-family:'Space Mono',monospace; }
    #table-view .type-moto { color:var(--accent-moto); font-size:0.65rem; font-weight:700; font-family:'Space Mono',monospace; }
    #table-view .tbl-nota { display:inline-block; width:5px; height:5px; border-radius:50%; background:transparent; vertical-align:middle; cursor:default; }
    #table-view .tbl-nota.has-nota { background:var(--accent-gold); box-shadow:0 0 5px rgba(240,180,41,0.5); }

    /* ── GALLERY VIEW ── */
    #gallery-container { display:flex; flex-direction:column; gap:1.6rem; }
    .gallery-group { animation: fadeUp 0.35s cubic-bezier(0.16,1,0.3,1) both; }
    .gallery-group-header {
    display:flex; align-items:center; gap:0.55rem;
    padding:0 0.15rem 0.6rem;
    margin-bottom:0.95rem;
    border-bottom:1px solid var(--border-color);
    }
    .gallery-group-header .gg-title {
    display:flex; align-items:center; gap:0.4rem;
    font-family:'Outfit', sans-serif; font-size:1.02rem; font-weight:700;
    letter-spacing:-0.01em; color:var(--text-primary);
    }
    .gallery-group-header .gg-swatch { width:12px; height:12px; border-radius:3px; border:1px solid var(--border-bright); flex-shrink:0; }
    .gallery-group-header .gg-count {
    display:flex; align-items:center;
    }

    /* ── BOTÓN RENOMBRAR ESTANTE (✎) ─────────────────────────── */
    /* Oculto por defecto en AMBAS vistas; se revela solo al pasar el cursor
       por la cabecera del estante (galería o card). */
    .shelf-rename-btn {
    cursor:pointer;
    color:var(--text-dim);
    font-size:0.8rem; line-height:1;
    flex-shrink:0;
    -webkit-user-select:none; user-select:none;
    opacity:0;
    pointer-events:none;
    transition:color 0.15s, opacity 0.15s, transform 0.15s;
    }
    .shelf-rename-btn:hover { color:var(--accent-car); }

    .gallery-group-header:hover .shelf-rename-btn,
    .country-header:hover .shelf-rename-btn,
    .shelf-rename-btn:focus-visible {
    opacity:1;
    pointer-events:auto;
    }

    /* Vista cards: pegar el botón al texto del título; el badge (contador) se va
       a la derecha gracias a margin-right:auto. En galería ya queda junto al
       título por el gap del header. */
    .country-header .shelf-rename-btn {
    margin-right:auto;
    margin-left:0.45rem;
    transform:translateX(-4px);
    }
    .country-header:hover .shelf-rename-btn,
    .country-header .shelf-rename-btn:focus-visible {
    transform:none;
    }

    /* ── Grupo de acciones de estante (renombrar / vaciar / eliminar) ── */
    .shelf-actions { display:inline-flex; align-items:center; gap:0.25rem; flex-shrink:0; }
    .country-header .shelf-actions { margin-right:auto; margin-left:0.45rem; transform:translateX(-4px); }
    .country-header:hover .shelf-actions { transform:none; }
    .shelf-act-btn {
    cursor:pointer;
    color:var(--text-dim);
    font-size:0.8rem; line-height:1;
    flex-shrink:0;
    -webkit-user-select:none; user-select:none;
    opacity:0;
    pointer-events:none;
    transition:color 0.15s, opacity 0.15s, transform 0.15s;
    }
    .gallery-group-header:hover .shelf-act-btn,
    .country-header:hover .shelf-act-btn,
    .shelf-act-btn:focus-visible {
    opacity:1;
    pointer-events:auto;
    }
    .shelf-act-btn.act-rename:hover { color:var(--accent-car); }
    .shelf-act-btn.act-empty:hover  { color:var(--accent-moto); }
    .shelf-act-btn.act-delete:hover { color:#e5534b; }

    /* ── DRAG & DROP DE ESTANTES ── */
    /* Estante (sección de galería o tarjeta de cards) resaltado mientras
       arrastras un vehículo por encima */
    .gallery-group.shelf-drag-over,
    .country-card.shelf-drag-over {
    outline: 2px dashed var(--accent-car);
    outline-offset: 4px;
    border-radius: 10px;
    background: var(--accent-car-dim);
    box-shadow: 0 0 0 4px rgba(77,159,255,0.14);
    transition: background 0.12s, box-shadow 0.12s, outline-color 0.12s;
    }
    .country-card.shelf-drag-over { outline-offset: 2px; }
    /* Cursor de agarre y feedback del elemento que se arrastra */
    .shelf-draggable { cursor: grab; }
    .shelf-dragging { opacity: 0.4; }

    /* ── SCRUBBER DE NAVEGACIÓN (vista galería) ── */
    .gallery-scrubber {
    position: fixed;
    top: 6.5rem; bottom: 1rem; right: 0.35rem;
    display: flex; flex-direction: column;
    justify-content: space-evenly; align-items: flex-end;
    z-index: 60;
    }
    .gallery-scrubber::before {
    content: '';
    position: absolute; top: 0; bottom: 0; right: 3px;
    width: 1px; background: var(--border-color);
    }
    .gallery-scrubber-item {
    display: flex; align-items: center; gap: 0.5rem;
    cursor: pointer;
    }
    /* dot del scrubber: compartido por galería y cronología (ver regla unificada abajo) */
    .gallery-scrubber-item:hover .gallery-scrubber-dot,
    .gallery-scrubber-item.active .gallery-scrubber-dot,
    .timeline-scrubber-item:hover .timeline-scrubber-dot,
    .timeline-scrubber-item.active .timeline-scrubber-dot {
    background: var(--accent-car);
    transform: scale(1.5);
    box-shadow: 0 0 6px var(--accent-car-glow);
    }
    .gallery-scrubber-dot,
    .timeline-scrubber-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--border-bright);
    transition: background var(--transition), transform 0.15s var(--ease-spring);
    flex-shrink: 0;
    }
    .gallery-scrubber-label {
    font-family: 'Outfit', sans-serif; font-size: 0.7rem; font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-element); border: 1px solid var(--border-bright);
    padding: 0.18rem 0.55rem; border-radius: 5px;
    white-space: nowrap;
    opacity: 0; transform: translateX(6px);
    transition: opacity var(--transition), transform var(--transition);
    pointer-events: none;
    }
    .gallery-scrubber-item:hover .gallery-scrubber-label,
    .gallery-scrubber-item.active .gallery-scrubber-label {
    opacity: 1; transform: translateX(0); color: var(--text-primary);
    }

    /* ── BOTÓN VOLVER ARRIBA ── */
    #scrollTopBtn {
    position: fixed;
    right: 1.6rem; bottom: 1.6rem;
    z-index: 70;
    width: 2.6rem; height: 2.6rem;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    background: var(--nav-btn-bg);
    border: 1px solid var(--nav-btn-border);
    border-radius: 50%;
    color: var(--nav-btn-color);
    cursor: pointer;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-lift);
    opacity: 0; visibility: hidden;
    transform: translateY(10px) scale(0.92);
    transition: opacity var(--transition), transform var(--transition),
                visibility var(--transition), background var(--transition),
                border-color var(--transition), color var(--transition);
    }
    #scrollTopBtn.visible {
    opacity: 1; visibility: visible;
    transform: translateY(0) scale(1);
    }
    #scrollTopBtn:hover {
    background: var(--nav-btn-bg-hover);
    border-color: var(--nav-btn-border-hover);
    color: var(--nav-btn-color-hover);
    transform: translateY(-2px) scale(1.05);
    }
    #scrollTopBtn:active { transform: translateY(0) scale(0.96); }
    #scrollTopBtn svg {
    width: 1.3rem; height: 1.3rem;
    fill: none; stroke: currentColor;
    stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
    }

    /* ── SCRUBBER DE NAVEGACIÓN (vista cronología, horizontal) ── */
    .timeline-scrubber {
    position: fixed;
    left: 50%; bottom: 0.85rem;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 3rem));
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    padding: 0.55rem 1rem 0.4rem;
    background: var(--bg-element);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    z-index: 60;
    }
    .timeline-scrubber::before {
    content: '';
    position: absolute; left: 1rem; right: 1rem; top: 1.05rem;
    height: 1px; background: var(--border-color);
    }
    .timeline-scrubber-item {
    display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
    cursor: pointer;
    position: relative;
    z-index: 1;
    }
    /* .timeline-scrubber-dot y su estado hover/active: unificados con gallery-scrubber-dot arriba */
    .timeline-scrubber-label {
    font-family: 'Space Mono', monospace; font-size: 0.66rem; font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.02em;
    transition: color var(--transition);
    }
    .timeline-scrubber-item:hover .timeline-scrubber-label,
    .timeline-scrubber-item.active .timeline-scrubber-label {
    color: var(--accent-car);
    }
    @media (max-width: 540px) {
    .timeline-scrubber { padding: 0.5rem 0.6rem 0.35rem; }
    .timeline-scrubber::before { left: 0.6rem; right: 0.6rem; }
    }
    .gallery-grid {
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(190px, 1fr));
    gap:0.85rem;
    }
    .gallery-grid + .gallery-grid { margin-top:0.6rem; }
    .gallery-tile {
    position:relative;
    background:var(--bg-card);
    border:1px solid var(--border-color);
    border-radius:var(--radius-lg);
    overflow:hidden;
    cursor:pointer;
    box-shadow:var(--shadow-card);
    transition:border-color var(--transition), box-shadow 0.25s ease, transform 0.3s cubic-bezier(0.34,1.45,0.64,1);
    animation: riseIn 0.65s cubic-bezier(0.16,1,0.3,1) backwards;
    animation-delay: calc(var(--si, 0) * 35ms);
    }
    @keyframes riseIn {
    from { opacity:0; transform:translateY(22px) scale(0.97); }
    }
    .tl-tile .gallery-tile { animation: none; }
    .gallery-tile:hover {
    border-color:var(--border-glow);
    box-shadow:var(--shadow-hover);
    transform:translateY(-3px);
    }

    /* ═══════════════════════════════════════════════════════════════
       VISTA ESTADÍSTICAS (integrada en el área principal)
       Antes era un modal; ahora es una vista más. Se reparte a lo ancho
       del contenido con rejillas auto-fit, respetando el lenguaje visual
       (var(--bg-card), bordes y radios) del resto de vistas.
       ═══════════════════════════════════════════════════════════════ */
    #stats-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.7rem;
    padding-top: 0.4rem;
    }

    /* — Título de la vista — */
    .stats-view-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    margin-bottom: 0.2rem;
    }
    .stats-view-header i { font-size: 1.1rem; color: var(--text-secondary); }

    /* — Tira de KPIs principales — */
    .stats-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
    gap: 0.6rem;
    }
    .stats-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.7rem 0.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    text-align: center;
    min-width: 0;
    }
    .stats-kpi-label {
    font-size: 0.66rem;
    color: var(--text-secondary);
    white-space: nowrap;
    letter-spacing: 0.03em;
    }
    .stats-kpi-val {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    line-height: 1;
    }

    /* — Títulos de sección (Inversión, Completitud) — */
    .stats-section-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    font-family: 'Space Mono', monospace;
    }

    /* — Distribuciones: paneles que llenan el ancho disponible — */
    .stats-dist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.1rem;
    align-items: start;
    }
    .stats-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
    min-width: 0;
    }
    .stats-panel-title {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-family: 'Space Mono', monospace;
    }

    /* — Inversión — */
    .stats-investment-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.95rem 1rem 1.05rem;
    }
    .stats-inv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.6rem;
    }
    .stats-inv-kpi {
    background: var(--bg-element);
    border: 1px solid var(--border-color);
    border-radius: 9px;
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    min-width: 0;
    }
    .stats-inv-label {
    font-size: 0.58rem;
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    }
    .stats-inv-val {
    font-size: 1rem;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    }
    .stats-inv-sub {
    font-size: 0.6rem;
    color: var(--text-dim);
    }

    /* — Completitud — */
    .stats-completeness {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.95rem 1rem;
    }
    .stats-completeness-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    }

    /* — Estado vacío — */
    .stats-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    line-height: 1.7;
    padding: 3rem 1rem;
    }

    /* ═══════════════════════════════════════════════════════════════
       AMPLIACIÓN DE ESTADÍSTICAS
       ═══════════════════════════════════════════════════════════════ */

    /* Lo monetario se oculta con el toggle de precios, igual que Inversión */
    body.prices-hidden .stats-money-section,
    body.prices-hidden .stats-rec--money { display: none; }

    /* — Destacados (records) — */
    .stats-rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
    }
    .stats-rec {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.7rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    }
    .stats-rec-label {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    font-family: 'Space Mono', monospace;
    white-space: nowrap;
    }
    .stats-rec-main {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    }
    .stats-rec-sub {
    font-size: 0.68rem;
    font-family: 'Space Mono', monospace;
    color: var(--text-dim);
    }

    /* — Fila de dos columnas: Composición (izq) + Salud de datos (der) — */
    .stats-comp-health-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.1rem;
    align-items: start;
    }
    @media (max-width: 640px) {
    .stats-comp-health-row { grid-template-columns: 1fr; }
    }

    /* — Composición: mismo lienzo que Inversión — */
    .stats-composition {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.95rem 1rem 1.05rem;
    }
    /* Grid interno más compacto: caben 3 cols cuando hay espacio */
    .stats-composition .stats-inv-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }

    /* — Rejilla de 2 paneles (histograma+maker, scatter+revalor.) — */
    .stats-twin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(238px, 1fr));
    gap: 1.1rem;
    align-items: start;
    }

    /* — Histograma de precios — */
    .stats-hist-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 6px 0;
    font-size: 0.75rem;
    }
    .stats-hist-label {
    font-family: 'Space Mono', monospace;
    color: var(--text-secondary);
    min-width: 58px;
    }
    .stats-hist-track {
    flex: 1;
    height: 8px;
    background: var(--bg-element);
    border-radius: 4px;
    overflow: hidden;
    }
    .stats-hist-fill {
    display: block;
    height: 100%;
    background: #4d9fff;
    opacity: 0.8;
    border-radius: 4px;
    }
    .stats-hist-val {
    font-family: 'Space Mono', monospace;
    color: var(--text-primary);
    min-width: 22px;
    text-align: right;
    }

    /* — Inversión por maker — */
    .stats-mk-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.56rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-family: 'Space Mono', monospace;
    margin-bottom: 0.3rem;
    }
    .stats-mk-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 6px 0;
    font-size: 0.75rem;
    }
    .stats-mk-name {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    }
    .stats-mk-bartrack { width: 80px; flex-shrink: 0; }
    .stats-mk-bar {
    display: inline-block;
    height: 4px;
    background: #f0b429;
    border-radius: 3px;
    opacity: 0.7;
    vertical-align: middle;
    }
    .stats-mk-coste {
    font-family: 'Space Mono', monospace;
    color: var(--text-primary);
    min-width: 46px;
    text-align: right;
    }
    .stats-mk-ratio {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    min-width: 42px;
    text-align: right;
    }

    /* — Revalorización por pieza (barras divergentes) — */
    .stats-div-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 5px 0;
    font-size: 0.74rem;
    }
    .stats-div-name {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    }
    .stats-div-track {
    display: flex;
    width: 110px;
    flex-shrink: 0;
    }
    .stats-div-half {
    width: 50%;
    height: 7px;
    display: flex;
    }
    .stats-div-neg { justify-content: flex-end; border-right: 1px solid var(--border-color); }
    .stats-div-fill { display: block; height: 100%; border-radius: 2px; opacity: 0.8; }
    .stats-div-val {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    min-width: 46px;
    text-align: right;
    }

    /* — Scatter precio vs valor — */
    .stats-scatter-host { width: 100%; min-height: 230px; }
    .stats-scatter { width: 100%; height: 230px; display: block; }
    .stats-scatter-legend {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
    font-size: 0.62rem;
    color: var(--text-dim);
    font-family: 'Space Mono', monospace;
    }
    .stats-scatter-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
    .stats-scatter-legend .sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
    .stats-scatter-legend .dash { width: 12px; height: 0; border-top: 1px dashed var(--text-dim); display: inline-block; }

    /* — Salud de datos (barra global) — */
    .stats-health-bar {
    height: 7px;
    background: var(--bg-element);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.85rem;
    }
    .stats-health-bar span { display: block; height: 100%; border-radius: 4px; opacity: 0.85; }

    /* — Vacío en paneles pequeños — */
    .stats-mini-empty {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-style: italic;
    padding: 0.6rem 0;
    }

    /* ═══════════════════════════════════════════════════════════════
       PANELES RANKEABLES (forma + métrica rotables)
       ═══════════════════════════════════════════════════════════════ */
    .stats-rk-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 0.95rem 0.95rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    }
    .stats-rk-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
    }
    .stats-rk-title {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-secondary);
    font-family: 'Space Mono', monospace;
    }
    .stats-rk-ctls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

    .stats-ctl {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    padding: 3px 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 7px;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    }
    .stats-ctl:hover { border-color: var(--text-dim); color: var(--text-primary); }
    .stats-ctl.on {
    background: var(--bg-element);
    color: var(--text-primary);
    border-color: var(--text-dim);
    font-weight: 700;
    }
    .stats-rk-rotate { display: inline-flex; align-items: center; gap: 4px; }
    .stats-rk-rotate i { font-size: 0.72rem; }
    .stats-metric-grp { display: inline-flex; gap: 3px; }

    .stats-rk-body { min-height: 190px; }

    /* Barras */
    .stats-rk-row { display: flex; align-items: center; padding: 7px 0; font-size: 0.77rem; gap: 8px; }
    .stats-rk-name { color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
    .stats-rk-track { width: 86px; height: 6px; background: var(--bg-element); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
    .stats-rk-fill { display: block; height: 100%; border-radius: 3px; opacity: 0.78; }
    .stats-rk-num { font-family: 'Space Mono', monospace; color: var(--text-primary); font-size: 0.72rem; min-width: 44px; text-align: right; }

    /* Donut */
    .stats-dn-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding-top: 0.3rem; }
    .stats-dn-legend { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
    .stats-dn-leg { display: flex; align-items: center; gap: 6px; font-size: 0.68rem; color: var(--text-secondary); white-space: nowrap; }
    .stats-dn-leg .sw { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }

    /* Treemap */
    .stats-tm { position: relative; width: 100%; height: 190px; border-radius: 8px; overflow: hidden; }
    .stats-tm-cell { position: absolute; box-sizing: border-box; border: 1.5px solid var(--bg-card); display: flex; align-items: flex-start; }
    .stats-tm-lbl { font-size: 0.62rem; font-weight: 700; color: #fff; background: rgba(0,0,0,0.38); border-radius: 4px; padding: 1px 5px; margin: 4px; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Tabla rankeable */
    .stats-rk-tbl { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
    .stats-rk-tbl th { text-align: right; font-weight: 700; color: var(--text-dim); padding: 5px 6px; border-bottom: 1px solid var(--border-color); font-family: 'Space Mono', monospace; font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.04em; }
    .stats-rk-tbl th.nm, .stats-rk-tbl td.nm { text-align: left; }
    .stats-rk-tbl td { padding: 5px 6px; border-bottom: 1px solid var(--border-color); font-family: 'Space Mono', monospace; text-align: right; color: var(--text-secondary); }
    .stats-rk-tbl td.nm { font-family: inherit; }
    .stats-rk-tbl td.on { color: var(--text-primary); font-weight: 700; }
    .stats-rk-tbl td.pct, .stats-rk-tbl th.pct { color: var(--text-dim); }

    /* Ocultar columnas/botones monetarios con el toggle de precios */
    body.prices-hidden .stats-metric--money,
    body.prices-hidden .stats-col-money { display: none; }
