/* ============================================
   AGGREGATE ANALYSIS - VERSIONE OTTIMIZZATA
   H1 semplice + Meta centrati + Mobile perfect
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #ffa600;
    --primary-light: #ffcc00;
    --primary-dark: #ff8800;
    --secondary: #0096ff;
    --success: #10b981;
    --danger: #ef4444;
    --dark-1: #1a1a2e;
    --dark-2: #16213e;
    --dark-3: #1e293b;
    --dark-4: #0f172a;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--dark-1) 0%, var(--dark-2) 100%);
    color: #ffffff;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* ============================================
   ANIMATED BACKGROUND PARTICLES
   ============================================ */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(255, 166, 0, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(0, 150, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    animation: particleFloat 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes particleFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ============================================
   HEADER - SEMPLICE SENZA BORDO TRICOLORE
   ============================================ */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, rgba(255, 166, 0, 0.1) 0%, rgba(255, 166, 0, 0.05) 100%);
    border-radius: 20px;
    border: 2px solid rgba(255, 166, 0, 0.2);
    animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* H1 SEMPLICE - RIPRISTINATO */
.header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffa600 0%, #ffcc00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.header-subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    font-weight: 400;
}

/* ============================================
   HERO CARD - MIGLIORATA
   ============================================ */
.hero-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 32px;
    padding: 40px;
    margin-bottom: 30px;
    border: 2px solid rgba(255, 166, 0, 0.3);
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(255, 166, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    min-height: 350px;
    position: relative;
    overflow: hidden;
    animation: heroAppear 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes heroAppear {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.hero-card:hover {
    transform: translateY(-8px);
    box-shadow:
        0 40px 120px rgba(0, 0, 0, 0.7),
        0 0 80px rgba(255, 166, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 166, 0, 0.5);
}

/* Gradient animato background */
.hero-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at center,
        rgba(255, 166, 0, 0.15) 0%,
        rgba(0, 150, 255, 0.1) 40%,
        transparent 70%
    );
    animation: heroRotate 15s linear infinite;
}

@keyframes heroRotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Particelle luminose */
.hero-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255, 166, 0, 0.3) 1px, transparent 1px),
        radial-gradient(circle at 80% 70%, rgba(0, 150, 255, 0.3) 1px, transparent 1px),
        radial-gradient(circle at 40% 80%, rgba(16, 185, 129, 0.3) 1px, transparent 1px);
    background-size: 50px 50px, 80px 80px, 60px 60px;
    opacity: 0.3;
    animation: particleMove 20s linear infinite;
}

@keyframes particleMove {
    0% {
        background-position: 0 0, 0 0, 0 0;
    }
    100% {
        background-position: 50px 50px, -80px 80px, 60px -60px;
    }
}

.hero-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    position: relative;
    z-index: 1;
}

.hero-loading .spinner {
    width: 80px;
    height: 80px;
    border: 5px solid rgba(255, 166, 0, 0.2);
    border-top-color: #ffa600;
    border-right-color: #ffcc00;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin-bottom: 25px;
    box-shadow:
        0 0 30px rgba(255, 166, 0, 0.5),
        inset 0 0 20px rgba(255, 166, 0, 0.2);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hero-loading p {
    color: #cbd5e1;
    font-size: 1.2rem;
    font-weight: 500;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ============================================
   STATUS BADGES - 3D EFFECT
   ============================================ */
.status-badge {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 25px;
    animation: badgePop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.3s both;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.status-badge:hover {
    transform: translateY(-3px) scale(1.05);
}

.status-excellent {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow:
        0 10px 40px rgba(16, 185, 129, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.status-good {
    background: linear-gradient(135deg, #ffa600 0%, #ff8800 100%);
    box-shadow:
        0 10px 40px rgba(255, 166, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.status-declining {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow:
        0 10px 40px rgba(239, 68, 68, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.status-poor {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow:
        0 10px 40px rgba(100, 116, 139, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* ============================================
   NARRATIVE TEXT - ENHANCED
   ============================================ */
.narrative-text {
    position: relative;
    z-index: 1;
    text-align: center; /* ✅ CENTRATO */
}

.narrative-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #ffa600 0%, #ffcc00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleSlide 0.6s ease-out 0.4s both;
}

@keyframes titleSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.narrative-body {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #e2e8f0;
    margin-bottom: 25px;
    max-width: 800px; /* ✅ LIMITA LARGHEZZA PER LEGGIBILITÀ */
    margin-left: auto;
    margin-right: auto;
    animation: fadeInUp 0.8s ease-out 0.5s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   META ITEMS - CENTRATI E MOBILE PERFECT
   ============================================ */
.narrative-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 30px;
    margin-top: 35px;
    padding-top: 25px;
    border-top: 2px solid rgba(255, 166, 0, 0.3);
    max-width: 700px; /* ✅ LIMITA LARGHEZZA */
    margin-left: auto;
    margin-right: auto;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center; /* ✅ CENTRATO */
    text-align: center; /* ✅ CENTRATO */
    animation: metaAppear 0.6s ease-out backwards;
    padding: 20px 15px;
    background: rgba(255, 166, 0, 0.05);
    border-radius: 16px;
    border: 1px solid rgba(255, 166, 0, 0.2);
    transition: all 0.3s ease;
}

.meta-item:hover {
    background: rgba(255, 166, 0, 0.1);
    border-color: rgba(255, 166, 0, 0.4);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 166, 0, 0.3);
}

.meta-item:nth-child(1) { animation-delay: 0.6s; }
.meta-item:nth-child(2) { animation-delay: 0.7s; }
.meta-item:nth-child(3) { animation-delay: 0.8s; }

@keyframes metaAppear {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.meta-label {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.meta-value {
    font-size: 2.2rem; /* ✅ DIMENSIONE OTTIMALE */
    font-weight: 900;
    background: linear-gradient(135deg, #ffa600 0%, #ffcc00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    transition: all 0.3s ease;
}

.meta-item:hover .meta-value {
    transform: scale(1.15);
    filter: brightness(1.3);
}

/* ============================================
   ACTION BUTTONS - SPECTACULAR
   ============================================ */
.action-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center; /* ✅ CENTRATO SU MOBILE */
}

.btn-primary, .btn-secondary, .btn-danger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    border: none;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    min-width: 180px; /* ✅ LARGHEZZA MINIMA */
    justify-content: center;
}

.btn-primary::before,
.btn-secondary::before,
.btn-danger::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before,
.btn-secondary:hover::before,
.btn-danger:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, #ffa600 0%, #ff8800 100%);
    color: #000;
    box-shadow:
        0 8px 25px rgba(255, 166, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow:
        0 12px 40px rgba(255, 166, 0, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(-2px) scale(0.98);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 166, 0, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(255, 166, 0, 0.3);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 2px solid rgba(239, 68, 68, 0.4);
    backdrop-filter: blur(10px);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

.btn-icon {
    font-size: 1.3rem;
    transition: transform 0.3s ease;
}

.btn-primary:hover .btn-icon,
.btn-secondary:hover .btn-icon,
.btn-danger:hover .btn-icon {
    transform: rotate(15deg) scale(1.2);
}

/* ============================================
   TABS - MODERN UNDERLINE
   ============================================ */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    overflow-x: auto;
    padding-bottom: 15px;
    position: relative;
    justify-content: center; /* ✅ CENTRATO */
    flex-wrap: wrap; /* ✅ WRAP SU MOBILE */
}

.tabs::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.tab-btn {
    padding: 14px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #94a3b8;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    position: relative;
}

.tab-btn::before {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #ffa600, #ffcc00);
    transform: translateX(-50%);
    transition: width 0.3s ease;
    border-radius: 3px 3px 0 0;
}

.tab-btn:hover {
    color: #ffa600;
}

.tab-btn:hover::before {
    width: 100%;
}

.tab-btn.active {
    color: #ffa600;
    font-weight: 700;
}

.tab-btn.active::before {
    width: 100%;
    box-shadow: 0 0 20px rgba(255, 166, 0, 0.8);
}

/* ============================================
   TAB CONTENT
   ============================================ */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: tabFade 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tabFade {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   STATS GRID - 3D CARDS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.stat-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 166, 0, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    border-color: rgba(255, 166, 0, 0.6);
    transform: translateY(-10px) scale(1.02);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(255, 166, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

.stat-card:hover .stat-icon {
    transform: rotate(10deg) scale(1.1);
}

.stat-title {
    font-size: 1rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffa600 0%, #ffcc00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.stat-card:hover .stat-value {
    transform: scale(1.05);
    filter: brightness(1.2);
}

.stat-description {
    font-size: 0.95rem;
    color: #cbd5e1;
    line-height: 1.6;
}

/* ============================================
   RECOMMENDATIONS
   ============================================ */
.recommendation {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-left: 5px solid;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.recommendation::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    filter: blur(10px);
}

.recommendation:hover {
    transform: translateX(10px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.recommendation.priority-high {
    border-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, transparent 100%);
}

.recommendation.priority-high::before {
    background: #ef4444;
}

.recommendation.priority-medium {
    border-color: #ffa600;
    background: linear-gradient(135deg, rgba(255, 166, 0, 0.15) 0%, transparent 100%);
}

.recommendation.priority-medium::before {
    background: #ffa600;
}

.recommendation.priority-low {
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, transparent 100%);
}

.recommendation.priority-low::before {
    background: #10b981;
}

.rec-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.rec-priority {
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rec-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #e2e8f0;
}

.rec-description {
    color: #cbd5e1;
    line-height: 1.8;
    margin-top: 12px;
}

.rec-impact {
    margin-top: 15px;
    padding: 10px 15px;
    background: rgba(255, 166, 0, 0.15);
    border-radius: 10px;
    border-left: 3px solid #ffa600;
    font-size: 0.95rem;
    color: #ffa600;
    font-weight: 600;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.empty-icon {
    font-size: 6rem;
    margin-bottom: 25px;
    opacity: 0.4;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.empty-state h3 {
    font-size: 1.8rem;
    color: #e2e8f0;
    margin-bottom: 12px;
}

.empty-state p {
    color: #94a3b8;
    font-size: 1.1rem;
}

/* ============================================
   LOADING MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
    animation: modalFade 0.3s ease-out;
}

@keyframes modalFade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-loading {
    text-align: center;
    padding: 50px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
    backdrop-filter: blur(30px);
    border-radius: 32px;
    border: 2px solid rgba(255, 166, 0, 0.4);
    max-width: 550px;
    width: 90%;
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.8),
        0 0 60px rgba(255, 166, 0, 0.3);
    animation: modalSlide 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.spinner-large {
    width: 100px;
    height: 100px;
    border: 6px solid rgba(255, 166, 0, 0.2);
    border-top-color: #ffa600;
    border-right-color: #ffcc00;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 0 auto 35px;
    box-shadow:
        0 0 50px rgba(255, 166, 0, 0.6),
        inset 0 0 30px rgba(255, 166, 0, 0.3);
}

.modal-loading h3 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #ffa600 0%, #ffcc00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 18px;
    font-weight: 900;
}

.modal-loading p {
    color: #cbd5e1;
    margin-bottom: 35px;
    font-size: 1.1rem;
    animation: pulse 2s ease-in-out infinite;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffa600 0%, #ffcc00 50%, #ffa600 100%);
    background-size: 200% 100%;
    border-radius: 10px;
    width: 0%;
    animation: progressFill 4s ease-in-out infinite, progressShine 2s linear infinite;
    box-shadow: 0 0 20px rgba(255, 166, 0, 0.8);
}

@keyframes progressFill {
    0%, 100% {
        width: 0%;
    }
    50% {
        width: 95%;
    }
}

@keyframes progressShine {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* ============================================
   RESPONSIVE - MOBILE PERFECT
   ============================================ */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .header {
        padding: 25px 18px;
        margin-bottom: 25px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .header-subtitle {
        font-size: 1rem;
    }

    .hero-card {
        padding: 25px 20px;
        min-height: 300px;
    }

    .narrative-title {
        font-size: 1.6rem;
    }

    .narrative-body {
        font-size: 1.05rem;
        line-height: 1.7;
    }

    /* ✅ META GRID MOBILE OTTIMIZZATO */
    .narrative-meta {
        grid-template-columns: 1fr; /* 1 colonna su mobile */
        gap: 15px;
        padding-top: 20px;
        margin-top: 25px;
    }

    .meta-item {
        padding: 18px 12px;
    }

    .meta-label {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    .meta-value {
        font-size: 2rem; /* Leggibile ma non eccessivo */
    }

    /* ✅ STATS GRID MOBILE */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .stat-card {
        padding: 25px 20px;
    }

    .stat-value {
        font-size: 2.5rem;
    }

    /* ✅ ACTION BUTTONS MOBILE */
    .action-buttons {
        flex-direction: column;
        gap: 12px;
    }

    .btn-primary, .btn-secondary, .btn-danger {
        width: 100%;
        min-width: auto;
        padding: 16px 24px;
    }

    /* ✅ TABS MOBILE */
    .tabs {
        gap: 8px;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 12px;
    }

    .tab-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        flex-shrink: 0; /* Non comprimere */
    }

    /* ✅ MODAL MOBILE */
    .modal-loading {
        padding: 35px 25px;
        max-width: 95%;
    }

    .spinner-large {
        width: 80px;
        height: 80px;
    }

    .modal-loading h3 {
        font-size: 1.5rem;
    }

    .modal-loading p {
        font-size: 1rem;
    }

    /* ✅ RECOMMENDATIONS MOBILE */
    .recommendation {
        padding: 20px 18px;
    }

    .rec-title {
        font-size: 1.1rem;
    }
}

/* ============================================
   TABLET (769px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .narrative-meta {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   TOUCH OPTIMIZATION
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .tab-btn,
    .stat-card,
    .meta-item {
        min-height: 44px; /* iOS touch target */
    }
}