/* Columba Harta - Main Styles */

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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --accent-color: #2563eb;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --header-height: 60px;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
}

[data-theme="dark"] .header {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .contest-select {
    background: #334155;
    color: #f1f5f9;
    border-color: #475569;
}

[data-theme="dark"] .stats span {
    background: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .arrivals-counter {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

[data-theme="dark"] .info-panel {
    background: #1e293b;
}

[data-theme="dark"] .leaflet-container {
    background: #0f172a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.header-left .subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 400px;
}

.contest-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--card-bg);
    cursor: pointer;
}

.contest-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Sub-groups inside header-right so the action-button row can wrap as a
 * single block below the counters on narrow screens, instead of buttons
 * individually reflowing around the counters. */
.header-counters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.online-counter {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(34, 197, 94, 0.2);
    border-radius: 4px;
}
.online-icon  { color: #22c55e; }
.online-count { font-weight: bold; color: #22c55e; }
.online-label { font-size: 0.7rem; color: #64748b; }

.arrivals-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    padding: 6px 14px;
    border-radius: 25px;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.arrivals-icon {
    font-size: 1.1rem;
}

.arrivals-count {
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
}

.stats {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
}

.stats span {
    padding: 4px 10px;
    background: var(--bg-color);
    border-radius: 20px;
    color: var(--text-muted);
}

.last-update {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-refresh {
    background: var(--primary-color);
    color: white;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.btn-refresh:hover {
    background: var(--primary-dark);
}

.btn-refresh.loading {
    animation: spin 1s linear infinite;
}

.btn-refresh:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-notify {
    background: var(--accent-color);
    color: white;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border-radius: 50%;
    margin-left: 12px;
}

.btn-notify:hover {
    background: var(--warning-color);
    transform: scale(1.1);
}

.btn-notify:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Map — top is derived from the live-measured header height so a wrapping
 * header on tablet/mobile widths doesn't hide the top of the map. JS sets
 * --header-height-mobile; we fall back to --header-height on desktop. */
#map {
    position: absolute;
    top: var(--header-height-mobile, var(--header-height));
    left: 0;
    right: 0;
    bottom: 0;
}

/* Info Panel */
.info-panel {
    position: fixed;
    top: calc(var(--header-height) + 10px);
    left: 10px;
    width: 280px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow: hidden;
}

.info-panel.hidden {
    display: none;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
}

.info-header h3 {
    font-size: 1rem;
    font-weight: 500;
}

.btn-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.info-body {
    padding: 16px;
}

.info-body p {
    margin-bottom: 8px;
    font-size: 0.875rem;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.waiting {
    background: var(--warning-color);
    color: white;
}

.status-badge.active {
    background: var(--success-color);
    color: white;
}

.status-badge.finished {
    background: var(--secondary-color);
    color: white;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay p {
    margin-top: 16px;
    color: var(--text-muted);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
}

.toast {
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 10px;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Marker Popups */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 12px 16px;
    font-size: 0.875rem;
    min-width: 350px;
}

.popup-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--primary-color);
}

.popup-location {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 12px;
}

.popup-pigeons {
    max-height: 200px;
    overflow-y: auto;
}

.popup-pigeon {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}

.popup-pigeon:last-child {
    border-bottom: none;
}

.popup-pigeon .rank {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 40px;
}

.popup-pigeon .ring {
    flex: 1;
    font-family: monospace;
    font-size: 0.85rem;
}

.popup-pigeon .time {
    color: var(--text-muted);
    font-size: 0.8rem;
    min-width: 70px;
    text-align: right;
}

.popup-pigeon .speed {
    font-size: 0.75rem;
    color: var(--success-color);
}

/* Clickable pigeons in popup */
.popup-pigeon.clickable {
    cursor: pointer;
    border-radius: 4px;
    padding: 6px 4px;
    margin: 0 -4px;
    transition: background 0.15s, transform 0.1s;
}

.popup-pigeon.clickable:hover {
    background: var(--primary-color);
    color: white;
    transform: translateX(3px);
}

.popup-pigeon.clickable:hover .rank,
.popup-pigeon.clickable:hover .time {
    color: white;
}

.popup-hint {
    text-align: center;
    font-size: 0.7rem;
    color: #94a3b8;
    padding: 8px 0 4px;
    border-top: 1px dashed var(--border-color);
    margin-top: 8px;
}

/* Release Point Marker */
.release-marker {
    background: var(--danger-color);
    border: 3px solid white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Custom Markers */
.custom-marker {
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    line-height: 1.1;
}

.custom-marker .rank {
    font-size: 0.85rem;
}

.custom-marker .count {
    font-size: 0.6rem;
    opacity: 0.9;
}

.custom-marker.rank-top3 {
    background: #fbbf24;
    border-color: #f59e0b;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
}

.custom-marker.rank-top10 {
    background: #f59e0b;
}

.custom-marker.rank-top50 {
    background: #22c55e;
}

.custom-marker.rank-top100 {
    background: #3b82f6;
}

.custom-marker.rank-default {
    background: #64748b;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 10px;
        gap: 6px;
    }
    
    .header-left {
        gap: 6px;
    }
    
    .header-left h1 {
        font-size: 1rem;
    }
    
    .header-left .subtitle {
        display: none;
    }
    
    .header-center {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin-top: 4px;
    }
    
    .header-right {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
        /* On mobile, stretch to the full header width so the two
         * sub-groups (counters + actions) can stack cleanly on two rows. */
        flex-basis: 100%;
    }
    .header-counters {
        gap: 6px;
        flex: 1 1 auto;
        justify-content: flex-start;
    }
    /* Force the action-button group onto its own row below the counters
     * — this is the "second row" of buttons the user asked for. */
    .header-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
        gap: 6px;
    }

    .arrivals-counter {
        padding: 4px 10px;
        font-size: 0.85rem;
    }
    
    .stats {
        display: none;
    }
    
    .last-update {
        display: none;
    }
    
    .btn-refresh, .btn-theme {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .btn-notify {
        width: 30px;
        height: 30px;
        font-size: 1rem;
        margin-left: 4px;
    }
    
    .btn-stats, .btn-weather, .btn-history {
        padding: 5px;
        font-size: 0.9rem;
    }

    /* #map top is handled globally via --header-height-mobile (set by JS) */

    .info-panel {
        display: none;
    }
}

/* CMD-style Leaderboard Panel */
.cmd-panel {
    position: fixed;
    bottom: 0;
    left: 10px;
    right: 10px;
    max-width: 1100px;
    background: #0c0c0c;
    border: 1px solid #333;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-family: 'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
}

.cmd-panel.collapsed {
    transform: translateY(calc(100% - 40px));
}

.cmd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(180deg, #2d2d2d 0%, #1a1a1a 100%);
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    user-select: none;
}

.cmd-title {
    color: #f0f0f0;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.cmd-toggle {
    color: #888;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.cmd-panel.collapsed .cmd-toggle {
    transform: rotate(180deg);
}

.cmd-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    font-size: 0.75rem;
}

.cmd-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.cmd-filter-select {
    background: #2d2d2d;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    min-width: 150px;
    cursor: pointer;
}

.cmd-filter-select:focus {
    outline: none;
    border-color: #3b82f6;
}

.cmd-filter-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.cmd-filter-btn:hover {
    background: #2563eb;
}

.cmd-filter-btn:active {
    background: #1d4ed8;
}

.cmd-info {
    display: flex;
    gap: 16px;
    align-items: center;
}

.cmd-status {
    color: #22c55e;
}

.cmd-status::before {
    content: '● ';
}

.cmd-count {
    color: #64748b;
}

.cmd-scope {
    color: #94a3b8;
    font-size: 0.78rem;
}

.cmd-body {
    max-height: 500px;
    overflow: hidden;
}

.cmd-content {
    max-height: 420px;
    overflow-y: auto;
    padding: 8px 0;
}

.cmd-content::-webkit-scrollbar {
    width: 8px;
}

.cmd-content::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.cmd-content::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.cmd-output {
    margin: 0;
    padding: 0 12px;
    color: #c0c0c0;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.cmd-row {
    display: flex;
    flex-wrap: wrap;
    padding: 6px 12px;
    border-bottom: 1px solid #1a1a1a;
    transition: background 0.15s;
    align-items: center;
    min-height: 32px;
}

.cmd-row:hover {
    background: #1a1a1a;
}

.cmd-row.top1 { background: linear-gradient(90deg, rgba(255,215,0,0.15) 0%, transparent 50%); }
.cmd-row.top2 { background: linear-gradient(90deg, rgba(192,192,192,0.12) 0%, transparent 50%); }
.cmd-row.top3 { background: linear-gradient(90deg, rgba(205,127,50,0.12) 0%, transparent 50%); }

/* Nominated pigeon (eMarker=*) highlighted */
.cmd-row.nominated-pigeon { background: linear-gradient(90deg, rgba(99,102,241,0.13) 0%, transparent 60%); }
.cmd-row.nominated-pigeon .cmd-breeder { color: #a5b4fc; }

/* Pigeons past 20% cutoff - no pen points, muted */
.cmd-row.past-cutoff { opacity: 0.5; border-left: 2px solid #ef4444; }

/* Recently arrived (within last 15 minutes) - highlight with a pulsing
 * orange/amber left border and a warm background tint so fresh landings
 * are unmissable during a live race. Stacks with top1/followed/nominated.
 */
.cmd-row.recent-arrival {
    background: linear-gradient(90deg, rgba(251,146,60,0.22) 0%, rgba(251,146,60,0.05) 55%, transparent 100%);
    border-left: 3px solid #fb923c;
    animation: recentArrivalPulse 2.4s ease-in-out infinite;
}
.cmd-row.recent-arrival .cmd-breeder { color: #fdba74; font-weight: 600; }
.cmd-row.recent-arrival .cmd-time    { color: #fed7aa; font-weight: 600; }
.cmd-row.recent-arrival .cmd-speed   { color: #fdba74; }

/* When a recent arrival is also followed, lean into the amber tint so the
 * "new and mine" combination still reads as fresh (the star prefix already
 * signals the follow). Otherwise the solid gold followed background would
 * win and the user would lose the "just arrived" signal. */
.cmd-row.recent-arrival.followed {
    background: linear-gradient(90deg, rgba(251,146,60,0.30) 0%, rgba(250,204,21,0.15) 50%, transparent 100%);
}

@keyframes recentArrivalPulse {
    0%, 100% { box-shadow: inset 3px 0 0 0 #fb923c; }
    50%      { box-shadow: inset 3px 0 0 0 #fed7aa, 0 0 8px rgba(251,146,60,0.25); }
}

/* Breeder classment — breeders with <2 nominated arrived */
.cmd-row.breeder-no-pts { color: #ef4444; opacity: 0.7; }
.cmd-row.breeder-no-pts .cmd-breeder { color: #fca5a5; }

/* Pen points column */
.cmd-pen {
    width: 55px;
    text-align: right;
    color: #f59e0b;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Breeder classment columns */
.cmd-county-place, .cmd-club-place {
    width: 40px;
    color: #94a3b8;
    font-size: 0.72rem;
}
.cmd-basketed { width: 45px; color: #64748b; font-size: 0.72rem; }
.cmd-arrived  { width: 32px; color: #22c55e; font-size: 0.72rem; }
/* Pigeons inside the 20% cutoff for the current scope */
.cmd-incutoff { width: 58px; color: #f59e0b; font-size: 0.72rem; font-weight: 600; }
.cmd-series   { flex: 1; color: #64748b; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Active breeder view button */
#breederViewBtn.active { background: #6366f1; color: #fff; }

.cmd-rank {
    width: 45px;
    color: #22c55e;
    font-weight: bold;
}

/* When a scope filter (county/center/club) is active, the rank cell
 * shows the scope-relative position as the primary number, with the
 * global contest rank annotated next to it in muted text so the user
 * can cross-reference. Reduce the cmd-rank width when this annotation
 * appears so the layout doesn't shift columns. */
.cmd-rank-global {
    color: #6b7280;
    font-size: 0.72rem;
    margin-left: 4px;
    font-weight: normal;
    font-style: italic;
}

/* Past-cutoff pigeons display an em dash in the points column to make
 * the unranked status visually obvious — they earn no points so the
 * column would otherwise be empty and the row could look like data is
 * missing. */
.cmd-pen-unranked {
    color: #ef4444;
    font-style: italic;
    opacity: 0.7;
}

.cmd-row.top1 .cmd-rank { color: #ffd700; }
.cmd-row.top2 .cmd-rank { color: #c0c0c0; }
.cmd-row.top3 .cmd-rank { color: #cd7f32; }

.cmd-club-rank {
    width: 35px;
    color: #f59e0b;
    font-size: 0.75rem;
    opacity: 0.8;
}

.cmd-breeder {
    flex: 1;
    color: #f0f0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.cmd-city {
    width: 150px;
    color: #64748b;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-club {
    width: 140px;
    color: #94a3b8;
    font-size: 0.75rem;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Breeder code column (e.g. SV1086) — shown on both pigeon and breeder
 * classments so visitors can copy/paste the ID without opening details. */
.cmd-code {
    width: 70px;
    color: #94a3b8;
    font-size: 0.72rem;
    font-family: monospace;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-ring {
    width: 120px;
    color: #3b82f6;
    font-size: 0.8rem;
}

.cmd-time {
    width: 70px;
    color: #22c55e;
    text-align: right;
    font-size: 0.8rem;
}

.cmd-speed {
    width: 85px;
    color: #f59e0b;
    text-align: right;
    font-size: 0.8rem;
}

/* Mobile adjustments */
/* ── Mobile filter toggle ─────────────────────────────────────────────
 *
 * On desktop (≥768px) the toggle button is hidden and the filter wrap
 * is always visible — same as before this change. On mobile (<768px),
 * filters start collapsed and the user taps "🔍 Filtre" to expand.
 *
 * Why: on a phone the leaderboard panel fits ~5–6 pigeon rows above
 * the keyboard fold. The full filter row (search + 4 dropdowns + sort)
 * easily eats 4 of those rows. Hiding it by default keeps the focus on
 * the actual ranking, which is what users open the panel to see.
 *
 * Implementation: cmd-filters-wrap is the host wrapper; max-height: 0
 * with overflow:hidden collapses it without removing from accessibility
 * tree (so screen readers can still announce filters when expanded
 * via aria-expanded). Tap on .cmd-filters-toggle flips a `.expanded`
 * class on the wrap, which animates max-height open. The CSS rotates
 * the arrow and changes its character via attribute selector.
 */
.cmd-filters-toggle {
    display: none; /* desktop default — hidden, filters always shown */
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(34, 197, 94, 0.12);
    color: #d4d4d8;
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 6px;
    -webkit-tap-highlight-color: transparent;
}
.cmd-filters-toggle:active {
    background: rgba(34, 197, 94, 0.2);
}
.cmd-filters-toggle-arrow {
    transition: transform 0.2s ease;
    font-size: 0.7rem;
    color: #22c55e;
}
.cmd-filters-toggle[aria-expanded="true"] .cmd-filters-toggle-arrow {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .cmd-filters-toggle {
        display: flex; /* show the toggle on mobile */
    }
    .cmd-filters-wrap {
        /* Collapsed by default. The .expanded class (toggled by JS on
         * cmd-filters-toggle tap) flips this open. transition on
         * max-height gives a smooth slide; we use a generous max-height
         * upper bound (600px) since the actual content varies but
         * fits well under that on phones. */
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.25s ease-out;
    }
    .cmd-filters-wrap.expanded {
        max-height: 600px;
    }
}

@media (max-width: 768px) {
    .cmd-panel {
        left: 5px;
        right: 5px;
    }
    
    .cmd-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cmd-filters {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .cmd-filter-select {
        min-width: 120px;
        flex: 1;
    }
    
    .cmd-info {
        justify-content: space-between;
        margin-top: 4px;
        padding-top: 6px;
        border-top: 1px solid #333;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    /* City + club on mobile: keep both visible but shrink them and allow
     * them to wrap under the breeder name instead of being hidden. Shown as
     * a single sub-line "📍 city · 🏛️ club" so the row stays compact.
     * Prefix emojis are scoped to the flex-based pigeon rows only — the
     * grid-based breeder rows below already place labels via grid areas. */
    .cmd-row:not(.cmd-breeder-row) .cmd-city,
    .cmd-row:not(.cmd-breeder-row) .cmd-club {
        display: inline-block;
        width: auto;
        max-width: 100%;
        font-size: 0.72rem;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .cmd-row:not(.cmd-breeder-row) .cmd-city::before { content: '📍 '; opacity: 0.7; }
    .cmd-row:not(.cmd-breeder-row) .cmd-club::before { content: '· 🏛️ '; opacity: 0.7; margin-left: 2px; }
    .cmd-row:not(.cmd-breeder-row) .cmd-city:empty,
    .cmd-row:not(.cmd-breeder-row) .cmd-club:empty { display: none; }

    /* Breeder code on mobile pigeon rows: show compactly after the name
     * (flex will put it on the sub-line alongside city/club). */
    .cmd-row:not(.cmd-breeder-row) .cmd-code {
        display: inline-block;
        width: auto;
        font-size: 0.7rem;
        margin-left: 4px;
    }
    .cmd-row:not(.cmd-breeder-row) .cmd-code::before { content: '🔢 '; opacity: 0.7; }
    .cmd-row:not(.cmd-breeder-row) .cmd-code:empty { display: none; }

    /* Breeder-classment rows on mobile — aligned grid so rows don't wrap
     * into a jumbled mess.
     *
     *   col:          A        B        C        D       E
     *   row 1:  #rank | breeder name ..........            code
     *   row 2:   .    | 🏛️ club · 📍 locality (spans B→E)
     *   row 3:   .    | 🗃️ bsk | ↩ arr | 🎯 cut | pen
     *   row 4:   .    | top-2 series (spans B→E)
     */
    .cmd-breeder-row {
        display: grid;
        grid-template-columns: 52px repeat(3, auto) 1fr auto;
        grid-template-areas:
            "rank name     name    name   name   code"
            "rank loc      loc     loc    loc    loc"
            "rank basketed arrived incut  pen    ."
            "rank series   series  series series series";
        column-gap: 8px;
        row-gap: 2px;
        padding: 8px 10px;
        align-items: start;
    }
    .cmd-breeder-row .cmd-rank {
        grid-area: rank;
        width: auto;
        align-self: center;
        font-size: 1rem;
    }
    .cmd-breeder-row .cmd-breeder {
        grid-area: name;
        width: auto;
        max-width: none;
        white-space: normal;
        overflow: visible;
        font-size: 0.9rem;
        line-height: 1.2;
    }
    .cmd-breeder-row .cmd-code {
        grid-area: code;
        width: auto;
        align-self: center;
        justify-self: end;
    }
    /* Club + locality live inside a single `.cmd-loc` wrapper so they
     * actually flow side-by-side in one cell instead of stacking on top
     * of each other (the old bug where "Phoenix Bucovina" overlapped the
     * locality name). */
    .cmd-breeder-row .cmd-loc {
        grid-area: loc;
        display: block;
        font-size: 0.72rem;
        line-height: 1.3;
        color: #94a3b8;
    }
    .cmd-breeder-row .cmd-loc .cmd-club,
    .cmd-breeder-row .cmd-loc .cmd-city {
        display: inline;
        width: auto;
        font-size: 0.72rem;
        white-space: normal;
    }
    .cmd-breeder-row .cmd-loc .cmd-club::before { content: '🏛️ '; opacity: 0.7; }
    .cmd-breeder-row .cmd-loc .cmd-city::before { content: ' · 📍 '; opacity: 0.7; }
    .cmd-breeder-row .cmd-loc .cmd-club:empty,
    .cmd-breeder-row .cmd-loc .cmd-city:empty   { display: none; }

    /* Numeric mini-columns each get their own grid cell so they line up
     * vertically between rows. */
    .cmd-breeder-row .cmd-basketed { grid-area: basketed; width: auto; font-size: 0.72rem; }
    .cmd-breeder-row .cmd-arrived  { grid-area: arrived;  width: auto; font-size: 0.72rem; }
    .cmd-breeder-row .cmd-incutoff { grid-area: incut;    width: auto; font-size: 0.72rem; }
    .cmd-breeder-row .cmd-pen      { grid-area: pen;      width: auto; font-size: 0.72rem; text-align: left; }

    .cmd-breeder-row .cmd-series {
        grid-area: series;
        display: block;
        width: auto;
        flex: initial;
        white-space: normal;
        word-break: break-all;
        font-size: 0.72rem;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .cmd-speed {
        display: block;
        width: auto;
        font-size: 0.75rem;
        color: #f59e0b;
        margin-left: 8px;
    }
    
    .cmd-distance {
        display: block;
        width: auto;
        font-size: 0.75rem;
        color: #8b5cf6;
    }
    
    .cmd-row {
        flex-wrap: wrap;
        padding: 8px 10px;
        min-height: auto;
        gap: 4px;
    }
    
    .cmd-breeder {
        max-width: none;
        width: calc(100% - 90px);
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .cmd-rank {
        width: 50px;
    }
    
    .cmd-club-rank {
        width: 35px;
    }
    
    .cmd-ring {
        width: 100%;
        margin-top: 2px;
        font-size: 0.75rem;
    }
    
    .cmd-time {
        width: auto;
        margin-left: auto;
    }
    
    .cmd-actions {
        justify-content: center;
        margin-top: 4px;
    }
    
    .cmd-search {
        width: 100%;
    }
}

/* Search input */
.cmd-search {
    background: #2d2d2d;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    min-width: 150px;
}

.cmd-search:focus {
    outline: none;
    border-color: #3b82f6;
}

.cmd-search::placeholder {
    color: #666;
}

/* Sort dropdown */
.cmd-sort {
    min-width: 120px;
}

/* Action buttons */
.cmd-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cmd-action-btn {
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.cmd-action-btn:hover {
    background: #3d3d3d;
    border-color: #555;
}

.cmd-action-btn:active {
    transform: scale(0.95);
}

/* Distance column */
.cmd-distance {
    width: 70px;
    color: #8b5cf6;
    text-align: right;
    font-size: 0.8rem;
}

/* Offline indicator */
.cmd-offline {
    color: #ef4444;
    font-size: 0.75rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Row highlight */
.cmd-row.highlighted {
    background: rgba(59, 130, 246, 0.3) !important;
    box-shadow: inset 0 0 0 2px #3b82f6;
}

/* Followed breeder */
.cmd-row.followed {
    border-left: 3px solid #f59e0b;
}

/* Marker animations */
.marker-pulse {
    animation: markerPulse 0.5s ease-out 3;
}

@keyframes markerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Highlighted marker (when clicked from leaderboard) */
.marker-highlighted {
    box-shadow: 0 0 0 4px #3b82f6, 0 0 20px 8px rgba(59, 130, 246, 0.5) !important;
    z-index: 1000 !important;
}

/* Followed marker */
.marker-followed {
    box-shadow: 0 0 10px 3px rgba(245, 158, 11, 0.5) !important;
}

.marker-followed .follow-star {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 12px;
}

/* Follow Dialog */
.follow-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.follow-dialog-content {
    background: #1e293b;
    border-radius: 12px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
}

.follow-dialog-content h3 {
    color: #f0f0f0;
    margin-bottom: 8px;
}

.follow-dialog-content p {
    color: #94a3b8;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.follow-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.follow-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.follow-item:hover {
    background: #475569;
}

.follow-item.followed {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid #f59e0b;
}

.follow-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #f59e0b;
}

.follow-item span.follow-name {
    color: #f0f0f0;
    flex: 1;
}

.follow-code {
    color: #64748b !important;
    font-size: 0.75rem;
}

.follow-count {
    background: #1e293b;
    color: #e5e7eb;
    border: 1px solid #475569;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    min-width: 72px;
}

.follow-count:focus {
    outline: none;
    border-color: #f59e0b;
}

.follow-close {
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.follow-close:hover {
    background: #2563eb;
}

/* Theme button */
.btn-theme {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .btn-theme {
    background: #334155;
    border-color: #475569;
}

/* Notification Settings Dialog */
.notification-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.notification-dialog-content {
    background: #1e293b;
    border-radius: 12px;
    padding: 24px;
    max-width: 450px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
}

.notification-dialog-content h3 {
    color: #f0f0f0;
    margin-bottom: 20px;
    font-size: 1.25rem;
}

.notify-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #334155;
}

.notify-section:last-of-type {
    border-bottom: none;
    margin-bottom: 16px;
}

.notify-section h4 {
    color: #f0f0f0;
    font-size: 1rem;
    margin-bottom: 6px;
}

.notify-desc {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.notify-status {
    margin-top: 10px;
}

.status-enabled {
    color: #22c55e;
    font-weight: 600;
}

.status-denied {
    color: #ef4444;
    font-weight: 600;
}

.notify-subscribe-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.notify-subscribe-btn:hover {
    background: #2563eb;
}

.notify-subscribe-btn:disabled {
    background: #64748b;
    cursor: not-allowed;
}

.breeder-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.breeder-filter-select {
    flex: 1;
    background: #334155;
    color: #f0f0f0;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.8rem;
    cursor: pointer;
}

.breeder-filter-select:focus {
    outline: none;
    border-color: #3b82f6;
}

.breeder-filter-select option {
    background: #1e293b;
    color: #f0f0f0;
}

.breeder-search {
    width: 100%;
    background: #334155;
    color: #f0f0f0;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.875rem;
    margin-bottom: 12px;
}

.breeder-search:focus {
    outline: none;
    border-color: #3b82f6;
}

.breeder-search::placeholder {
    color: #64748b;
}

.breeder-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 45vh;
    overflow-y: auto;
}

.breeder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.breeder-item:hover {
    background: #475569;
}

.breeder-item.followed {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid #f59e0b;
}

.breeder-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #f59e0b;
    flex-shrink: 0;
}

.breeder-name {
    color: #f0f0f0;
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breeder-code {
    color: #3b82f6;
    font-size: 0.75rem;
    font-weight: 600;
}

.breeder-city {
    color: #64748b;
    font-size: 0.7rem;
    white-space: nowrap;
}

/* Pigeon count input in follow dialog */
.pigeon-count-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.pigeon-count-wrapper.hidden {
    display: none;
}

.pigeon-count-label {
    font-size: 0.65rem;
    color: #94a3b8;
    white-space: nowrap;
}

.pigeon-count-input {
    width: 44px;
    background: #1e293b;
    color: #f59e0b;
    border: 1px solid #475569;
    border-radius: 4px;
    padding: 3px 4px;
    font-size: 0.8rem;
    text-align: center;
    font-weight: 600;
}

.pigeon-count-input:focus {
    outline: none;
    border-color: #f59e0b;
}

.breeder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    flex-wrap: wrap;
}

.more-hint, .no-results {
    color: #64748b;
    font-size: 0.75rem;
    text-align: center;
    padding: 10px;
}

.notify-close-btn {
    width: 100%;
    padding: 12px;
    background: #475569;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.notify-close-btn:hover {
    background: #64748b;
}

/* ===== Pigeon Detail Panel (Sandwich) ===== */
.pigeon-detail-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 3000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.pigeon-detail-panel .detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e3a5f 0%, #0a192f 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.pigeon-detail-panel .detail-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pigeon-detail-panel .detail-rank {
    background: #3b82f6;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1rem;
}

.pigeon-detail-panel .detail-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.pigeon-detail-panel .detail-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.pigeon-detail-panel .detail-close:hover {
    background: rgba(255,255,255,0.3);
}

.pigeon-detail-panel .detail-body {
    background: var(--card-bg);
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
    width: 100%;
    max-width: 650px;
    border-radius: 16px 16px 0 0;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.pigeon-detail-panel .detail-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.pigeon-detail-panel .detail-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pigeon-detail-panel .detail-row .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pigeon-detail-panel .detail-row .value {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

.pigeon-detail-panel .detail-section-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.pigeon-detail-panel .detail-pigeons-list {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.pigeon-detail-panel .detail-pigeon {
    display: flex;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: background 0.15s;
}

.pigeon-detail-panel .detail-pigeon:hover {
    background: var(--hover-bg);
}

.pigeon-detail-panel .detail-pigeon.selected {
    background: rgba(59, 130, 246, 0.2);
    border-left: 3px solid #3b82f6;
}

.pigeon-detail-panel .dp-rank {
    font-weight: 700;
    color: var(--primary-color);
    min-width: 35px;
}

.pigeon-detail-panel .dp-ring {
    flex: 1;
    font-family: monospace;
}

.pigeon-detail-panel .dp-time {
    color: var(--text-muted);
    min-width: 60px;
}

.pigeon-detail-panel .dp-speed {
    color: var(--success-color);
    min-width: 65px;
    text-align: right;
}

.pigeon-detail-panel .detail-actions {
    display: flex;
    gap: 10px;
}

.pigeon-detail-panel .detail-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

.pigeon-detail-panel .detail-actions button:active {
    transform: scale(0.98);
}

.pigeon-detail-panel .btn-zoom {
    background: #3b82f6;
    color: white;
}

.pigeon-detail-panel .btn-zoom:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.pigeon-detail-panel .btn-follow {
    background: #f59e0b;
    color: white;
}

.pigeon-detail-panel .btn-follow:hover {
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Mobile adjustments for detail panel */
@media (max-width: 768px) {
    .pigeon-detail-panel .detail-body {
        max-height: 85vh;
        width: 100vw;
        max-width: 100vw;
        border-radius: 16px 16px 0 0;
        margin: 0;
        padding: 16px;
    }
    
    .pigeon-detail-panel .detail-info {
        grid-template-columns: 1fr;
    }
}

/* ===== Notification History Panel ===== */
.history-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 360px;
    max-height: calc(100vh - 100px);
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    overflow: hidden;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.history-panel.hidden {
    display: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #1e3a5f 0%, #0a192f 100%);
    color: white;
}

.history-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.history-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 15px;
}

.history-item {
    background: var(--hover-bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 3px solid var(--primary-color);
}

.history-item .history-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.history-item .history-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 3px;
}

.history-item .history-body {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    padding: 0;
    max-height: none;
}

.history-item .history-stats {
    font-size: 0.7rem;
    display: flex;
    gap: 15px;
}

.history-item .history-stats .sent {
    color: var(--success-color);
}

.history-item .history-stats .failed {
    color: var(--danger-color);
}

.no-history, .error, .loading-text, .no-weather {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Weather Panel ===== */
.weather-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 400px;
    max-height: calc(100vh - 100px);
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    overflow: hidden;
    animation: slideInRight 0.3s ease;
}

.weather-panel.hidden {
    display: none;
}

.weather-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
}

.weather-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.weather-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 15px;
}

.weather-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.weather-status .status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-scheduled { background: #3b82f6; color: white; }
.status-active { background: #10b981; color: white; }
.status-completed { background: #64748b; color: white; }
.status-cancelled { background: #ef4444; color: white; }

.weather-status .recording-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.weather-locations {
    display: grid;
    gap: 12px;
    margin-bottom: 15px;
}

.weather-location-card {
    background: var(--hover-bg);
    border-radius: 10px;
    padding: 15px;
}

.weather-location-card .location-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.weather-location-card .location-icon {
    font-size: 1.2rem;
}

.weather-location-card .location-name {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
}

.weather-location-card .weather-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--hover-bg);
    padding: 3px 8px;
    border-radius: 12px;
}

.weather-location-card .weather-main {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 5px;
}

.weather-location-card .weather-icon {
    font-size: 2.5rem;
}

.weather-location-card .weather-temp {
    font-size: 2rem;
    font-weight: 700;
}

.weather-location-card .weather-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.weather-location-card .weather-details-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.weather-location-card .weather-temp-block {
    display: flex;
    flex-direction: column;
}

.weather-location-card .weather-feels {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Collapsible "sandwich" weather card ---------------------------- */
.weather-location-card .wx-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: 0;
    color: inherit;
    text-align: left;
    padding: 2px 0;
    margin-bottom: 10px;
    cursor: pointer;
    font: inherit;
}
.weather-location-card .wx-toggle:hover .location-name {
    color: var(--brand-500, #3b82f6);
}
.weather-location-card .wx-headline {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55%;
}
.weather-location-card .wx-chevron {
    font-size: 0.9rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s ease;
    transform: rotate(0deg);
}
.weather-location-card.collapsed .wx-chevron {
    transform: rotate(-90deg);
}
.weather-location-card .wx-collapse-body {
    display: block;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    max-height: 5000px;
    opacity: 1;
}
.weather-location-card.collapsed .wx-collapse-body {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}
.weather-location-card.collapsed {
    padding-bottom: 8px;
}
.weather-location-card.collapsed .wx-toggle {
    margin-bottom: 0;
}

/* Date chip next to each hour in the race-window breakdown. */
.rw-hour-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.12);
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
}

.weather-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.weather-detail-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: var(--hover-bg);
    padding: 8px;
    border-radius: 6px;
}

.weather-detail-item .detail-icon {
    font-size: 0.9rem;
}

.weather-detail-item .detail-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.weather-detail-item .detail-value {
    font-size: 0.85rem;
    font-weight: 600;
}

.hourly-forecast {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.hourly-forecast .hourly-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.hourly-forecast .hourly-items {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 5px;
}

.hourly-forecast .hourly-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--hover-bg);
    padding: 6px 10px;
    border-radius: 8px;
    min-width: 50px;
}

.hourly-forecast .hourly-item .hour {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.hourly-forecast .hourly-item .h-icon {
    font-size: 1.2rem;
    margin: 3px 0;
}

.hourly-forecast .hourly-item .h-temp {
    font-size: 0.8rem;
    font-weight: 600;
}

.hourly-forecast .hourly-item .h-rain {
    font-size: 0.65rem;
    color: #3b82f6;
}

/* ---- Race Window: per-hour detailed cards ---------------------------------- */
.race-window-wrap { margin-top: 10px; }
.race-window-wrap .hourly-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    padding-left: 2px;
}
.race-window-hours {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rw-hour-card {
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 10px;
    padding: 10px 12px;
}
.rw-hour-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.rw-hour-time {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e2e8f0;
    min-width: 48px;
}
.rw-hour-icon { font-size: 1.3rem; }
.rw-hour-temp {
    margin-left: auto;
    font-size: 1.2rem;
    font-weight: 700;
    color: #f1f5f9;
}
.rw-hour-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
}
.rw-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    gap: 6px;
}
.rw-cell .rw-lbl {
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.rw-cell .rw-val {
    color: #e2e8f0;
    font-weight: 600;
    text-align: right;
}
.rw-arrow {
    color: #60a5fa;
    margin-right: 2px;
    transform-origin: center center;
}
@media (min-width: 600px) {
    .rw-hour-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

.weather-status .status-badge.status-live {
    background: #22c55e;
}

.no-weather {
    text-align: center;
    padding: 30px 20px;
}

.no-weather .no-weather-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.no-weather .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.weather-timeline-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.weather-timeline {
    display: flex;
    overflow-x: auto;
    gap: 5px;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.weather-timeline .timeline-item {
    flex: 0 0 55px;
    text-align: center;
    background: var(--hover-bg);
    border-radius: 8px;
    padding: 8px 5px;
}

.weather-timeline .timeline-item .time {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.weather-timeline .timeline-item .icon {
    font-size: 1.3rem;
    display: block;
    margin: 5px 0;
}

.weather-timeline .timeline-item .temp {
    font-size: 0.75rem;
    font-weight: 600;
}

.windy-link {
    display: block;
    text-align: center;
    background: #3b82f6;
    color: white;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.windy-link:hover {
    background: #2563eb;
}

/* Header buttons */
.btn-history, .btn-weather {
    background: rgba(100, 116, 139, 0.3);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-history:hover, .btn-weather:hover {
    background: rgba(59, 130, 246, 0.4);
}

.btn-weather {
    background: rgba(59, 130, 246, 0.3);
}

/* Mobile adjustments for panels */
@media (max-width: 768px) {
    .history-panel, .weather-panel, .stats-panel {
        left: 0;
        right: 0;
        width: 100%;
        top: auto;
        bottom: 0;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
        box-sizing: border-box;
        /* Stack ABOVE the leaderboard panel on mobile so the
         * filter toolbar of the (collapsed) leaderboard doesn't bleed
         * through and cover the stats header. The leaderboard sits at
         * z-index 1000; we put these panels above at 1100 since when
         * either is open it should fully obscure the leaderboard
         * underneath rather than fight it for screen real estate. */
        z-index: 1100;
    }

    /* When stats/history/weather panel is open on mobile, fully hide the
     * leaderboard panel — they share the same bottom-sheet slot and the
     * collapsed leaderboard header would otherwise show through above
     * the panel header. body class is added by the panel-open code in
     * app.js (we add it below). */
    /* When stats/history/weather panel is open on mobile, fully hide the
     * leaderboard panel and the map filter overlay — they share the same
     * screen real estate as the open panel and would otherwise float
     * above (or peek through) the stats content.
     *
     * Leaderboard: collapsed-state header would show through above the
     * panel header.
     * Map filter overlay: a fixed-position bar (Județ / Club / cod /
     * crescator) anchored top-left of the map; on mobile it overlaps
     * the panel header area.
     *
     * body class is added by the panel-open code in app.js
     * (initBottomPanelTracker, watching panel hidden state via
     * MutationObserver).
     */
    body.bottom-panel-open .cmd-panel,
    body.bottom-panel-open .map-filter-overlay {
        display: none;
    }
    
    .stats-panel-body {
        padding: 12px;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .stats-overview {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-speed-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-times {
        flex-direction: column;
        gap: 4px;
    }
}

/* Statistics Panel */
.stats-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 400px;
    max-width: 100vw;
    max-height: calc(100vh - var(--header-height));
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    z-index: 999;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    box-sizing: border-box;
    overflow: hidden;
}

.stats-panel.hidden {
    display: none;
}

.stats-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
}

.stats-panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.stats-panel-header .btn-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.stats-panel-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.stats-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    box-sizing: border-box;
}

.btn-stats {
    background: rgba(139, 92, 246, 0.3);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-stats:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Stats Content */
.stats-summary {
    text-align: center;
    margin-bottom: 15px;
}

.stats-contest-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color);
}

.stats-distance {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

@media (max-width: 500px) {
    .stats-overview {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-speed-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    background: var(--hover-bg);
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
}

.stat-card .stat-icon {
    font-size: 1.2rem;
    margin-bottom: 3px;
}

.stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.stat-card .stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stats-times {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 10px;
    background: var(--hover-bg);
    border-radius: 8px;
    margin-bottom: 15px;
}

/* Stats Speed Grid */
.stats-speed-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.speed-stat {
    background: var(--hover-bg);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
}

.speed-stat .speed-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.speed-stat .speed-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
}

/* Speed Distribution Chart */
.speed-distribution {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.speed-range-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speed-range-row .range-label {
    width: 70px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.speed-range-row .range-bar-container {
    flex: 1;
    height: 16px;
    background: var(--hover-bg);
    border-radius: 4px;
    overflow: hidden;
}

.speed-range-row .range-bar {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6 0%, #6366f1 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.speed-range-row .range-count {
    width: 35px;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-color);
    font-weight: 500;
}

/* Center/Club List */
.center-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.center-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--hover-bg);
    border-radius: 6px;
    font-size: 0.8rem;
}

.center-item .center-name {
    flex: 1;
    color: var(--text-color);
    font-weight: 500;
}

.center-item .center-avg {
    color: #8b5cf6;
    margin-right: 12px;
    font-size: 0.75rem;
}

.center-item .center-count {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Enhanced Club Statistics Cards */
.club-stats-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.club-stat-card {
    background: var(--hover-bg);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.club-stat-card .club-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(100, 116, 139, 0.2);
}

.club-stat-card .club-name {
    font-weight: 600;
    color: #8b5cf6;
    font-size: 0.9rem;
}

.club-stat-card .club-arrivals {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.club-stat-card .club-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.club-stat-card .club-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.club-stat-card .club-detail .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.club-stat-card .club-detail .value {
    font-size: 0.85rem;
    color: var(--text-color);
    font-weight: 500;
}

.club-stat-card .club-detail .value small {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Year Stats */
.year-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.year-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--hover-bg);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
}

.year-badge .year-name {
    color: var(--text-color);
    font-weight: 600;
}

.year-badge .year-count {
    background: #8b5cf6;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
}

.stats-section {
    margin-bottom: 20px;
}

.stats-section h4 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text-color);
}

/* Fastest Pigeons List */
.fastest-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fastest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--hover-bg);
    padding: 10px;
    border-radius: 8px;
}

.fastest-item.first-place {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.2) 0%, rgba(251, 191, 36, 0.1) 100%);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.fastest-rank {
    font-size: 1.2rem;
    min-width: 30px;
    text-align: center;
}

.fastest-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.fastest-ring {
    font-weight: 600;
    font-size: 0.85rem;
}

.fastest-breeder {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.fastest-speed {
    font-weight: 700;
    font-size: 0.9rem;
    color: #22c55e;
}

/* Top Breeders List */
.breeders-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.breeder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--hover-bg);
    padding: 10px;
    border-radius: 8px;
}

.breeder-rank {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 25px;
    text-align: center;
}

.breeder-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.breeder-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.breeder-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.breeder-count {
    font-weight: 600;
    font-size: 0.85rem;
}

/* Arrival Timeline Chart */
.timeline-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    padding: 10px;
    background: var(--hover-bg);
    border-radius: 8px;
    overflow-x: auto;
}

.chart-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 30px;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar .bar-fill {
    width: 20px;
    background: linear-gradient(180deg, #8b5cf6 0%, #6366f1 100%);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.3s ease;
}

.chart-bar .bar-count {
    font-size: 0.6rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-color);
}

.chart-bar .bar-time {
    font-size: 0.55rem;
    color: var(--text-muted);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    margin-top: 5px;
}

/* Hourly Arrivals Chart */
.hourly-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hourly-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hourly-bar .hourly-time {
    width: 45px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.hourly-bar .hourly-bar-container {
    flex: 1;
    height: 18px;
    background: var(--hover-bg);
    border-radius: 4px;
    overflow: hidden;
}

.hourly-bar .hourly-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.hourly-bar .hourly-count {
    width: 40px;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-color);
    font-weight: 600;
}

/* No Stats State */
.no-stats {
    text-align: center;
    padding: 40px 20px;
}

.no-stats .no-stats-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.no-stats p {
    margin: 5px 0;
}

.no-stats .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ========================================
   GDPR Consent Modal
   ======================================== */

.gdpr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: gdprFadeIn 0.3s ease;
}

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

.gdpr-modal-content {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border-radius: 16px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(100, 116, 139, 0.3);
    animation: gdprSlideUp 0.4s ease;
}

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

.gdpr-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid rgba(100, 116, 139, 0.2);
}

.gdpr-header .gdpr-icon {
    font-size: 2rem;
}

.gdpr-header h2 {
    color: #f1f5f9;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.gdpr-body {
    padding: 1.25rem 1.5rem;
    color: #cbd5e1;
    font-size: 0.9rem;
    line-height: 1.6;
}

.gdpr-body p {
    margin-bottom: 1rem;
}

.gdpr-details {
    background: rgba(30, 41, 59, 0.5);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.gdpr-details h4 {
    color: #00d4ff;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.gdpr-details h4:not(:first-child) {
    margin-top: 1rem;
}

.gdpr-details ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.gdpr-details li {
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: #94a3b8;
}

.gdpr-details li strong {
    color: #e2e8f0;
}

.gdpr-note {
    font-size: 0.8rem;
    color: #64748b;
    font-style: italic;
    text-align: center;
    margin-top: 0.5rem !important;
}

.gdpr-actions {
    padding: 1rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gdpr-link {
    display: block;
    text-align: center;
    color: #00d4ff;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.gdpr-link:hover {
    background: rgba(0, 212, 255, 0.1);
    text-decoration: underline;
}

.gdpr-buttons {
    display: flex;
    gap: 0.75rem;
}

.gdpr-btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gdpr-btn-reject {
    background: rgba(100, 116, 139, 0.3);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.5);
}

.gdpr-btn-reject:hover {
    background: rgba(100, 116, 139, 0.5);
    color: #e2e8f0;
}

.gdpr-btn-accept {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
}

.gdpr-btn-accept:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

/* GDPR Rejected State Overlay */
.gdpr-rejected-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.gdpr-rejected-content {
    max-width: 400px;
}

.gdpr-rejected-content .emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.gdpr-rejected-content h2 {
    color: #f1f5f9;
    margin-bottom: 1rem;
}

.gdpr-rejected-content p {
    color: #94a3b8;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.gdpr-change-mind {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.gdpr-change-mind:hover {
    background: #1d4ed8;
}

/* Mobile GDPR adjustments */
@media (max-width: 480px) {
    .gdpr-modal-content {
        border-radius: 12px;
    }
    
    .gdpr-header {
        padding: 1.25rem;
    }
    
    .gdpr-body {
        padding: 1rem 1.25rem;
    }
    
    .gdpr-actions {
        padding: 1rem 1.25rem 1.25rem;
    }
    
    .gdpr-buttons {
        flex-direction: column;
    }
    
    .gdpr-btn {
        padding: 1rem;
    }
}

/* GDPR Footer Link (persistent) */
.gdpr-footer-link {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 100;
    background: rgba(30, 41, 59, 0.9);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid rgba(100, 116, 139, 0.2);
}

.gdpr-footer-link:hover {
    color: #00d4ff;
    background: rgba(30, 41, 59, 1);
}

/* Map filter overlay — independent from CMD filters.
 * Anchors just below the (dynamic) header via --header-height-mobile which
 * JS keeps in sync; falls back to 70px if JS hasn't measured yet. */
.map-filter-overlay {
    position: fixed;
    top: calc(var(--header-height-mobile, 70px) + 10px);
    left: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(100, 116, 139, 0.35);
    border-radius: 8px;
    padding: 5px 8px;
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    flex-wrap: wrap;
    max-width: 460px;
}
.map-filter-select {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(100, 116, 139, 0.35);
    border-radius: 5px;
    color: #e2e8f0;
    font-size: 0.75rem;
    padding: 2px 4px;
    outline: none;
    cursor: pointer;
    max-width: 130px;
}
.map-filter-select:focus { border-color: #00d4ff; }
.map-filter-select option { background: #1e293b; color: #e2e8f0; }
.map-search-input {
    background: transparent;
    border: 1px solid rgba(100, 116, 139, 0.25);
    border-radius: 5px;
    outline: none;
    color: #e2e8f0;
    font-size: 0.75rem;
    width: 150px;
    padding: 2px 5px;
    caret-color: #00d4ff;
}
.map-search-input:focus { border-color: #00d4ff; }
.map-search-input::placeholder { color: #64748b; }
.map-search-clear {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 5px;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.72rem;
    padding: 2px 6px;
    line-height: 1.4;
    white-space: nowrap;
}
.map-search-clear:hover { background: rgba(239, 68, 68, 0.3); }

/* ------------------------------------------------------------------
 * Full map mode — hide header + panels, give the map the full screen.
 * ------------------------------------------------------------------ */
.btn-fullmap {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border-radius: 6px;
}
.btn-fullmap:hover { background: var(--bg-color); }

.fullmap-exit-btn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 2000;
    padding: 8px 14px;
    border: none;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    color: #f1f5f9;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
    backdrop-filter: blur(6px);
}
.fullmap-exit-btn:hover { background: rgba(15, 23, 42, 1); }

body.map-fullscreen .header,
body.map-fullscreen .map-filter-overlay,
body.map-fullscreen .gdpr-footer-link { display: none !important; }

body.map-fullscreen #map {
    top: 0 !important;
}

body.map-fullscreen .fullmap-exit-btn { display: inline-flex; align-items: center; }

/* Keep the leaderboard available but collapsed; user can still expand if needed. */
body.map-fullscreen .cmd-panel { z-index: 999; }

/* ------------------------------------------------------------------
 * Mobile refinements — target the real-world ~400px wide phones where
 * the header buttons wrap onto multiple rows and the filter overlay
 * overlaps the Leaflet zoom controls.
 * ------------------------------------------------------------------ */

/* Push the map filter overlay below the (dynamic-height) header on small
 * screens instead of the hard-coded 70px. Also shrink the controls and
 * let them wrap cleanly. */
@media (max-width: 768px) {
    /* Overlay stretches edge-to-edge on narrow screens so the inputs fit. */
    .map-filter-overlay {
        left: 6px;
        right: 6px;
        max-width: none;
        padding: 4px 6px;
        gap: 4px;
    }
    .map-filter-select { flex: 1 1 auto; min-width: 0; max-width: none; font-size: 0.72rem; padding: 3px 4px; }
    .map-search-input  { flex: 2 1 120px; width: auto; min-width: 0; font-size: 0.72rem; }
    .map-search-clear  { flex: 0 0 auto; }

    /* Shrink the full-map button to match the other header buttons on mobile. */
    .btn-fullmap { width: 28px; height: 28px; font-size: 0.9rem; }

    /* On tight screens the arrivals counter + online counter + 7 icon
     * buttons don't fit comfortably — trim the online counter visual weight. */
    .online-counter { margin-right: 4px; padding: 2px 6px; font-size: 0.75rem; }
    .online-counter .online-label { display: none; }  /* hide the "online" label */
}

/* Very narrow phones: drop the year picker — counties + contest list
 * are enough, and the extra select just forces another wrap row. */
@media (max-width: 480px) {
    #yearSelect { display: none; }
    .header-center > div { gap: 4px !important; }
    .contest-select { font-size: 0.8rem; padding: 6px 8px; }
}

