:root {
    /* Ohio Flag Palette */
    --ohio-red: #BF0A30;
    --ohio-blue: #002868;
    --ohio-white: #FFFFFF;

    --bg-color: #F5F7FA;
    /* Very light cool gray */
    --card-bg: #FFFFFF;
    --text-primary: #002868;
    /* Deep Navy for text */
    --text-secondary: #475569;
    --accent-color: #BF0A30;
    /* Red accent */
    --border-color: #E2E8F0;
    --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--ohio-red);
    /* Distinct separator */
}

header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--ohio-blue);
    background: none;
    -webkit-text-fill-color: initial;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 40, 104, 0.1);
    /* Blue-tinted shadow */
}

/* Combined Stats Styling */
.combined-stats {
    display: flex;
    align-items: center;
    justify-content: space-around;
    text-align: center;
}

.stat-divider {
    width: 2px;
    height: 60px;
    background-color: var(--border-color);
    margin: 0 1rem;
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
}

.content-section {
    background-color: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-input {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    width: 300px;
    font-size: 1rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--ohio-blue);
    box-shadow: 0 0 0 3px rgba(0, 40, 104, 0.1);
}

.cities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.city-card {
    background-color: var(--card-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.city-card:hover {
    transform: translateY(-2px);
    border-color: var(--ohio-red);
    box-shadow: 0 4px 6px -1px rgba(191, 10, 48, 0.1);
}

.city-count {
    background-color: #F1F5F9;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* Table Styles - Optimized for Mobile */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    /* Prevent wrapping in cells by default to keep structure */
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--ohio-blue);
    background-color: #F8FAFC;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #F8FAFC;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-btn {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    cursor: pointer;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 1rem;
}

.back-link:hover {
    color: var(--accent-color);
}

/* Filter Buttons */
.filter-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.75rem 2rem;
    border-radius: 2rem;
    border: 2px solid var(--border-color);
    /* Thicker border */
    background-color: #F1F5F9;
    /* Slate-100 to stand out from white bg */
    color: var(--text-primary);
    font-weight: 700;
    /* Bolder text */
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    min-width: 120px;
    /* Ensure uniform width */
}

.filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 40, 104, 0.1);
}

.filter-btn.active {
    color: #FFFFFF;
    border-color: transparent;
}

.filter-btn[data-party="R"].active {
    background-color: var(--ohio-red);
}

.filter-btn[data-party="D"].active {
    background-color: var(--ohio-blue);
}

.filter-btn[data-party="Unadhered"].active {
    background-color: var(--text-secondary);
}

#btn-reset.active {
    background-color: #0f172a;
    /* Dark Navy/Black for All */
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-input {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .content-section {
        padding: 1rem;
    }
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgba(0, 40, 104, 0.1);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-card h1 {
    font-size: 1.5rem;
    color: var(--ohio-blue);
    margin-bottom: 1rem;
}

.login-card input {
    width: 100%;
    padding: 0.75rem;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.login-card button {
    background-color: var(--ohio-blue);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s;
}

.login-card button:hover {
    background-color: #001f4d;
    /* Darker navy */
}

.error-msg {
    color: var(--ohio-red);
    margin-top: 1rem;
    font-size: 0.875rem;
    min-height: 1.25em;
    /* Prevent layout jump */
}