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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f1923;
    color: #e0e0e0;
    min-height: 100vh;
}

header {
    background: #0f1923;
    border-bottom: 1px solid #2a4a6a;
    padding: 0.6rem 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.header-logo {
    height: 65px;
}

.header-author {
    font-family: 'Dancing Script', cursive;
    font-weight: 700;
}

header h1 {
    font-family: 'Dancing Script', cursive;
    font-weight: 700;
    font-size: 1.3rem;
    color: #f0f0f0;
    cursor: default;
}

/* Sticky filter bar */
.filter-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.6rem 2rem;
    background: rgba(18, 30, 42, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #2a4a6a;
}

.filter-bar label {
    color: #aaa;
    font-size: 0.85rem;
}

.filter-bar input[type="date"],
.filter-bar select {
    background: #1a2a3a;
    border: 1px solid #3a5a7a;
    color: #e0e0e0;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.filter-bar button {
    background: #2a6a9a;
    color: white;
    border: none;
    padding: 0.4rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.filter-bar button:hover {
    background: #3a7aaa;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Who Won The Day banner */
.won-the-day {
    background: linear-gradient(135deg, #1a2a3a 0%, #2a3a4a 100%);
    border: 1px solid #3a5a7a;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.won-the-day-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.won-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #d4a843;
    text-transform: uppercase;
    background: rgba(212, 168, 67, 0.1);
    padding: 0.3rem 0.7rem;
    border-radius: 3px;
    border: 1px solid rgba(212, 168, 67, 0.3);
}

.won-winner {
    font-size: 1.4rem;
    font-weight: 700;
}

.won-details {
    font-size: 0.85rem;
    color: #8ab4d8;
}

.status-bar {
    display: flex;
    gap: 2rem;
    justify-content: center;
    padding: 0.8rem;
    background: #1a2a3a;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: #8ab4d8;
}

.chart-section {
    background: #1a2a3a;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #2a3a4a;
}

.chart-section h2 {
    font-size: 1.2rem;
    color: #d0d0d0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #2a3a4a;
    padding-bottom: 0.5rem;
}

.chart-container {
    position: relative;
}

.chart-container.wide {
    height: 450px;
}

.chart-row {
    margin-bottom: 0.8rem;
}

.chart-row select {
    background: #0f1923;
    border: 1px solid #3a5a7a;
    color: #e0e0e0;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

/* Source legend */
.source-legend {
    margin-bottom: 0.8rem;
    padding: 0.5rem 0;
}

.source-legend-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.3rem;
}

.source-legend-extra {
    margin-top: 0.3rem;
}

.source-legend-extra .source-legend-item {
    font-size: 0.7rem;
    gap: 0.25rem;
    padding: 0.15rem 0.35rem;
}

.source-legend-extra .source-legend-dot {
    width: 8px;
    height: 8px;
}

.source-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #ccc;
}

.source-legend-clickable {
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    transition: background 0.15s;
}

.source-legend-clickable:hover {
    background: rgba(255,255,255,0.08);
}

.source-legend-active {
    background: rgba(255,255,255,0.15);
    outline: 1px solid rgba(255,255,255,0.3);
}

.source-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

.source-legend-toggle {
    display: inline-block;
    font-size: 0.8rem;
    color: #6a9abf;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    margin-top: 0.2rem;
}

.source-legend-toggle:hover {
    color: #8ab4d8;
    text-decoration: underline;
}

.table-note {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

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

thead th {
    background: #0f1923;
    color: #8ab4d8;
    padding: 0.7rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 2px solid #2a4a6a;
    user-select: none;
}

thead th[data-sort] {
    cursor: pointer;
    position: relative;
    padding-right: 1.3rem;
}

thead th[data-sort]:hover {
    color: #b0d4f0;
}

thead th[data-sort]::after {
    content: '\2195';
    position: absolute;
    right: 0.4rem;
    opacity: 0.3;
    font-size: 0.75rem;
}

thead th.sort-asc::after {
    content: '\25B2';
    opacity: 0.9;
}

thead th.sort-desc::after {
    content: '\25BC';
    opacity: 0.9;
}

tbody td {
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid #2a3a4a;
    font-size: 0.9rem;
}

tbody tr:hover {
    background: #1f3040;
}

.candidate-clickable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(138, 180, 216, 0.3);
    text-underline-offset: 2px;
}

.candidate-clickable:hover {
    color: #8ab4d8;
    text-decoration-color: #8ab4d8;
}

.party-dem {
    color: #5b9bd5;
}

.party-rep {
    color: #e06060;
}

.gap-positive {
    color: #ff9944;
    font-weight: 600;
}

.gap-negative {
    color: #66bb6a;
    font-weight: 600;
}

.gap-neutral {
    color: #888;
}

/* Word cloud section */
#wordcloud-section {
    border: 1px solid #2a4a5a;
}

.wordcloud-candidate-bar {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

.wordcloud-candidate-btn {
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid #3a5a7a;
    background: #0f1923;
    color: #8ab4d8;
    transition: all 0.15s;
}

.wordcloud-candidate-btn:hover {
    background: #1a3a5a;
}

.wordcloud-candidate-btn.active {
    background: #2a6a9a;
    color: white;
    border-color: #4a8aba;
}

.wordcloud-layout {
    display: flex;
    gap: 1.5rem;
}

.wordcloud-canvas-wrap {
    flex: 2;
    min-height: 300px;
    display: flex;
    align-items: stretch;
}

.wordcloud-canvas-wrap canvas {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: rgba(0,0,0,0.15);
}

.wordcloud-descriptors {
    flex: 1;
    min-width: 250px;
}

.wordcloud-descriptors h3 {
    font-size: 0.95rem;
    color: #8ab4d8;
    margin-bottom: 0.7rem;
    border-bottom: 1px solid #2a3a4a;
    padding-bottom: 0.4rem;
}

.descriptor-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.descriptor-item {
    font-size: 0.85rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.descriptor-count {
    color: #8ab4d8;
    font-weight: 600;
    min-width: 2.5rem;
    display: inline-block;
}

.descriptor-text {
    color: #ccc;
    font-style: italic;
}

@media (max-width: 768px) {
    .wordcloud-layout {
        flex-direction: column;
    }
}

/* Pundit section */
#pundit-section {
    border: 1px solid #4a3a2a;
    background: linear-gradient(135deg, #1a2a3a 0%, #1f2530 100%);
}

#pundit-section h2 {
    color: #d4a843;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.3rem;
    }

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

    .status-bar {
        flex-direction: column;
        gap: 0.3rem;
        text-align: center;
    }

    table {
        font-size: 0.8rem;
    }
}
