/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables - Tier-1 SaaS Performance Theme */
:root {
    /* Brand Colors - Sophisticated Blue Palette */
    --color-primary: #3b82f6;
    /* Blue 500 */
    --color-primary-soft: #eff6ff;
    --color-primary-dark: #1d4ed8;

    /* Semantic Status - System UI Approach */
    --color-success: #059669;
    /* Emerald 600 */
    --color-warning: #d97706;
    /* Amber 600 */
    --color-danger: #dc2626;
    /* Red 600 */
    --color-neutral: #64748b;
    /* Slate 500 */

    /* Surface & Backgrounds */
    --bg-app: #f8fafc;
    /* Slate 50 */
    --bg-surface: #ffffff;
    --border-subtle: #e2e8f0;
    /* Slate 200 */
    --border-focus: #cbd5e1;
    /* Slate 300 */

    /* Text & Hierarchy */
    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --text-tertiary: #94a3b8;
    /* Slate 400 */

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    /* Metrics & Spacing */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-subtle: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Transitions */
[data-theme="dark"] {
    --bg-app: #0f172a;
    /* Slate 900 */
    --bg-surface: #1e293b;
    /* Slate 800 */
    --border-subtle: #334155;
    /* Slate 700 */
    --border-focus: #475569;
    /* Slate 600 */

    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #cbd5e1;
    /* Slate 300 */
    --text-tertiary: #94a3b8;
    /* Slate 400 */

    --color-primary-soft: rgba(59, 130, 246, 0.15);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
}

/* Dark mode specific overrides */
[data-theme="dark"] select,
[data-theme="dark"] input {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

[data-theme="dark"] .text-tertiary {
    color: var(--text-tertiary) !important;
}

/* Global Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    /* Standard SaaS density */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
    letter-spacing: -0.0125em;
    color: var(--text-primary);
}

/* Layout Utilities */
.max-w-8xl {
    max-width: 1440px;
}

/* Reduce top space in main dashboard */
main#mainContent {
    margin-top: 110px !important;
    padding-top: 0 !important;
}

/* Bento Grid System */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(100px, auto);
    gap: 16px;
    overflow: visible;
}

.bento-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-subtle);
    overflow: visible;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bento-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: var(--border-focus);
}

[data-theme="dark"] .bento-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
}

/* Stat Card specific additions */
.stat-card-badge {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 9999px;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Dark mode stat cards */
[data-theme="dark"] .stat-card-badge {
    background-color: rgba(51, 65, 85, 0.6) !important;
}

[data-theme="dark"] .stat-card-target-label {
    color: #94a3b8 !important;
}

/* Dark mode stat cards */
[data-theme="dark"] .stat-card-badge {
    background-color: rgba(51, 65, 85, 0.6) !important;
}

[data-theme="dark"] .stat-card-target-label {
    color: #94a3b8 !important;
}

.stat-card-progress-wrapper {
    margin-top: 12px;
    margin-bottom: 4px;
}

.stat-card-progress-bar {
    height: 4px;
    width: 100%;
    background: var(--border-subtle);
    border-radius: 2px;
    overflow: hidden;
}

.stat-card-progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-card-target-label {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
}

/* Sticky Utility Bar */
.utility-bar {
    position: sticky;
    top: 64px;
    /* Height of the main nav */
    z-index: 40;
    background: var(--bg-app);
    /* Opaque background to prevent stacking transparency */
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 0;
    margin-bottom: 24px;
}

/* Nav specific sticky fix */
nav.sticky {
    background: var(--bg-surface);
}

/* Utility Classes for Colors (Restoring missing Tailwind-like classes) */
.bg-primary {
    background-color: var(--color-primary) !important;
    color: white !important;
}

.bg-warning {
    background-color: var(--color-warning) !important;
    color: white !important;
}

.bg-success {
    background-color: var(--color-success) !important;
    color: white !important;
}

.bg-danger {
    background-color: var(--color-danger) !important;
    color: white !important;
}

.text-primary {
    color: var(--color-primary) !important;
}

.text-warning {
    color: var(--color-warning) !important;
}

.text-success {
    color: var(--color-success) !important;
}

.text-danger {
    color: var(--color-danger) !important;
}

.bg-primary-soft {
    background-color: var(--color-primary-soft) !important;
    color: var(--color-primary) !important;
}

/* Panel Management */
.panel {
    display: none;
}

.panel.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

/* Nav Tabs in Utility Bar */
.nav-tab {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: transparent;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--color-primary-soft);
}

.nav-tab.active {
    color: var(--color-primary);
    background: var(--color-primary-soft);
}

/* Scrollbar refinement */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-focus);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Navigation - Clean Solid Header */
.nav-glass {
    background: var(--bg-card);
    border-bottom: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo-container {
    width: 40px;
    height: 40px;
    background: var(--color-primary-dark);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon {
    color: white;
    font-size: 1.2rem;
}

.text-gradient {
    color: var(--color-primary-dark);
    font-weight: 700;
}

[data-theme="dark"] .text-gradient {
    color: var(--color-primary-light);
}

.stat-pill {
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.2;
}

/* Controls */
.control-button,
.modern-select {
    background: var(--bg-card);
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.control-button:hover,
.modern-select:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.control-button:focus,
.modern-select:focus {
    outline: 2px solid var(--color-primary-light);
    outline-offset: 2px;
}

.action-button {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease;
}

.action-button:hover {
    background: var(--color-primary-dark);
}

/* Tab Navigation */
.tab-navigation {
    margin-bottom: 2rem;
}

.tab-container {
    background: var(--bg-card);
    border: 1px solid var(--color-gray-200);
    padding: 4px;
    border-radius: var(--radius-md);
    display: inline-flex;
    gap: 0;
    box-shadow: var(--shadow-sm);
}

.nav-tab {
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-tab:hover {
    color: var(--text-main);
    background: var(--color-gray-100);
}

.nav-tab.active {
    background: var(--color-primary-dark);
    /* Solid Navy */
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Card Base - Clean Solid */
.metric-card,
.gauge-card,
.progress-card,
.chart-card,
.data-card,
.commune-card,
.detail-card,
.hero-tube-card {
    background: var(--bg-card);
    border: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.metric-card:hover,
.gauge-card:hover,
.chart-card:hover,
.hero-tube-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-focus);
}

[data-theme="dark"] .metric-card,
[data-theme="dark"] .gauge-card,
[data-theme="dark"] .progress-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .data-card,
[data-theme="dark"] .commune-card,
[data-theme="dark"] .detail-card,
[data-theme="dark"] .hero-tube-card {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
}

/* Hero Section Grids */
.hero-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Type Styles */
.dashboard-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

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

.section-header {
    font-size: 1.15rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-gray-200);
}

.section-header::before {
    content: '';
    display: none;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.section-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-left: auto;
}

/* Metric Card Internals */
.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.metric-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.metric-value {
    font-size: 2.25rem;
    font-weight: 700;
    font-family: var(--font-display);
    color: var(--text-main);
    line-height: 1;
}

/* Progress Bars */
/* Progress Bars - Beautiful */
.progress-stat-card {
    background: transparent;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-gray-100);
}

.progress-stat-card:last-child {
    border-bottom: none;
}

.progress-stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.progress-stat-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.progress-stat-value {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.progress-stat-percent {
    font-weight: 800;
    font-family: var(--font-body);
    color: var(--text-main);
}

.progress-bar-track {
    height: 12px;
    background: var(--color-gray-200);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    /* Inner shadow for depth */
}

.progress-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

/* Gradients for bars */
.progress-bar-fill--primary {
    background: linear-gradient(90deg, #3b82f6 0%, #1e40af 100%);
}

.progress-bar-fill--success {
    background: linear-gradient(90deg, #34d399 0%, #059669 100%);
}

.progress-bar-fill--warning {
    background: linear-gradient(90deg, #fcd34d 0%, #d97706 100%);
}

/* Charts & Canvas */
canvas {
    max-width: 100%;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.chart-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.chart-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chart-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

.chart-content {
    position: relative;
    width: 100%;
    min-height: 350px;
    height: 400px;
}

.chart-content canvas {
    max-width: 100%;
    max-height: 100%;
}


/* Table Tabs & Panels */
.table-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    padding: 0 16px;
    border-bottom: 1px solid var(--color-gray-200);
    overflow-x: auto;
}

.table-tab {
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    /* Bottom line style */
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    border-radius: 0;
}

.table-tab:hover {
    color: var(--color-primary-dark);
    background: var(--color-gray-50);
}

.table-tab.active {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary-dark);
    background: transparent;
}

.table-tab.active::after {
    display: none;
}

.table-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.table-panel.active {
    display: block;
}

/* Data Tables - Professional Grid */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--color-gray-200);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--color-gray-50);
    border-bottom: 2px solid var(--color-gray-200);
    position: sticky;
    top: 0;
    z-index: 5;
}

[data-theme="dark"] .data-table th {
    background: var(--bg-app);
    border-bottom-color: var(--border-subtle);
    color: var(--text-secondary);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.data-table tr:hover td {
    background: var(--color-primary-soft);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Loading Overlay */
.loading-overlay {
    background: rgba(255, 255, 255, 0.9) !important;
}

[data-theme="dark"] .loading-overlay {
    background: rgba(15, 23, 42, 0.9) !important;
}

/* --- Modern Timeline (Gantt) Refactor --- */
.chronogram-gantt {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 0;
    max-height: 500px;
    overflow-y: auto;
}

.timeline-section-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 12px 8px 6px;
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-subtle);
}

.gantt-row {
    display: flex;
    align-items: center;
    padding: 8px 8px;
    transition: background 0.2s ease;
}

.gantt-row:hover {
    background: var(--bg-app);
}

.gantt-label {
    flex: 0 0 240px;
    padding-right: 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.gantt-label-title {
    font-weight: 600;
    line-height: 1.2;
}

.gantt-label-meta {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Label toggle: show full labels and wrap */
.chronogram-gantt.chronogram-show-labels .gantt-label {
    flex-basis: 360px;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

.gantt-timeline {
    flex: 1;
    position: relative;
    height: 26px;
    background: var(--bg-app);
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
}

.gantt-bar-pill {
    position: absolute;
    height: 12px;
    top: 7px;
    border-radius: 5px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.gantt-bar-pill:hover {
    height: 16px;
    top: 5px;
    filter: brightness(1.1);
    z-index: 5;
}

.chronogram-header {
    display: flex;
    margin-left: 240px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    position: sticky;
    top: -1px;
    z-index: 20;
}

.chronogram-header.chronogram-show-labels {
    margin-left: 360px;
}

.chronogram-header .month {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Bullet Graph Styles */
.bullet-graph {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.bullet-graph:last-child {
    border-bottom: none;
}

.bullet-graph .bg-red-100 {
    background-color: #fee2e2;
}

.bullet-graph .bg-yellow-100 {
    background-color: #fef3c7;
}

.bullet-graph .bg-green-100 {
    background-color: #d1fae5;
}

.bullet-graph .bg-blue-600 {
    background-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

/* Info Tooltip Styles */
.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 10px;
    color: #94a3b8;
    cursor: help;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.info-tooltip:hover {
    color: #3b82f6;
    background: #eff6ff;
}

/* Native tooltip styling enhancement */
.info-tooltip[title] {
    position: relative;
}

/* Bullet Chart Styles */
.bullet-chart {
    margin-bottom: 12px;
}

.bullet-chart:last-child {
    margin-bottom: 0;
}

/* KPI Cards Enhancement */
.kpi-metric {
    transition: transform 0.2s ease;
}

.kpi-metric:hover {
    transform: translateY(-2px);
}

/* Efficiency Section */
.efficiency-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Text color utilities for KPIs */
.text-danger {
    color: #dc2626;
}

/* KPI Cards Modern Design */
.kpi-card {
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Dark mode KPI cards */
[data-theme="dark"] .kpi-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.8) 100%) !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

[data-theme="dark"] .kpi-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

/* Dark mode icon backgrounds */
[data-theme="dark"] .kpi-card .bg-blue-100,
[data-theme="dark"] .kpi-card .bg-amber-100,
[data-theme="dark"] .kpi-card .bg-red-100,
[data-theme="dark"] .kpi-card .bg-indigo-100,
[data-theme="dark"] .kpi-card .bg-purple-100,
[data-theme="dark"] .kpi-card .bg-emerald-100 {
    background-color: rgba(51, 65, 85, 0.4) !important;
}

/* Dark mode text colors for KPI cards */
[data-theme="dark"] .kpi-card .text-slate-600 {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .kpi-card .text-slate-400 {
    color: #94a3b8 !important;
}

/* KPI Card Tooltip Styling */
.kpi-card.cursor-help {
    cursor: help;
}

.kpi-card[data-tooltip] {
    position: relative;
    overflow: visible;
}

/* Custom tooltip for KPI cards using CSS */
.kpi-card[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 350px;
    min-width: 250px;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.97);
    color: #f8fafc;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.6;
    border-radius: 8px;
    white-space: pre-wrap;
    z-index: 10000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    animation: tooltipFadeIn 0.2s ease;
}

.kpi-card[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(15, 23, 42, 0.95);
    z-index: 10001;
    pointer-events: none;
    animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Info tooltip enhancement */
.info-tooltip {
    cursor: help;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.info-tooltip:hover {
    opacity: 1;
}

.info-tooltip i {
    font-size: 12px;
}

/* Performance panel legend */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 10px;
    font-weight: 600;
}

.chart-legend span {
    display: flex;
    align-items: center;
}

/* Bullet chart improvements */
.bullet-chart .bar-container {
    position: relative;
    height: 16px;
    border-radius: 4px;
    overflow: hidden;
}

/* ========================================
   Performance Optimization Styles
   ======================================== */

/* Filter updating state - instant visual feedback */
.filter-updating {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* Skeleton loading animation */
@keyframes skeleton-shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

.skeleton-loading {
    position: relative;
    overflow: hidden;
}

.skeleton-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        var(--bg-surface) 0%, 
        var(--border-subtle) 50%, 
        var(--bg-surface) 100%);
    background-size: 200px 100%;
    animation: skeleton-shimmer 1.2s infinite;
}

/* Skeleton card placeholder */
.skeleton-card {
    padding: 1rem;
}

.skeleton-line {
    border-radius: 4px;
}

/* Optimized transitions - GPU accelerated */
.chart-container canvas,
.stat-card,
.kpi-card,
.card {
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .skeleton-loading::after {
        animation: none;
        background: var(--border-subtle);
    }
}

/* Lazy-loaded content fade in */
.lazy-fade-in {
    animation: fadeInSmooth 0.3s ease forwards;
}

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

/* Loading overlay improvements */
#loadingOverlay {
    backdrop-filter: blur(4px);
    transition: opacity 0.2s ease;
}

#loadingOverlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Table row virtualization helper */
.table-virtualized {
    contain: content;
}

.table-virtualized tbody {
    display: block;
    overflow-y: auto;
    max-height: 400px;
}

.table-virtualized thead,
.table-virtualized tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* Fast scroll shadow indicators */
.scroll-shadow-top {
    box-shadow: inset 0 8px 8px -8px rgba(0, 0, 0, 0.15);
}

.scroll-shadow-bottom {
    box-shadow: inset 0 -8px 8px -8px rgba(0, 0, 0, 0.15);
}

/* Chart loading placeholder */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.chart-loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Instant hover states */
.btn-instant-hover {
    transition: background-color 0.1s, transform 0.1s;
}

.btn-instant-hover:hover {
    transform: translateY(-1px);
}

.btn-instant-hover:active {
    transform: translateY(0);
}