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

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1e293b;
    overflow-x: hidden;
}

/* ---- Dashboard content wrapper ---- */

.dashboard-content {
    display: flex;
    height: 100vh;
}

/* ---- Top nav ---- */

.top-nav {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9em 2em;
    background: linear-gradient(135deg, #0b285b 0%, #1a4a8a 100%);
    color: #fff;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.05rem;
}

.nav-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    margin-left: 2rem;
    margin-right: auto;
}

.nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    border-bottom-color: #3b82f6;
}

.nav-links .top-bar-badge {
    background: #334155;
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.85rem;
    border-bottom: none;
    white-space: nowrap;
}

.nav-links .top-bar-badge:hover {
    background: #475569;
    color: #fff;
}

/* Hamburger button — hidden on desktop */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: auto;
}

.nav-hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

/* ---- Footer ---- */

.site-footer {
    text-align: center;
    padding: 2em 1em;
    font-size: 0.82em;
    color: #7a8aaa;
    border-top: 1px solid #dde4f0;
    flex-shrink: 0;
    width: 100%;
}

.site-footer a {
    color: #1a4a8a;
    text-decoration: none;
}

/* ---- Chart panel ---- */

#chart-panel {
    width: 100%;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
}

.chart-header h3 {
    font-size: 0.9rem;
    color: #334155;
    margin: 0;
}

.chart-toggle {
    background: none;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    color: #64748b;
}

.chart-toggle:hover {
    background: #e2e8f0;
}

#chart-container,
#meat-chart-container {
    height: 220px;
    padding: 0 1rem 0.75rem;
    transition: height 0.25s ease;
    overflow: hidden;
}

#chart-container.collapsed,
#meat-chart-container.collapsed {
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

#meat-chart-panel {
    width: 100%;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* ---- Sidebar ---- */

#sidebar {
    width: 280px;
    min-width: 280px;
    height: auto;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-logos {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-logo {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
}

.sidebar-cfrf-logo {
    max-width: 200px;
}

#sidebar h1 {
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
    text-align: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.filter-group h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.filter-group label {
    font-size: 0.85rem;
}

.filter-group select,
.filter-group input[type="date"] {
    padding: 0.35rem 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.85rem;
}

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

#apply-filters {
    background: #2563eb;
    color: #fff;
}

#apply-filters:hover {
    background: #1d4ed8;
}

button.secondary {
    background: #e2e8f0;
    color: #334155;
}

button.secondary:hover {
    background: #cbd5e1;
}

/* ---- Summary & Legend ---- */

.summary, .legend {
    font-size: 0.85rem;
}

.legend ul {
    list-style: none;
    padding: 0;
}

.legend li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.2rem;
}

.dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.ripe        { background: #22c55e; }
.dot.developing  { background: #facc15; }
.dot.spent       { background: #ef4444; }
.dot.resting     { background: #8b5cf6; }
.dot.unknown     { background: #94a3b8; }

/* ---- Map ---- */

#map {
    flex: 1;
    min-height: 0;
}

/* Popup styling */
.scallop-popup h4 {
    margin: 0 0 0.3rem;
    font-size: 0.95rem;
}

.scallop-popup table {
    border-collapse: collapse;
    font-size: 0.8rem;
    width: 100%;
}

.scallop-popup td {
    padding: 2px 6px;
}

.scallop-popup td:first-child {
    font-weight: 600;
    white-space: nowrap;
}

.scallop-popup .disease-positive {
    color: #dc2626;
    font-weight: 600;
}

.scallop-popup .disease-negative {
    color: #16a34a;
}

/* ---- Mobile: sidebar on top ---- */

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

    .top-nav {
        order: 0;
        flex-wrap: wrap;
        position: relative;
    }

    .nav-hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        gap: 0;
        padding: 0.25rem 0 0.75rem;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        padding: 0.65rem 0.5rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        font-size: 1rem;
    }

    .nav-links a:last-child {
        border-bottom: none;
    }

    .nav-links .top-bar-badge {
        border-radius: 0;
        background: none;
        padding: 0.65rem 0.5rem;
        font-size: 1rem;
    }

    #sidebar {
        width: 100%;
        min-width: unset;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: 35vh;
        overflow-y: auto;
    }

    #map {
        flex: 1;
        min-height: 200px;
    }

    .sidebar-logos {
        flex-direction: row;
        justify-content: center;
        gap: 0.75rem;
    }

    .sidebar-logo {
        width: 50px;
        height: 50px;
    }

    .sidebar-cfrf-logo {
        max-width: 100px;
    }
}

/* ================================================================
   About page
   ================================================================ */

.page-about {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.about-main {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 3rem;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.about-hero {
    text-align: center;
    padding: 2rem 0 1.5rem;
}

.about-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.hero-logo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
}

.hero-cfrf-logo {
    max-width: 140px;
}

.about-hero h1 {
    font-size: 1.75rem;
    margin-bottom: 0.35rem;
}

.hero-subtitle {
    color: #64748b;
    font-size: 1rem;
}

.about-section {
    margin-top: 2rem;
}

.about-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid #3b82f6;
    display: inline-block;
    padding-bottom: 0.15rem;
}

.about-section p {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.section-intro {
    margin-bottom: 1rem;
}

/* Cards */

.cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.card {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 1rem;
}

.card h3 {
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.card p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

/* Leaderboard table */

.leaderboard {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.leaderboard thead {
    background: #1e293b;
    color: #fff;
}

.leaderboard th,
.leaderboard td {
    padding: 0.6rem 0.75rem;
    text-align: left;
}

.leaderboard tbody tr {
    border-bottom: 1px solid #e2e8f0;
}

.leaderboard tbody tr:nth-child(even) {
    background: #f8fafc;
}

.leaderboard .top-three {
    background: #fffbeb;
    font-weight: 600;
}

.leaderboard .rank {
    width: 3rem;
    text-align: center;
}

.leaderboard .samples {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.loading-text {
    color: #64748b;
    font-style: italic;
}

.error-text {
    color: #dc2626;
}

/* About page – tablet+ */
@media (min-width: 640px) {
    .cards {
        grid-template-columns: repeat(3, 1fr);
    }

    .about-main {
        padding: 0 2rem 3rem;
    }
}

/* About page – mobile tweaks */
@media (max-width: 639px) {
    .about-hero h1 {
        font-size: 1.35rem;
    }

    .hero-logo {
        width: 56px;
        height: 56px;
    }

    .hero-cfrf-logo {
        max-width: 100px;
    }

    .leaderboard th,
    .leaderboard td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
}
