/* ===== CSS RESET AND BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --sidebar-bg: #1e293b;
    --sidebar-bg-light: #334155;
    
    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-white: #ffffff;
    --text-light: #f8fafc;
    
    /* Border Colors */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

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

/* ===== DASHBOARD LAYOUT ===== */
.dashboard {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ===== SIDEBAR STYLES ===== */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-light) 100%);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.sidebar-header {
    padding: var(--spacing-xl);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo i {
    font-size: 2rem;
    color: var(--primary-color);
}

.logo-icon {
    width: 36px;
    height: 36px;
}

.logo h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-white);
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-lg) 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    margin: var(--spacing-xs) 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-xl);
    color: var(--text-light);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    margin-right: var(--spacing-md);
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    transform: translateX(4px);
}

.nav-item.active .nav-link {
    background-color: var(--primary-color);
    color: var(--text-white);
    box-shadow: var(--shadow-md);
}

.nav-link i {
    font-size: 1.125rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: var(--spacing-xl);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.project-info h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--text-white);
}

.project-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== MAIN CONTENT STYLES ===== */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: var(--spacing-2xl);
    background-color: var(--bg-secondary);
    min-height: 100vh;
    width: calc(100vw - 280px);
    max-width: calc(100vw - 280px);
    overflow-x: hidden;
}

.page-header {
    margin-bottom: var(--spacing-lg);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.header-content h1 {
    font-size: 1.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

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


/* ===== BUTTON STYLES ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

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

.btn-secondary {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-medium);
    transform: translateY(-1px);
}

.btn-sm {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.75rem;
}

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

/* ===== METRICS GRID ===== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.metric-card {
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(255, 255, 255, 0.95) 100%);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--info-color));
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.metric-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.metric-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-white);
}

.metric-icon.loc {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.metric-icon.complexity {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
}

.metric-icon.maintainability {
    background: linear-gradient(135deg, var(--success-color), #059669);
}

.metric-icon.avg-loc {
    background: linear-gradient(135deg, var(--info-color), #0891b2);
}

.metric-title h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.metric-title p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.metric-value {
    margin-bottom: var(--spacing-md);
    position: relative;
}

.metric-value .value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: inline-block;
}

.metric-value .unit {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-left: var(--spacing-sm);
}

.trend-badge {
    position: absolute;
    top: -4px;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 600;
    border: 1px solid;
    cursor: help;
    transition: all var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.trend-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.12);
}

.trend-badge i {
    font-size: 0.625rem;
}

.trend-badge .trend-value {
    font-weight: 700;
}

.trend-badge.positive {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #059669;
}

.trend-badge.negative {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.trend-badge.neutral {
    background-color: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.3);
    color: #64748b;
}

.metric-description {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-light);
}

.metric-description p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

/* Metric Segmentation Styles */
.metric-segmentation {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md); /* Add padding to prevent tooltip clipping */
}

.segment-bar {
    display: flex;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--bg-tertiary);
    margin-bottom: var(--spacing-md);
}

.segment {
    height: 100%;
    transition: all 0.3s ease;
    flex-shrink: 0;
    flex-grow: 0;
    cursor: pointer;
    position: relative;
    /* min-width now handled dynamically in JavaScript */
}

.segment:hover {
    transform: scaleY(1.2);
    z-index: 10;
}

/* Tooltip styles */
.segment[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.segment[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    margin-bottom: -5px;
    z-index: 1000;
}

.segment.good {
    background-color: #10b981; /* Green */
}

.segment.okay {
    background-color: #f59e0b; /* Yellow/Amber */
}

.segment.warning {
    background-color: #f97316; /* Orange */
}

.segment.critical {
    background-color: #ef4444; /* Red */
}

.segment-labels {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
}

.segment-label {
    text-align: center;
    padding: var(--spacing-xs);
}

.segment-count {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.segment-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.segment-label.good .segment-count {
    color: #10b981;
}

.segment-label.okay .segment-count {
    color: #f59e0b;
}

.segment-label.warning .segment-count {
    color: #f97316;
}

.segment-label.critical .segment-count {
    color: #ef4444;
}


/* ===== CHART SECTION ===== */
.chart-section {
    margin-bottom: var(--spacing-2xl);
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-xl);
}

.chart-container {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-xl);
}

.chart-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.chart-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.chart-controls {
    display: flex;
    gap: var(--spacing-sm);
}

.chart-content {
    height: 300px;
    position: relative;
}

.chart-container.small .chart-content {
    height: 250px;
}

.chart-container.small {
    padding: var(--spacing-lg);
}

.chart-container.small .chart-header h3 {
    font-size: 1.125rem;
}

.chart-container.small .chart-header p {
    font-size: 0.8125rem;
}

/* ===== ADDITIONAL CONTENT SECTIONS ===== */
.content-sections {
    margin-bottom: var(--spacing-2xl);
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-xl);
}

.info-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.info-card h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .page-header {
        flex-direction: column;
        gap: var(--spacing-lg);
    }
    
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .dashboard {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .main-content {
        padding: var(--spacing-lg);
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .section-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-section {
        grid-template-columns: 1fr;
    }
    
    .chart-header {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .header-content h1 {
        font-size: 2rem;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.metric-card {
    animation: fadeInUp var(--transition-normal) ease-out;
}

.metric-card:nth-child(1) { animation-delay: 0.1s; }
.metric-card:nth-child(2) { animation-delay: 0.2s; }
.metric-card:nth-child(3) { animation-delay: 0.3s; }
.metric-card:nth-child(4) { animation-delay: 0.4s; }

/* ===== LOADING STATES ===== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    border-top: 2px solid transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== GIT ANALYSIS PAGE SPECIFIC STYLES ===== */
.git-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.hotspot-table, .contributor-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--spacing-md);
    table-layout: auto; /* Allow table to expand for content */
}

.hotspot-table th, .hotspot-table td,
.contributor-table th, .contributor-table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    word-wrap: break-word; /* Allows long text to wrap */
    overflow: hidden;
}

.hotspot-table th, .contributor-table th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.hotspot-table td, .contributor-table td {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* First column (file path/name) should be wider and show tooltip */
.hotspot-table td:first-child,
.contributor-table td:first-child {
    min-width: 250px;
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}

.hotspot-table th:first-child,
.contributor-table th:first-child {
    min-width: 250px;
    max-width: 400px;
}

/* Owner column in Knowledge Silos table should also be wider */
.hotspot-table td:nth-child(2) {
    min-width: 150px;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}

.hotspot-table th:nth-child(2) {
    min-width: 150px;
}

.risk-badge {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    white-space: nowrap;
}

.risk-high { background-color: rgba(239, 68, 68, 0.1); color: #dc2626; }
.risk-medium { background-color: rgba(245, 158, 11, 0.1); color: #d97706; }
.risk-low { background-color: rgba(16, 185, 129, 0.1); color: #059669; }

.author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    margin-right: var(--spacing-sm);
    vertical-align: middle;
    flex-shrink: 0;
}

.progress-bar {
    width: 100px;
    height: 8px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-left: var(--spacing-sm);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--info-color));
    transition: width 0.3s ease;
}

.two-column-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.stat-highlight {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
}

.section-divider {
    margin: var(--spacing-2xl) 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}

/* Table container with horizontal scroll for mobile */
.table-container {
    overflow-x: auto;
    margin: -1px; /* Prevent scrollbar from clipping */
}

/* ===== RESPONSIVE STYLES FOR GIT ANALYSIS ===== */
@media (max-width: 1200px) {
    .git-metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    .git-metrics-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .two-column-section {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .hotspot-table, .contributor-table {
        font-size: 0.8rem;
    }
    
    .hotspot-table th, .hotspot-table td,
    .contributor-table th, .contributor-table td {
        padding: var(--spacing-sm);
    }
    
    /* Stack author info vertically on mobile */
    .contributor-table td:first-child {
        white-space: normal;
    }
    
    .author-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    .progress-bar {
        width: 80px;
        margin: var(--spacing-xs) 0;
        display: block;
    }
    
    .stat-highlight {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: var(--spacing-md);
    }
    
    .git-metrics-grid {
        gap: var(--spacing-md);
    }
    
    .two-column-section {
        gap: var(--spacing-md);
    }
    
    .hotspot-table, .contributor-table {
        font-size: 0.75rem;
    }
    
    .hotspot-table th, .hotspot-table td,
    .contributor-table th, .contributor-table td {
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    /* Hide less important columns on very small screens */
    .hotspot-table th:last-child,
    .hotspot-table td:last-child {
        display: none;
    }
    
    .risk-badge {
        font-size: 0.65rem;
        padding: 2px var(--spacing-xs);
    }
}

/* ===== TRENDS PAGE STYLES ===== */
.trends-section {
    margin-bottom: var(--spacing-2xl);
}

.section-header {
    margin-bottom: var(--spacing-xl);
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.section-header h2 i {
    color: var(--primary-color);
}

.section-header p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-left: 2.25rem;
}

/* Health Distribution Grid */
.health-distribution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-xl);
}

.health-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.health-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
}

.health-card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.time-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Segment Comparison */
.segment-comparison {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.comparison-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.row-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 70px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.segment-bar-horizontal {
    flex: 1;
    height: 40px;
    display: flex;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    background: var(--bg-tertiary);
}

.segment-piece {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    color: white;
    transition: all var(--transition-normal);
    position: relative;
    cursor: pointer;
}

.segment-piece::after {
    content: attr(data-count);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.segment-piece:hover::after {
    opacity: 1;
}

.segment-piece:hover {
    filter: brightness(1.1);
}

.segment-piece.good {
    background: linear-gradient(90deg, #10b981, #059669);
}

.segment-piece.okay {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.segment-piece.warning {
    background: linear-gradient(90deg, #f97316, #ea580c);
}

.segment-piece.critical {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

/* Segment Legend */
.segment-legend {
    display: flex;
    justify-content: space-around;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-light);
    margin-top: var(--spacing-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
    min-width: 140px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-dot.good { background: linear-gradient(135deg, #10b981, #059669); }
.legend-dot.okay { background: linear-gradient(135deg, #f59e0b, #d97706); }
.legend-dot.warning { background: linear-gradient(135deg, #f97316, #ea580c); }
.legend-dot.critical { background: linear-gradient(135deg, #ef4444, #dc2626); }

.legend-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.legend-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.legend-values {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-family: 'Monaco', 'Courier New', monospace;
}

/* Improvement Grid */
.improvement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-xl);
}

.trend-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.trend-card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid;
}

.trend-card-header.improved {
    border-color: var(--success-color);
    color: var(--success-color);
}

.trend-card-header.worsened {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.trend-card-header i {
    font-size: 1.25rem;
}

.trend-card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Trend List */
.trend-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.trend-item {
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    transition: all var(--transition-fast);
}

.trend-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.trend-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.trend-item-details {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.prev-value, .curr-value {
    font-weight: 600;
}

.curr-value {
    color: var(--text-primary);
}

.trend-item-details i {
    font-size: 0.625rem;
    color: var(--text-muted);
}

/* Trend Delta */
.trend-delta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.trend-delta.positive {
    color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

.trend-delta.negative {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.trend-delta i {
    font-size: 0.875rem;
}

.delta-value {
    font-weight: 700;
}

.trend-item:hover .trend-delta {
    transform: scale(1.05);
}

.trend-item:hover .trend-delta.positive {
    background: rgba(16, 185, 129, 0.15);
}

.trend-item:hover .trend-delta.negative {
    background: rgba(239, 68, 68, 0.15);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    text-align: center;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-radius: var(--radius-xl);
    border: 2px dashed var(--border-light);
    min-height: 400px;
}

.empty-state i {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
}

.empty-state h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 500px;
}

/* Responsive */
@media (max-width: 768px) {
    .health-distribution-grid {
        grid-template-columns: 1fr;
    }

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

    .comparison-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-xs);
    }

    .row-label {
        min-width: auto;
        font-size: 0.6875rem;
    }

    .segment-bar-horizontal {
        height: 35px;
    }

    .segment-piece {
        font-size: 0.75rem;
    }

    .legend-item {
        min-width: 120px;
    }

    .legend-label {
        font-size: 0.6875rem;
    }

    .legend-values {
        font-size: 0.6875rem;
    }

    .legend-dot {
        width: 10px;
        height: 10px;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }
.text-info { color: var(--info-color); }

.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }

.d-none { display: none; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }
