/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --spacing: 1.5rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing);
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    text-align: center;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Loading */
.loading {
    text-align: center;
    padding: 4rem 0;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Error */
.error {
    background-color: #fee2e2;
    border: 1px solid var(--danger-color);
    color: #991b1b;
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    margin: 2rem 0;
}

/* Filters */
.filters {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin: 2rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-group select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-group select:hover,
.filter-group select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.btn-primary, .btn-secondary {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin: 2rem 0 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 0.9375rem;
}

.tab-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

/* Content */
.content {
    margin: 2rem 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Small info icon used in performer headings */
.info-icon {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.95);
    cursor: default;
    vertical-align: middle;
}
.performer-card h3 .info-icon {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-left: 0.5rem;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kpi-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.kpi-content {
    flex: 1;
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.kpi-change {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.kpi-change.positive {
    background: #d1fae5;
    color: #065f46;
}

.kpi-change.negative {
    background: #fee2e2;
    color: #991b1b;
}

/* Charts */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.chart-card canvas {
    max-height: 300px;
}

/* Performers */
.performers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.performer-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.performer-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.performer-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.performer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.performer-item:hover {
    background: #e0e7ff;
    transform: translateX(4px);
}

.performer-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.performer-rank.gold {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.performer-rank.silver {
    background: linear-gradient(135deg, #e5e7eb 0%, #9ca3af 100%);
}

.performer-rank.bronze {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

.performer-name {
    flex: 1;
    margin: 0 0.75rem;
    font-weight: 500;
    font-size: 0.9375rem;
}

.performer-value {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9375rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin: 2rem 0;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.stat-card h4 {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

/* Insights */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.insight-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid;
}

.insight-card.success {
    border-left-color: var(--secondary-color);
}

.insight-card.warning {
    border-left-color: var(--warning-color);
}

/* Stat card typography improvements */
.stat-card h4 {
    font-size: 1.15rem; /* slightly larger title */
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
    color: rgba(255,255,255,0.95);
}

.stat-card .stat-value {
    display: block;
    font-size: 1.6rem; /* larger value for prominence */
    font-weight: 800;
    margin-top: 0.35rem;
    color: rgba(255,255,255,0.98);
    text-shadow: 0 1px 0 rgba(0,0,0,0.08);
}

/* Responsive scaling for smaller screens */
@media (max-width: 640px) {
    .stat-card h4 {
        font-size: 1rem;
    }
    .stat-card .stat-value {
        font-size: 1.35rem;
    }
}

.insight-card.info {
    border-left-color: var(--primary-color);
}

.insight-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.insight-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.insight-content ul {
    list-style: none;
    padding: 0;
}

.insight-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.insight-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 400;
}

.chart-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.insight-content li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.insight-content li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: 700;
}

/* Superlatives */
.superlatives {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.superlatives h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
}

.superlatives-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.superlative-item {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 1.25rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.superlative-item h4 {
    font-size: 0.875rem;
    color: #92400e;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.superlative-item p {
    font-size: 1.125rem;
    font-weight: 700;
    color: #78350f;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer p {
    opacity: 0.8;
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

/* Retention Analysis Styles */
.retention-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.retention-stats .stat {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
}

.retention-stats .stat h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.9;
}

.retention-stats .stat .big {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.retention-stats .stat small {
    font-size: 0.85rem;
    opacity: 0.8;
}

.yearly-retention {
    margin-top: 1.5rem;
}

.yearly-retention h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.year-retention {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.year-retention .year {
    font-weight: 600;
    color: var(--primary-color);
}

.year-retention .percentage {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success-color);
}

.year-retention small {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Category Health Score Styles */
.chart-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: -0.5rem 0 1rem 0;
    line-height: 1.5;
}

/* Item Cards for Items Tab */
.item-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.item-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
}

.item-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 50px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.item-content {
    flex: 1;
}

.item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.badge {
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.badge-hot {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

.badge-popular {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.badge-exceptional {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    animation: shimmer 3s ease-in-out infinite;
}

.badge-excellent {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.badge-good {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes shimmer {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

.item-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.stat-separator {
    color: #d1d5db;
    margin: 0 0.25rem;
}

.stat-arrow {
    color: #9ca3af;
    margin: 0 0.25rem;
}

.health-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.legend-item {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.legend-item.excellent {
    background: #10b981;
    color: white;
}

.legend-item.good {
    background: #3b82f6;
    color: white;
}

.legend-item.neutral {
    background: #6b7280;
    color: white;
}

.legend-item.warning {
    background: #f59e0b;
    color: white;
}

.legend-item.critical {
    background: #ef4444;
    color: white;
}

.category-health-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-health {
    padding: 1.25rem;
    border-radius: 8px;
    border-left: 4px solid;
    background: var(--bg-secondary);
}

.category-health.excellent {
    border-left-color: #10b981;
    background: linear-gradient(to right, rgba(16, 185, 129, 0.05), transparent);
}

.category-health.good {
    border-left-color: #3b82f6;
    background: linear-gradient(to right, rgba(59, 130, 246, 0.05), transparent);
}

.category-health.neutral {
    border-left-color: #6b7280;
    background: linear-gradient(to right, rgba(107, 114, 128, 0.05), transparent);
}

.category-health.warning {
    border-left-color: #f59e0b;
    background: linear-gradient(to right, rgba(245, 158, 11, 0.05), transparent);
}

.category-health.critical {
    border-left-color: #ef4444;
    background: linear-gradient(to right, rgba(239, 68, 68, 0.05), transparent);
}

.health-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.category-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.health-score {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.health-metrics {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.health-metrics span {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.health-reason {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .logo {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.875rem;
    }

    .filters {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .kpi-icon {
        font-size: 2rem;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .performers-grid,
    .insights-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .chart-card canvas {
        max-height: 250px;
    }
}

/* Print Styles */
@media print {
    .header,
    .filters,
    .tabs,
    .footer {
        display: none;
    }

    .tab-content {
        display: block !important;
        page-break-after: always;
    }

    .chart-card,
    .kpi-card,
    .performer-card {
        page-break-inside: avoid;
    }
}
