:root {
    --primary-color: #1b4332;
    --primary-light: #2d6a4f;
    --primary-dark: #081c15;
    --accent-color: #52b788;
    --accent-light: #95d5b2;
    --secondary-color: #6c757d;
    --background: #f8faf9;
    --card-background: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #d8e6e0;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8faf9 0%, #e8f0ec 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.4s ease-out, visibility 0.4s ease-out;
}

.loading-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.02);
        opacity: 0.9;
    }
}

.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    border: 4px solid #e8f0ec;
    border-top: 4px solid var(--primary-color);
    border-right: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.loading-subtext {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 600;
}

header {
    background: var(--primary-color);
    color: white;
    padding: 2rem;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

header .subtitle {
    opacity: 0.9;
}

header .last-updated {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-top: 0.5rem;
}

.history-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.history-selector label {
    font-size: 0.875rem;
    opacity: 0.9;
    color: white;
}

.history-selector select {
    padding: 0.35rem 0.6rem;
    font-size: 0.875rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 0.25rem;
    background: rgba(255,255,255,0.12);
    color: white;
    cursor: pointer;
    appearance: auto;
}

.history-selector select option {
    background: var(--primary-color);
    color: white;
}

.tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.tab:hover {
    background: var(--background);
}

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

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

#filters {
    padding: 1rem;
    background: var(--card-background);
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filter-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-row:last-of-type {
    margin-bottom: 0;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-group select,
.filter-group input[type="text"] {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 1rem;
}

.filter-group input[type="text"] {
    min-width: 200px;
}

/* Condition and Country dropdowns can have very long option text;
   cap them so they don't blow out the filter row */
#condition,
#country {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* For browsers that support it, allow option text to wrap */
#condition option,
#country option {
    white-space: normal;
    word-wrap: break-word;
}

.filter-group input[type="range"] {
    width: 100px;
}

.filter-search {
    position: relative;
}

.clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
    line-height: 1;
}

.clear-btn:hover {
    color: var(--primary-color);
}

.reset-btn {
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.2s;
}

.reset-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.toggle-filters-btn {
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s;
}

.toggle-filters-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.expanded-filters {
    border-top: 1px dashed var(--border-color);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

.active-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 1rem;
    font-size: 0.875rem;
}

.filter-tag button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
}

.filter-tag button:hover {
    opacity: 0.8;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-container h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.chart-container.full-width {
    grid-column: 1 / -1;
}

.subcategory-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.subcat-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.subcat-btn:hover {
    border-color: var(--primary-color);
}

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

.note {
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1rem;
}

/* Table Styles */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.table-controls input[type="text"] {
    flex: 1;
    max-width: 400px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 1rem;
}

.study-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
}

/* Tufte-style table design: maximize data-ink ratio */
.studies-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    border: none; /* Remove outer borders */
}

.studies-table thead {
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.05); /* Subtle shadow instead of heavy border */
}

.studies-table th {
    padding: 0.75rem 1rem 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border: none; /* No vertical borders */
    border-bottom: 1px solid #d1d5db; /* Subtle horizontal line */
    background: white;
}

.studies-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.studies-table th.sortable:hover {
    background: #f9fafb; /* Very subtle hover */
}

.studies-table th.sorted-asc::after {
    content: " ▲";
    color: var(--primary-color);
}

.studies-table th.sorted-desc::after {
    content: " ▼";
    color: var(--primary-color);
}

.studies-table td {
    padding: 0.75rem 1rem 0.75rem 0.5rem;
    border: none; /* No vertical borders - Tufte principle */
    border-bottom: 1px solid #f3f4f6; /* Very light horizontal guides only */
}

/* Publications column: allow wrapping so long link text doesn't stretch the table */
.studies-table td.col-publications {
    max-width: 260px;
    white-space: normal;
    word-wrap: break-word;
}

.studies-table tbody tr {
    /* No zebra striping - rely on whitespace and subtle lines */
}

.studies-table tbody tr:hover {
    background: #fafbfc; /* Very subtle hover for interaction */
}

.studies-table .nct-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.studies-table .nct-link:hover {
    text-decoration: underline;
}

.studies-table .check-mark {
    color: var(--accent-color);
    font-size: 1.25rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.studies-table .x-mark {
    color: #95a5a6;
    font-size: 1.1rem;
    opacity: 0.7;
    font-weight: 300;
}

.studies-table .text-center {
    text-align: center;
}

.studies-table .text-right {
    text-align: right;
}

.phase-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--background);
    color: var(--text-primary);
}

footer {
    text-align: center;
    padding: 2rem;
    background: var(--card-background);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

footer a {
    color: var(--primary-color);
}

footer p {
    margin: 0.25rem 0;
}

@media (max-width: 768px) {
    .chart-row {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .filter-group input[type="text"] {
        min-width: 150px;
    }

    .table-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .table-controls input[type="text"] {
        max-width: 100%;
    }

    .studies-table {
        font-size: 0.75rem;
    }

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

    header h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 1rem;
    }

    .tabs {
        gap: 0.25rem;
    }

    .tab {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}
}

/* Clickable demographic checkmarks */
.demo-check {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    padding: 0;
    line-height: 34px;
    box-shadow: 0 2px 4px rgba(27, 67, 50, 0.15);
    position: relative;
}

.demo-check::before {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.demo-check:hover {
    transform: translateY(-2px) scale(1.1);
    box-shadow: 0 4px 12px rgba(82, 183, 136, 0.35);
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-color) 100%);
}

.demo-check:active {
    transform: translateY(0) scale(1.05);
    box-shadow: 0 2px 6px rgba(27, 67, 50, 0.25);
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.breakdown-modal {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease-out;
}

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

.breakdown-modal h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.breakdown-table th,
.breakdown-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.breakdown-table th {
    background: #f1f5f9;
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
}

.breakdown-table tbody tr:hover {
    background: #f8fafc;
}

.breakdown-table td:nth-child(2),
.breakdown-table td:nth-child(3) {
    text-align: right;
}

/* Visual percentage bar in last column */
.breakdown-table td:last-child {
    position: relative;
}

.breakdown-table td:last-child::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), #3b82f6);
    width: calc(var(--percent) * 1%);
    border-radius: 2px;
}

.modal-close-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 1rem;
    transition: background 0.2s;
}

.modal-close-btn:hover {
    background: #1d4ed8;
}

.modal-close-btn:active {
    transform: scale(0.98);
}

/* Mobile responsive modal */
@media (max-width: 768px) {
    .breakdown-modal {
        width: 95%;
        padding: 1.5rem;
        max-height: 90vh;
    }

    .breakdown-modal h4 {
        font-size: 1.1rem;
    }

    .breakdown-table th,
    .breakdown-table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
}

/* Study Details Modal */
.study-details-modal {
    background: white;
    padding: 0;
    border-radius: 8px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease-out;
}

.study-details-modal .modal-header {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: white;
    padding: 1.5rem 2rem;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.study-details-modal .modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.study-details-modal .close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.study-details-modal .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.study-details-modal .modal-body {
    padding: 2rem;
}

.detail-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.detail-section:last-child {
    border-bottom: none;
}

.detail-section h5 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.detail-grid div {
    padding: 0.5rem 0;
}

.detail-row {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.description {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 4px;
    margin-top: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

.collaborators-list,
.outcomes-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.collaborators-list li,
.outcomes-list li {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f9fafb;
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
}

.badge {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.alert {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
    color: #991b1b;
}

/* Details Button */
.details-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.details-btn:hover {
    background: #1d4ed8;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.details-btn svg {
    width: 16px;
    height: 16px;
}

/* Enrollment Badge */
.enrollment-badge {
    font-weight: 600;
    color: #2563eb;
}

.enrollment-badge::after {
    content: " (est.)";
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: normal;
}

/* Status with tooltip */
.status-stopped {
    color: #dc2626;
    font-weight: 600;
    cursor: help;
    border-bottom: 1px dashed #dc2626;
}

/* Responsive adjustments for study details */
@media (max-width: 768px) {
    .study-details-modal {
        width: 95%;
        max-height: 95vh;
    }

    .study-details-modal .modal-header {
        padding: 1rem;
    }

    .study-details-modal .modal-header h3 {
        font-size: 1rem;
    }

    .study-details-modal .modal-body {
        padding: 1rem;
    }

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

/* Match Quality Badges in Breakdown Modal */
.match-high {
    color: #10b981;
    font-weight: 600;
}

.match-medium {
    color: #f59e0b;
    font-weight: 600;
}

.match-low {
    color: #ef4444;
    font-weight: 600;
}

.match-na {
    color: #9ca3af;
}

.original-label {
    font-style: italic;
    color: #6b7280;
}

/* Categories not included in the study's reporting structure */
.not-reported-row {
    opacity: 0.5;
}
.not-reported-row .original-label {
    color: #9ca3af;
}

.modal-note {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f3f4f6;
    border-left: 3px solid var(--primary-color);
    font-size: 0.875rem;
    line-height: 1.5;
}

.modal-note-custom {
    border-left-color: #f59e0b;
    background: #fef9c3;
}

.modal-subtitle {
    color: #6b7280;
    font-size: 0.875rem;
    margin: 0.5rem 0 1rem 0;
}

/* Wider breakdown modal for new columns */
.breakdown-modal {
    max-width: 800px !important;
}

.breakdown-table th:nth-child(1),
.breakdown-table td:nth-child(1) {
    min-width: 150px;
}

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

/* Sparkline styles for time metrics - Tufte principle: small multiples */
.sparkline-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.sparkline-bar {
    display: inline-block;
    height: 16px;
    background: linear-gradient(90deg, #10b981 0%, #f59e0b 50%, #ef4444 100%);
    border-radius: 2px;
    min-width: 2px;
    max-width: 100px;
    transition: all 0.2s;
}

.sparkline-bar.fast {
    background: #10b981; /* Green for fast reporting (< 180 days) */
}

.sparkline-bar.medium {
    background: #f59e0b; /* Orange for medium (180-365 days) */
}

.sparkline-bar.slow {
    background: #ef4444; /* Red for slow (> 365 days) */
}

.sparkline-value {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    min-width: 50px;
}

/* Tooltip for raw/mapped demographic labels */
.demographic-tooltip {
    position: relative;
    cursor: help;
}

.demographic-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    border-radius: 0.25rem;
    z-index: 1000;
    margin-bottom: 0.25rem;
    pointer-events: none;
}

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

/* Publication list styling */
.pub-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 4.5rem;          /* ~3 visible lines before fade */
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    mask-image:         linear-gradient(to bottom, black 60%, transparent 100%);
    text-align: left;
}

.pub-list-link {
    display: block;
    font-size: 0.8rem;
    color: var(--primary-color);
    text-decoration: none;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.35;
}

.pub-list-link:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

.pub-list-more {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    margin-top: 0.15rem;
}

.pub-list-more:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.page-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--card-background);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    transition: all 0.15s;
    min-width: 36px;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.page-ellipsis {
    padding: 0.5rem 0.25rem;
    color: var(--text-secondary);
}

/* FAQ Section Styles */
.faq-section {
    margin-bottom: 1.5rem;
}

.faq-section h4 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.faq-mapping-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.faq-mapping-table th,
.faq-mapping-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.faq-mapping-table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.faq-mapping-table tbody tr:hover {
    background: #f9fafb;
}

.faq-mapping-table td:first-child {
    width: 25%;
    white-space: nowrap;
}

.faq-mapping-table td:last-child {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Simplified condition dropdown styling */
#condition-simplified {
    max-width: 250px;
}

/* ===== About Page Styles ===== */
.about-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.about-intro {
    margin-bottom: 3rem;
    text-align: center;
}

.about-intro p {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.about-team {
    margin-bottom: 3rem;
}

.about-team h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
}

.team-grid {
    display: flex;
    gap: 3rem;
    justify-content: center;
    flex-wrap: wrap;
}

.team-member {
    flex: 1;
    min-width: 280px;
    max-width: 400px;
    text-align: center;
}

.team-photo-placeholder {
    width: 150px;
    height: 150px;
    background-color: #d1d5db;
    border-radius: 50%;
    margin: 0 auto 1.5rem auto;
}

.team-member h4 {
    color: var(--primary-color);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.team-link {
    margin-bottom: 1rem;
}

.team-link a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.team-link a:hover {
    text-decoration: underline;
}

.team-bio {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: left;
}

.about-mission {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.about-mission p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    font-style: italic;
}

/* Team photo image styling */
.team-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1.5rem auto;
    display: block;
}

/* ===== Geography Page Styles ===== */
.geography-controls {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.geography-filter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.geography-view-toggle {
    display: flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.view-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: var(--card-background);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.view-btn:hover {
    background: #f3f4f6;
}

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

.geography-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.geography-stats .stat-card {
    background: var(--card-background);
    padding: 1.25rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.geography-stats .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

.geography-stats .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.geography-chart-wide {
    width: 100%;
}

.geography-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.geography-table th,
.geography-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.geography-table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.geography-table tbody tr:hover {
    background: #f9fafb;
}

.geography-table td:first-child {
    width: 60px;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
}

.geography-table td:nth-child(3),
.geography-table td:nth-child(4) {
    text-align: right;
}

.geography-table th:nth-child(3),
.geography-table th:nth-child(4) {
    text-align: right;
}

/* Master-Detail city rows */
.city-master-row {
    cursor: pointer;
    user-select: none;
}

.city-master-row:hover {
    background: #eef2ff;
}

.city-master-row .expand-chevron {
    display: inline-block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-left: 0.35rem;
    transition: transform 0.2s ease;
    vertical-align: middle;
}

.city-master-row.expanded .expand-chevron {
    transform: rotate(180deg);
}

.city-detail-row .detail-cell {
    padding: 0;
    background: #f8fafc;
    border-left: 3px solid var(--primary-color);
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.detail-table th {
    background: #eef2ff;
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.5rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.detail-table td {
    padding: 0.45rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.detail-table .detail-title {
    max-width: 340px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-table .text-right,
.detail-table th.text-right {
    text-align: right;
}

.detail-table .nct-link {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

#geography-list-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

#geography-sponsor {
    min-width: 300px;
    max-width: 400px;
}

/* Reporting Layer Toggle Controls */
.reporting-layer-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.layer-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.layer-toggle-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.layer-btn {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border-color);
    background: var(--card-background);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.layer-btn:hover {
    background: #f3f4f6;
    border-color: var(--primary-color);
}

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

/* US Map Container */
#us-map-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    min-height: 400px;
    overflow: hidden;
    border-radius: 8px;
    background: #f8fafc;
}

#us-map-container svg {
    width: 100%;
    height: auto;
    display: block;
}

#us-map-container svg .states-group {
    transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1);
}

#us-map-container svg path.state {
    stroke: #fff;
    stroke-width: 1;
    cursor: pointer;
    transition: fill 0.3s ease, stroke-width 0.2s ease, opacity 0.3s ease;
}

#us-map-container svg path.state:hover {
    stroke-width: 2;
    stroke: var(--primary-color);
    filter: brightness(0.95);
}

#us-map-container svg path.state.selected {
    stroke-width: 3;
    stroke: var(--primary-color);
}

#us-map-container svg path.state.dimmed {
    opacity: 0.3;
}

/* Map Controls Row */
.map-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Reset Zoom Button */
.reset-zoom-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.reset-zoom-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.reset-zoom-btn .reset-icon {
    font-size: 1rem;
}

/* Map Legend */
.map-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-gradient {
    width: 200px;
    height: 12px;
    background: linear-gradient(to right, #e8f5e9, #1b4332);
    border-radius: 2px;
    border: 1px solid var(--border-color);
}

.legend-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 40px;
}

.legend-label:first-child {
    text-align: right;
}

.legend-label:last-child {
    text-align: left;
}

/* Map Tooltip */
.map-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 1000;
    display: none;
    max-width: 250px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.map-tooltip.visible {
    display: block;
}

.map-tooltip .tooltip-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.map-tooltip .tooltip-value {
    color: #a5d6a7;
}

.map-tooltip .tooltip-hint {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-size: 0.75rem;
    color: #94a3b8;
    font-style: italic;
}

/* Regional Chart Container */
.geography-chart-narrow {
    flex: 0 0 280px;
    max-width: 320px;
}

#regional-chart-container {
    height: 180px;
    position: relative;
}

.region-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.region-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
}

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

.region-name {
    color: var(--text-secondary);
}

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

/* Adjust chart row for side-by-side layout */
#us-map-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

#us-map-row .geography-chart-wide {
    flex: 1;
    min-width: 500px;
}

/* State Detail Section */
.state-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.state-detail-header h3 {
    margin: 0;
}

.close-detail-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.close-detail-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

#state-detail-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

/* Hide layer controls for international view */
.reporting-layer-controls.hidden {
    display: none;
}

/* ===== Study Sites Display Styles ===== */
.sites-container {
    margin-top: 0.75rem;
}

.country-sites {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 6px;
}

.country-sites > strong {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.sites-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.sites-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sites-list li:last-child {
    border-bottom: none;
}

.sites-list .facility-name {
    font-weight: 500;
    flex: 1 1 100%;
}

.sites-list .location-details {
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex: 1;
}

.sites-list .more-sites {
    color: var(--text-secondary);
    font-style: italic;
    padding-top: 0.5rem;
}

/* Geo identification badges */
.badge-green {
    background: #dcfce7;
    color: #166534;
}

.badge-yellow {
    background: #fef3c7;
    color: #92400e;
}

.badge-orange {
    background: #ffedd5;
    color: #9a3412;
}

.badge-gray {
    background: #f3f4f6;
    color: #6b7280;
}

/* ===== Geography Tab Responsive Styles ===== */
@media (max-width: 900px) {
    #us-map-row {
        flex-direction: column;
    }

    #us-map-row .geography-chart-wide {
        min-width: 100%;
    }

    .geography-chart-narrow {
        flex: 1 1 100%;
        max-width: 100%;
    }

    #regional-chart-container {
        height: 150px;
    }

    .region-legend {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    #us-map-container {
        min-height: 280px;
    }

    .map-controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .map-legend {
        justify-content: center;
    }

    .reset-zoom-btn {
        align-self: center;
    }

    .geography-view-toggle {
        flex-wrap: wrap;
    }

    .reporting-layer-controls {
        flex-wrap: wrap;
    }

    .layer-toggle-group {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .layer-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
}
