/* Survey Dashboard Styles - Team Cofidis 2025 */

/* ===== Material Icons - Thin Outlined Style ===== */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

/* ===== Theme System ===== */

/* Dark Theme (Default) */
:root {
    --content-max-width: 1600px;
    --bg-primary: #101014;
    --bg-secondary: #18181c;
    --bg-card: #1e1e24;
    --bg-hover: #26262e;
    --bg-sidebar: #141418;
    --text-primary: #f0f0f2;
    --text-secondary: #9898a4;
    --text-muted: #6e6e7a;
    --border: #2a2a32;
    --primary: #d0103a;
    --secondary: #fecb00;
    --tertiary: #83332C;
    --quaternary: #b91c1c;
    --accent: #16a34a;
    --info: #1e88e5;
    
    /* Theme-specific */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
    --chart-grid: rgba(255,255,255,0.04);
    --chart-label: #c0c0c8;
    --range-track: rgba(255,255,255,0.15);
    --range-fill: rgba(255,255,255,0.4);
    --range-marker: rgba(255,255,255,0.5);
    --loading-bg: rgba(16, 16, 20, 0.8);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f0f2f8;
    --bg-sidebar: #fafbfe;
    --text-primary: #1a1d2d;
    --text-secondary: #5c6478;
    --text-muted: #8892a8;
    --border: #d0d5e0;
    --primary: #a32830;
    --secondary: #ca9a04;
    --tertiary: #6b2520;
    --quaternary: #991b1b;
    --accent: #15803d;
    --info: #1e88e5;
    
    /* Theme-specific */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
    --chart-grid: rgba(0,0,0,0.06);
    --chart-label: #4a5568;
    --range-track: rgba(0,0,0,0.1);
    --range-fill: rgba(37, 99, 235, 0.25);
    --range-marker: rgba(0,0,0,0.3);
    --loading-bg: rgba(248, 249, 252, 0.9);
}

/* Auto theme - respects system preference */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-primary: #f8f9fc;
        --bg-secondary: #ffffff;
        --bg-card: #ffffff;
        --bg-hover: #f0f2f8;
        --bg-sidebar: #fafbfe;
        --text-primary: #1a1d2d;
        --text-secondary: #5c6478;
        --text-muted: #8892a8;
        --border: #e4e8f0;
        --primary: #a32830;
        --secondary: #ca9a04;
        --tertiary: #6b2520;
        --quaternary: #991b1b;
        --accent: #15803d;
        --info: #1e88e5;
        
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
        --shadow-lg: 0 12px 32px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
        --chart-grid: rgba(0,0,0,0.06);
        --chart-label: #4a5568;
        --range-track: rgba(0,0,0,0.1);
        --range-fill: rgba(37, 99, 235, 0.25);
        --range-marker: rgba(0,0,0,0.3);
        --loading-bg: rgba(248, 249, 252, 0.9);
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Smooth theme transitions */
body,
.sidebar,
.chart-card,
.hero-right,
.comments-card,
.finding-card,
.data-table-wrapper,
.issues-table,
.analysis-card,
.filter-select,
.theme-btn {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

body {
    font-family: 'IBM Plex Sans', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.sidebar-header {
    padding: 28px 24px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.2s ease;
}

.sidebar-header.at-top::before {
    background: var(--primary);
}

/* Logo Container - stacked vertically below title */
.sidebar-logos {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-logos img {
    width: 140px;
    height: auto;
    transition: filter 0.25s ease;
}

.logo-cofidis {
    width: 130px !important;
}

.logo-ipw {
    width: 120px !important;
}

/* Light mode (default): show original logo colors */
.sidebar-logos img {
    filter: none;
}

/* Dark mode: make logos white */
[data-theme="dark"] .sidebar-logos img {
    filter: brightness(0) invert(1);
}

/* Auto theme - when system prefers dark */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .sidebar-logos img {
        filter: brightness(0) invert(1);
    }
}

.sidebar-logo {
    font-family: 'Fraunces', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.sidebar-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.sidebar-subtitle.at-top {
    color: var(--primary);
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-section {
    margin-bottom: 12px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 24px 8px;
}

.nav-item {
    display: block;
    padding: 14px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    position: relative;
    transition: all 0.15s ease;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.15s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    background: var(--primary);
}

/* Theme Switcher */
.theme-switcher {
    padding: 20px 16px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.theme-switcher-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
    padding: 0 8px;
}

.theme-options {
    display: flex;
    gap: 4px;
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 4px;
}

.theme-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-btn .material-symbols-outlined {
    font-size: 26px;
}

.theme-btn-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.theme-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-card);
}

.theme-btn.active {
    color: var(--primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

/* Content max-width is set later in .content-area */

/* Filters Bar */
.filters-bar {
    width: 100%;
    padding: 18px 40px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-secondary);
    box-sizing: border-box;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filters-bar label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.filter-select {
    padding: 11px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    min-width: 150px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.filter-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Compact age filter */
.filter-select-compact {
    min-width: 70px;
    padding: 11px 12px;
}

/* Gender icon buttons */
.filter-group-icons {
    gap: 4px;
}

.gender-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s ease;
}

.gender-btn .material-symbols-outlined {
    font-size: 22px;
}

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

.gender-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.gender-btn[data-gender="Female"].active {
    background: #7b1fa2;
    border-color: #7b1fa2;
}

.gender-btn[data-gender="Male"].active {
    background: #1565c0;
    border-color: #1565c0;
}

.btn-reset {
    padding: 11px 16px;
    height: 42px;
    min-width: 60px; /* Reserve space */
    background: var(--quaternary);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
    box-shadow: var(--shadow-sm);
    visibility: hidden; /* Reserve space but hide */
}

.btn-reset.visible {
    visibility: visible;
}

.btn-reset:hover {
    background: #dc2626;
}

.filters-wrapper {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.filters-left {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-right {
    display: flex;
    align-items: center;
}

.display-toggle {
    display: flex;
    background: var(--bg-hover);
    border-radius: 6px;
    padding: 3px;
}

.display-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.display-toggle-btn .material-symbols-outlined {
    font-size: 20px;
}

.display-toggle-btn:hover {
    color: var(--text-primary);
}

.display-toggle-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Hero Section */
.hero-section {
    width: 100%;
    padding: 48px 40px;
    box-sizing: border-box;
}

[data-theme="light"] .hero-section,
:root:not([data-theme="dark"]) .hero-section {
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.04) 0%, rgba(255,255,255,0) 100%);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .hero-section {
        background: linear-gradient(180deg, rgba(37, 99, 235, 0.03) 0%, transparent 100%);
    }
}

.hero-content {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px;
}

.hero-text {
    flex: 1;
}

.hero-logos {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-shrink: 0;
    margin-top: 28px; /* align with headline, skip the IPW PROJECT label */
}

.hero-logos img {
    width: auto;
    height: auto;
    transition: filter 0.25s ease;
}

.hero-logos .logo-cofidis {
    height: 90px;
}

.hero-logos .logo-ipw {
    height: 62px;
}

.hero-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
}

.hero-headline {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
    margin: 0 0 16px 0;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0 0 28px 0;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    font-size: 15px;
    color: var(--text-secondary);
}

.hero-meta strong {
    color: var(--text-primary);
    font-weight: 600;
}

.hero-meta .meta-separator {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
}

/* Dark mode: white logos */
[data-theme="dark"] .hero-logos img,
:root:not([data-theme="light"]) .hero-logos img {
    filter: brightness(0) invert(1);
}

/* Light mode: original colors */
[data-theme="light"] .hero-logos img {
    filter: none;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .hero-logos img {
        filter: none;
    }
}

/* Hero meta filtered state */
.hero-meta.filtered strong:first-of-type {
    color: var(--quaternary);
}

/* Content Sections */
.content-area {
    width: 100%;
    padding: 0 40px;
    box-sizing: border-box;
}

section {
    max-width: var(--content-max-width);
    margin: 0 auto 64px;
    scroll-margin-top: 90px;
}

.section-header {
    margin-bottom: 28px;
}


.section-header h2 {
    font-family: 'Fraunces', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Filter stats in top bar */
.filter-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.filter-stats .filter-count strong {
    color: var(--text-primary);
    font-weight: 600;
}

.filter-stats.filtered .filter-count strong:first-child {
    color: var(--primary);
}

.filter-stats .filter-applied {
    color: var(--primary);
    font-weight: 600;
    display: none;
}

.filter-stats .filter-separator {
    display: none;
    color: var(--text-muted);
}

.filter-stats.filtered .filter-separator {
    display: inline;
}

.filter-stats.filtered .filter-applied {
    display: inline;
}

.filter-stats .btn-reset {
    display: none;
    margin-left: 6px;
}

.filter-stats.filtered .btn-reset {
    display: inline-flex;
}

/* Chart Grid - 2 columns for distribution charts */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    align-items: stretch;
}

.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 420px;
    transition: box-shadow 0.2s ease;
}

.chart-card:hover {
    box-shadow: var(--shadow-md);
}

/* Custom curved legend for doughnut charts */
.chart-container {
    position: relative;
    display: flex;
    align-items: center;
}

.chart-container canvas {
    flex: 1;
    min-width: 0;
}

/* When legend is present, canvas takes 50% */
.chart-container.has-legend canvas {
    flex: 0 0 50%;
    max-width: 50%;
}

.custom-legend {
    flex: 0 0 50%;
    max-width: 50%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
}

/* Simple centered legend */
.legend-items {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    padding: 5px 0;
    white-space: nowrap;
}

.legend-item .legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}

.legend-item .legend-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.legend-item.clickable {
    cursor: pointer;
    border-radius: 4px;
    padding: 5px 8px;
    margin: 0 -8px;
}

.legend-item.clickable:hover {
    background: var(--bg-hover);
}

.legend-item.clickable:hover .legend-label {
    color: var(--text-primary);
}

/* Curved SVG Legend */
.curved-legend-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.curved-legend-svg .legend-text {
    font-family: 'IBM Plex Sans', -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 700;
    fill: var(--text-primary);
    dominant-baseline: middle;
    text-anchor: start;
}

.curved-legend-svg .legend-dot {
    transition: r 0.15s ease;
}

.curved-legend-svg .legend-item-group {
    transition: opacity 0.15s ease;
}

.curved-legend-svg .legend-item-group.clickable:hover .legend-text {
    fill: var(--text-primary);
}

.curved-legend-svg .legend-item-group.clickable:hover .legend-dot {
    r: 8;
}

/* Debug panel for arc parameters */
.legend-debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    min-width: 380px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.legend-debug-panel .debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.legend-debug-panel .debug-title {
    font-weight: 600;
    color: var(--primary);
    font-size: 16px;
}

.legend-debug-panel .debug-copy-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.legend-debug-panel .debug-copy-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.legend-debug-panel .debug-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 16px 0 8px 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.legend-debug-panel .debug-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.legend-debug-panel .debug-row {
    display: grid;
    grid-template-columns: 80px 1fr 65px;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.legend-debug-panel .debug-row label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
}

.legend-debug-panel input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 3px;
    cursor: pointer;
}

.legend-debug-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.legend-debug-panel input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.legend-debug-panel input[type="number"] {
    width: 100%;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    text-align: center;
}

.legend-debug-panel input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
}

.legend-debug-panel .debug-legend-guide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    margin-top: 16px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.legend-debug-panel .debug-legend-guide span {
    font-weight: bold;
    margin-right: 4px;
}

.legend-debug-panel .debug-output {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    word-break: break-all;
    line-height: 1.4;
}

/* Bar Chart Debug Panel */
.bar-debug-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    min-width: 320px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.bar-debug-panel .debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.bar-debug-panel .debug-title {
    font-weight: 600;
    color: var(--accent-teal);
    font-size: 16px;
}

.bar-debug-panel .debug-header-buttons {
    display: flex;
    gap: 8px;
}

.bar-debug-panel .debug-copy-btn,
.bar-debug-panel .debug-reset-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.bar-debug-panel .debug-copy-btn:hover {
    background: var(--accent-teal);
    color: white;
    border-color: var(--accent-teal);
}

.bar-debug-panel .debug-reset-btn:hover {
    background: var(--accent-coral);
    color: white;
    border-color: var(--accent-coral);
}

.bar-debug-panel .debug-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
    font-style: italic;
}

.bar-debug-panel .debug-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 16px 0 8px 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.bar-debug-panel .debug-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.bar-debug-panel .debug-row {
    display: grid;
    grid-template-columns: 80px 1fr 60px;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.bar-debug-panel .debug-row label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
}

.bar-debug-panel input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 3px;
    cursor: pointer;
}

.bar-debug-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-teal);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.bar-debug-panel input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.bar-debug-panel input[type="number"] {
    width: 100%;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    text-align: center;
}

.bar-debug-panel input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-teal);
}

.bar-debug-panel input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-teal);
}

.bar-debug-panel .debug-output {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    word-break: break-all;
    line-height: 1.4;
}

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

.chart-card.full-width .chart-container {
    min-height: 320px;
    max-height: 360px;
}

.chart-card.full-width-compact {
    grid-column: 1 / -1;
    align-self: start;
    min-height: auto;
}

.chart-card.full-width-compact .chart-container {
    min-height: 280px;
    max-height: 320px;
}

.chart-card.tall {
    min-height: 520px;
}

.chart-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.chart-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    color: var(--primary);
    border-radius: 0;
    font-size: 24px;
    flex-shrink: 0;
}

.chart-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

/* Chart reset button */
.chart-reset-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 28px;
    padding: 0 10px 0 12px;
    background: var(--quaternary);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chart-reset-btn .reset-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-reset-btn .material-symbols-outlined {
    font-size: 16px;
}

.chart-reset-btn:hover {
    background: #dc2626;
    transform: scale(1.02);
}

.chart-reset-btn.visible {
    display: inline-flex;
}

/* Filterable chart cards */
.chart-card--filterable .chart-container {
    cursor: pointer;
}

.chart-card--filterable.filtered {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary), var(--shadow-md);
}

.chart-card--filterable.filtered .chart-title {
    color: var(--primary);
}

/* Range Indicator - Minimal Line Style */
.range-indicator {
    margin-bottom: 20px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-radius: 10px;
    flex-shrink: 0;
}

.range-bar-container {
    position: relative;
    height: 56px;
}

.range-bar-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--range-track);
    transform: translateY(-50%);
}

.range-bar-fill {
    position: absolute;
    top: 50%;
    height: 2px;
    background: var(--range-fill);
    transform: translateY(-50%);
}

.range-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.range-marker-line {
    width: 2px;
    height: 20px;
    background: var(--range-marker);
}

.range-marker-line.min,
.range-marker-line.max {
    height: 16px;
    opacity: 0.7;
}

.range-marker-line.avg {
    height: 28px;
    width: 3px;
    background: var(--text-primary);
}

.range-marker-line.median {
    height: 22px;
    opacity: 0.85;
}

.range-marker-label {
    position: absolute;
    top: 24px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.range-marker-value {
    position: absolute;
    bottom: 24px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

/* When markers are too close, flip one above */
.range-marker.above .range-marker-label {
    top: auto;
    bottom: 46px;
}

.range-marker.above .range-marker-value {
    bottom: auto;
    top: 24px;
}

.chart-container {
    position: relative;
    flex: 1;
    min-height: 240px;
}

/* Comments Section */

/* Analysis Card - Full width at top */
.analysis-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.analysis-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}


.analysis-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.analysis-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.analysis-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.analysis-item {
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    gap: 16px;
    border: 1px solid var(--border);
    align-items: flex-start;
}

.analysis-item-icon {
    font-size: 52px;
    color: var(--primary);
    flex-shrink: 0;
}

.analysis-item-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.analysis-item-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Comments Section with Grid Cards */
.comments-section {
    margin-bottom: 36px;
}

.comments-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.comments-section-title .material-symbols-outlined {
    font-size: 32px;
    color: var(--primary);
}

.comments-section-title .count {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
	margin-left: 10px;
    background: var(--bg-hover);
    padding: 4px 12px;
    border-radius: 20px;
}

.comment-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.comment-row {
    display: grid;
    gap: 14px;
    align-items: center;
}

.comment-row.cols-1 { grid-template-columns: 1fr; }
.comment-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.comment-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.comment-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.comment-row.cols-5 { grid-template-columns: repeat(5, 1fr); }

.comment-card {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.comment-card .comment-gender {
    font-size: 52px;
    color: var(--text-muted);
    flex-shrink: 0;
    line-height: 1;
    font-variation-settings: 'FILL' 0, 'wght' 200, 'GRAD' -25, 'opsz' 48;
}

.comment-card .comment-gender.male {
	color: #1565c0; /* Blue - matches gender chart */
}

.comment-card .comment-gender.female {
	color: #7b1fa2; /* Purple - matches gender chart */
}

.comment-card .bubble {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border-radius: 16px;
    border-top-left-radius: 4px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.comment-card .bubble::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 18px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid var(--border);
}

.comment-card .bubble::after {
    content: '';
    position: absolute;
    left: -10px;
    top: 18px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid var(--bg-card);
}

.comment-card:hover .bubble {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.comment-card .comment-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    word-wrap: break-word;
}

.comment-card .meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 500;
}

.comment-cards-empty {
    color: var(--text-muted);
    font-size: 14px;
    padding: 20px;
    text-align: center;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 100%;
}

@media (max-width: 1024px) {
    .analysis-content {
        grid-template-columns: 1fr;
    }
    .comment-row.cols-4,
    .comment-row.cols-5 {
        grid-template-columns: repeat(2, 1fr);
    }
    .comment-row.cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .comment-row.cols-2,
    .comment-row.cols-3,
    .comment-row.cols-4,
    .comment-row.cols-5 {
        grid-template-columns: 1fr;
    }
}

/* Findings Grid - 2 per row, bigger */
.findings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 36px;
}

.finding-card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 28px 32px;
    display: flex;
    align-items: flex-start;
    gap: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.finding-card:hover {
    box-shadow: var(--shadow-md);
}

.finding-stat {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    min-width: 90px;
    flex-shrink: 0;
}

.finding-card.unexpected .finding-stat {
    color: var(--secondary);
}

.finding-content {
    flex: 1;
    padding-top: 4px;
}

.finding-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.finding-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* Data Tables */
.data-table-wrapper {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.data-table th,
.data-table td {
    padding: 16px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: var(--bg-hover);
}

.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.pagination-info {
    color: var(--text-muted);
    font-size: 15px;
}

.pagination-buttons {
    display: flex;
    gap: 10px;
}

.pagination-buttons button {
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
}

.pagination-buttons button:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.pagination-buttons button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* Issues Table */
.issues-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    font-size: 15px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.issues-table th,
.issues-table td {
    padding: 16px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.issues-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.issues-table tr:last-child td {
    border-bottom: none;
}

/* Study Limitations */
.study-limitations {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.study-limitations h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
}

.limitations-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.limitation-item {
    display: flex;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.limitation-item .material-symbols-outlined {
    font-size: 22px;
    color: var(--text-muted);
}

.limitation-item strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.limitation-item p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-high {
    background: transparent;
    border: 1px solid #c62828;
    color: #c62828;
}

.badge-medium {
    background: transparent;
    border: 1px solid #757575;
    color: #757575;
}

.badge-low {
    background: transparent;
    border: 1px solid #2e7d32;
    color: #2e7d32;
}

/* Footer */
footer {
    padding: 37px 0;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    bottom: 0;
    background: var(--loading-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 1200px) {
    .chart-grid { grid-template-columns: repeat(2, 1fr); }
    .findings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; }
    .hero-grid { grid-template-columns: 1fr; }
    .chart-grid { grid-template-columns: repeat(2, 1fr); }
    .loading-overlay { left: 220px; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .loading-overlay { left: 0; }
    .chart-grid { grid-template-columns: 1fr; }
    .filters-bar { padding: 14px 20px; }
    .content-area { padding: 24px; }
    .findings-grid { grid-template-columns: 1fr; }
}
