:root {
    --primary: #10b981; /* Emerald 500 */
    --primary-hover: #059669;
    --secondary: #06b6d4; /* Cyan 500 */
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --background: #0f172a; /* Slate 900 */
    --surface: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(255, 255, 255, 0.05);
    --ring-size: 100px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    overflow: hidden; /* Main layout handles scrolling */
}

h1, h2, h3, h4, h5 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Mobile-only elements */
.mobile-only-logo {
    display: none !important;
}

/* Header Styling */
.app-header {
    height: 64px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.25rem;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo span {
    color: var(--primary);
    font-weight: 800;
}

.icon-pulse {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    position: relative;
}

.icon-pulse::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

/* Map Layout */
.main-layout {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

#map-container {
    flex: 1;
    position: relative;
}

#map {
    height: 100%;
    width: 100%;
    background: #0b0e14;
    display: block; /* Force block to ensure correct size rendering */
}

.map-legend {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.8rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.swatch.low { background: #10b981; }
.swatch.moderate { background: #f59e0b; }
.swatch.high { background: #ef4444; }

/* Map Controls & Heatmap */
.map-controls {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
}

.btn-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(12px);
}

.btn-control:hover, .btn-control.active {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.heatmap-legend {
    bottom: auto;
    top: 6rem;
    left: auto;
    right: 1.5rem;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.gradient-bar {
    height: 10px;
    width: 100%;
    background: linear-gradient(to right, #3b82f6, #a855f7, #ef4444);
    border-radius: 5px;
    margin-bottom: 0.25rem;
}

.gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Sidebar Styling */
.sidebar {
    width: 400px;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    box-shadow: -10px 0 30px rgba(0,0,0,0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-handle {
    display: none; /* Desktop only */
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 12px auto 0;
}

/* Top Bar / Address Bar */
.top-bar {
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: center;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1010;
}

.search-wrapper {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    max-width: 600px;
    align-items: center;
}

.sidebar-header {
    display: none; /* Removed in HTML, safe-guard here */
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.glass {
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.hidden { display: none !important; }

/* Welcome View */
.welcome-view {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-content h2 {
    font-size: 2.25rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #fff 0%, #64748b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.quick-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

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

.hotspots-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.hotspots-section h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.hotspots-section p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.hotspot-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hotspot-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    border: 1px solid var(--glass-border);
}

.hotspot-item strong {
    color: var(--danger);
    font-weight: 700;
}

.how-to-use, .tick-safety {
    margin-top: 1.5rem;
    padding: 1.25rem;
    border: 1px solid var(--glass-border);
    transition: transform 0.3s ease;
}

.how-to-use:hover, .tick-safety:hover {
    transform: translateY(-2px);
}

.how-to-use h3, .tick-safety h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.how-to-use p, .tick-safety p {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    opacity: 0.8;
}

.guide-list, .safety-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.guide-list li, .safety-list li {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    padding-left: 1.25rem;
    position: relative;
    line-height: 1.4;
}

.guide-list li::before, .safety-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
}

/* Tooltip Styling */
.custom-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text);
    padding: 12px 16px;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 3000;
    border-left: 4px solid var(--primary);
    transition: opacity 0.15s ease, transform 0.1s ease-out;
}

.custom-tooltip strong {
    color: var(--primary);
    display: block;
    margin-bottom: 2px;
}

.custom-tooltip small {
    display: block;
    opacity: 0.6;
    margin-top: 4px;
    font-size: 0.75rem;
}

/* Risk Score Display */
.risk-header {
    margin-bottom: 2.5rem;
}

.risk-score-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.score-ring {
    width: var(--ring-size);
    height: var(--ring-size);
    position: relative;
}

.circular-chart {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 2.8;
}

.circle {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    transition: stroke-dasharray 1s ease, stroke 0.5s ease;
}

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

#risk-score-num {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}

.score-total {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Factors Bar */
.risk-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.factor-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: var(--primary);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Surveillance Stats */
.surveillance-stats {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.25rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    border: 1px solid var(--glass-border);
}

/* Safety Essentials */
.safety-essentials {
    margin-top: 2rem;
    padding-bottom: 2rem;
}

.essentials-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.essential-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.75rem 0.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    transition: background 0.2s;
}

.essential-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.essential-card img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: white;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.essential-info h5 {
    font-size: 0.7rem;
    margin: 0 0 0.25rem 0;
    line-height: 1.2;
    color: var(--text-muted);
}

.essential-link {
    font-size: 0.65rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px dashed var(--primary);
    opacity: 0.8;
}

.essential-link:hover {
    opacity: 1;
}

.essential-link small {
    font-size: 0.55rem;
    font-weight: 400;
    opacity: 0.6;
    margin-left: 2px;
}

.compliance-footer {
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.compliance-footer p {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0 0 0.4rem 0;
    opacity: 0.7;
}

.report-sighting {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
}

.report-sighting h4 {
    margin-bottom: 1rem !important;
    font-size: 0.85rem !important;
    color: var(--text);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.form-group input, 
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input:focus, 
.form-group textarea:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.1);
}

.submit-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.75rem;
}

.submit-btn.primary {
    background: var(--primary);
    color: #111827;
}

.submit-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 212, 191, 0.3);
    filter: brightness(1.1);
}

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

.cf-turnstile {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.form-message {
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 1rem;
}

.form-message.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.form-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.form-help {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.4;
    font-style: italic;
    opacity: 0.6;
}

.surveillance-stats h4 {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.stats-footer {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

.source-link {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--primary);
    transition: opacity 0.2s;
}

.source-link:hover {
    opacity: 0.8;
}

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

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-icon {
    font-size: 1.5rem;
    background: rgba(6, 182, 212, 0.1);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary);
    line-height: 1;
    margin: 0.2rem 0;
}

.stat-count small {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
}

.stat-unit {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.stats-footer {
    font-size: 0.7rem;
    color: rgba(148, 163, 184, 0.5);
    margin-top: 1rem;
    text-align: center;
    font-style: italic;
}

/* Seasonal Forecast Chart */
.seasonal-forecast {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.25rem;
    border-radius: 16px;
    margin-bottom: 2.5rem;
    border: 1px solid var(--glass-border);
}

.seasonal-forecast h4 {
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    color: var(--text-muted);
}

.chart-container {
    background: rgba(0,0,0,0.2);
    padding: 1rem 0.5rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
}

.risk-chart {
    width: 100%;
}

.bar {
    fill: #3b82f6; /* Blue for regular months */
    opacity: 0.6;
}

.bar-peak {
    fill: var(--danger); /* Red for peak months */
    opacity: 0.9;
}

.chart-text {
    fill: var(--text-muted);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
}

.chart-text.highlight {
    fill: white;
    font-weight: 700;
}

.chart-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: normal;
}

/* Product Grid */
.recommendations h4 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

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

.product-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.product-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

.product-icon {
    width: 44px;
    height: 44px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.product-info h5 {
    font-size: 0.95rem;
    margin-bottom: 0.1rem;
}

.product-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.prevention-checklist {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
}

.prevention-checklist h4 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

.checklist {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.check-item:hover {
    color: var(--text);
}

.check-item input {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--glass-border);
    border-radius: 6px;
    position: relative;
    transition: all 0.2s ease;
}

.check-item input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.check-item input:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
}

.tick-id-section {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
}

.tick-id-section h4 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

.id-graphic {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    margin-bottom: 0.75rem;
    display: block;
}

.id-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: normal;
    text-align: center;
}

/* Search Bar Override */
.search-container {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.recent-searches {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 0 0 12px 12px;
    margin-top: -1px;
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.recent-searches:empty {
    display: none;
}

.recent-item {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.05);
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.recent-item:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.geosearch form {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px !important;
    padding: 0 1rem !important;
}

.geosearch input {
    background: transparent !important;
    color: var(--text) !important;
    font-family: inherit !important;
    border: none !important;
    padding: 10px 0 !important;
}

/* Geosearch Dropdown Styling (The "White List" Fix) */
.leaflet-control-geosearch .results {
    background: var(--background) !important;
    backdrop-filter: blur(16px) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 0 0 12px 12px !important;
    margin-top: 4px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
    color: var(--text) !important;
    overflow: hidden !important;
}

.leaflet-control-geosearch .results > div {
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--glass-border) !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    transition: background 0.2s ease !important;
    background: transparent !important;
    color: var(--text) !important;
}

.leaflet-control-geosearch .results > div:hover {
    background: var(--primary) !important;
    color: #111827 !important;
}

.leaflet-control-geosearch .results > div.active {
    background: var(--primary) !important;
}

.leaflet-control-geosearch .results .reset {
    background: var(--surface) !important;
    color: var(--text-muted) !important;
    border: none !important;
    padding: 8px !important;
    font-size: 0.75rem !important;
}

.btn-locate {
    background: var(--primary);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-locate:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Map Legend & View Toggle */
.map-legend {
    position: absolute;
    bottom: 24px;
    left: 24px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    z-index: 1000;
    min-width: 180px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    transition: all 0.3s ease;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.legend-header span {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.view-toggle-group {
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 2px;
    display: flex;
    gap: 2px;
}

.view-toggle-group button {
    background: transparent;
    border: none;
    color: var(--text);
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.5;
}

.view-toggle-group button.active {
    background: var(--primary);
    color: white;
    opacity: 1;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.legend-item i {
    width: 24px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
}

#heatmap-legend.hidden, #dots-legend.hidden, #habitat-legend.hidden {
    display: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
/* Habitat Progress Bar */
.stat-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, #7dd3fc, #ef4444);
    box-shadow: 0 0 10px rgba(125, 211, 252, 0.5);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animated Tick Styles */
.tick-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.tick-icon {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
    will-change: transform; /* Hardware Acceleration for Mobile Performance */
}

.animated-tick-1 .tick-icon { animation: crawl1 2s infinite alternate ease-in-out; }
.animated-tick-2 .tick-icon { animation: crawl2 2.5s infinite alternate ease-in-out; }
.animated-tick-3 .tick-icon { animation: crawl3 3s infinite alternate ease-in-out; }

@keyframes crawl1 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); }
    33% { transform: translate(3px, -2px) rotate(15deg) scale(1.1); }
    66% { transform: translate(-2px, -4px) rotate(-10deg) scale(0.95); }
    100% { transform: translate(-4px, 2px) rotate(25deg) scale(1); }
}

@keyframes crawl2 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); }
    33% { transform: translate(-3px, 3px) rotate(-15deg) scale(1.1); }
    66% { transform: translate(2px, 4px) rotate(10deg) scale(0.95); }
    100% { transform: translate(5px, -2px) rotate(-25deg) scale(1); }
}

@keyframes crawl3 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); }
    33% { transform: translate(2px, 3px) rotate(20deg) scale(1.1); }
    66% { transform: translate(-3px, 2px) rotate(-20deg) scale(0.95); }
    100% { transform: translate(-1px, -4px) rotate(15deg) scale(1); }
}

/* Habitat Infographic Sidebar Styles */
.habitat-infographic {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #3b82f6;
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.infographic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.infographic-header h4 {
    margin: 0 !important;
    font-size: 0.8rem !important;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.6;
    color: #94a3b8;
}

.suitability-tag {
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: 20px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    font-weight: 600;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.habitat-infographic h4 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.infographic-content .land-type {
    font-size: 1.1rem;
    color: #f1f5f9;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.infographic-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #94a3b8;
    margin: 0.5rem 0 1.5rem 0;
}

.habitat-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.habitat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom Classic Blue Marker Fix (Ensures search and click look identical) */
.classic-pin {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* ==========================================================================
   MOBILE RESPONSIVENESS OVERHAUL (End of file for max precedence)
   ========================================================================== */

@media (max-width: 1024px) {
    #app {
        display: grid !important;
        grid-template-rows: 48px calc(100dvh - 48px - 33.33vh) 33.33vh !important; /* Explicit row heights for stability */
        grid-template-columns: 100% !important;
        height: 100dvh !important;
        width: 100vw !important;
        overflow: hidden !important;
    }

    .app-header {
        display: none !important; 
    }

    .top-bar {
        grid-row: 1 / 2 !important;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 0 0.75rem !important;
        height: 48px !important;
        background: var(--background) !important;
        border-bottom: 1px solid var(--glass-border);
        z-index: 2000 !important;
        gap: 0.5rem;
    }

    .data-status-banner {
        position: absolute;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(15, 23, 42, 0.95);
        border: 1px solid var(--glass-border);
        padding: 0.4rem 0.8rem;
        border-radius: 20px;
        font-size: 0.65rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        z-index: 2500;
        white-space: nowrap;
        box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    }

    .data-status-banner.hidden {
        display: none !important;
    }

    .status-dot {
        width: 8px;
        height: 8px;
        background: #f59e0b;
        border-radius: 50%;
        box-shadow: 0 0 8px #f59e0b;
        animation: pulse 1.5s infinite;
    }

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

    .mobile-only-logo {
        display: flex !important;
        margin-right: auto;
    }

    .mobile-only-logo h1 {
        font-size: 1.1rem !important;
        font-weight: 800 !important;
        letter-spacing: -0.02em;
        white-space: nowrap;
    }

    .search-wrapper {
        display: flex !important;
        align-items: center;
        gap: 0.4rem;
        flex: 1;
        justify-content: flex-end;
    }

    .geosearch form {
        height: 36px !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 200px;
    }

    .geosearch input {
        border-radius: 12px !important;
        font-size: 0.9rem !important;
        padding-left: 2.2rem !important;
    }

    .btn-locate {
        width: 32px !important;
        height: 32px !important;
        flex-shrink: 0;
    }

    .main-layout {
        display: contents !important; /* Keep display: contents ONLY if we use the grid directly on its children. Wait, I'll remove it. */
    }

    /* Bypassing main-layout to keep map and sidebar in #app grid */
    #map-container {
        grid-row: 2 / 3 !important;
        position: relative !important;
        height: 100% !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    .sidebar {
        grid-row: 3 / 4 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        position: relative !important;
        border-radius: 24px 24px 0 0 !important;
        background: var(--background) !important;
        box-shadow: 0 -20px 40px rgba(0,0,0,0.4) !important;
        z-index: 1000;
        overflow: hidden !important;
        border-top: 1px solid rgba(255,255,255,0.1) !important;
    }

    .sidebar-content {
        height: 100% !important;
        overflow-y: auto !important;
        padding: 1rem !important;
    }

    .welcome-view {
        padding: 0.5rem 0.25rem !important;
    }

    .hero-content h2 {
        font-size: 1.5rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
        color: var(--text) !important;
    }

    .hero-content p {
        font-size: 0.85rem !important;
        line-height: 1.5 !important;
        opacity: 0.8;
    }

    .map-controls {
        top: auto !important;
        bottom: 1rem !important;
        left: 0.75rem !important;
        right: auto !important;
        z-index: 1005;
    }

    /* Fixed single-line legend for mobile at bottom-right of map */
    .map-legend {
        top: auto !important;
        bottom: 1rem !important;
        right: 0.75rem !important;
        left: auto !important;
        padding: 0.3rem 0.5rem !important;
        font-size: 0.65rem !important;
        background: rgba(15, 23, 42, 0.7) !important;
        border-radius: 8px !important;
        max-width: fit-content !important;
        z-index: 1005;
    }

    .map-legend .legend-header,
    .map-legend .legend-divider,
    .map-legend .legend-label,
    .map-legend .legend-item:not(:first-child) {
        display: none !important;
    }

    .leaflet-control-attribution {
        display: none !important;
    }

    /* Force Leaflet panes to stay visible and on-top of the grid container */
    #map .leaflet-pane {
        z-index: 400 !important;
    }

    #map .leaflet-tile-pane {
        z-index: 200 !important;
    }

    #map .leaflet-habitatPane-pane {
        z-index: 410 !important;
    }

    /* countyPane and overlay-pane are both used for heatmaps */
    #map .leaflet-countyPane-pane,
    #map .leaflet-overlay-pane {
        z-index: 450 !important;
        visibility: visible !important;
    }

    /* dotsPane is for the moving tick icons */
    #map .leaflet-dotsPane-pane {
        z-index: 610 !important;
        pointer-events: none !important;
    }

    #map .leaflet-marker-pane {
        z-index: 700 !important;
    }
}

@media (max-width: 480px) {
    .essentials-grid {
        grid-template-columns: 1fr !important;
    }
}
