* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

#react-entry-point,
#_dash-app-content,
#_dash-app-content > div {
    width: 100%;
    height: 100%;
}

body {
    font-family: "Inter", Arial, sans-serif;
    background: #0d1117;
    overflow: hidden;
    overscroll-behavior: none;
}

.app-shell {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    color: #e6edf3;
    background: #0d1117;
    overflow: hidden;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #ffffff;
}

.loading-overlay__logo {
    width: auto;
    height: 80px;
    max-width: min(260px, 70vw);
    margin-bottom: 24px;
}

.loading-overlay__spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #002f5a;
    border-radius: 999px;
    animation: spin 1s linear infinite;
}

.loading-overlay__text {
    margin: 16px 0 0;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
}

.app-header {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    padding: 14px clamp(16px, 3vw, 28px);
    background: #002f5a;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.app-header__logo {
    display: block;
    flex: 0 0 auto;
    width: auto;
    height: clamp(42px, 5.2vw, 54px);
}

.app-header__copy {
    flex: 1 1 280px;
    min-width: 220px;
}

.app-header__title {
    margin: 0;
    color: #ffffff;
    font-size: clamp(0.96rem, 1.7vw, 1.12rem);
    font-weight: 800;
    line-height: 1.18;
}

.app-header__subtitle {
    margin: 3px 0 0;
    color: #f3f4f6;
    font-size: clamp(0.72rem, 1.2vw, 0.8rem);
    font-weight: 700;
    line-height: 1.25;
}

.stats-row {
    display: flex;
    flex: 0 1 auto;
    gap: 8px;
    min-width: 0;
}

.stat-card {
    min-width: 100px;
    padding: 10px 18px;
    text-align: center;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(17, 24, 39, 0.16);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(17, 24, 39, 0.16);
}

.stat-card__value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card__label {
    margin-top: 4px;
    color: #374151;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.15;
}

.map-loading {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
}

.map-loading > div,
.map-loading [data-dash-is-loading] {
    width: 100% !important;
    height: 100% !important;
}

.map-graph {
    width: 100%;
}

#mapa-principal {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
}

#mapa-principal .js-plotly-plot,
#mapa-principal .plot-container,
#mapa-principal .svg-container,
#mapa-principal .main-svg,
#mapa-principal .mapboxgl-map,
#mapa-principal .mapboxgl-canvas,
#mapa-principal .mapboxgl-canvas-container,
#mapa-principal .maplibregl-map,
#mapa-principal .maplibregl-canvas,
#mapa-principal .maplibregl-canvas-container {
    width: 100% !important;
    height: 100% !important;
}

.filter-bar {
    position: absolute;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    left: max(16px, env(safe-area-inset-left));
    z-index: 1000;
    display: flex;
    justify-content: center;
    gap: 8px;
    max-width: 560px;
    margin: 0 auto;
    padding: 6px 8px;
    overflow-x: auto;
    background: rgba(22, 27, 34, 0.92);
    border: 1px solid #30363d;
    border-radius: 999px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 20px;
    color: #8b949e;
    font: 600 0.8rem "Inter", Arial, sans-serif;
    white-space: nowrap;
    letter-spacing: 0.01em;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    border: 0;
    border-radius: 999px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.filter-btn:hover {
    transform: translateY(-1px);
}

.filter-btn--all.is-active {
    color: #0d1117;
    background: #e6edf3;
}

.filter-btn--sim.is-active {
    color: #ffffff;
    background: #2196f3;
}

.filter-btn--nao.is-active {
    color: #ffffff;
    background: #f44336;
}

@media (max-width: 1024px) {
    .app-header {
        align-items: flex-start;
        gap: 10px 16px;
    }

    .stats-row {
        flex: 1 1 100%;
    }

    .stat-card {
        flex: 1 1 0;
        min-width: 0;
        padding: 9px 12px;
    }
}

@media (max-width: 768px) {
    .app-shell {
        min-height: 100dvh;
    }

    .app-header {
        padding: 10px 12px;
    }

    .app-header__logo {
        height: 40px;
    }

    .app-header__copy {
        flex-basis: calc(100% - 56px);
        min-width: 0;
    }

    .app-header__title {
        font-size: 0.95rem;
    }

    .app-header__subtitle {
        font-size: 0.7rem;
    }

    .stats-row {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .stat-card {
        padding: 8px 6px;
    }

    .stat-card__value {
        font-size: 1.05rem;
    }

    .stat-card__label {
        font-size: 0.58rem;
    }

    .filter-bar {
        justify-content: flex-start;
        max-width: none;
        padding: 6px;
        border-radius: 18px;
    }

    .filter-btn {
        min-height: 36px;
        padding: 8px 14px;
        font-size: 0.76rem;
    }
}

@media (max-width: 420px) {
    .app-header {
        gap: 8px 10px;
    }

    .app-header__logo {
        height: 34px;
    }

    .app-header__copy {
        flex-basis: calc(100% - 46px);
    }

    .app-header__title {
        font-size: 0.86rem;
    }

    .app-header__subtitle {
        font-size: 0.64rem;
    }

    .stat-card {
        padding: 7px 4px;
    }

    .stat-card__value {
        font-size: 0.95rem;
    }

    .filter-btn {
        padding: 8px 12px;
        font-size: 0.72rem;
    }
}
