:root {
    --app-bg: #071827;
    --app-surface: #10283a;
    --app-surface-2: #16364a;
    --app-line: rgba(168, 209, 225, .14);
    --app-text: #f3f8fa;
    --app-muted: #9fb5c2;
    --app-accent: #38d39f;
    --app-blue: #2f8cff;
    --app-danger-species: #ff7b86;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--app-bg); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--app-text);
    background:
        radial-gradient(circle at 90% -5%, rgba(47, 140, 255, .22), transparent 32rem),
        linear-gradient(180deg, #071827, #091b28 55%, #06141f);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 1010;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: calc(.65rem + env(safe-area-inset-top)) 1rem .65rem;
    border-bottom: 1px solid var(--app-line);
    background: rgba(7, 24, 39, .84);
    backdrop-filter: blur(16px);
}

.app-brand { display: flex; align-items: center; gap: .7rem; color: white; font-size: 1.05rem; font-weight: 750; text-decoration: none; }
.app-brand img { width: 38px; height: 30px; object-fit: contain; object-position: left; }
.app-icon-button, .app-back {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    color: var(--app-text);
    border: 1px solid var(--app-line);
    border-radius: 14px;
    background: rgba(255,255,255,.04);
    text-decoration: none;
}

.app-main { width: min(100%, 1080px); margin: auto; padding: 1.1rem 1rem calc(6.5rem + env(safe-area-inset-bottom)); }
.app-hero { padding: 1.4rem 0 1.6rem; }
.app-hero h1, .app-page-title h1 { margin: .3rem 0 .45rem; font-size: clamp(1.65rem, 7vw, 2.5rem); letter-spacing: -.035em; }
.app-hero p { max-width: 36rem; margin: 0; color: var(--app-muted); }
.app-eyebrow { color: var(--app-accent); font-size: .7rem; font-weight: 800; letter-spacing: .15em; }
.app-page-title { display: flex; align-items: center; gap: .9rem; padding: .4rem 0 1rem; }
.app-page-title h1 { margin-bottom: 0; font-size: 1.65rem; }

.app-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.app-results-heading { flex-wrap: wrap; gap: .5rem; }
.app-results-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
#latest-results-filter .dropdown-menu { width: max-content; max-width: min(280px, calc(100vw - 3rem)); max-height: 320px; overflow-y: auto; }
#latest-results-filter .form-check-label { white-space: normal; }
#latest-results-species-options .form-check-label { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
#latest-results-species-options img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
#latest-results-filter-button.btn-outline-primary { color: #91c2ff; border-color: var(--app-blue); background: rgba(47,140,255,.1); }
.app-section-heading h2, .app-panel h2 { margin: 0; font-size: .98rem; }
.app-pill, .app-status {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: .25rem .65rem;
    border-radius: 99px;
    color: var(--app-muted);
    background: rgba(255,255,255,.07);
    font-size: .72rem;
    font-weight: 700;
}
.app-status.online { color: var(--edge-device-online-color); background: var(--edge-device-online-background); }
.app-status.offline { color: var(--edge-device-offline-color); background: var(--edge-device-offline-background); }
.app-status.neverConnected,
.app-status.noEdgeDevice { color: var(--edge-device-inactive-color); background: var(--edge-device-inactive-background); }

.app-card-list { display: grid; gap: .8rem; }
.app-project-card, .app-panel, .app-kpi, .app-device-hero {
    border: 1px solid var(--app-line);
    border-radius: 20px;
    background: linear-gradient(145deg, rgba(22, 54, 74, .92), rgba(12, 35, 51, .94));
    box-shadow: 0 16px 50px rgba(0,0,0,.14);
}
.app-project-card { display: block; padding: 1rem; color: var(--app-text); text-decoration: none; }
.app-project-card header { display: flex; justify-content: space-between; gap: 1rem; }
.app-project-card h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.app-project-card p { margin: 0; color: var(--app-muted); font-size: .78rem; }
.app-project-card footer { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-top: .7rem; }
.app-project-stat { padding: .55rem .25rem; border-radius: 12px; background: rgba(0,0,0,.14); text-align: center; }
.app-project-stat strong { display: block; font-size: 1rem; }
.app-project-stat span { display: block; overflow: hidden; color: var(--app-muted); font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.app-project-stat.danger { outline: 1px solid rgba(255,101,116,.55); background: rgba(220,53,69,.14); }
.app-project-stat.danger strong, .app-project-stat.danger span { color: #ffd2d2; }
.app-project-no-pest { grid-column: 1 / -1; padding: .65rem; color: var(--app-muted); text-align: center; font-size: .72rem; }
.app-project-filter { margin-bottom: .9rem; padding: .85rem; border: 1px solid var(--app-line); border-radius: 16px; background: rgba(0,0,0,.12); }
.app-project-filter summary { display: flex; align-items: center; justify-content: space-between; color: var(--app-text); font-size: .8rem; font-weight: 700; cursor: pointer; list-style: none; }
.app-project-filter summary::-webkit-details-marker { display: none; }
.app-project-filter summary > i { transition: transform .2s ease; }
.app-project-filter[open] summary > i { transform: rotate(180deg); }
.app-project-filter form { margin-top: .8rem; }
.app-project-filter label, .app-project-filter label > span { display: block; color: var(--app-muted); font-size: .72rem; }
.app-project-filter input, .app-project-filter select { margin-top: .3rem; color: var(--app-text); border-color: var(--app-line); background-color: var(--app-surface); }
.app-project-filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-top: .65rem; }
.app-danger-alert { flex: 0 0 auto; align-self: flex-start; padding: .35rem .55rem; border-radius: 99px; color: #ffd2d2; background: rgba(220,53,69,.28); font-size: .68rem; font-weight: 800; }
.app-safe-status { flex: 0 0 auto; color: #70efbd; font-size: .68rem; }
.app-danger-species { margin-top: .7rem; padding: .5rem .65rem; border-left: 3px solid #ff6574; color: #ffd2d2; background: rgba(220,53,69,.12); font-size: .75rem; }
.app-detection-status { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .75rem; color: var(--app-muted); font-size: .72rem; }
.app-detection-status strong { color: var(--app-text); }
.app-station-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .55rem; margin-top: .65rem; padding: .5rem .6rem; border-radius: 10px; color: var(--app-muted); background: rgba(0,0,0,.12); font-size: .66rem; }
.app-station-summary strong { margin-right: auto; color: var(--app-text); }
.app-station-summary .fa-circle { font-size: .48rem; }
.app-station-summary .online { color: #70efbd; }
.app-station-summary .offline { color: #ffbe87; }
.app-station-summary .never { color: #aebdc6; }
.app-project-heading-title { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.app-project-heading-title h2 { flex: 0 0 auto; }
.app-project-scope { overflow: hidden; color: var(--app-muted); font-size: .62rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.app-paging { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-top: 1rem; }
.app-paging span { color: var(--app-muted); font-size: .78rem; }
.app-paging .btn { min-width: 88px; border-radius: 12px; }

.app-station-filter .app-station-filter-meta { display: flex; align-items: center; gap: .55rem; }
.app-station-filter summary .app-pill { color: var(--app-muted); font-size: .68rem; }
.app-station-filter summary .app-station-filter-meta > i { transition: transform .2s ease; }
.app-station-filter[open] summary .app-station-filter-meta > i { transform: rotate(180deg); }
.app-station-filter .app-edge-device-switch { margin-top: .8rem; }
.app-mobile-sort { min-width: 0; margin-top: .8rem; }
.app-mobile-sort-label { display: block; margin-bottom: .35rem; color: var(--app-muted); font-size: .72rem; }
.app-mobile-sort-controls { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.app-mobile-sort-chips { display: flex; flex: 1 1 auto; gap: .4rem; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.app-mobile-sort-chips::-webkit-scrollbar { display: none; }
.app-sort-chip {
    flex: 0 0 auto;
    min-height: 36px;
    padding: .45rem .75rem;
    color: var(--app-muted);
    border: 1px solid var(--app-line);
    border-radius: 99px;
    background: rgba(255,255,255,.035);
    font-size: .7rem;
    white-space: nowrap;
}
.app-sort-chip.active { color: #06261e; border-color: var(--app-accent); background: var(--app-accent); font-weight: 750; }
.app-sort-direction {
    display: grid;
    flex: 0 0 38px;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--app-text);
    border: 1px solid var(--app-line);
    border-radius: 50%;
    background: var(--app-surface-2);
}
.app-edge-device-switch { display: flex; align-items: center; justify-content: flex-start; gap: .55rem; min-height: 28px; margin: 0; padding-left: 0; }
.app-edge-device-switch .form-check-input { flex: 0 0 auto; margin: 0; }
.app-edge-device-switch .form-check-input:checked { border-color: var(--app-accent); background-color: var(--app-accent); }
.app-edge-device-switch .form-check-input:focus { border-color: var(--app-accent); box-shadow: 0 0 0 .2rem rgba(56, 211, 159, .18); }
.app-edge-device-switch .form-check-label { color: var(--app-muted); font-size: .76rem; }
.app-station-list-card {
    display: block;
    padding: 1rem;
    color: var(--app-text);
    border: 1px solid var(--app-line);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(22, 54, 74, .92), rgba(12, 35, 51, .94));
    text-decoration: none;
    cursor: pointer;
}
.app-station-list-card:focus-visible { outline: 2px solid var(--app-accent); outline-offset: 2px; }
.app-station-list-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.app-station-list-card h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.app-station-list-card header p { margin: 0; color: var(--app-muted); font-size: .72rem; }
.app-station-list-card .app-status { flex: 0 0 auto; }
.app-station-list-card .app-status i { margin-right: .3rem; font-size: .45rem; }
.app-station-projects { display: flex; align-items: flex-start; gap: .55rem; margin-top: .75rem; padding: .55rem .65rem; border-radius: 11px; color: var(--app-muted); background: rgba(0,0,0,.13); font-size: .72rem; }
.app-station-projects i { margin-top: .15rem; color: var(--app-accent); }
.app-station-list-card dl { display: grid; gap: .45rem; margin: .75rem 0 0; }
.app-station-list-card dl > div { display: grid; grid-template-columns: minmax(86px, .7fr) minmax(0, 1.3fr); gap: .6rem; }
.app-station-list-card dt { color: var(--app-muted); font-size: .68rem; font-weight: 500; }
.app-station-list-card dd { overflow: hidden; margin: 0; font-size: .7rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.app-station-quick-tests { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .8rem; }
.app-station-quick-tests .btn { min-width: 0; min-height: 38px; padding-inline: .35rem; border-radius: 11px; font-size: .7rem; }
.app-station-quick-tests .btn:disabled { position: relative; opacity: .48; }
.app-station-quick-tests .app-disabled-indicator { margin-left: .35rem; font-size: .62rem; }
.app-station-command-result { grid-column: 1 / -1; padding: .45rem .55rem; color: var(--app-muted); border-radius: 9px; background: rgba(0,0,0,.14); font-size: .68rem; }
.app-station-command-result.success { color: #70efbd; }
.app-station-command-result.error { color: #ff9da6; }
.app-station-capture-preview { grid-column: 1 / -1; width: 100%; padding: 0; overflow: hidden; border: 1px solid var(--app-line); border-radius: 11px; background: #02080d; cursor: zoom-in; }
.app-station-capture-preview strong { display: block; padding: .45rem .6rem; color: var(--app-text); border-bottom: 1px solid var(--app-line); text-align: left; font-size: .72rem; }
.app-station-capture-preview img { display: block; width: 100%; height: 160px; object-fit: contain; }
.app-station-list-card footer { margin-top: .8rem; }
.app-station-list-card footer a { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; color: var(--app-accent); font-size: .7rem; font-weight: 700; text-decoration: none; }

.app-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-bottom: .9rem; }
.app-toolbar label { min-width: 0; width: 100%; color: var(--app-muted); font-size: .72rem; }
.app-toolbar select { width: 100%; margin-top: .3rem; border-color: var(--app-line); background-color: var(--app-surface); }
.app-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: .8rem; }
.app-kpi { min-height: 125px; padding: .9rem; }
.app-kpi span, .app-kpi small { display: block; color: var(--app-muted); font-size: .7rem; }
.app-kpi strong { display: block; margin: .5rem 0 .15rem; overflow: hidden; font-size: 1.35rem; text-overflow: ellipsis; white-space: nowrap; }
.app-kpi-primary { background: linear-gradient(145deg, #176559, #10483f); }
.app-kpi-primary strong { font-size: 2rem; color: #8effd6; }
.app-peak-species { display: flex !important; justify-content: space-between; gap: .4rem; margin-top: .18rem; }
.app-peak-species b { overflow: hidden; color: var(--app-text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.app-peak-species.danger, .app-peak-species.danger b { color: var(--app-danger-species); }
.app-peak-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem; margin-top: .55rem; }
.app-peak-images a { display: block; overflow: hidden; border: 1px solid var(--app-line); border-radius: 8px; background: #02080d; }
.app-peak-images img { display: block; width: 100%; height: 52px; object-fit: cover; }
.app-kpi.danger { outline: 1px solid rgba(255,101,116,.6); background: linear-gradient(145deg, rgba(112,34,46,.94), rgba(56,25,36,.94)); }
.app-kpi.danger strong { color: #ffd2d2; }
.app-latest-capture { min-height: 0; }
.app-latest-capture > a { display: block; margin-top: .55rem; color: var(--app-text); text-decoration: none; }
.app-latest-capture img { width: 100%; height: 112px; border: 1px solid var(--app-line); border-radius: 11px; background: #02080d; object-fit: cover; }
.app-latest-capture a strong { display: block; margin: .5rem 0 .3rem; overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.app-latest-capture a small { display: block; margin-top: .18rem; }
.app-latest-capture-empty { margin-top: .65rem; padding: .7rem; border-radius: 10px; color: var(--app-muted); background: rgba(0,0,0,.12); text-align: center; font-size: .72rem; }
.app-monitoring-filter .app-toolbar { margin: .8rem 0 0; }
.app-monitoring-danger { display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem; padding: .85rem 1rem; border: 1px solid rgba(255,101,116,.55); border-radius: 16px; color: #ffd2d2; background: rgba(220,53,69,.16); }
.app-monitoring-danger[hidden] { display: none; }
.app-monitoring-danger > i { font-size: 1.25rem; }
.app-monitoring-danger strong, .app-monitoring-danger small { display: block; }
.app-monitoring-danger small { margin-top: .15rem; color: #ffb9c0; font-size: .7rem; }
.app-monitoring-station-status { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .65rem; color: var(--app-muted); font-size: .69rem; }
details.app-panel summary.app-monitoring-station-status { justify-content: flex-start; }
.app-monitoring-station-status strong { margin-right: auto; color: var(--app-text); }
.app-monitoring-station-status .fa-circle { font-size: .5rem; }
.app-monitoring-station-status .online { color: var(--edge-device-online-color); }
.app-monitoring-station-status .offline { color: var(--edge-device-offline-color); }
.app-monitoring-station-status .never { color: var(--edge-device-inactive-color); }
.app-monitoring-station-status .app-summary-chevron { margin-left: .15rem; color: var(--app-muted); transition: transform .2s ease; }
details[open] > .app-monitoring-station-status .app-summary-chevron { transform: rotate(180deg); }
.app-panel { margin-bottom: .8rem; padding: 1rem; overflow: hidden; }
details.app-panel { padding: 0; }
details.app-panel summary { display: flex; justify-content: space-between; padding: 1rem; font-size: .98rem; font-weight: 650; cursor: pointer; list-style: none; }
.app-collapsible-content { padding: 0 1rem 1rem; }
.app-project-risk-overview { flex-basis: 100%; display: grid; gap: .35rem; margin-top: .4rem; font-weight: 400; }
.app-project-risk-group { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .5rem; align-items: baseline; }
.app-project-risk-group.danger { color: #ffb9c0; }
.app-project-risk-group.normal { color: var(--edge-device-online-color); }
.app-project-risk-group.no-data { color: var(--app-muted); }
.app-project-risk-names { overflow-wrap: anywhere; font-weight: 400; }

.app-map { height: min(58vh, 420px); border-top: 1px solid var(--app-line); background: #0c2637; }
.app-map-popup { min-width: 180px; max-width: min(260px, 72vw); max-height: 230px; overflow: auto; padding: .75rem; border: 1px solid var(--bs-border-color); border-radius: .75rem; background: var(--bs-body-bg); box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.22); }
.app-map-popup strong, .app-map-popup small, .app-map-popup div { display: block; }
.app-map-popup > small { margin-bottom: .4rem; color: var(--bs-secondary-color); }
.app-map-popup-close { float: right; border: 0; background: transparent; color: var(--bs-secondary-color); font-size: 1.25rem; line-height: 1; }
.app-map .ol-layerswitcher { top: .55rem; right: .55rem; left: auto; }
.app-map .ol-layerswitcher > button { width: 2rem; height: 2rem; border-radius: .45rem; font-size: 1.35rem !important; overflow: visible; box-sizing: border-box; }
.app-map .ol-layerswitcher > button::before, .app-map .ol-layerswitcher > button::after { left: .42rem; }
.app-map .ol-layerswitcher .panel { width: min(210px, 62vw); max-height: 45vh; font-size: .78rem; }
.app-map .ol-layerswitcher .panel-container { width: min(210px, 62vw); }
.app-map .ol-layerswitcher .li-content { padding-top: .15rem; padding-bottom: .15rem; }
.app-map-page { overflow: hidden; }
.app-map-page .app-header, .app-map-page .app-bottom-nav { display: none; }
.app-global-map-page .app-bottom-nav { display: flex; }
.app-project-map-page .app-bottom-nav { display: flex; }
.app-map-page .app-main { width: 100%; max-width: none; height: 100dvh; margin: 0; padding: 0; }
.app-project-workspace { position: fixed; z-index: 0; inset: 0; background: #0c2637; }
.app-project-map { width: 100%; height: 100%; border: 0; }
.app-project-map .ol-zoom { display: none; }
.app-project-map .ol-layerswitcher { z-index: 40; top: calc(.75rem + env(safe-area-inset-top)); }
.app-project-map .ol-layerswitcher .panel-container,
.app-project-map .ol-layerswitcher .panel { position: relative; z-index: 41; }
.app-project-layer-switcher { position: absolute !important; z-index: 60 !important; top: calc(.75rem + env(safe-area-inset-top)) !important; right: max(.65rem, env(safe-area-inset-right)) !important; left: auto !important; }
.app-project-layer-switcher > button { width: 2rem; height: 2rem; border-radius: .45rem; font-size: 1.35rem !important; overflow: visible; box-sizing: border-box; }
.app-project-layer-switcher > button::before, .app-project-layer-switcher > button::after { left: .42rem; }
.app-project-layer-switcher .panel { position: relative; z-index: 61; width: min(210px, 62vw); max-height: 45vh; font-size: .78rem; }
.app-project-layer-switcher .panel-container { position: relative; z-index: 61; width: min(210px, 62vw); }
.app-station-status-legend {
    position: absolute;
    z-index: 55;
    top: calc(3.25rem + env(safe-area-inset-top));
    right: max(.65rem, env(safe-area-inset-right));
    display: grid;
    gap: .25rem;
    padding: .4rem .5rem;
    color: var(--app-text);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 10px;
    background: rgba(7,24,39,.88);
    box-shadow: 0 6px 18px rgba(0,0,0,.25);
    font-size: .58rem;
    pointer-events: none;
    backdrop-filter: blur(12px);
}
.app-station-status-legend span { display: flex; align-items: center; gap: .35rem; }
.app-station-status-legend i { width: .55rem; height: .55rem; border: 2px solid #fff; border-radius: 50%; }
.app-station-status-legend i.online { background: #198754; }
.app-station-status-legend i.offline { background: #fd9843; }
.app-station-status-legend i.never { background: #adb5bd; }
.app-project-map-overlay {
    position: absolute;
    z-index: 10;
    top: calc(.65rem + env(safe-area-inset-top));
    left: max(.65rem, env(safe-area-inset-left));
    width: calc(100vw - 1.3rem - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-width: 1060px;
    pointer-events: none;
}
.app-project-map-overlay > * { pointer-events: auto; }
.app-project-map-overlay .app-page-title { width: calc(100% - 4.5rem); min-height: 44px; padding: 0 0 .55rem; filter: drop-shadow(0 2px 8px rgba(0,0,0,.55)); }
.app-project-map-overlay .app-page-title > div { min-width: 0; padding: .35rem .65rem; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; background: rgba(3,14,23,.9); box-shadow: 0 5px 18px rgba(0,0,0,.4); backdrop-filter: blur(14px); }
.app-project-map-overlay .app-page-title h1 { max-width: 100%; margin-top: .08rem; overflow: hidden; color: #fff; font-size: 1rem; font-weight: 800; text-shadow: 0 1px 3px #000; text-overflow: ellipsis; white-space: nowrap; }
.app-project-map-overlay .app-page-title .app-eyebrow { color: #7dffd2; text-shadow: 0 1px 2px #000; }
.app-project-map-overlay .app-page-title .app-back { width: 38px; height: 38px; border-color: rgba(255,255,255,.22); background: rgba(7,24,39,.78); backdrop-filter: blur(12px); }
.app-project-map-overlay .app-project-filter { width: calc(100% - 4.5rem); margin-bottom: .45rem; padding: .55rem .65rem; border-color: rgba(255,255,255,.2); background: rgba(7,24,39,.88); box-shadow: 0 8px 24px rgba(0,0,0,.25); backdrop-filter: blur(16px); }
.app-project-map-overlay .app-toolbar { gap: .45rem; margin-top: .6rem; }
.app-project-map-overlay .app-toolbar select { font-size: .72rem; }
.app-project-map-overlay .app-loading { padding: .65rem; border-radius: 14px; background: rgba(7,24,39,.82); backdrop-filter: blur(14px); }
.app-project-map-overlay .app-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .3rem; margin: 0; padding: 0; }
.app-project-map-overlay .app-kpi { min-width: 0; min-height: 72px; padding: .45rem; border-radius: 12px; background: rgba(10,31,45,.9); backdrop-filter: blur(16px); }
.app-project-map-overlay .app-kpi-primary { background: rgba(16,82,70,.92); }
.app-project-map-overlay .app-kpi span, .app-project-map-overlay .app-kpi small { overflow: hidden; font-size: .56rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.app-project-map-overlay .app-kpi strong { margin: .22rem 0 .08rem; font-size: .82rem; line-height: 1.1; }
.app-project-map-overlay .app-kpi-primary strong { font-size: 1.15rem; }
.app-project-map-overlay #kpi-species { overflow: visible; font-size: .66rem; line-height: 1.15; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
.app-project-map-overlay #global-top-species { overflow: visible; font-size: .66rem; line-height: 1.15; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
.app-project-map-overlay #kpi-species-card.danger #kpi-species { color: var(--app-danger-species); }
.app-project-map-overlay .app-peak-species { display: block !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-project-map-overlay .app-peak-species.danger, .app-project-map-overlay .app-peak-species.danger b { color: var(--app-danger-species); font-weight: 800; }
.app-project-map-overlay .app-peak-images { display: none; }
.app-project-map-overlay .app-latest-capture img { display: block; width: 38px; height: 38px; border-radius: 7px; }
.app-project-map-overlay .app-latest-capture > a { display: grid; grid-template-columns: 38px minmax(0,1fr); gap: .3rem; align-items: center; margin-top: .2rem; }
.app-project-map-overlay .app-latest-capture a strong { margin: 0 0 .08rem; font-size: .56rem; line-height: 1.15; }
.app-project-map-overlay .app-latest-capture .app-kpi-species-danger { color: var(--app-danger-species); font-weight: 800; }
.app-project-map-overlay .app-latest-capture a small { margin-top: .05rem; font-size: .46rem; line-height: 1.15; }
.app-project-sheet {
    --sheet-offset: 48dvh;
    position: fixed;
    z-index: 1010;
    top: max(.4rem, env(safe-area-inset-top));
    right: max(.5rem, env(safe-area-inset-right));
    bottom: 0;
    left: max(.5rem, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    max-width: 1060px;
    margin: auto;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.16);
    border-bottom: 0;
    border-radius: 28px 28px 0 0;
    background: rgba(10,31,45,.9);
    box-shadow: 0 -12px 50px rgba(0,0,0,.36);
    backdrop-filter: blur(22px);
    transform: translateY(var(--sheet-offset));
    transition: transform .32s cubic-bezier(.22,.8,.25,1);
    will-change: transform;
}
.app-project-sheet.dragging { transition: none; }
.app-project-sheet-handle { flex: 0 0 30px; width: 100%; padding: 0; border: 0; background: transparent; touch-action: none; cursor: ns-resize; }
.app-project-sheet-handle span { display: block; width: 48px; height: 5px; margin: 10px auto; border-radius: 99px; background: rgba(220,235,241,.48); }
.app-project-sheet-scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 1rem calc(1.5rem + env(safe-area-inset-bottom) + var(--sheet-offset));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}
.app-project-sheet .app-page-title { padding-top: .2rem; }
.app-project-sheet .app-page-title > div { min-width: 0; }
.app-project-sheet .app-page-title h1 { overflow: hidden; color: #fff; text-overflow: ellipsis; white-space: nowrap; }
.app-project-sheet .app-back { flex: 0 0 auto; }
.app-project-sheet .app-loading { padding-top: 1.5rem; }

.app-chart-grid { display: grid; gap: .8rem; }
.app-chart { height: 280px; margin-top: .6rem; }
.app-station-strip { display: grid; gap: .55rem; }
.app-station-chip { padding: .75rem .8rem; color: var(--app-text); border: 1px solid var(--app-line); border-radius: 14px; background: rgba(0,0,0,.12); text-decoration: none; }
.app-station-chip > div { display: flex; align-items: center; justify-content: space-between; margin-bottom: .45rem; }
.app-station-chip > div i { color: var(--app-muted); font-size: .7rem; }
.app-station-chip strong, .app-station-chip small { display: block; }
.app-station-chip small { margin-top: .25rem; color: var(--app-muted); }
.app-image-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: .7rem; }
.app-image-card { display: grid; grid-template-columns: minmax(125px, 42%) minmax(0, 1fr); overflow: hidden; border: 1px solid var(--app-line); border-radius: 15px; background: rgba(0,0,0,.18); }
.app-image-card > img { width: 100%; height: 100%; min-height: 135px; object-fit: cover; background: #02080d; }
.app-image-result { min-width: 0; padding: .7rem; font-size: .72rem; }
.app-image-meta { padding-bottom: .5rem; border-bottom: 1px solid var(--app-line); }
.app-image-meta strong, .app-image-meta small { display: block; }
.app-image-meta small, .app-image-species > small { color: var(--app-muted); }
.app-image-species { display: grid; gap: .35rem; padding-top: .55rem; }
.app-image-species span { display: flex; align-items: start; justify-content: space-between; gap: .5rem; }
.app-image-species span b { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.app-image-species span strong { flex: 0 0 auto; color: var(--app-accent); }
.app-image-species span.danger, .app-image-species span.danger strong { color: var(--bs-danger); font-weight: 700; }

.app-global-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .5rem 0 1rem; }
.app-global-heading > div { min-width: 0; margin-right: auto; }
.app-global-heading .app-back { flex: 0 0 auto; }
.app-global-heading h1 { margin: .2rem 0 .3rem; font-size: clamp(1.08rem, 4.8vw, 1.45rem); }
.app-global-heading p { max-width: 38rem; margin: 0; color: var(--app-muted); font-size: .8rem; }
.app-global-heading .app-icon-button { position: relative; flex: 0 0 auto; }
#global-alert-badge { position: absolute; display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; color: #fff; background: #dc3545; font-size: .58rem; line-height: 1; }
#global-alert-badge { top: -5px; right: -5px; }
#global-alert-badge[hidden] { display: none; }
.app-global-filter form { margin-top: .75rem; }
.app-global-filter:not([open]) form { display: none; }
.app-monitoring-filter:not([open]) .app-toolbar { display: none; }
.app-global-filter summary { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: .45rem; }
.app-global-filter summary small { display: block; min-width: 0; overflow: hidden; color: var(--app-muted); font-size: .57rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.app-global-filter[open] summary small { display: none; }
.app-kpi .app-kpi-source { display: block; overflow: hidden; margin-top: .08rem; color: var(--app-muted); font-size: .52rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.app-global-filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.app-global-filter-grid label, .app-global-filter-grid label > span { display: block; color: var(--app-muted); font-size: .7rem; }
.app-global-filter-grid input, .app-global-filter-grid select { margin-top: .3rem; border-color: var(--app-line); background-color: var(--app-surface); }
.app-global-filter-actions { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: .75rem; }
.app-global-filter-actions .form-check { margin: 0; color: var(--app-text); font-size: .72rem; }
.app-global-kpis { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; margin-bottom: .8rem; }
.app-global-kpis .app-kpi { color: var(--app-text); text-align: left; }
.app-global-kpis .app-kpi.danger { border-color: rgba(255,101,116,.55); }
.app-global-safe { display: flex; align-items: center; gap: .65rem; margin-bottom: .8rem; padding: .8rem 1rem; color: #70efbd; border: 1px solid rgba(56,211,159,.3); border-radius: 14px; background: rgba(56,211,159,.09); font-size: .78rem; }
.app-global-safe[hidden] { display: none; }
.app-global-map-panel { padding: 0; }
.app-global-map-panel .app-section-heading { padding: 1rem 1rem 0; }
.app-global-map-panel .app-section-heading small { color: var(--app-muted); font-size: .62rem; }
.app-global-map-panel .app-map { height: min(55vh, 520px); }
.app-global-ranking { display: grid; gap: .5rem; }
.app-global-rank { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: .65rem; align-items: center; padding: .7rem; color: var(--app-text); border: 1px solid var(--app-line); border-radius: 13px; background: rgba(0,0,0,.12); text-decoration: none; cursor: pointer; }
.app-global-rank > b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.08); font-size: .7rem; }
.app-global-rank div { min-width: 0; }
.app-global-rank div strong, .app-global-rank div small, .app-global-rank div span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-global-rank div strong { font-size: .8rem; }
.app-global-rank div small, .app-global-rank div span { margin-top: .15rem; color: var(--app-muted); font-size: .65rem; }
.app-global-rank aside { text-align: right; }
.app-global-rank aside strong, .app-global-rank aside small { display: block; }
.app-global-rank aside small { color: var(--app-danger-species); font-size: .62rem; }
.app-rank-zoom { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; margin-top: .35rem; margin-left: auto; padding: 0; color: #fff; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; background: rgba(255,255,255,.08); }
.app-global-rank.danger { border-color: rgba(255,101,116,.38); background: rgba(90,25,38,.16); }
.app-alert-center[hidden] { display: none; }
.app-map-alert-control { position: absolute; z-index: 65; top: calc(.75rem + env(safe-area-inset-top)); right: calc(3.15rem + env(safe-area-inset-right)); pointer-events: none; }
.app-map-alert-control > .app-icon-button { position: relative; display: grid; width: 2rem; height: 2rem; margin-left: auto; color: #fff; border-color: rgba(255,255,255,.25); background: rgba(7,24,39,.92); box-shadow: 0 6px 18px rgba(0,0,0,.3); pointer-events: auto; }
.app-map-alert-control .app-alert-center { width: min(360px,calc(100vw - 1.3rem)); max-height: min(55vh,430px); margin-top: .45rem; overflow: auto; border: 1px solid rgba(255,255,255,.2); background: rgba(7,24,39,.96); box-shadow: 0 12px 32px rgba(0,0,0,.42); pointer-events: auto; }
.app-map-alert-control .app-section-heading { position: sticky; z-index: 1; top: 0; padding: .65rem; background: rgba(7,24,39,.98); }
.app-alert-row { display: grid; grid-template-columns: 52px minmax(0,1fr); gap: .65rem; align-items: center; padding: .6rem; color: var(--app-text); border-bottom: 1px solid var(--app-line); text-decoration: none; }
.app-alert-row img, .app-alert-row > i { width: 52px; height: 45px; border-radius: 9px; object-fit: cover; }
.app-alert-row > i { display: grid; place-items: center; color: var(--app-danger-species); background: rgba(220,53,69,.14); }
.app-alert-row strong, .app-alert-row small { display: block; }
.app-alert-row strong { font-size: .72rem; }
.app-alert-row small { margin-top: .2rem; color: var(--app-muted); font-size: .62rem; }
.app-alert-row.unread { border-left: 3px solid var(--app-danger-species); background: rgba(220,53,69,.08); }
.app-danger-toast { display: grid; grid-template-columns: 54px minmax(0,1fr) 24px; gap: .6rem; align-items: center; width: min(420px,calc(100vw - 2rem)); margin-bottom: .5rem; padding: .65rem; color: #fff; border: 1px solid rgba(255,130,140,.6); border-radius: 14px; background: rgba(78,20,31,.96); box-shadow: 0 12px 35px rgba(0,0,0,.42); text-decoration: none; }
.app-danger-toast > img { width: 54px; height: 50px; border-radius: 9px; object-fit: cover; }
.app-danger-toast strong, .app-danger-toast span, .app-danger-toast small { display: block; }
.app-danger-toast strong { color: #ffd3d8; font-size: .74rem; }
.app-danger-toast span { margin-top: .15rem; font-size: .68rem; }
.app-danger-toast small { margin-top: .15rem; color: #eebbc1; font-size: .58rem; }
.app-danger-toast button { align-self: start; color: #fff; border: 0; background: transparent; font-size: 1.1rem; }
.app-map-alert-toasts { position: relative; z-index: 80; display: grid; justify-items: end; width: 100%; margin-top: .5rem; pointer-events: none !important; }
.app-map-alert-toasts .app-danger-toast { pointer-events: auto; }
.app-map-alert-image { display: block; width: 100%; margin: 0 0 .55rem; padding: 0; overflow: hidden; border: 0; border-radius: 9px; background: #02080d; }
.app-map-alert-image img { display: block; width: 100%; max-height: 155px; object-fit: cover; }
.app-global-map-page .app-project-sheet-scroll { padding-bottom: calc(9.5rem + env(safe-area-inset-bottom) + var(--sheet-offset)); }
.app-project-map-page .app-project-sheet-scroll { padding-bottom: calc(9.5rem + env(safe-area-inset-bottom) + var(--sheet-offset)); }
.app-station-chip .app-station-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .5rem; }
.app-station-chip .app-station-detail { padding: .25rem .55rem; font-size: .62rem; }

.app-device-hero { display: flex; align-items: center; justify-content: space-between; padding: 1.15rem; margin-bottom: .8rem; }
.app-device-hero h2 { margin: .7rem 0 .2rem; }
.app-device-hero p { margin: 0; color: var(--app-muted); }
.app-device-hero > i { color: var(--app-accent); font-size: 2.5rem; opacity: .8; }
.app-station-detail-hero { justify-content: flex-start; gap: .85rem; }
.app-station-detail-hero > div { flex: 1 1 auto; min-width: 0; }
.app-station-detail-hero h1 { margin: .55rem 0 .15rem; overflow: hidden; font-size: 1.45rem; text-overflow: ellipsis; white-space: nowrap; }
.app-station-detail-hero > i { flex: 0 0 auto; }
.app-command-grid .app-disabled-indicator { margin-left: .4rem; font-size: .65rem; }
.app-data-list { display: grid; grid-template-columns: 1fr 1.25fr; margin: .8rem 0 0; gap: 0; }
.app-data-list dt, .app-data-list dd { margin: 0; padding: .65rem 0; border-bottom: 1px solid var(--app-line); font-size: .78rem; }
.app-data-list dt { color: var(--app-muted); font-weight: 500; }
.app-data-list dd { overflow-wrap: anywhere; text-align: right; }
.app-command-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.app-command-grid button { min-height: 50px; border-radius: 13px; font-size: .78rem; }
.app-command-grid button:last-child { grid-column: 1 / -1; }
.app-command-result { margin-top: .8rem; padding: .8rem; border-radius: 12px; background: rgba(255,255,255,.06); font-size: .78rem; }
.app-command-result.success { color: #78edbe; }
.app-command-result.error { color: #ffaaa4; }
.app-command-preview { margin: .8rem 0 0; }
.app-command-preview figcaption { margin-bottom: .4rem; color: var(--app-text); font-size: .8rem; font-weight: 700; }
.app-capture-preview { width: 100%; max-height: 440px; border-radius: 14px; object-fit: contain; background: #000; cursor: zoom-in; }
.camera-section-frame { width: 100%; aspect-ratio: 4 / 3; }
.camera-section-pwa [data-camera-status] { padding: .2rem .55rem; border-radius: 999px; background: rgba(255,255,255,.1); font-size: .72rem; }

.app-bottom-nav {
    position: fixed;
    z-index: 1020;
    bottom: calc(.7rem + env(safe-area-inset-bottom));
    left: 50%;
    display: flex;
    width: fit-content;
    max-width: calc(100vw - 1.5rem);
    min-height: 64px;
    padding: .35rem;
    border: 1px solid var(--app-line);
    border-radius: 22px;
    background: rgba(12, 35, 51, .94);
    box-shadow: 0 16px 50px rgba(0,0,0,.38);
    backdrop-filter: blur(18px);
    transform: translateX(-50%);
}
.app-bottom-nav a, .app-bottom-nav button { display: flex; flex: 0 1 clamp(68px,22vw,110px); width: clamp(68px,22vw,110px); min-width: 0; flex-direction: column; align-items: center; justify-content: center; gap: .22rem; color: var(--app-muted); border: 0; border-radius: 16px; background: transparent; font-size: .64rem; text-decoration: none; }
.app-bottom-nav a i, .app-bottom-nav button i { font-size: 1rem; }
.app-bottom-nav .active { color: #fff; background: rgba(47,140,255,.16); }
.app-profile { height: auto !important; color: var(--app-text); border-radius: 24px 24px 0 0; background: var(--app-surface); }
.app-network-banner { position: fixed; z-index: 1100; top: 0; right: 0; left: 0; padding: .55rem; color: #241002; background: #ffb36f; text-align: center; font-size: .75rem; }
.app-update { position: fixed; z-index: 1100; right: 1rem; bottom: calc(6rem + env(safe-area-inset-bottom)); left: 1rem; display: flex; align-items: center; justify-content: space-between; max-width: 480px; margin: auto; padding: .8rem; border-radius: 14px; background: #eff9ff; color: #10283a; box-shadow: 0 12px 40px #0008; font-size: .8rem; }
.app-loading, .app-empty { padding: 2.5rem 1rem; color: var(--app-muted); text-align: center; }
.app-empty i, .app-offline-page > i { display: block; margin-bottom: 1rem; color: var(--app-accent); font-size: 2.5rem; }
.app-offline-page { padding-top: 20vh; }

@media (min-width: 720px) {
    .app-card-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .app-kpi-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
    .app-chart-grid { grid-template-columns: 1fr 1fr; }
    .app-image-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .app-data-grid { grid-template-columns: repeat(4, 1fr); }
    .app-data-grid > dd:nth-child(4n + 2) { padding-right: .85rem; }
    .app-data-grid > dt:nth-child(4n + 3) { padding-left: .85rem; }
    .app-global-filter-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
    .app-global-kpis { grid-template-columns: repeat(4,minmax(0,1fr)); }
}

/* iOS zooms the viewport when a focused form control renders below 16px. */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        body[data-app-root] input,
        body[data-app-root] select,
        body[data-app-root] textarea,
        body[data-app-root] .form-control,
        body[data-app-root] .form-select {
            font-size: 16px !important;
        }
    }
}

@media (display-mode: standalone) {
    .app-header { padding-top: calc(.8rem + env(safe-area-inset-top)); }
}
