/* expenseCorrelation.css - Professional Financial SaaS Version */
/* Fonts loaded globally via design-tokens.css */

/* ===== MAIN WRAPPER ===== */
.correlation-analysis-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.625rem;
    font-family: var(--liq-font-body), -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--liq-surface);
    border-radius: 6px;

    max-width: 1200px; /* Maximum width for readability */
    margin: 0 auto; /* Center the content */}

/* ===== HEADER ===== */
.correlation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--liq-border-light);
}

.correlation-title-section {
    flex: 1;
}

.correlation-main-title {
    margin: 0;
    color: var(--liq-text);
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.correlation-main-title svg {
    color: var(--liq-info);
}

.correlation-subtitle {
    color: var(--liq-text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.correlation-actions {
    display: flex;
    gap: 0.5rem;
}

.correlation-action-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--liq-border-light);
    border-radius: 6px;
    background: white;
    color: var(--liq-info);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.correlation-action-btn:hover {
    background: var(--liq-bg);
    border-color: var(--liq-info);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ===== CONTROLS PANEL ===== */
.correlation-controls-panel {
    background: white;
    border-radius: 6px;
    padding: 0.625rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--liq-border-light);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}

.correlation-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.correlation-control-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--liq-text-muted);
    font-weight: 500;
}

.correlation-radio-group {
    display: flex;
    background: var(--liq-bg);
    border-radius: 6px;
    padding: 0.25rem;
}

.correlation-radio-option {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.correlation-radio-option input[type="radio"] {
    accent-color: var(--liq-info);
}

.correlation-radio-option:has(input:checked) {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    color: var(--liq-info);
}

/* ===== ACCOUNT SELECTOR ===== */
.correlation-account-selector-group {
    min-width: 300px;
}

.correlation-account-selector-wrapper {
    position: relative;
}

.correlation-account-selector-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--liq-border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    width: 100%;
}

.correlation-account-selector-btn:hover {
    border-color: var(--liq-info);
    background: var(--liq-bg);
}

.correlation-account-dropdown {
    position: absolute;
    top: calc(100% + 0.375rem);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--liq-border-light);
    border-radius: 6px;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.correlation-account-dropdown-header {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--liq-border-light);
}

.correlation-account-dropdown-header button {
    flex: 1;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--liq-border-light);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.correlation-account-dropdown-header button:hover {
    background: var(--liq-bg);
    border-color: var(--liq-info);
}

.correlation-account-list {
    padding: 0.5rem;
}

.correlation-account-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.correlation-account-item:hover {
    background: var(--liq-bg);
}

.correlation-account-item input[type="checkbox"] {
    accent-color: var(--liq-info);
}

/* ===== ANALYZE BUTTON ===== */
.correlation-analyze-btn {
    padding: 0.5rem 0.875rem;
    border: none;
    border-radius: 6px;
    background: var(--liq-info);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.correlation-analyze-btn:hover {
    background: #1E40AF;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.correlation-analyze-btn:active {
    background: #1E3A8A;
}

/* ===== TABS ===== */
.correlation-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--liq-bg);
    padding: 0.375rem;
    border-radius: 6px;
}

.correlation-tab {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--liq-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.correlation-tab:hover {
    color: var(--liq-info);
}

.correlation-tab-active {
    background: white;
    color: var(--liq-info);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ===== RESULTS AREA ===== */
.correlation-results-area {
    background: white;
    border-radius: 6px;
    padding: 0.625rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--liq-border-light);
    min-height: 240px;
}

.correlation-view {
    display: none;
}

.correlation-view-active {
    display: block;
}

.correlation-chart-container {
    position: relative;
    height: 500px;
    width: 100%;
    margin-top: 0.625rem;
}

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

.correlation-chart-container .liq-apex-host[id="correlationScatterChart"] {
    width: 100%;
    height: 100%;
}

.correlation-placeholder {
    text-align: center;
    color: var(--liq-text-muted);
    font-size: 0.875rem;
    padding: 0.875rem 0;
}

/* ===== CUSTOM HEATMAP GRID ===== */
.custom-correlation-heatmap {
    width: 100%;
    overflow-x: auto;
}

.correlation-heatmap-grid {
    display: inline-block;
    min-width: 100%;
    border: 1px solid var(--liq-border-light);
    border-radius: 6px;
    overflow: hidden;
}

.correlation-heatmap-row {
    display: flex;
}

.correlation-heatmap-cell {
    min-width: 80px;
    max-width: 150px;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.8125rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.correlation-heatmap-corner {
    background: var(--liq-bg);
    border: none;
}

.correlation-heatmap-header {
    background: var(--liq-bg);
    font-weight: 500;
    color: var(--liq-info);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 0.625rem 0.375rem;
    min-height: 90px;
}

.correlation-heatmap-row-header {
    background: var(--liq-bg);
    font-weight: 500;
    color: var(--liq-info);
    text-align: left;
    min-width: 150px;
    max-width: 200px;
}

.correlation-heatmap-data-cell {
    cursor: help;
    font-weight: 400;
    font-family: var(--liq-font-mono), 'SF Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
}

.correlation-heatmap-data-cell:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 10;
    position: relative;
}

.correlation-heatmap-legend {
    margin-top: 0.5rem;
    padding: 0.375rem;
    background: var(--liq-bg);
    border-radius: 6px;
}

.correlation-legend-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.correlation-legend-color {
    height: 30px;
    border-radius: 4px;
    border: 1px solid var(--liq-border-light);
}

.correlation-legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--liq-text-muted);
}

/* ===== INSIGHTS VIEW ===== */
.correlation-insights-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.correlation-insight-card {
    padding: 0.75rem;
    border-radius: 6px;
    border-left: 3px solid var(--liq-info);
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--liq-border-light);
    transition: all 0.2s ease;
}

.correlation-insight-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.correlation-insight-high {
    border-left-color: #dc2626;
    background: rgba(239, 68, 68, 0.05);
}

.correlation-insight-medium {
    border-left-color: #d97706;
    background: rgba(251, 191, 36, 0.05);
}

.correlation-insight-low {
    border-left-color: #059669;
    background: rgba(16, 185, 129, 0.05);
}

.correlation-insight-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.correlation-insight-icon {
    flex-shrink: 0;
}

.correlation-insight-title {
    flex: 1;
    font-weight: 500;
    font-size: 1.0625rem;
    color: var(--liq-text);
}

.correlation-insight-priority {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

.correlation-insight-high .correlation-insight-priority {
    background: #dc2626;
    color: white;
}

.correlation-insight-medium .correlation-insight-priority {
    background: #d97706;
    color: white;
}

.correlation-insight-low .correlation-insight-priority {
    background: #059669;
    color: white;
}

.correlation-insight-message {
    color: var(--liq-text-secondary);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.correlation-insight-action {
    color: var(--liq-text);
    font-size: 0.875rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--liq-bg);
}

/* ===== SCATTER VIEW ===== */
.correlation-scatter-controls {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 0.375rem;
}

.correlation-scatter-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--liq-text-secondary);
}

.correlation-scatter-controls select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--liq-border);
    border-radius: 6px;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
}

/* ===== STATISTICS VIEW ===== */
.correlation-statistics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.correlation-stat-card {
    background: var(--liq-bg);
    border-radius: 6px;
    padding: 0.75rem;
    border: 1px solid var(--liq-border-light);
}

.correlation-stat-label {
    font-size: 0.8125rem;
    color: var(--liq-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}

.correlation-stat-value {
    font-size: 1rem;
    font-weight: 400;
    font-family: var(--liq-font-mono), 'SF Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    color: var(--liq-info);
}

.correlation-statistics-table-wrapper {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid var(--liq-border-light);
}

.correlation-statistics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.correlation-statistics-table thead {
    background: var(--liq-bg);
}

.correlation-statistics-table th {
    padding: 0.625rem;
    text-align: left;
    font-weight: 500;
    color: var(--liq-text);
    border-bottom: 1px solid var(--liq-border-light);
}

.correlation-statistics-table td {
    padding: 0.625rem;
    border-bottom: 1px solid var(--liq-bg);
    font-family: var(--liq-font-mono), 'SF Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
}

.correlation-statistics-table tr:hover {
    background: var(--liq-bg);
}

.correlation-strong {
    color: #dc2626;
    font-weight: 400;
}

.correlation-moderate {
    color: #d97706;
    font-weight: 400;
}

.correlation-weak {
    color: var(--liq-text-muted);
    font-weight: 400;
}

.correlation-sig-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.correlation-sig-yes {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.correlation-sig-no {
    background: rgba(113, 128, 150, 0.1);
    color: var(--liq-text-muted);
}

/* ===== TOAST NOTIFICATIONS ===== */
.correlation-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: white;
    padding: 0.625rem 0.875rem;
    border-radius: 6px;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--liq-border-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 400px;
    transform: translateX(calc(100% + 1.5rem));
    transition: transform 0.3s ease;
    z-index: 9999;
}

.correlation-toast-show {
    transform: translateX(0);
}

.correlation-toast-icon {
    flex-shrink: 0;
}

.correlation-toast-message {
    color: var(--liq-text);
    font-size: 0.875rem;
}

.correlation-toast-success {
    border-left: 3px solid #059669;
}

.correlation-toast-error {
    border-left: 3px solid #dc2626;
}

.correlation-toast-warning {
    border-left: 3px solid #d97706;
}

.correlation-toast-info {
    border-left: 3px solid var(--liq-info);
}

/* ===== WELCOME MODAL ===== */
.correlation-welcome-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.correlation-welcome-show {
    opacity: 1;
}

.correlation-welcome-content {
    background: white;
    border-radius: 6px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.correlation-welcome-header {
    background: var(--liq-info);
    color: white;
    padding: 0.875rem;
    border-radius: 6px 6px 0 0;
}

.correlation-welcome-header h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.correlation-welcome-header p {
    margin: 0.5rem 0 0;
    opacity: 0.9;
}

.correlation-welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.375rem;
    padding: 0.875rem;
}

.correlation-welcome-card {
    padding: 0.75rem;
    border-radius: 6px;
    border-left: 3px solid var(--liq-info);
    background: var(--liq-bg);
    transition: all 0.2s ease;
}

.correlation-welcome-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.correlation-welcome-card svg {
    margin-bottom: 0.5rem;
}

.correlation-welcome-card h3 {
    margin: 0.5rem 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--liq-text);
}

.correlation-welcome-card p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--liq-text-muted);
}

.correlation-welcome-footer {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border-top: 1px solid var(--liq-border-light);
}

.correlation-welcome-button {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    background: var(--liq-info);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.correlation-welcome-button:hover {
    background: #1E40AF;
}

.correlation-welcome-link {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: var(--liq-text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.correlation-welcome-link:hover {
    color: var(--liq-info);
}

/* ===== KEYBOARD SHORTCUTS MODAL ===== */
.correlation-shortcuts-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.correlation-shortcuts-show {
    opacity: 1;
}

.correlation-shortcuts-content {
    background: white;
    border-radius: 6px;
    padding: 0.875rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.correlation-shortcuts-content h3 {
    margin: 0 0 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--liq-text);
    font-weight: 600;
}

.correlation-shortcuts-grid {
    display: grid;
    gap: 0.375rem;
}

.correlation-shortcut-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem;
    border-radius: 6px;
    background: var(--liq-bg);
}

.correlation-shortcut-item kbd {
    background: white;
    border: 1px solid var(--liq-border-light);
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    font-family: var(--liq-font-mono), 'SF Mono', 'Consolas', monospace;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--liq-info);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.05);
}

.correlation-shortcut-item span {
    color: var(--liq-text-muted);
    font-size: 0.875rem;
}

.correlation-shortcuts-close {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    background: var(--liq-info);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.correlation-shortcuts-close:hover {
    background: #1E40AF;
}

/* ===== ERROR STATES ===== */
.correlation-error {
    text-align: center;
    padding: 0.875rem;
    color: #dc2626;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    border-left: 3px solid #dc2626;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .correlation-controls-panel {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
    }

    .correlation-account-selector-group {
        min-width: auto;
    }

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

@media (max-width: 768px) {
    .correlation-analysis-wrapper {
        padding: 1rem;
    }

    .correlation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .correlation-tabs {
        flex-direction: column;
    }

    .correlation-welcome-features {
        grid-template-columns: 1fr;
    }

    .correlation-scatter-controls {
        flex-direction: column;
    }

    .correlation-toast {
        bottom: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }

    .correlation-chart-container {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .correlation-analysis-wrapper {
        padding: 0.75rem;
    }

    .correlation-main-title {
        font-size: 1rem;
    }

    .correlation-chart-container {
        height: 300px;
    }

    .correlation-statistics-table {
        font-size: 0.75rem;
    }

    .correlation-statistics-table th,
    .correlation-statistics-table td {
        padding: 0.5rem;
    }

    .correlation-controls-panel {
        padding: 0.625rem;
    }

    .correlation-results-area {
        padding: 0.625rem;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .correlation-header .correlation-actions,
    .correlation-controls-panel,
    .correlation-tabs {
        display: none;
    }

    .correlation-view {
        display: block !important;
    }

    .correlation-toast,
    .correlation-welcome-modal,
    .correlation-shortcuts-modal {
        display: none !important;
    }

    .correlation-results-area,
    .correlation-insight-card,
    .correlation-stat-card {
        border: 1px solid var(--liq-border);
        page-break-inside: avoid;
    }

    .correlation-welcome-header {
        background: var(--liq-info);
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===== ACCESSIBILITY ===== */
.correlation-action-btn:focus,
.correlation-analyze-btn:focus,
.correlation-tab:focus,
.correlation-account-selector-btn:focus,
.correlation-welcome-button:focus,
.correlation-shortcuts-close:focus {
    outline: 2px solid var(--liq-info);
    outline-offset: 2px;
}

/* ===== LEDGERIQ CORRELATION REDESIGN OVERRIDES ===== */
:root {
    --corr-display: var(--liq-font-display), 'Trebuchet MS', serif;
    --corr-body: var(--liq-font-body), 'Segoe UI', sans-serif;
    --corr-mono: var(--liq-font-mono), 'Consolas', monospace;

    --corr-bg: #F2F7FB;
    --corr-surface: #FFFFFF;
    --corr-surface-soft: #EDF4FB;
    --corr-border: #D7E3EF;
    --corr-border-strong: #B7CDE3;

    --corr-ink: #0F1D2E;
    --corr-muted: #4B6078;
    --corr-muted-soft: #7089A6;

    --corr-primary: #0F766E;
    --corr-primary-strong: #115E59;
    --corr-accent: #0369A1;
    --corr-success: #15803D;
    --corr-warning: #B45309;
    --corr-danger: #B91C1C;
}

.correlation-analysis-wrapper {
    background:
        radial-gradient(circle at 8% 4%, rgba(3, 105, 161, 0.12), transparent 36%),
        radial-gradient(circle at 92% 0%, rgba(15, 118, 110, 0.1), transparent 34%),
        linear-gradient(180deg, #F7FAFD 0%, var(--corr-bg) 100%);
    border: 1px solid var(--corr-border);
    border-radius: 12px;
    padding: 0.75rem;
    gap: 0.5rem;
    font-family: var(--corr-body);
    max-width: 1320px;
}

.correlation-analysis-wrapper * {
    box-sizing: border-box;
}

.correlation-header {
    background: linear-gradient(135deg, #0F1D2E 0%, #16314D 48%, #0E7490 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 0.5rem 0.625rem;
    box-shadow: 0 14px 28px rgba(15, 29, 46, 0.2);
}

.correlation-main-title {
    color: #F8FCFF;
    font-family: var(--corr-display);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.correlation-main-title svg {
    color: #7DD3FC;
}

.correlation-subtitle {
    color: rgba(237, 245, 255, 0.86);
    font-size: 0.92rem;
    margin-top: 0.45rem;
    max-width: 60ch;
}

.correlation-action-btn {
    border: 1px solid rgba(125, 211, 252, 0.35);
    color: #D7F0FF;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.correlation-action-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: #7DD3FC;
    color: #FFFFFF;
    transform: translateY(-1px);
}

.correlation-overview-strip {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.6fr;
    gap: 0.5rem;
}

.correlation-overview-card {
    background: linear-gradient(180deg, var(--corr-surface) 0%, #F9FCFF 100%);
    border: 1px solid var(--corr-border);
    border-radius: 10px;
    padding: 0.625rem 0.75rem;
    min-height: 88px;
    box-shadow: 0 8px 18px rgba(15, 29, 46, 0.06);
}

.correlation-overview-card-wide {
    grid-column: span 1;
}

.correlation-overview-label {
    color: var(--corr-muted);
    font-size: 0.69rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 0.4rem;
}

.correlation-overview-value {
    color: var(--corr-ink);
    font-family: var(--corr-mono);
    font-size: 0.9rem;
    line-height: 1.45;
    font-weight: 600;
}

.correlation-controls-panel {
    border: 1px solid var(--corr-border);
    border-radius: 12px;
    background: linear-gradient(180deg, var(--corr-surface) 0%, #F5FAFF 100%);
    box-shadow: 0 10px 24px rgba(15, 29, 46, 0.06);
    padding: 0.5rem;
    gap: 0.45rem;
}

.correlation-control-label {
    color: var(--corr-muted-soft);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.09em;
}

.correlation-radio-group {
    background: var(--corr-surface-soft);
    border: 1px solid var(--corr-border);
    border-radius: 10px;
    padding: 0.28rem;
}

.correlation-radio-option {
    font-weight: 700;
    color: var(--corr-muted);
    border-radius: 8px;
}

.correlation-radio-option:has(input:checked) {
    background: #FFFFFF;
    color: var(--corr-accent);
    box-shadow: 0 3px 8px rgba(3, 105, 161, 0.12);
}

.correlation-account-selector-btn {
    border: 1px solid var(--corr-border-strong);
    border-radius: 10px;
    background: #FFFFFF;
    color: var(--corr-ink);
    font-weight: 700;
}

.correlation-account-selector-btn:hover {
    border-color: var(--corr-accent);
    background: #F9FDFF;
}

.correlation-account-dropdown {
    border: 1px solid var(--corr-border-strong);
    border-radius: 12px;
    box-shadow: 0 20px 30px rgba(15, 29, 46, 0.14);
}

.correlation-account-dropdown-header {
    background: #F7FAFD;
}

.correlation-account-dropdown-header button {
    border-radius: 8px;
    border: 1px solid var(--corr-border);
    color: var(--corr-muted);
    font-weight: 700;
}

.correlation-account-dropdown-header button:hover {
    color: var(--corr-accent);
    border-color: var(--corr-accent);
}

.correlation-account-item {
    border-radius: 8px;
    color: var(--corr-ink);
}

.correlation-account-item:hover {
    background: #F0F8FF;
}

.correlation-analyze-btn {
    border-radius: 11px;
    background: linear-gradient(135deg, var(--corr-primary) 0%, #0D9488 45%, #0891B2 100%);
    color: #FFFFFF;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    border: 1px solid rgba(13, 148, 136, 0.25);
    box-shadow: 0 12px 20px rgba(15, 118, 110, 0.25);
}

.correlation-analyze-btn:hover {
    background: linear-gradient(135deg, var(--corr-primary-strong) 0%, #0F766E 45%, #0E7490 100%);
    box-shadow: 0 14px 24px rgba(15, 118, 110, 0.3);
    transform: translateY(-1px);
}

.correlation-analyze-btn-disabled {
    cursor: not-allowed;
    opacity: 0.58;
    box-shadow: none;
}

.correlation-analyze-btn-loading {
    cursor: progress;
}

.correlation-analyze-btn-loading svg {
    animation: correlationSpin 1s linear infinite;
}

@keyframes correlationSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.correlation-tabs {
    background: #DCEAF8;
    border-radius: 12px;
    padding: 0.3rem;
    gap: 0.3rem;
}

.correlation-tab {
    color: #46617C;
    border-radius: 10px;
    font-weight: 700;
}

.correlation-tab:hover {
    color: var(--corr-accent);
    background: rgba(255, 255, 255, 0.7);
}

.correlation-tab-active {
    background: #FFFFFF;
    color: var(--corr-accent);
    box-shadow: 0 4px 10px rgba(15, 29, 46, 0.09);
}

.correlation-results-area {
    background: linear-gradient(180deg, var(--corr-surface) 0%, #F8FBFF 100%);
    border: 1px solid var(--corr-border);
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 14px 24px rgba(15, 29, 46, 0.08);
    min-height: 260px;
}

.correlation-chart-container {
    margin-top: 0.5rem;
    border-radius: 10px;
    border: 1px solid var(--corr-border);
    background: #FFFFFF;
    padding: 0.6rem;
}

.correlation-placeholder {
    color: var(--corr-muted-soft);
    font-size: 0.9rem;
    border: 1px dashed var(--corr-border-strong);
    border-radius: 10px;
    padding: 0.75rem 0.375rem;
    background: #F8FCFF;
}

.custom-correlation-heatmap {
    border-radius: 12px;
    overflow: auto;
}

.correlation-heatmap-grid {
    border: 1px solid var(--corr-border-strong);
    border-radius: 12px;
    background: #FFFFFF;
}

.correlation-heatmap-cell {
    border: 1px solid #E6EEF7;
    font-family: var(--corr-mono);
}

.correlation-heatmap-corner,
.correlation-heatmap-header,
.correlation-heatmap-row-header {
    background: #EEF5FC;
}

.correlation-heatmap-header,
.correlation-heatmap-row-header {
    color: #1D4E89;
    font-weight: 700;
}

.correlation-heatmap-data-cell {
    border-radius: 6px;
}

.correlation-heatmap-data-cell:hover {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75), 0 8px 14px rgba(15, 29, 46, 0.14);
    transform: scale(1.02);
}

.correlation-heatmap-legend {
    border: 1px solid var(--corr-border);
    border-radius: 10px;
    background: #F6FAFF;
}

.correlation-legend-labels {
    color: var(--corr-muted);
    font-weight: 600;
}

.correlation-insights-list {
    gap: 0.5rem;
}

.correlation-insight-card {
    border-radius: 10px;
    border: 1px solid var(--corr-border);
    box-shadow: 0 8px 16px rgba(15, 29, 46, 0.06);
}

.correlation-insight-high {
    border-left-color: var(--corr-danger);
    background: linear-gradient(90deg, rgba(248, 113, 113, 0.1) 0%, #FFFFFF 24%);
}

.correlation-insight-medium {
    border-left-color: var(--corr-warning);
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.12) 0%, #FFFFFF 24%);
}

.correlation-insight-low {
    border-left-color: var(--corr-success);
    background: linear-gradient(90deg, rgba(74, 222, 128, 0.12) 0%, #FFFFFF 24%);
}

.correlation-insight-title {
    color: var(--corr-ink);
    font-family: var(--corr-display);
    font-weight: 600;
}

.correlation-insight-priority {
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-weight: 700;
}

.correlation-insight-message {
    color: #22374C;
}

.correlation-insight-action {
    color: #1D2D3D;
    border-top: 1px dashed #D8E5F2;
}

.correlation-scatter-controls {
    gap: 0.45rem;
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--corr-border);
    background: #F4F9FF;
}

.correlation-scatter-controls label {
    color: #34506A;
    font-weight: 700;
}

.correlation-scatter-controls select {
    border: 1px solid var(--corr-border-strong);
    border-radius: 8px;
    color: var(--corr-ink);
    font-family: var(--corr-body);
}

.correlation-scatter-controls select:focus {
    outline: 2px solid rgba(3, 105, 161, 0.3);
    outline-offset: 1px;
}

.correlation-statistics-summary {
    gap: 0.5rem;
}

.correlation-stat-card {
    border: 1px solid var(--corr-border);
    border-radius: 10px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F5FAFF 100%);
}

.correlation-stat-label {
    color: var(--corr-muted-soft);
    font-size: 0.68rem;
    font-weight: 800;
}

.correlation-stat-value {
    color: var(--corr-accent);
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--corr-mono);
}

.correlation-statistics-table-wrapper {
    border: 1px solid var(--corr-border);
    border-radius: 10px;
    background: #FFFFFF;
}

.correlation-statistics-table thead {
    background: #EEF5FC;
}

.correlation-statistics-table th {
    color: #1B3652;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.69rem;
    letter-spacing: 0.06em;
}

.correlation-statistics-table td {
    color: #273D53;
    font-family: var(--corr-mono);
    font-size: 0.78rem;
}

.correlation-statistics-table tr:hover {
    background: #F5FAFF;
}

.correlation-strong { color: var(--corr-danger); }
.correlation-moderate { color: var(--corr-warning); }
.correlation-weak { color: #5A6F86; }

.correlation-sig-badge {
    border-radius: 999px;
    font-weight: 700;
}

.correlation-sig-yes {
    color: var(--corr-success);
    background: rgba(21, 128, 61, 0.12);
}

.correlation-sig-no {
    color: #5A6F86;
    background: rgba(88, 107, 129, 0.12);
}

.correlation-toast {
    border: 1px solid var(--corr-border-strong);
    border-radius: 10px;
    background: #FFFFFF;
    box-shadow: 0 20px 30px rgba(15, 29, 46, 0.16);
}

.correlation-toast-message {
    color: var(--corr-ink);
    font-weight: 600;
}

.correlation-toast-success { border-left: 4px solid var(--corr-success); }
.correlation-toast-error { border-left: 4px solid var(--corr-danger); }
.correlation-toast-warning { border-left: 4px solid var(--corr-warning); }
.correlation-toast-info { border-left: 4px solid var(--corr-accent); }

.correlation-welcome-content,
.correlation-shortcuts-content {
    border-radius: 10px;
    border: 1px solid var(--corr-border-strong);
    box-shadow: 0 24px 36px rgba(15, 29, 46, 0.2);
}

.correlation-welcome-header {
    border-radius: 10px 10px 0 0;
    background: linear-gradient(135deg, #0E7490 0%, #0F766E 100%);
}

.correlation-welcome-card {
    border-radius: 10px;
    border: 1px solid var(--corr-border);
    border-left: 4px solid var(--corr-accent);
    background: #F7FBFF;
}

.correlation-welcome-button,
.correlation-shortcuts-close {
    border-radius: 10px;
    background: linear-gradient(135deg, var(--corr-primary) 0%, #0E7490 100%);
    font-weight: 700;
}

.correlation-welcome-link {
    color: var(--corr-muted);
    font-weight: 600;
}

.correlation-error {
    border: 1px solid #FECACA;
    border-left: 4px solid var(--corr-danger);
    border-radius: 10px;
    background: #FEF2F2;
    color: #991B1B;
    font-weight: 700;
}

.correlation-action-btn:focus,
.correlation-analyze-btn:focus,
.correlation-tab:focus,
.correlation-account-selector-btn:focus,
.correlation-welcome-button:focus,
.correlation-shortcuts-close:focus {
    outline: 2px solid rgba(3, 105, 161, 0.42);
    outline-offset: 2px;
}

@media (max-width: 1100px) {
    .correlation-overview-strip {
        grid-template-columns: 1fr 1fr;
    }

    .correlation-overview-card-wide {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .correlation-analysis-wrapper {
        border-radius: 14px;
        padding: 0.625rem;
        gap: 0.55rem;
    }

    .correlation-header {
        border-radius: 12px;
        padding: 0.625rem;
    }

    .correlation-main-title {
        font-size: 1.1rem;
    }

    .correlation-subtitle {
        font-size: 0.86rem;
    }

    .correlation-overview-strip {
        grid-template-columns: 1fr;
    }

    .correlation-overview-card-wide {
        grid-column: span 1;
    }

    .correlation-controls-panel,
    .correlation-results-area {
        border-radius: 12px;
        padding: 0.625rem;
    }

    .correlation-chart-container {
        height: 360px;
    }
}

@media (max-width: 480px) {
    .correlation-action-btn {
        font-size: 0.74rem;
        padding: 0.5rem 0.75rem;
    }

    .correlation-overview-value {
        font-size: 0.82rem;
    }

    .correlation-chart-container {
        height: 300px;
    }

    .correlation-statistics-table th,
    .correlation-statistics-table td {
        font-size: 0.72rem;
    }
}

@media print {
    .correlation-header .correlation-actions,
    .correlation-controls-panel,
    .correlation-tabs,
    .correlation-overview-strip {
        display: none !important;
    }
}

/* Matrix alignment fix: enforce consistent column geometry across all rows */
.correlation-heatmap-grid {
    display: inline-block;
    width: max-content;
    min-width: 100%;
}

.correlation-heatmap-row {
    display: grid;
    grid-template-columns: 220px repeat(var(--correlation-matrix-cols, 2), 96px);
}

.correlation-heatmap-cell {
    min-width: 0;
    max-width: none;
}

.correlation-heatmap-corner,
.correlation-heatmap-row-header {
    width: 220px;
}

.correlation-heatmap-header,
.correlation-heatmap-data-cell {
    width: 96px;
}

.correlation-heatmap-row-header {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
