/* AVILIGHT Dashboard - Themeable Stylesheet (light default, dark mode via [data-theme="dark"]) */

/* ── Light theme (default) ─────────────────────────────── */
:root {
    --bg-dark: #f0f2f6;
    --bg-card: #ffffff;
    --bg-card-alt: #f4f6fb;
    --bg-input: #eaecf2;
    --text-primary: #1e2330;
    --text-secondary: #5c6278;
    --text-muted: #9ca3af;
    --accent-blue: #2563eb;
    --accent-teal: #0d9488;
    --accent-green: #16a34a;
    --accent-red: #dc2626;
    --accent-yellow: #ca8a04;
    --primary-color: #2563eb;
    --secondary-color: #6366f1;
    --accent-color: #d97706;
    --danger-color: #dc2626;
    --warning-color: #ca8a04;
    --info-color: #0891b2;
    --light-bg: #eaecf2;
    --dark-text: #1e2330;
    --border-color: #dde1ea;
    --shadow: 0 2px 8px rgba(0,0,0,0.07);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.11);
    --navbar-height: 60px;
    --bg-overlay: rgba(255, 255, 255, 0.93);
    --leaflet-attr-bg: rgba(240, 242, 246, 0.8);
}

/* ── Dark theme override ────────────────────────────────── */
[data-theme="dark"] {
    --bg-dark: #0f1117;
    --bg-card: #1a1d23;
    --bg-card-alt: #1e2128;
    --bg-input: #252830;
    --text-primary: #ffffff;
    --text-secondary: #a0a4b0;
    --text-muted: #6b7080;
    --accent-blue: #3b82f6;
    --accent-teal: #2dd4bf;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
    --primary-color: #3b82f6;
    --secondary-color: #6366f1;
    --accent-color: #f59e0b;
    --danger-color: #ef4444;
    --warning-color: #eab308;
    --info-color: #06b6d4;
    --light-bg: #252830;
    --dark-text: #ffffff;
    --border-color: #2a2d35;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
    --bg-overlay: rgba(26, 29, 35, 0.92);
    --leaflet-attr-bg: rgba(15, 17, 23, 0.7);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Navigation Bar */
.navbar {
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    display: none;
}

.nav-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.nav-menu li a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-menu li a:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.nav-menu li a.active:hover {
    color: #ffffff;
    background: var(--accent-blue);
}

.nav-menu li a.active {
    color: #ffffff;
    background: var(--accent-blue);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
    position: relative;
}

.nav-menu li a.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: #ffffff;
    border-radius: 2px;
    opacity: 0.7;
}

.nav-divider {
    display: none;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-icon {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
}

.nav-icon:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

.nav-menu-item {
    position: relative;
}

/* Hamburger toggle button — hidden on desktop, shown on mobile */
.nav-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    padding: 0;
    transition: color 0.2s, background 0.2s;
}

.nav-hamburger:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.nav-hamburger svg {
    width: 22px;
    height: 22px;
}

/* Main Content */
.nav-popover {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 10px;
    display: none;
    z-index: 1100;
}

.nav-popover.is-open {
    display: block;
}

.nav-popover-title {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 2px 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.nav-notification-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-decoration: none;
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-primary);
}

.nav-notification-row:hover {
    background: var(--bg-input);
}

.nav-notification-title {
    font-size: 0.86rem;
    line-height: 1.3;
}

.nav-notification-date {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.nav-account-email {
    padding: 8px 10px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
    overflow-wrap: anywhere;
}

.nav-account-link {
    display: block;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.9rem;
}

.nav-account-link:hover {
    background: var(--bg-input);
}

.nav-account-logout {
    color: var(--accent-red);
}

/* Main Content */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px;
    min-height: calc(100vh - var(--navbar-height));
}

/* AVP entry animations (Home, Dashboard, Analytics, Species, Reports, Settings) */
body.avp-animated-page .main-content > * {
    opacity: 0;
    transform: translateY(16px);
    animation: avpPageEnter 0.58s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

body.avp-animated-page .main-content > *:nth-child(1) { animation-delay: 0.04s; }
body.avp-animated-page .main-content > *:nth-child(2) { animation-delay: 0.10s; }
body.avp-animated-page .main-content > *:nth-child(3) { animation-delay: 0.16s; }
body.avp-animated-page .main-content > *:nth-child(4) { animation-delay: 0.22s; }
body.avp-animated-page .main-content > *:nth-child(5) { animation-delay: 0.28s; }
body.avp-animated-page .main-content > *:nth-child(6) { animation-delay: 0.34s; }
body.avp-animated-page .main-content > *:nth-child(7) { animation-delay: 0.40s; }
body.avp-animated-page .main-content > *:nth-child(8) { animation-delay: 0.46s; }
body.avp-animated-page .main-content > *:nth-child(n+9) { animation-delay: 0.52s; }

@keyframes avpPageEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.avp-animated-page .main-content > * {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.card-header {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.card-body {
    padding: 10px 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-blue);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

.stat-card.info {
    border-left-color: var(--info-color);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

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

.stat-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 5px;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: #000;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

th {
    background: var(--bg-input);
    font-weight: 600;
    color: var(--text-secondary);
}

tr:hover {
    background: var(--bg-input);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Sliders */
.slider-container {
    margin: 20px 0;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
}

/* Map Container */
#map {
    height: 600px;
    width: 100%;
    border-radius: 10px;
}

#map.leaflet-container {
    overflow: hidden !important;
}

.map-container {
    position: relative;
}

.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: var(--bg-card);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

/* Loading Indicator */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s linear infinite;
}

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

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.alert-info {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--text-primary);
}

[data-theme="dark"] .alert-info {
    color: #67e8f9;
}

.alert-warning {
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.3);
    color: #fde047;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--accent-green);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.2);
    color: var(--accent-yellow);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.badge-info {
    background: rgba(6, 182, 212, 0.2);
    color: var(--info-color);
}

.badge-secondary {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
}

/* Data-source badges inside card headers */
.data-source-badge {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 8px;
}

.data-source-csv {
    background: rgba(44, 95, 45, 0.15);
    color: var(--accent-green);
}

.data-source-hardcoded {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-yellow);
}

.data-source-sample {
    background: rgba(6, 182, 212, 0.15);
    color: var(--info-color);
}

/* Tooltips */
.tooltip-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: var(--info-color);
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 12px;
    line-height: 18px;
    cursor: help;
    margin-left: 5px;
}

/* Species Cards */
.species-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.species-card {
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s;
    border: 1px solid var(--border-color);
}

.species-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.species-image {
    width: 100%;
    min-height: 240px;
    height: 240px;
    background: var(--bg-input);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08), inset 0 10px 20px rgba(15, 23, 42, 0.08);
}

.species-image.has-photo::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.06), rgba(15, 23, 42, 0.16));
    pointer-events: none;
}

.species-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(0.9) contrast(0.96);
}

.species-card .badge-success {
    background: rgba(34, 197, 94, 0.12);
    color: #3f7f55;
}

.species-card .badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #8a4b4b;
}

.species-detail-image-shell {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(15, 23, 42, 0.05);
}

.species-detail-image-empty {
    background: var(--bg-card-alt);
}

[data-theme="dark"] .species-card .badge-success {
    background: rgba(34, 197, 94, 0.18);
    color: #9be7b6;
}

[data-theme="dark"] .species-card .badge-danger {
    background: rgba(239, 68, 68, 0.18);
    color: #f3b0b0;
}

[data-theme="dark"] .species-image {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 10px 20px rgba(0, 0, 0, 0.18);
}

[data-theme="dark"] .species-image.has-photo::after,
[data-theme="dark"] .species-detail-image-shell.has-photo::after {
    background: linear-gradient(180deg, rgba(15, 17, 23, 0.08), rgba(15, 17, 23, 0.3));
}

[data-theme="dark"] .species-detail-image-bg {
    filter: blur(18px) saturate(0) brightness(0.55);
    opacity: 0.38;
}

[data-theme="dark"] .species-detail-photo {
    filter: saturate(0.92) contrast(0.96) brightness(0.96);
}

[data-theme="dark"] .species-detail-image-empty {
    border-color: var(--border-color);
}

.species-detail-image-shell {
    position: relative;
    width: 320px;
    max-width: 100%;
    height: 320px;
    max-height: 60vh;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(15, 23, 42, 0.05);
}

.species-detail-image-shell.has-photo::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(165deg, rgba(30, 41, 59, 0.06), rgba(30, 41, 59, 0.14));
    pointer-events: none;
    z-index: 2;
}

.species-detail-image-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transform: scale(1.12);
    filter: blur(18px) saturate(0) brightness(0.9);
    opacity: 0.45;
    z-index: 0;
}

.species-detail-photo {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform 0.2s ease;
    filter: saturate(0.9) contrast(0.95) brightness(0.98);
}

.species-detail-photo:hover {
    transform: scale(1.03);
}

.species-detail-image-empty {
    border: 1px solid var(--border-color);
}

.species-info {
    padding: 15px;
    background: var(--bg-card);
}

[data-theme="dark"] .species-info {
    background: var(--bg-card);
}

.species-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.species-scientific {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.species-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Filters */
.filter-container {
    background: var(--bg-card-alt);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-label {
    font-weight: 500;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    display: none;
}

.footer-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
}

.footer-section {
    flex: 1;
}

.footer-section p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 5px 0;
}

/* ====== Dashboard-specific styles ====== */

/* Two-column dashboard layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
    height: calc(100vh - var(--navbar-height) - 40px);
}

.dashboard-map-col {
    min-height: 0;
}

.dashboard-map-col #map {
    height: 100%;
    min-height: 500px;
    border-radius: 0 0 10px 10px;
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-right: 4px;
}

#riskSidebarPanels {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 0 8px;
}

#riskSidebarPanels .dash-stats {
    margin-bottom: 2px;
}

#riskSidebarPanels .activity-feed {
    gap: 12px;
}

/* Dashboard stat cards (compact) */
.dash-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dash-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
}

.historical-site-card {
    max-height: 540px;
    overflow-y: auto;
    overflow-x: hidden;
}

.hist-site-close-btn {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 4px;
}

.hist-site-close-btn:hover {
    color: var(--text-primary);
}

.historical-site-species-list {
    max-height: 165px;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    padding-right: 6px;
}

.historical-site-species-items {
    margin: 0;
    padding-left: 15px;
}

.historical-site-species-items li {
    color: var(--accent-blue);
    font-style: italic;
    margin: 0 0 3px;
    font-size: 0.95rem;
}

/* Species type badges */
.spp-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-style: normal;
    font-weight: 600;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 999px;
    vertical-align: middle;
    margin-left: 3px;
    white-space: nowrap;
}
.spp-badge-resident  { background: rgba(34,197,94,0.18);  color: #4ade80; }
.spp-badge-migrant   { background: rgba(59,130,246,0.18); color: #60a5fa; }
.spp-badge-tolerant  { background: rgba(234,179,8,0.15);  color: #facc15; }
.spp-badge-sensitive { background: rgba(239,68,68,0.15);  color: #f87171; }

.historical-site-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dash-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.dash-stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.dash-stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 10px;
}

.dash-stat-trend.up {
    color: var(--accent-green);
}

.dash-stat-trend.down {
    color: var(--accent-red);
}

/* Section headers (teal uppercase) */
.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-teal);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
}

/* Bird richness chart container */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
}

.chart-card canvas {
    max-height: 200px;
}

/* Recent activity feed */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.activity-icon.red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.activity-icon.green {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
}

.activity-icon.blue {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.activity-text {
    flex: 1;
}

.activity-text strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.activity-text span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Map legend */
.map-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    z-index: 1000;
    color: var(--text-primary);
}

.map-legend h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    font-size: 0.85rem;
}

.map-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Dark Leaflet overrides */
.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-input) !important;
}

.leaflet-control-attribution {
    background: var(--leaflet-attr-bg) !important;
    color: var(--text-muted) !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip {
    background: var(--bg-card) !important;
}

/* Map hover tooltip */
.leaflet-tooltip-pane {
    z-index: 650 !important;
}

.map-tooltip {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    box-shadow: var(--shadow) !important;
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
    z-index: 651 !important;
    pointer-events: none !important;
}

.map-tooltip::before {
    border-top-color: var(--bg-card) !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .dashboard-map-col #map {
        height: 450px;
    }
}

@media (max-width: 768px) {
    /* Show hamburger; keep navbar as a single row */
    .nav-hamburger {
        display: flex;
    }

    .nav-container {
        padding: 0 14px;
        height: 60px;
        position: relative;
    }

    /* Nav menu becomes a collapsible dropdown below the navbar */
    .nav-menu {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        padding: 8px 14px 14px;
        gap: 4px;
        z-index: 999;
        box-shadow: var(--shadow-lg);
        flex: unset;
        justify-content: unset;
    }

    .navbar.nav-open .nav-menu {
        display: flex;
    }

    .nav-menu li a {
        display: block;
        text-align: left;
        padding: 10px 12px;
    }

    /* Reduce main content padding */
    .main-content {
        padding: 14px 12px;
    }

    /* Grids: single column */
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

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

    .dash-stats {
        grid-template-columns: 1fr 1fr;
    }

    /* Allow cards to scroll horizontally (handles wide tables) */
    .card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Map heights */
    #map {
        height: 350px;
    }

    .dashboard-map-col #map {
        height: 350px;
        min-height: 300px;
    }

    /* Chart height */
    .chart-container {
        height: 260px;
    }

    /* Page header font */
    .page-title {
        font-size: 1.35rem;
    }

    /* Side panel: bottom sheet on mobile */
    .side-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 65vh;
    }
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 400px;
    margin: 20px 0;
}

.chart-small {
    height: 300px;
}

/* Side Panel for Map */
.side-panel {
    position: absolute;
    right: 20px;
    top: 80px;
    width: 350px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    z-index: 1000;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.side-panel-close {
    float: right;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
}

.side-panel-close:hover {
    color: var(--danger-color);
}

/* Species list inside side panel — keep text within bounds */
.side-panel ul {
    padding-left: 18px;
    margin: 6px 0;
}

.side-panel ul li {
    overflow-wrap: break-word;
    word-break: break-word;
    margin-bottom: 3px;
    color: var(--text-primary);
}

/* Progress indicators */
.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--bg-input);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-blue);
    transition: width 0.3s;
}

/* Legacy legend (for geospatial page) */
.legend {
    background: var(--bg-overlay);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    position: absolute;
    bottom: 30px;
    left: 10px;
    z-index: 1000;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.legend-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Analytics richness prediction panel */
.geo-prediction-layout {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 18px;
}

.geo-prediction-form,
.geo-prediction-output {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
}

.geo-prediction-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.geo-prediction-subtitle {
    margin-top: 4px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.geo-city-group {
    margin-top: 12px;
    margin-bottom: 0;
}

.geo-covariates-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.geo-covariate-item {
    margin-bottom: 0;
}

.geo-auto-landtype {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--bg-card);
    font-size: 0.9rem;
}

.geo-month-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.geo-month-group {
    margin-top: 14px;
    margin-bottom: 0;
}

#predMonthBadge {
    min-width: 84px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 5px 8px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.2);
    color: #c4b5fd;
}

.geo-output-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #6d28d9;
    border-radius: 10px;
    padding: 12px;
    background: rgba(109, 40, 217, 0.12);
    margin-bottom: 12px;
}

.geo-output-total small {
    font-size: 0.7rem;
    color: #c4b5fd;
    letter-spacing: 0.25px;
}

.geo-output-context {
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.geo-output-value {
    font-size: 2rem;
    font-weight: 800;
    color: #a855f7;
    line-height: 1;
}

.geo-output-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    background: var(--bg-card);
    margin-bottom: 12px;
}

.geo-output-row {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
}

.geo-row-value {
    font-weight: 700;
}

.geo-bar-track {
    margin-top: 5px;
    height: 8px;
    border-radius: 999px;
    background: var(--bg-input);
    overflow: hidden;
}

.geo-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    transition: width 0.35s ease;
}

.geo-bar-red { background: #ef4444; }
.geo-bar-blue { background: #3b82f6; }
.geo-bar-green { background: #10b981; }
.geo-bar-yellow { background: #f59e0b; }
.geo-bar-purple { background: #8b5cf6; }
.geo-bar-teal { background: #14b8a6; }

.geo-output-shap-title {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.geo-driver-text {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

@media (max-width: 1200px) {
    .geo-prediction-layout {
        grid-template-columns: 1fr;
    }

    .geo-covariates-grid {
        grid-template-columns: 1fr;
    }
}

/* Home page styles */
.home-stats-grid {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
    .home-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .home-stats-grid {
        grid-template-columns: 1fr;
    }
}

.home-lower-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .home-lower-grid {
        grid-template-columns: 1fr;
    }
}

.home-kba-table th,
.home-kba-table td {
    font-size: 0.85rem;
    padding: 10px;
}

.announcements-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.announcement-item {
    border-left: 3px solid var(--accent-blue);
    padding: 12px 16px;
    background: var(--bg-card-alt);
    border-radius: 0 8px 8px 0;
}

.announcement-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.announcement-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.announcement-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.announcement-summary {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.screenshot-announcements {
    gap: 14px;
}

.announcement-featured {
    border: 1px solid rgba(37, 99, 235, 0.35);
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.10);
    padding: 14px 16px;
}

.announcement-featured-chip {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-blue);
    background: rgba(37, 99, 235, 0.18);
    border-radius: 7px;
    padding: 2px 10px;
    margin-bottom: 8px;
}

.announcement-featured-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.announcement-featured-summary {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
}

.announcement-featured-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
}

.announcement-featured-link:hover {
    text-decoration: underline;
}

.announcement-row {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card-alt);
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.announcement-row-icon {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.announcement-row-content {
    flex: 1;
}

.announcement-row-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.announcement-row-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.announcement-row-badge {
    font-size: 0.78rem;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 2px 8px;
}

.announcement-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.announcement-title a:hover {
    text-decoration: underline;
    color: var(--accent-blue);
}

.bmb-view-all {
    float: right;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-blue);
    text-decoration: none;
    opacity: 0.8;
}

.bmb-view-all:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Home page demo entry animation */
.home-entry-ready .home-demo-entry .home-enter {
    opacity: 0;
    transform: translateY(16px) scale(0.99);
    animation: homeEnterFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.home-entry-ready .home-demo-entry .home-enter-1  { animation-delay: 0.05s; }
.home-entry-ready .home-demo-entry .home-enter-2  { animation-delay: 0.12s; }
.home-entry-ready .home-demo-entry .home-enter-3  { animation-delay: 0.20s; }
.home-entry-ready .home-demo-entry .home-enter-4  { animation-delay: 0.26s; }
.home-entry-ready .home-demo-entry .home-enter-5  { animation-delay: 0.33s; }
.home-entry-ready .home-demo-entry .home-enter-6  { animation-delay: 0.40s; }
.home-entry-ready .home-demo-entry .home-enter-7  { animation-delay: 0.47s; }
.home-entry-ready .home-demo-entry .home-enter-8  { animation-delay: 0.55s; }
.home-entry-ready .home-demo-entry .home-enter-9  { animation-delay: 0.62s; }
.home-entry-ready .home-demo-entry .home-enter-10 { animation-delay: 0.70s; }

@keyframes homeEnterFadeUp {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-entry-ready .home-demo-entry .home-enter {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* ── Theme toggle button ────────────────────────────────── */

/* Smooth transitions active only during an explicit theme switch */
.theme-transitioning,
.theme-transitioning * {
    transition: background-color 0.25s, color 0.25s, border-color 0.25s !important;
}
.theme-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    font-size: 0.82rem;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.theme-toggle svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* ── Metro Manila map label ─────────────────────────────── */
.metro-manila-label {
    background: rgba(59,130,246,0.85);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    border: 1px solid #3b82f6;
}

/* ── Dashboard stat card description text ──────────────── */
.dash-stat-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

.risk-medium-indicator {
    color: #eab308;
    font-weight: 600;
}

.risk-high-indicator {
    color: #ef4444;
    font-weight: 600;
}

/* Bird richness year-slider controls */
.bird-richness-controls {
    margin-bottom: 12px;
}

.bird-richness-controls .slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Extra small screens (≤480px) ───────────────────────── */
@media (max-width: 480px) {
    /* Stack stat cards to single column */
    .dash-stats {
        grid-template-columns: 1fr;
    }

    /* Tighten main content padding */
    .main-content {
        padding: 10px 8px;
    }

    /* Smaller page title */
    .page-title {
        font-size: 1.15rem;
    }

    /* Hide theme label text to save space */
    #themeLabel {
        display: none;
    }

    /* Tighter nav icon gap on very small screens */
    .nav-user {
        gap: 6px;
    }
}
