:root {
    --primary-color: #2e5cb8;
    --primary-light: #4a7ad4;
    --secondary-color: #15397a;
    --background-color: #f5f7fa;
    --surface-color: #ffffff;
    --text-color: #333;
    --text-secondary: #666;
    --border-color: #e0e6f0;
    --hover-color: #f6f9ff;
    --success-color: #07a77d;
    --warning-color: #e67e22;
    --danger-color: #e53e3e;
    --accent-color: #f0f4fa;
    --republican-color: #D83A3A;
    --democrat-color: #3A7BD8;
    --neutral-color: #7d7d7d;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 24px 40px;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    background-color: var(--surface-color);
    box-shadow: var(--shadow-md);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 64px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    height: 40px;
}

.main-header h1 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    line-height: 1;
    color: #303e4f;
    letter-spacing: -0.01em;
}

.header-nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    font-size: 0.94rem;
}

.nav-link:hover {
    color: var(--primary-color);
    background-color: var(--hover-color);
}

.stats-container {
    display: flex;
    gap: 20px;
    margin: 30px 0;
}

.stat-box {
    background: var(--surface-color);
    padding: 16px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    flex: 1;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: slideIn 0.4s ease-out forwards;
    opacity: 0;
    border: 1px solid var(--border-color);
    position: relative;
    padding-left: 55px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 120px;
}

.stat-box:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-box .icon {
    position: absolute;
    left: 15px;
    top: 15px;
    width: 34px;
    height: 34px;
    background-color: rgba(46, 92, 184, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    transition: transform 0.2s ease;
}

.stat-box:hover .icon {
    transform: scale(1.1);
}

.stat-box h3 {
    font-size: .8rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    min-height: 2.4em;
    display: flex;
    align-items: flex-start;
}

.stat-box p {
    font-size: 1.5rem !important;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.02em;
    line-height: 1;
    margin: 0;
}

.stat-box:nth-child(2) {
    animation-delay: 0.1s;
}

.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.top-controls h2 {
    margin: 0;
    flex-grow: 1;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: -0.01em;
}

.dimension-filters {
    display: flex;
    gap: 12px;
}

.dimension-filters select {
    padding: 10px 16px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    font-size: 0.9rem;
    min-width: 180px;
    color: var(--text-color);
    font-weight: 500;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23546278' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 36px;
}

.dimension-filters select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46, 92, 184, 0.15);
}

.records-container {
    background: var(--surface-color);
    box-shadow: var(--shadow-md);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-top: 10px;
    width: 100%;
    overflow-x: auto;
}

/* Records Grid Layout - Models */
.records-header, 
#records-list .record {
    display: grid;
    grid-template-columns: 70px minmax(160px, 1fr) 160px 160px 180px 180px minmax(120px, 1fr);
    padding: 12px 20px;
    gap: 10px;
    align-items: center;
    box-sizing: border-box;
    min-width: 1030px; /* Ensure header and rows have min-width */
}

/* Records Header */
.records-header {
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 10;
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    min-height: 75px;
}

/* Record Item Shared Styles */
.record-item {
    padding: 0 10px;
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: 0.01em;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

/* Header Items */
.records-header .record-item {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    white-space: normal;
    overflow: visible;
    line-height: 1.2;
    color: white;
}

/* Sortable Column Headers */
.records-header .record-item.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px; /* Make space for sort indicator */
}

/* Sort Icon Space */
.records-header .record-item.sortable:after {
    content: "";
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
}

/* Record Row Styles */
.record {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
    animation: fadeIn 0.3s ease-out forwards;
    opacity: 0;
}

/* Alignment for special columns */
.record-item.rank, 
.records-header .record-item[data-sort="rank"] {
    text-align: center;
}

.record-item.slant-number, 
.record-item.percent-slanted,
.record-item.republican-slant, 
.record-item.democrat-slant,
.records-header .record-item[data-sort="slant"],
.records-header .record-item[data-sort="percent_slanted"],
.records-header .record-item[data-sort="percent_republican"],
.records-header .record-item[data-sort="percent_democrat"] {
    text-align: right;
    padding-right: 20px;
    white-space: normal;
}

.records-list {
    max-height: none;
    overflow: visible;
}

.record:hover {
    background-color: var(--hover-color);
}

.record:last-child {
    border-bottom: none;
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

.record .rank {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.record .model {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.8rem;
}

.record .company {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.record .slant {
    font-weight: 600;
}

.record .slant.positive {
    color: white;
    background-color: var(--republican-color);
    padding: 6px 8px;
    font-size: 0.7em;
    border-radius: 2px;
    display: inline-block;
    height: auto;
    width: max-content;
    line-height: 1.2;
    white-space: nowrap;
}

.record .slant.negative {
    color: white;
    background-color: var(--democrat-color);
    padding: 6px 8px;
    font-size: 0.7em;
    border-radius: 2px;
    display: inline-block;
    height: auto;
    width: max-content;
    line-height: 1.2;
    white-space: nowrap;
}

.record .slant.neutral {
    color: white;
    background-color: var(--neutral-color);
    padding: 6px 8px;
    font-size: 0.7em;
    border-radius: 2px;
    display: inline-block;
    height: auto;
    width: max-content;
    line-height: 1.2;
    white-space: nowrap;
}

.record .slant-number {
    font-weight: 600;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
}

.records-header .record-item.sortable:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Sort Indicators */
.records-header .record-item.sortable.asc::after,
.records-header .record-item.sortable.desc::after {
    content: "";
    position: absolute;
    right: 5px;
    top: 50%;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    width: 0;
    height: 0;
}

.records-header .record-item.sortable.asc::after {
    transform: translateY(-60%);
    border-bottom: 5px solid white;
}

.records-header .record-item.sortable.desc::after {
    transform: translateY(-40%);
    border-top: 5px solid white;
}

/* Model Detail Panel */
.model-detail-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background-color: var(--surface-color);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    overflow-y: auto;
    transition: right 0.3s ease-in-out;
    padding: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    backdrop-filter: none;
}

.model-detail-panel.active {
    right: 0;
}

.model-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background-color: var(--primary-color);
    color: white;
    position: sticky;
    top: 0;
    z-index: 1;
}

.model-detail-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.close-panel {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-panel:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.model-detail-content {
    padding: 20px;
    flex-grow: 1;
}

/* New styles for the model info table */
.model-info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px; /* Add some space before Topic Breakdown */
}

.model-info-table td {
    padding: 0px 0; /* Vertical padding, no horizontal */
    margin-right: 5px;
    vertical-align: top;
}

.detail-info-label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
    padding-left: 10px; /* Space between label and value */
    white-space: nowrap; /* Prevent labels from wrapping */
    width: 1%; /* Let label column take minimum width */
}

.detail-info-value {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
    padding-left: 10px !important;
    /* The div inside will contain the actual value */
}

/* Styling for topic breakdown table */
.topic-breakdown-table {
    width: 100%;
    border-collapse: collapse; 
    margin-top: 16px;
}

.topic-breakdown-table th {
    text-align: left;
    padding: 8px 5px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.topic-breakdown-table td {
    padding: 4px 5px; /* Reduced vertical padding from 8px */
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

/* Remove border from last row */
.topic-breakdown-table tr:last-child td {
    border-bottom: none;
}

/* Align second column (Slant) content to the left */
.topic-breakdown-table td:nth-child(2) {
    text-align: left;
}

/* Adjust slant label alignment within the table */
.topic-breakdown-table td:nth-child(2) .slant-label {
    text-align: left;
    width: auto; /* Remove fixed width */
    display: inline; /* Change display to allow natural flow */
    margin-left: 0; /* Ensure no unintended margin */
}

/* Styling for topic breakdown table headers */
.topic-breakdown-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px; /* Space for sort arrow */
}

/* Reuse existing sort arrows */
.topic-breakdown-table th.sortable:after {
    content: "";
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
}

.topic-breakdown-table th.sortable.asc::after,
.topic-breakdown-table th.sortable.desc::after {
    content: "";
    position: absolute;
    right: 5px;
    top: 50%;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    width: 0;
    height: 0;
}

.topic-breakdown-table th.sortable.asc::after {
    transform: translateY(-60%);
    border-bottom: 5px solid var(--text-secondary); /* Use a visible color */
}

.topic-breakdown-table th.sortable.desc::after {
    transform: translateY(-40%);
    border-top: 5px solid var(--text-secondary); /* Use a visible color */
}

.detail-info-value #detail-average-slant span {
    display: inline-block; /* Ensure slant label stays next to value */
}

.model-detail-content h4 {
    margin: 24px 0 16px;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.detail-topics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.topic-item {
    background-color: var(--accent-color);
    padding: 14px;
    border-radius: 0;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.topic-name {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-color);
    font-size: 0.85rem;
}

.topic-slant {
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 0;
    display: inline-block;
    color: white;
    font-size: 0.8rem;
}

.topic-slant.positive {
    background-color: var(--republican-color);
}

.topic-slant.negative {
    background-color: var(--democrat-color);
}

.topic-slant.neutral {
    color: white;
    background-color: var(--neutral-color) !important;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1050;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.overlay.active {
    display: block;
    opacity: 1;
}

/* Make model names clickable */
.record .model {
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.record .model:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.dashboard-content {
    line-height: 1.7;
}

.dashboard-content p {
    margin-bottom: 1.2em;
    color: var(--text-secondary);
    font-size: 1rem;
}

.dashboard-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 1.5em 0 0.75em;
    color: var(--text-color);
    letter-spacing: -0.01em;
}

.dashboard-content h2:first-child {
    margin-top: 0;
}

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

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.error-message {
    padding: 20px;
    background-color: #fff5f5;
    color: var(--danger-color);
    border-radius: var(--border-radius);
    margin: 20px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #fed7d7;
}

.no-records {
    padding: 20px;
    background-color: var(--accent-color);
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    margin: 20px;
    text-align: center;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    .main-header {
        padding: 10px 16px;
        height: auto;
        position: relative;
    }

    .header-content {
        flex-direction: row;
        padding: 0;
        gap: 10px;
    }
    
    .logo-container {
        justify-content: flex-start;
    }
    
    .logo {
        height: 30px;
    }
    
    .main-header h1 {
        font-size: 1.1rem;
    }
    
    .header-nav {
        gap: 10px;
    }
    
    .nav-link {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .container {
        padding: 16px 12px;
    }
    
    .dashboard-content {
        padding: 0;
    }
    
    .dashboard-content h2 {
        font-size: 1.4rem;
    }
    
    .dashboard-content p {
        font-size: 0.95rem;
    }
    
    .top-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .top-controls h2 {
        font-size: 1.2rem;
        margin-bottom: 5px;
    }
    
    .dimension-filters {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .dimension-filters select {
        width: 100%;
        min-width: 0;
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    /* Mobile view adjustments for tables */
    .records-header, 
    #records-list .record {
        /* Rank(40) Model(1fr) Slant(100) %Slant(100) RepSlant(120) DemSlant(120) Company(1fr) */
        grid-template-columns: 40px minmax(100px, 1fr) 100px 100px 120px 120px minmax(80px, 1fr);
        font-size: 0.9em;
        min-width: 750px; /* Adjust min-width if needed */
        gap: 5px;
        padding: 8px;
    }
    
    .records-container {
        overflow-x: auto;
    }
    
    .records-header .record-item {
        font-size: 0.7rem;
        padding-left: 2px;
    }
    
    .record-item {
        padding: 2px;
        font-size: 0.65rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .record .slant.positive, 
    .record .slant.negative {
        padding: 3px 5px;
        font-size: 0.65em;
        width: max-content;
        min-width: 0;
    }
    
    /* Mobile stats container */
    .stats-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin: 20px 0 24px;
    }
    
    .stat-box {
        padding: 12px;
        padding-left: 54px; /* Keep left padding */
        margin-bottom: 0;
        min-height: 100px; /* Keep min-height if desired, or remove */
        /* height: auto; */ /* Or set height to auto */
        /* REMOVE height override if fixed height is causing issues */
        /* height: 120px; */ /* Restore original height if needed */
    }

    .stat-box .icon {
        left: 14px;
        top: 16px;
        /* REMOVE width/height overrides */
        /* width: 28px; */
        /* height: 28px; */
        border-radius: 6px; /* Keep smaller radius if desired */
    }

    .stat-box .icon svg {
        /* REMOVE width/height overrides */
        /* width: 16px; */
        /* height: 16px; */
    }
    
    .stat-box h3 {
        /* REMOVE font-size override */
        /* font-size: 0.5rem; */ 
        margin-bottom: 4px;
        min-height: initial; /* Remove fixed min-height for mobile */
    }
    
    .stat-box p {
        /* REMOVE font-size override */
        /* font-size: 1rem !important; */
        margin: 0;
    }
    
    /* Mobile model detail panel */
    .model-detail-panel {
        width: 100%;
        right: -100%;
    }
    
    .model-detail-content {
        padding: 16px;
    }
    
    /* Comment out mobile detail section styles */
    /*
    .detail-section {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 16px;
    }
    
    .detail-label {
        margin-bottom: 4px;
        font-size: 0.8rem;
    }
    
    .detail-value {
        font-size: 0.9rem;
    }
    */

    /* Add mobile adjustments for the table if needed */
    .model-info-table td {
        padding: 6px 0;
        vertical-align: middle; /* Center align vertically on mobile? */
    }

    .detail-info-label {
        font-size: 0.85rem;
        padding-right: 8px;
        color: var(--text-color);
    }

    .detail-info-value {
        font-size: 0.85rem;
        color: var(--text-color);
    }

    .model-detail-content h4 {
        font-size: 0.95rem;
        margin: 20px 0 12px;
    }
    
    .detail-topics-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Space after paragraphs */
    .dashboard-content > p {
        margin-bottom: 20px;
    }

    .accordion-header {
        font-size: 1rem;
        padding: 12px 16px;
    }
    
    .accordion-item.active .accordion-body {
        padding: 16px;
    }
    
    .accordion-content {
        font-size: 0.95rem;
    }
    
    .about-section {
        padding: 24px;
    }

    .about-section h2 {
        font-size: 1.6rem;
        margin-bottom: 20px;
    }

    .about-section h3 {
        font-size: 1.2rem;
        margin: 20px 0 15px;
    }

    .about-section p,
    .about-section ul li {
        font-size: 1rem;
    }

    .about-section .highlight {
        padding: 20px;
        margin: 20px 0;
    }
}

@media (max-width: 576px) {
    .records-header, .record {
        grid-template-columns: 30px 1.5fr 1.5fr 1.5fr 1.5fr 1.5fr 1fr;
        font-size: 0.8em;
        min-width: 950px; /* Slightly smaller minimum width for very small screens */
    }
}

/* Filter container */
.filter-container {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

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

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

.filter select {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: white;
    font-size: 0.9em;
}

.republican-slant {
    color: var(--republican-color);
    font-weight: 600;
    text-align: right;
}

.democrat-slant {
    color: var(--democrat-color);
    font-weight: 600;
    text-align: right;
}

.model-type {
    color: var(--text-secondary);
}

/* Right-align numeric columns in the header */
.records-header .record-item[data-sort="slant"],
.records-header .record-item[data-sort="percent_slanted"],
.records-header .record-item[data-sort="percent_republican"],
.records-header .record-item[data-sort="percent_democrat"] {
    text-align: right;
    padding-right: 25px;
    white-space: normal;
    color: white;
}

.info-icon {
    display: inline-block;
    margin-left: 5px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: bold;
    border-radius: 50%;
    vertical-align: middle;
}

.info-icon:hover {
    opacity: 0.8;
}

#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    display: none;
    justify-content: center;
    align-items: center;
}

#explanation-popup {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 600px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1110;
}

.popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
}

.popup-title {
    margin-top: 0;
    color: var(--primary-color);
}

.popup-content {
    line-height: 1.5;
    color: var(--text-primary);
}

.percent-slanted {
    font-weight: 600;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--text-primary);
}

/* About page styles */
.about-section {
    background-color: var(--surface-color);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
    border: 1px solid var(--border-color);
}

.about-section h2 {
    font-size: 2rem;
    margin: 0 0 30px;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
}

.about-section h3 {
    font-size: 1.4rem;
    margin: 0 0 20px;
    color: var(--text-color);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    position: relative;
    padding-left: 15px;
}

.about-section h3::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background-color: var(--primary-light);
    border-radius: 4px;
}

.about-section p {
    margin-bottom: 20px;
    line-height: 1.7;
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 100%;
    letter-spacing: 0.01em;
}

.about-section a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    border-bottom: 1px solid transparent;
}

.about-section a:hover {
    color: var(--primary-light);
    border-bottom-color: var(--primary-light);
}

.about-section .highlight {
    background-color: var(--accent-color);
    padding: 30px;
    border-radius: var(--border-radius);
    margin: 30px 0;
    border-left: 4px solid var(--primary-color);
}

.about-section .highlight p {
    margin: 0;
    font-style: italic;
    color: var(--text-color);
    line-height: 1.6;
}

/* FAQ Accordion Styles */
.faq-accordion {
    margin-bottom: 40px;
}

.accordion-item {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 10px;
    background-color: var(--surface-color);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.accordion-item:hover {
    box-shadow: var(--shadow-md);
}

.accordion-header {
    padding: 15px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background-color: var(--primary-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background-color: var(--primary-light);
}

.accordion-header:after {
    content: "+";
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    transition: transform 0.3s ease;
}

.accordion-item.active .accordion-header:after {
    content: "−";
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 20px;
}

.accordion-item.active .accordion-body {
    max-height: none;
    overflow: visible;
    padding: 20px;
}

.accordion-content {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 1rem;
}

/* Add specific styling for lists inside accordion */
.accordion-content ul,
.accordion-content ol {
    margin: 15px 0 15px 0; /* Add some vertical margin */
    padding-left: 60px; /* Indent the list itself */
    list-style-type: none; /* Remove default bullets/numbers */
}

.accordion-content ul li,
.accordion-content ol li {
    position: relative;
    padding-left: 0; /* No padding on the LI itself */
    line-height: 1.6; /* Standardize line-height */
    font-size: 1rem; /* Explicitly set font-size */
}

/* Style custom bullets/numbers */
.accordion-content ul li::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    position: absolute;
    left: -25px; /* Position bullet within the parent padding */
}

/* For ordered lists, use counters */
.accordion-content ol {
    counter-reset: item;
}

.accordion-content ol li::before {
    content: counter(item) "."; 
    counter-increment: item; 
    color: var(--primary-color);
    font-weight: bold;
    position: absolute;
    left: -25px; /* Position number within the parent padding */
    width: 20px; /* Give number some space */
    text-align: right;
    margin-right: 5px;
}

@media (max-width: 768px) {
    .accordion-header {
        font-size: 1rem;
        padding: 12px 16px;
    }
    
    .accordion-item.active .accordion-body {
        padding: 16px;
    }
    
    .accordion-content {
        font-size: 0.95rem;
    }
    
    .about-section {
        padding: 24px;
    }

    .about-section h2 {
        font-size: 1.6rem;
        margin-bottom: 20px;
    }

    .about-section h3 {
        font-size: 1.2rem;
        margin: 20px 0 15px;
    }

    .about-section p,
    .about-section ul li {
        font-size: 1rem;
    }

    .about-section .highlight {
        padding: 20px;
        margin: 20px 0;
    }
}

/* Data page styles */
.data-section {
    background-color: var(--surface-color);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.data-downloads {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.download-card {
    background-color: var(--accent-color);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.download-card h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-color);
}

.download-card p {
    margin-bottom: 20px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.download-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white !important;
    padding: 10px 16px;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

.download-button:hover {
    background-color: var(--primary-light);
    color: white !important;
}

.data-usage {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.data-usage h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.data-usage ul {
    margin-left: 25px;
    margin-bottom: 20px;
}

.data-usage ul li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.data-section a {
    color: var(--primary-color);
    font-weight: 500;
    transition: color 0.2s;
}

.data-section a:not(.download-button):hover {
    color: var(--primary-light);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .data-downloads {
        grid-template-columns: 1fr;
    }
    
    .download-card {
        padding: 16px;
    }
    
    .about-section, .data-section {
        padding: 16px;
    }
}

/* Guidance popup styles */
.guidance-link {
    /* Remove specific color, inherit instead */
    /* color: var(--primary-color); */
    text-decoration: none; /* Ensure no default underline */
    /* font-weight: 500; */ /* Remove specific weight, inherit */
    cursor: pointer;
    border-bottom: none; /* Remove dashed border */
    transition: color 0.2s ease; /* Match topic link transition */
}

.guidance-link:hover {
    color: var(--primary-color); /* Match topic link hover color */
    /* border-bottom-color: var(--primary-light); */ /* Remove border hover */
    text-decoration: underline; /* Match topic link hover underline */
}

.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    z-index: 1100;
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    backdrop-filter: none;
}

.popup-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.popup-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.close-popup {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    padding: 0;
    line-height: 1;
}

.close-popup:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.popup-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 58px); /* 58px is approx header height */
}

.popup-content ol {
    padding-left: 25px;
    margin: 0;
}

.popup-content ol li {
    margin-bottom: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1050;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    .popup {
        width: 95%;
        max-width: 450px;
    }
    
    .popup-header h3 {
        font-size: 1.1rem;
    }
    
    .popup-content p {
        font-size: 0.95rem;
    }
}


/* Topic slant styling for neutral values */
.topic-slant.neutral {
    color: white;
    background-color: white;
}

.slant-label {
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: bold;
    display: inline-block;
    width: 30px;
    text-align: center;
}

.slant-label.positive {
    background-color: #FFE8E8;
    color: #D83A3A;
}

.slant-label.negative {
    background-color: #E8F0FF;
    color: #3A7BD8;
}

.slant-label.neutral {
    /* background-color: #ECECEC; */
    color: var(--neutral-color);
}

/* Make sure the slant-number text color matches the label */
.positive-text {
    color: var(--republican-color);
}

.negative-text {
    color: var(--democrat-color);
}

.neutral-text {
    color: #333 !important;
}

/* Slant legend styles */
.slant-legend {
    margin-top: 15px;
    background-color: var(--surface-color);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.slant-legend h4 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-weight: 600;
}

.slant-legend p {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

/* Responsive styles for the legend */
@media (max-width: 768px) {
    .slant-legend {
        padding: 12px;
        margin-top: 10px;
    }
    
    .legend-items {
        gap: 10px;
    }
    
    .legend-item {
        gap: 6px;
    }
    
    .legend-text {
        font-size: 0.75rem;
    }
}

/* Topics Section - with additional debug styling */
.topics-section {
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    padding-top: 30px;
    position: relative; /* Ensure proper positioning */
    display: block; /* Force display as block */
    min-height: 200px; /* Ensure minimum height */
}

.topics-section h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.topics-section p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.topics-header {
    position: sticky; /* Ensure header sticks properly */
    top: 0;
    z-index: 10;
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    min-height: 75px;
}

/* Ensure topics list has specific styling */
#topics-list {
    position: relative;
    max-height: none;
    overflow: visible;
    min-height: 50px; /* Ensure minimum height */
    background-color: var(--surface-color);
}

/* Grid template for topics table - 6 columns */
.topics-header, 
#topics-list .record {
    display: grid;
    grid-template-columns: 70px minmax(150px, 1fr) 160px 160px 180px 180px;
    align-items: center;
    padding: 12px 15px;
    gap: 10px;
    min-width: 880px; /* Ensure header and rows have min-width */
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .topics-header, 
    #topics-list .record {
        /* Rank(60) Model(1fr) Slant(140) %Slant(140) RepSlant(160) DemSlant(160) */
        grid-template-columns: 60px minmax(140px, 1fr) 140px 140px 160px 160px;
        gap: 8px;
    }
}

@media (max-width: 992px) {
    .topics-header, 
    #topics-list .record {
        /* Rank(50) Model(1fr) Slant(120) %Slant(120) RepSlant(140) DemSlant(140) */
        grid-template-columns: 50px minmax(120px, 1fr) 120px 120px 140px 140px;
        padding: 10px;
        gap: 6px;
    }
}

@media (max-width: 768px) {
    .topics-section {
        margin-top: 30px;
        padding-top: 20px;
    }
    
    .topics-section h2 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
    
    .topics-header, 
    #topics-list .record {
        /* Rank(40) Model(1fr) Slant(100) %Slant(100) RepSlant(120) DemSlant(120) */
        grid-template-columns: 40px minmax(100px, 1fr) 100px 100px 120px 120px;
        font-size: 0.75rem;
        padding: 8px;
        gap: 5px;
    }
}

/* Loading message styling */
.loading-message {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    background-color: var(--surface-color);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* Providers Section */
.providers-section {
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    padding-top: 30px;
}

.providers-section h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.providers-section p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

/* Grid template for providers table - 6 columns */
.providers-header,
#providers-list .record {
    display: grid;
    grid-template-columns: 70px minmax(150px, 1fr) 160px 160px 180px 180px;
    align-items: center;
    padding: 12px 15px;
    gap: 10px;
    min-width: 880px; /* Ensure header and rows have min-width */
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .providers-header,
    #providers-list .record {
        /* Rank(60) Company(1fr) Slant(140) %Slant(140) RepSlant(160) DemSlant(160) */
        grid-template-columns: 60px minmax(130px, 1fr) 140px 140px 160px 160px;
        gap: 8px;
    }
}

@media (max-width: 992px) {
    .providers-header,
    #providers-list .record {
        /* Rank(50) Company(1fr) Slant(120) %Slant(120) RepSlant(140) DemSlant(140) */
        grid-template-columns: 50px minmax(120px, 1fr) 120px 120px 140px 140px;
        padding: 10px;
        gap: 6px;
    }
}

@media (max-width: 768px) {
    .providers-section {
        margin-top: 30px;
        padding-top: 20px;
    }

    .providers-section h2 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }

    .providers-header,
    #providers-list .record {
        /* Rank(40) Company(1fr) Slant(100) %Slant(100) RepSlant(120) DemSlant(120) */
        grid-template-columns: 40px minmax(100px, 1fr) 100px 100px 120px 120px;
        font-size: 0.75rem;
        padding: 8px;
        gap: 5px;
    }
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    margin-bottom: 0; /* Remove margin, border will separate */
    border-bottom: 1px solid var(--border-color);
    background-color: transparent; /* Make it blend */
    padding: 0;
    /* box-shadow: var(--shadow-sm); */ /* Remove shadow if not needed */
}

.tab-button {
    padding: 14px 22px;
    cursor: pointer;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent; /* Thicker indicator */
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-bottom: -1px; /* Align border with navigation border */
    text-align: center;
}

.tab-button:hover {
    color: var(--primary-color);
    background-color: var(--hover-color); /* Use hover color */
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: var(--surface-color); /* Give active tab slight background */
}

/* Tab Content */
.tab-content {
    /* Container for panels */
    margin-top: 0;
}

.tab-panel {
    display: none; /* Hide inactive tabs */
    padding: 25px; /* Add padding inside the panel */
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-top: none; /* Remove top border as nav has bottom border */
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    /* box-shadow: var(--shadow-sm); */ /* Remove shadow if desired */
    animation: fadeIn 0.4s ease-out;
}

.tab-panel.active {
    display: block; /* Show active tab */
}

/* Adjustments for sections within tabs */
.tab-panel section {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.tab-panel .top-controls {
    margin-bottom: 20px;
}

.tab-panel .records-container {
    margin-top: 0;
}

.tab-panel .slant-legend {
    margin-top: 25px; /* Add space before legend inside tab */
}

/* Footer Styles */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color); /* Optional: match surface color */
}

/* Style for clickable topic names */
.record-item.clickable-topic {
    cursor: pointer;
    color: var(--text-color); /* Match model base color */
    font-weight: 600; /* Match model font weight */
    text-decoration: none; /* No underline by default */
    transition: color 0.2s, text-decoration 0.2s;
}

.record-item.clickable-topic:hover {
    color: var(--primary-color); /* Match model hover color */
    text-decoration: underline; /* Underline on hover */
}

/* Popup content scroll */
.popup-content-scrollable {
    max-height: 60vh; /* Limit height */
    overflow-y: auto; /* Add scrollbar if needed */
    margin-top: 15px; /* Space from title */
    padding-right: 10px; /* Space for scrollbar */
}

/* Styling for clickable topic names in model detail */
.clickable-topic-detail {
    cursor: pointer;
    transition: color 0.2s ease;
}

.clickable-topic-detail:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.popup-content-scrollable {
    max-height: 400px; /* Adjust as needed */
    overflow-y: auto;
} 