body {
    margin: 0;
    padding: 0;
    background-color: #ededed;
    color: #333;
}

/* Fullscreen */
.fullscreen-toggle-btn {
    position: absolute;
    top: 0.8rem;
    right: 1rem;
    z-index: 1000;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 0.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    font-family: "Font Awesome 6 Free" !important;
}

.fullscreen-toggle-btn:hover {
    background-color: #0056b3;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
}

.fullscreen-toggle-btn:active {
    transform: scale(0.95);
}

/* Geolocation button styles */
.leaflet-control-geolocation {
    background: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    cursor: pointer;
    display: block;
    height: 30px;
    width: 30px;
    text-align: center;
    line-height: 26px;
    font-size: 18px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
}

.leaflet-control-geolocation:hover {
    background: #f4f4f4;
    color: #000;
    border-color: rgba(0,0,0,0.3);
}

.leaflet-control-geolocation:active {
    background: #e4e4e4;
}

.leaflet-control-geolocation.loading {
    animation: spin 2s linear infinite;
    color: #000;
}

.leaflet-control-geolocation.active {
    color: #007bff;
    background: #f0f8ff;
    border-color: #007bff;
}

.leaflet-control-geolocation.found {
    color: #28a745;
    background: #f8fff8;
}

.leaflet-control-geolocation.error {
    color: #dc3545;
    background: #fff8f8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 767px) {
    .leaflet-control-geolocation {
        width: 28px;
        height: 28px;
        line-height: 22px;
        font-size: 24px;
        border-radius: 6px;
        margin-left: 0.1rem;
    }
}

.dashboard-container.stats-expanded #type-stats-panel {
    position: absolute;
    top: 0rem;
    left: 0rem;
    right: 1rem;
    bottom: 1rem;
    width: auto;
    height: calc(100% - 2rem);
    max-height: none !important;
    z-index: 1500;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
    overflow: auto;
    display: block;
}

.dashboard-container.stats-expanded .left-side-content,
.dashboard-container.stats-expanded .charts-panel,
.dashboard-container.stats-expanded #top-10-chart-panel {
    display: none !important;
}

.dashboard-container.stats-expanded .right-side-content {
    display: block;
}

.dashboard-container.stats-expanded #type-stats-panel {
    position: absolute;
}

.dashboard-container .fullscreen-toggle-btn {
    z-index: 1600;
}

body.modal-open .fullscreen-toggle-btn {
    pointer-events: none;
    opacity: 1;
    cursor: not-allowed;
}

@media (min-width: 469px) and (max-width: 853px) {
    .fullscreen-toggle-btn {
        top: 0.95rem !important;   
        right: 0.95rem !important;
    }
    .dashboard-container.stats-expanded .fullscreen-toggle-btn {
        top: 0.75rem !important;   
    }
}

@media (max-width: 767px) {
    .dashboard-container.stats-expanded #type-stats-panel {
        top: 0rem;
        left: 0rem;
        right: 0.5rem;
        bottom: 0.5rem;
        border-radius: 6px;
    }
    .fullscreen-toggle-btn { 
        top: 1.75rem; 
        right: 1rem; 
    }
}

@media (max-width: 767px) and (orientation: landscape) {
    .dashboard-container .fullscreen-toggle-btn {
        width: 28px !important;
        height: 28px !important;
        top: 0.5rem !important;
        right: 0.5rem !important;
        font-size: 0.9rem !important;
        padding: 0.2rem !important;
    }
}


@media (orientation: landscape) and (max-height: 500px) {
    .dashboard-container .fullscreen-toggle-btn {
        width: 30px !important;
        height: 30px !important;
        top: 0.35rem !important;
        right: 0.45rem !important;
        font-size: 0.95rem !important;
        padding: 0.25rem !important;
    }
}

/* Charts fullscreen toggle button */
.charts-fullscreen-toggle-btn {
    position: absolute;
    top: 0.8rem;
    right: 1rem;
    z-index: 1000;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    font-family: "Font Awesome 6 Free" !important;
}

.charts-fullscreen-toggle-btn:hover {
    background-color: #0056b3;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
}

.charts-fullscreen-toggle-btn:active {
    transform: scale(0.95);
}

.dashboard-container.charts-expanded .charts-panel {
    position: absolute;
    top: 0rem;
    left: 0rem;
    right: 1rem;
    bottom: 1rem;
    width: auto;
    height: calc(100% - 2rem);
    max-height: none !important;
    z-index: 1500;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
    overflow: auto;
    display: block;
}

.dashboard-container.charts-expanded .left-side-content,
.dashboard-container.charts-expanded #type-stats-panel {
    display: none !important;
}

.dashboard-container.charts-expanded .right-side-content {
    display: block;
}

.dashboard-container.charts-expanded .charts-panel {
    position: absolute;
}

.dashboard-container.charts-expanded .charts-panel .charts-fullscreen-toggle-btn {
    z-index: 1600;
}

@media (max-width: 767px) {
    .charts-fullscreen-toggle-btn {
        top: 0.8rem;
        right: 1rem;
        /* display: none; */
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .dashboard-container .charts-fullscreen-toggle-btn {
        width: 30px !important;
        height: 30px !important;
        top: 0.6rem !important;
        right: 0.7rem !important;
        font-size: 0.9rem !important;
        padding: 0.2rem !important;
    }
}

.dashboard-container.charts-expanded .charts-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
    gap: 2rem !important;
    padding: 2rem !important;
    height: calc(100% - 120px) !important;
}

.dashboard-container.charts-expanded .chart-item {
    min-height: 300px !important;
    max-height: 400px !important;
    padding: 1.5rem !important;
}

.dashboard-container.charts-expanded .chart-item .chart-wrapper {
    height: 200px !important;
}

.dashboard-container.charts-expanded .chart-item h3 {
    font-size: 1.3rem !important;
    margin-bottom: 1rem !important;
}

@media (max-width: 767px) {
    .dashboard-container.charts-expanded .charts-panel {
        top: 0rem;
        left: 0rem;
        right: 0.5rem;
        bottom: 0.5rem;
        border-radius: 6px;
    }

    .dashboard-container.charts-expanded .charts-grid {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        gap: 1rem !important;
        padding: 1rem !important;
        height: calc(100% - 80px) !important;
        overflow-y: auto !important;
        max-height: calc(100vh - 120px) !important;
    }

    .dashboard-container.charts-expanded .chart-item {
        min-height: 180px !important;
        max-height: 220px !important;
        padding: 0.75rem !important;
    }

    .dashboard-container.charts-expanded .chart-item .chart-wrapper {
        height: 100px !important;
    }

    .dashboard-container.charts-expanded .chart-item h3 {
        font-size: 0.95rem !important;
        margin-bottom: 0.5rem !important;
        line-height: 1.2 !important;
    }

    .dashboard-container.charts-expanded .charts-navigation {
        height: calc(100% - 80px) !important;
        overflow: hidden !important;
    }

    .dashboard-container.charts-expanded .charts-scroll {
        display: none !important;
    }

    .dashboard-container.charts-expanded .charts-panel {
        overflow: hidden !important;
    }
}

/* Horizontal mobile landscape for charts - even smaller buttons */
@media (max-width: 767px) and (orientation: landscape) {
    .dashboard-container.charts-expanded .charts-grid {
        gap: 0.3rem !important;
        padding: 0.3rem !important;
        height: calc(100% - 50px) !important;
        max-height: calc(100vh - 60px) !important;
    }

    .dashboard-container.charts-expanded .chart-item {
        min-height: 90px !important;
        max-height: 110px !important;
        padding: 0.3rem !important;
    }

    .dashboard-container.charts-expanded .chart-item .chart-wrapper {
        height: 50px !important;
    }

    .dashboard-container.charts-expanded .chart-item h3 {
        font-size: 0.7rem !important;
        margin-bottom: 0.2rem !important;
        line-height: 1.0 !important;
    }

    .dashboard-container.charts-expanded .charts-navigation {
        height: calc(100% - 50px) !important;
    }

    .dashboard-container.charts-expanded .charts-scroll {
        display: none !important;
    }

    .dashboard-container.charts-expanded .charts-panel {
        top: 0rem !important;
        left: 0rem !important;
        right: 0.3rem !important;
        bottom: 0.3rem !important;
    }
}

.dashboard-container {
    display: flex;
    padding: 1rem;
    gap: 1rem;
    height: calc(100vh - 2rem);
    flex-direction: column;
    position: relative;
    transition: margin-left 0.3s ease;
}

.filters-panel {
    position: absolute;
    top: 1rem; 
    left: 10px;
    width: 320px; 
    max-width: 90vw;
    height: calc(100vh - 5rem); 
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.filters-panel.active {
    display: flex;
    opacity: 1;
}

.filters-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    min-height: 0;
}

.filters-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.filters-panel h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
}

.filters-panel .close-button {
    font-size: 1.5rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
}

.filters-panel .close-button:hover,
.filters-panel .close-button:focus {
    color: #000;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    padding-top: 5px;
    font-weight: bold;
    color: #555;
    font-size: 1rem;
}

.filter-group select,
.filter-group input[type="text"] {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    font-size: 1rem;
    color: #333;
    background-color: #fff;
}

.filter-group input[type="text"]::placeholder {
    color: #777;
    font-style: italic;
}

.filter-group form {
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#reset-filters {
    padding: 0.75rem;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

#reset-filters:hover {
    background-color: #c82333;
}

.filter-toggle-button {
    background-color: #007bff;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: none;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-top: 10px;
}

.filter-toggle-button:hover {
    background-color: #0056b3;
}

.main-content {
    flex-grow: 1;
    display: flex;
    gap: 1rem;
    position: relative;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    padding: 1rem;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.filters-open .main-content {
    margin-left: 340px; 
}

/* Desktop and large tablet landscape styles */
@media (min-width: 1024px), (min-width: 927px) and (orientation: landscape) and (min-height: 500px) {
    .dashboard-container {
        flex-direction: row;
    }

    .main-content {
        flex-direction: row;
    }

    .filters-open .main-content {
        margin-left: 370px; 
    }

    .left-side-content,
    .right-side-content {
        width: 50%;
        flex: 1;
        gap: 1rem;
    }

    .charts-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        grid-template-rows: auto auto !important;
        gap: 1.2rem;
        height: auto;
        position: static;
        align-content: center;
        padding: 2rem;
    }

    .chart-item {
        position: static;
        width: auto;
        height: auto;
        flex: none;
        min-height: 200px !important;
        max-height: 270px !important;
    }

    .chart-item .chart-wrapper {
        height: 100px !important;
    }

    .charts-grid .chart-item:last-child {
        grid-column: auto !important;
        justify-self: stretch;
        max-width: none;
    }

    .charts-grid .chart-item:nth-child(1) {
        grid-column: 1 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(2) {
        grid-column: 3 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(3) {
        grid-column: 5 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(4) {
        grid-column: 1 / span 3 !important;
    }

    .charts-grid .chart-item:nth-child(5) {
        grid-column: 4 / span 3 !important;
    }

    .charts-scroll {
        display: none !important;
    }

    .charts-navigation {
        flex: none;
    }

    .charts-panel {
        background-color: white;
        padding: 1rem;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
}

@media (min-width: 991px) and (max-width: 1023px) {
    .charts-panel {
        flex: 1.2 !important;
        min-height: 360px !important;
        max-height: 400px !important;
        padding: 1rem !important;
        overflow: hidden !important;
    }

    .charts-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        grid-template-rows: auto auto !important;
        gap: 0.8rem;
        height: auto;
        position: static;
        align-content: start;
        padding: 1rem;
        overflow: visible;
    }

    .chart-item {
        position: static;
        width: auto;
        height: auto;
        flex: none;
        min-height: 140px !important;
        max-height: 170px !important;
    }

    .chart-item .chart-wrapper {
        height: 75px !important;
    }

    .chart-item h3 {
        font-size: 0.85rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.4rem !important;
    }

    .charts-grid .chart-item:last-child {
        grid-column: auto !important;
        justify-self: stretch;
        max-width: none;
    }

    .charts-grid .chart-item:nth-child(1) {
        grid-column: 1 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(2) {
        grid-column: 3 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(3) {
        grid-column: 5 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(4) {
        grid-column: 1 / span 3 !important;
    }

    .charts-grid .chart-item:nth-child(5) {
        grid-column: 4 / span 3 !important;
    }

    .charts-scroll {
        display: none !important;
    }
}

/* Desktop styles for shorter screens - horizontal scroll for charts */
@media (min-width: 1024px) and (max-height: 969px) {
    .charts-panel {
        background-color: white;
        padding: 1rem;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .panel-header {
        flex-shrink: 0;
        padding-bottom: 1rem;
        border-bottom: 1px solid #ddd;
        margin-bottom: 1rem;
    }

    .charts-navigation {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .charts-grid {
        display: flex;
        flex-direction: row;
        gap: 1rem;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        align-items: stretch;
        min-height: 0;
        scrollbar-width: thin;
        scrollbar-color: #c0c0c0 #f0f2f5;
    }

    .charts-grid::-webkit-scrollbar {
        height: 8px;
    }

    .charts-grid::-webkit-scrollbar-track {
        background: #f0f2f5;
        border-radius: 4px;
    }

    .charts-grid::-webkit-scrollbar-thumb {
        background: #007bff;
        border-radius: 4px;
    }

    .charts-grid::-webkit-scrollbar-thumb:hover {
        background: #0056b3;
    }

    .chart-item {
        min-width: 280px;
        max-width: 320px;
        flex: 0 0 300px;
        height: auto;
        min-height: 160px;
        max-height: 200px;
        position: static;
        margin-right: 0;
    }

    .chart-item:last-child {
        margin-right: 1rem;
    }

    .charts-scroll {
        display: none !important;
    }
}

/* Desktop styles - prevent chart buttons from shrinking on wider screens */
@media (min-width: 1024px) {
    .charts-grid {
        display: grid !important;
        grid-template-columns: repeat(6, 1fr) !important;
        grid-template-rows: auto auto !important;
        gap: 1.2rem;
        padding: 2rem;
        overflow: visible;
        flex: 1;
        align-items: stretch;
        min-height: 0;
        align-content: center;
    }

    .chart-item {
        min-width: auto;
        max-width: none;
        flex: none;
        height: auto;
        min-height: 200px !important;
        max-height: 270px !important;
        position: static;
        margin-right: 0;
    }

    .chart-item .chart-wrapper {
        height: 100px !important;
    }

    .chart-item:last-child {
        grid-column: auto !important;
        justify-self: stretch;
        max-width: none;
        margin-right: 0;
    }

    .charts-grid .chart-item:nth-child(1) {
        grid-column: 1 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(2) {
        grid-column: 3 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(3) {
        grid-column: 5 / span 2 !important;
    }

    .charts-grid .chart-item:nth-child(4) {
        grid-column: 1 / span 3 !important;
    }

    .charts-grid .chart-item:nth-child(5) {
        grid-column: 4 / span 3 !important;
    }

    .charts-scroll {
        display: none !important;
    }
}

/* Tablet portrait styles */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
    .dashboard-container {
        flex-direction: column;
    }

    .main-content {
        flex-direction: column;
    }

    .filters-open .main-content {
        margin-left: 0;
        opacity: 0.3;
    }

    .filters-panel.active {
        width: 100vw;
        max-width: 100vw;
        left: 0;
        top: 0;
        height: 100vh;
        border-radius: 0;
        padding: 1rem;
        box-sizing: border-box;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Tablet landscape and mobile landscape styles */
@media (max-width: 1023px) and (orientation: landscape), (max-width: 767px) {
    .filters-open .main-content {
        margin-left: 0;
        opacity: 0.3;
    }

    .filters-panel.active {
        width: 100vw;
        max-width: 100vw;
        left: 0;
        top: 0;
        height: 100vh; 
        border-radius: 0;
        padding: 1rem;
        box-sizing: border-box;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .filters-panel .filters-content {
        flex: 1;
        overflow-y: auto;
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    .filters-panel #reset-filters {
        position: sticky;
        bottom: 0;
        background-color: #dc3545;
        margin-top: auto;
        z-index: 10;
    }

    .main-content {
        flex-direction: column;
        overflow-y: auto;
        gap: 0.25rem;
    }

    .left-side-content,
    .right-side-content {
        width: 100%;
        flex: none;
        gap: 0.25rem;
    }

    .left-side-content {
        order: 1;
    }

    .right-side-content {
        order: 2;
        display: flex;
        flex-direction: column;
        transition: all 0.3s ease;
        gap: 0.25rem;
    }

    .map-container {
        min-height: 300px;
        height: 40vh;
    }

    #type-stats-panel {
        height: auto;
        min-height: 180px;
        flex: 0 0 auto;
        flex-shrink: 0;
        transition: all 0.3s ease;
    }

    #type-stats-panel.expanded {
        min-height: 250px;
    }

    .charts-panel {
        height: auto;
        min-height: 240px;
        flex: 0 0 auto;
        padding: 0.75rem;
    }

    #top-10-chart-panel {
        min-height: 240px;
        flex: 0 0 auto;
        padding: 0.75rem;
    }

    .stats-panel {
        padding: 0.75rem;
    }

    .charts-grid {
        display: flex;
        flex-direction: row;
        gap: 0;
        max-height: none;
        height: 180px;
        flex: 0 0 auto;
        transition: margin-top 0.3s ease;
        padding: 1rem;
        justify-items: center;
        overflow: hidden;
        position: relative;
    }

    .charts-grid .chart-item:last-child {
        grid-column: 1;
        justify-self: stretch;
        max-width: none;
    }

    .charts-grid.moved-up {
        margin-top: -100px;
    }

    .chart-wrapper {
        height: 120px;
    }

    .chart-item {
        margin-bottom: 0;
        min-height: 180px;
        max-height: 200px;
        padding: 0.75rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        min-width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .chart-item h3 {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
        line-height: 1.1;
        text-align: center;
        padding: 0 0.25rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    body.modal-open .charts-scroll {
        display: none !important;
    }
}

.left-side-content,
.right-side-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.map-container {
    flex: 1;
    min-height: 400px;
    border-radius: 8px;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* User location marker - highest z-index */
.leaflet-marker-pane svg[style*="z-index"] {
    z-index: 9999 !important;
}

.leaflet-overlay-pane svg path[fill="#007bff"] {
    z-index: 9999 !important;
}

.user-location-marker path {
    z-index: 1900 !important;
}

.user-location-marker {
    z-index: 1900 !important;
} 

.user-accuracy-circle {
    transition: fill-opacity 0.5s ease-in-out;
}

.user-accuracy-circle path {
    transition: fill-opacity 0.5s ease-in-out;
} 

/* Custom marker styles */
.custom-marker {
    background: transparent !important;
    border: none !important;
}

.marker-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: all 0.2s ease;
}

.marker-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
}

.marker-container:hover {
    transform: scale(1.1);
}

.marker-container:hover .marker-logo {
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
}

/* 
   ЗАКОМЕНТОВАНІ СТИЛІ ДЛЯ КОЛЬОРОВИХ ОБВОДОК ТА БІЛИХ КРУЖЕЧКІВ

.marker-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    border: 2px solid #fff;
    transition: all 0.2s ease;
}

.marker-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 2px;
}

.marker-container:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.marker-dia-center .marker-container {
    border-color: #3388ff;
    box-shadow: 0 2px 8px rgba(51, 136, 255, 0.3);
}

.marker-cnap .marker-container {
    border-color: #28a745;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.marker-vrm .marker-container {
    border-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.marker-tp .marker-container {
    border-color: #ffc107;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.marker-bti .marker-container {
    border-color: #ff8c00;
    box-shadow: 0 2px 8px rgba(255, 140, 0, 0.3);
}
*/

/* Styles for the map legend control */
.leaflet-control-legend {
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    min-width: 130px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.legend-item:hover {
    background-color: rgba(0, 123, 255, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.legend-item.active {
    background-color: rgba(0, 123, 255, 0.2);
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
}

.legend-item.active span {
    font-weight: bold;
    color: #0056b3;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    object-fit: contain;
    flex-shrink: 0;
}

.legend-item span {
    font-weight: normal;
    font-size: 14px;
    color: #333;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

@media (max-width: 767px) {
    .leaflet-control-legend {
        font-size: 12px;
        padding: 10px;
        min-width: 110px;
    }
    
    .legend-icon {
        width: 16px;
        height: 16px;
        margin-right: 6px;
    }
    
    .legend-item span {
        font-size: 12px;
    }
}

/* Slider styles */
#services-slider {
    margin: 0.4rem 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0 12px;
    max-width: 100%;
    display: block;
    overflow: hidden;
}

#services-slider .noUi-target,
#services-slider .noUi-base {
    width: 100%;
    box-sizing: border-box;
    touch-action: none;
}

#services-slider .noUi-base {
    height: 6px;
    border-radius: 6px;
    background: rgba(0,0,0,0.06); 
}

#services-slider .noUi-connect {
    background: #007bff;
    border-radius: 6px;
    height: 100%;
}

#services-slider .noUi-horizontal .noUi-handle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 2px solid rgba(255,255,255,0.9);
    cursor: grab;
}

#services-slider .noUi-horizontal .noUi-handle:active {
    cursor: grabbing;
}

#services-slider .noUi-handle:before,
#services-slider .noUi-handle:after,
#services-slider .noUi-marker,
#services-slider .noUi-value,
#services-slider .noUi-horizontal .noUi-marker {
    display: none !important;
}

.slider-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
    padding: 0 6px;
}

.filters-panel {
    overflow-x: hidden;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 80vh;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: #f2f2f2;
    border-bottom: 2px solid #007bff;
    cursor: default; 
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: calc(100% - 48px);
}

.modal-body {
    padding: 0.75rem;
    overflow-y: auto;
    flex-grow: 1;
}

.close-button {
    font-size: 1.5rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
}

.close-button:hover,
.close-button:focus {
    color: #000;
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.modal-table th,
.modal-table td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
    font-size: 1rem;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.modal-table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.chart-modal .chart-modal-content {
    width: 95%;
    max-width: 1400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.chart-modal .chart-modal-body {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    align-items: stretch;
    min-width: 0;
}
.chart-detail-left {
    flex: 1 1 65%;
    min-width: 320px;
}
.chart-detail-right {
    flex: 0 1 auto;
    min-width: 300px;
    max-width: 450px;
    overflow-x: auto;
    overflow-y: auto;
    border-left: 1px solid #e9ecef;
    padding-left: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
}

.chart-detail-right .stat-item {
    width: 100%;
    max-width: none;
    min-width: 280px;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    border: 1px solid #f1f3f5;
    background: #fff;
    box-sizing: border-box;
    white-space: normal;
    overflow: visible;
}

.chart-detail-right .stat-item .label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
    word-wrap: break-word;
    line-height: 1.4;
}

.chart-detail-right .stat-item .counts {
    color: #555;
    font-size: 0.95rem;
}

.chart-modal .modal-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #f2f2f2; 
}
.chart-modal canvas { width: 100% !important; height: 480px !important; }
.chart-modal .modal-header { cursor: default; }

/* Loader styles */
.loader-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    transition: opacity 0.5s ease;
}

.loader-container.hidden {
    opacity: 0;
    pointer-events: none;
}

.sk-cube-grid {
    color: #007bff;
}

/* Stats panel styles */
.stats-panel {
    background-color: white;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#type-stats-panel {
    flex: 0 0 auto;
    height: auto;
    max-height: 30vh;
}

.panel-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid #ddd;
    margin-bottom: 1rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.small-label {
    display: inline-block;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.1;
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stats-list.empty {
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 200px;
}

.empty-state {
    text-align: center;
    color: #6c757d;
    padding: 2rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #495057;
}

.empty-state-text {
    font-size: 1rem;
    line-height: 1.5;
}

.stats-item {
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    border: 1px solid #e9ecef;
    background-color: #fff;
}

.stats-item:hover {
    background-color: #e2e6ea;
}

.stats-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 1rem;
}

.stats-item-header .count {
    font-size: 1rem;
    color: #007bff;
}

.stats-item-details {
    display: none;
    flex-direction: column;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e9ecef;
}

.stats-item-details.active {
    display: flex;
}

.stats-item-details a {
    text-decoration: none;
    color: #444;
    padding: 0.4rem 0;
    border-bottom: 1px dashed #e9ecef;
    transition: background-color 0.2s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-item-details a:last-child {
    border-bottom: none;
}

.stats-item-details a:hover {
    background-color: #f8f9fa;
    text-decoration: none;
    border-radius: 5px;
    padding: 0.4rem;
}

.list-item-icon {
    flex-shrink: 0;
    font-size: 0.9rem;
}

.list-item-text {
    flex: 1;
}

/* Charts grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto auto auto;
    gap: 1rem;
    background-color: white;
    padding: 1rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    justify-items: stretch;
    align-items: stretch;
    touch-action: manipulation; 
    user-select: none; 
    position: relative; 
}

.charts-grid .chart-item:last-child {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 400px;
}

.charts-panel {
    background-color: white;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.charts-navigation {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.charts-scroll {
    background: rgba(0,0,0,0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 18px;
    display: none; 
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    align-self: center;
    flex-shrink: 0;
}

.chart-item.pressed {
    transform: translateY(2px) !important;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.08);
    background-color: #eef6ff;
}

.charts-navigation .charts-scroll.left { order: 0; }
.charts-navigation .charts-scroll.right { order: 2; }
.charts-navigation .charts-grid { order: 1; flex: 1 1 auto; min-height: 0; }

.charts-scroll:focus {
    outline: 2px solid rgba(0,123,255,0.4);
}

body.modal-open .charts-scroll {
    display: none !important;
}

@media (max-width: 991px) {
    .charts-scroll { display: flex; }

    .charts-grid {
        display: flex;
        flex-direction: row;
        gap: 0;
        padding: 1rem;
        overflow: hidden;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        justify-items: center;
        align-items: stretch;
        position: relative;
        height: 220px;
        touch-action: manipulation; 
        user-select: none;
    }

    .charts-grid .chart-item:last-child {
        grid-column: auto;
        justify-self: auto;
        max-width: none;
    }

    .chart-item {
        min-width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        min-height: 200px;
        max-height: 220px;
        margin-bottom: 0;
        margin-right: 0;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        padding: 0.75rem;
        background-color: #fff;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        z-index: 1;
        pointer-events: auto;
        cursor: pointer;
    }

    .chart-item:hover,
    .chart-item:focus {
        transform: translateX(var(--current-offset, 0%)) !important;
        box-shadow: none;
        background-color: #fff;
        z-index: 1;
        cursor: pointer; 
    }

    .charts-panel { 
        background-color: white;
        padding: 1rem;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .charts-navigation { 
        padding: 0 0.5rem; 
        align-items: center;
        justify-content: center;
        position: relative;
        height: 100%;
    }

    .charts-navigation .charts-scroll {
        width: 44px;
        height: 44px;
        border-radius: 22px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
        margin: 0 8px;
        flex: 0 0 auto;
        display: flex !important;
        align-items: center;
        justify-content: center;
        align-self: center;
    }

    .charts-navigation { gap: 0.75rem; }
}

.chart-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
    padding: 0.75rem;
    transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
    width: 100%;
    min-height: 130px;
    max-height: 160px;
    box-sizing: border-box;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    background-color: #fff;
}

.chart-item:hover,
.chart-item:focus {
    transform: translateY(-6px);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.12);
    background-color: #f8fbff;
    outline: none;
}

.chart-wrapper {
    width: 100%;
    height: 110px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chart-item h3 {
    font-size: 1rem;
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #555;
    text-align: center;
    line-height: 1.2;
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: break-word;
    padding: 0 0.25rem;
}

.chart-item canvas {
    max-width: 100%;
    height: auto;
}

@media (min-width: 576px) {
    .charts-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .charts-grid .chart-item:last-child {
        grid-column: 1 / -1;
        justify-self: center;
        max-width: 400px;
    }
}

@media (min-width: 576px) and (max-width: 1023px) and (orientation: portrait) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .charts-grid .chart-item:last-child {
        grid-column: 1 / -1;
        justify-self: center;
        max-width: 350px;
    }
    
    .left-side-content,
    .right-side-content {
        width: 100%;
        gap: 0.35rem;
    }
    
    .main-content {
        flex-direction: column;
        gap: 0.35rem;
    }

    #type-stats-panel {
        height: auto;
        min-height: 180px;
        transition: all 0.3s ease;
    }

    #type-stats-panel.expanded {
        min-height: 250px;
    }

    .charts-panel {
        min-height: 240px;
    }

    #top-10-chart-panel {
        min-height: 240px;
    }

    .charts-grid {
        transition: margin-top 0.3s ease;
    }

    .charts-grid.moved-up {
        margin-top: -50px;
    }
}

/* List filter styles */
.list-filter {
    font-size: 1rem;
    flex-direction: column;
    max-height: 30vh;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fafafa;
    padding: 1rem;
    gap: 0.5rem;
}

.filter-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
    color: #495057;
}

.filter-item:hover {
    background-color: #e9ecef;
}

.filter-item.active {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

/* Multiple select styles */
.multiple-select {
    position: relative;
    display: inline-block;
    width: 100%;
}

.multiple-select-dropdown {
    position: relative;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 20px;
}

.multiple-select-dropdown:hover {
    border-color: #007bff;
}

.multiple-select-dropdown.active {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.multiple-select-placeholder {
    color: #6c757d;
    font-style: italic;
}

.multiple-select-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-height: 60px;
    overflow-y: auto;
}

.multiple-select-tag {
    background-color: #007bff;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.multiple-select-tag .remove {
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
}

.multiple-select-tag .remove:hover {
    color: #ffdddd;
}

.multiple-select-arrow {
    margin-left: auto;
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    color: #666;
}

.multiple-select-dropdown.active .multiple-select-arrow {
    transform: rotate(180deg);
}

.multiple-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.multiple-select-dropdown.active + .multiple-select-options {
    display: block;
}

.multiple-select-option {
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s ease;
}

.multiple-select-option:hover {
    background-color: #f8f9fa;
}

.multiple-select-option.selected {
    background-color: #e7f3ff;
}

.multiple-select-option input[type="checkbox"] {
    margin: 0;
}

/* Checkbox list styles */
.checkbox-list {
    display: flex;
    flex-direction: column;
    max-height: 20vh;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fafafa;
    padding: 0.5rem;
    gap: 0.3rem;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    .checkbox-list {
        max-height: 15vh;
    }
    
    .list-filter {
        max-height: 20vh;
    }
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 0.9rem;
}

.checkbox-item:hover {
    background-color: #e9ecef;
}

.checkbox-item input[type="checkbox"] {
    margin-right: 0.5rem;
    cursor: pointer;
}

.checkbox-item label {
    cursor: pointer;
    font-weight: normal;
    margin: 0;
    flex: 1;
}

/* Mobile improvements for modal readability and chart-detail responsiveness */
@media (max-width: 1023px) and (orientation: portrait), (max-width: 767px) {
    .modal {
        padding: 0.5rem;
    }

    .modal-content {
        width: 96%;
        max-width: 96%;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        border-radius: 8px;
        overflow: hidden;
    }

    .modal-body {
        padding: 0.75rem;
        max-height: calc(90vh - 72px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-table th,
    .modal-table td {
        font-size: 1.05rem;
        padding: 0.75rem;
        line-height: 1.3;
        vertical-align: top;
        white-space: normal;
    }

    .modal-table th {
        font-size: 1.05rem;
    }

    .modal .close-button {
        padding: 6px 8px;
        font-size: 1.4rem;
    }

    .chart-modal .chart-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }

    .chart-modal .chart-modal-body {
        flex-direction: column;
        gap: 0;
        padding: 0.5rem;
        flex: 1;
        overflow: hidden;
    }

    .chart-detail-left,
    .chart-detail-right {
        min-width: 100%;
        flex: none;
        padding: 0.5rem;
        border-left: none;
    }

    .chart-detail-left {
        flex: 1 1 60%;
        min-height: 200px;
        display: flex;
        flex-direction: column;
    }

    .chart-detail-right {
        flex: 0 0 30%;
        border-top: 1px solid #e9ecef;
        padding-top: 0.5rem;
        max-height: 30vh;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    .chart-modal canvas { height: 240px !important; flex: 1; }

    .chart-detail-right .stat-item {
        max-width: none;
        min-width: 200px;
        padding: 0.5rem 0.75rem;
        margin: 0.15rem 0;
        font-size: 0.85rem;
        white-space: normal;
    }

    .chart-detail-right .stat-item .counts {
        font-size: 0.75rem;
    }

    .chart-detail-right .stat-item .label {
        font-size: 0.85rem;
        margin-bottom: 0.15rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-wrap: break-word;
        line-height: 1.3;
    }

    .chart-modal .modal-header {
        padding: 0.5rem 0.75rem;
        flex-shrink: 0;
    }
    
    .chart-modal .modal-header h3 {
        font-size: 1rem;
        line-height: 1.2;
        max-width: calc(100% - 2rem);
    }
    
    .chart-modal .modal-header .close-button {
        font-size: 1.8rem;
        padding: 0.25rem;
        min-width: 2rem;
        min-height: 2rem;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #666;
        font-weight: bold;
        background: transparent;
        border-radius: 4px;
    }

    .chart-modal .modal-header .close-button:hover,
    .chart-modal .modal-header .close-button:focus {
        background: rgba(220, 53, 69, 0.1);
        color: #dc3545;
    }

    .modal-table th,
    .modal-table td {
        font-size: 0.9rem;
        padding: 0.5rem 0.4rem;
        line-height: 1.2;
    }

    .modal-table th {
        font-size: 0.9rem;
    }
}

@media (min-width: 992px) {
    #type-stats-panel {
        height: 50vh;
    }
    
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem;
    }
    
    .charts-grid .chart-item:last-child {
        grid-column: 1 / -1;
        justify-self: center;
        max-width: 400px;
    }
    
    .chart-item {
        min-height: 120px;
        max-height: 150px;
    }
    
    .chart-wrapper {
        height: 100px;
    }
}

/* Specific styles for mobile landscape orientation */
@media (max-width: 926px) and (orientation: landscape) and (max-height: 500px) {
    .dashboard-container {
        height: calc(100vh - 1rem);
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .filters-panel.active {
        width: 100vw;
        height: 100vh;
        padding: 0.75rem;
        left: 0;
        top: 0;
        border-radius: 0;
        box-sizing: border-box;
    }

    .filters-open .main-content {
        margin-left: 0;
        opacity: 0.3;
    }

    .main-content {
        padding: 0.5rem;
        flex-direction: row;
        gap: 0.5rem;
    }

    .left-side-content,
    .right-side-content {
        width: 50%;
        flex: 1;
        gap: 0.5rem;
    }

    .map-container {
        min-height: 250px;
        height: calc(100vh - 3rem);
    }

    #type-stats-panel {
        height: auto;
        min-height: 150px;
        max-height: 200px;
    }

    .charts-panel {
        height: auto;
        min-height: 200px;
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
    }

    .charts-navigation {
        height: calc(100% - 50px);
        align-items: center;
        justify-content: center;
    }

    .charts-grid {
        height: 100%;
        padding: 0;
        position: relative;
        overflow: hidden;
        display: flex;
        flex-direction: row;
        gap: 0;
    }

    .chart-item {
        min-height: 140px;
        max-height: 150px;
        padding: 0.5rem;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        flex: 0 0 100%;
        z-index: 1;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .chart-item h3 {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .chart-wrapper {
        height: 100px;
    }

    #top-10-chart-panel {
        min-height: 180px;
        padding: 0.5rem;
    }

    .stats-panel {
        padding: 0.5rem;
    }

    .panel-header {
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .panel-header h2 {
        font-size: 1.2rem;
    }

    .stats-item {
        padding: 0.5rem;
    }

    .charts-scroll {
        align-self: center;
    }

    .modal-content {
        max-width: 95%;
        max-height: 90vh;
    }

    .modal-table th,
    .modal-table td {
        font-size: 0.85rem;
        padding: 0.4rem;
    }
}

/* Large phone landscape styles */
@media (min-width: 668px) and (max-width: 926px) and (orientation: landscape) and (min-height: 350px) and (max-height: 500px) {
    .dashboard-container {
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .main-content {
        flex-direction: row;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .left-side-content,
    .right-side-content {
        width: 50%;
        flex: 1;
        gap: 0.75rem;
    }

    .map-container {
        min-height: 280px;
        height: calc(100vh - 4rem);
    }

    .charts-panel {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 280px;
        padding: 0.75rem;
    }

    .charts-navigation {
        height: calc(100% - 70px);
        align-items: center;
        justify-content: center;
        margin-top: 0.5rem;
    }

    .charts-grid {
        display: flex;
        flex-direction: row;
        gap: 0;
        padding: 0;
        overflow: hidden;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        justify-items: center;
        align-items: stretch;
        position: relative;
        height: 100%;
        touch-action: manipulation; 
        user-select: none;
    }

    .chart-item {
        min-width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        min-height: 150px;
        max-height: 180px;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        padding: 1rem;
        background-color: #fff;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .chart-wrapper {
        height: 110px;
    }

    #type-stats-panel {
        height: auto;
        min-height: 160px;
        max-height: 220px;
    }

    .panel-header {
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
        flex-shrink: 0;
    }

    .panel-header h2 {
        font-size: 1.2rem;
        margin: 0;
    }

    .stats-item {
        padding: 0.5rem;
    }

    .charts-navigation {
        height: 200px;
        align-items: center;
        justify-content: center;
    }

    .charts-scroll {
        align-self: center;
    }

    .modal-content {
        max-width: 90%;
        max-height: 85vh;
    }
}

/* Small phone landscape styles */
@media (max-width: 667px) and (orientation: landscape) and (max-height: 450px) {
    .dashboard-container {
        padding: 0.5rem;
        gap: 0.5rem;
        height: calc(100vh - 1rem);
    }

    .main-content {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .left-side-content,
    .right-side-content {
        width: 50%;
        flex: 1;
        gap: 0.5rem;
    }

    .map-container {
        min-height: 220px;
        height: calc(100vh - 3rem);
    }

    .charts-panel {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 200px;
        padding: 0.5rem;
    }

    .charts-navigation {
        height: calc(100% - 50px);
        align-items: center;
        justify-content: center;
    }

    .charts-grid {
        height: 100%;
        padding: 0;
        position: relative;
        overflow: hidden;
    }

    .chart-item {
        min-height: 140px;
        max-height: 160px;
        padding: 0.75rem;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        min-width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        z-index: 1;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        background-color: #fff;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .chart-item h3 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .chart-wrapper {
        height: 100px;
    }

    .charts-navigation {
        height: 150px;
        align-items: center;
        justify-content: center;
    }

    .charts-scroll {
        display: flex !important;
        width: 32px;
        height: 32px;
        border-radius: 16px;
        align-self: center;
    }

    #type-stats-panel {
        height: auto;
        min-height: 140px;
        max-height: 180px;
    }

    .stats-panel {
        padding: 0.5rem;
    }

    .stats-item {
        padding: 0.4rem;
    }

    .panel-header h2 {
        font-size: 1.1rem;
    }

    #top-10-chart-panel {
        min-height: 160px;
        padding: 0.5rem;
    }
}

/* Portrait mobile styles */
@media (max-width: 991px) and (orientation: portrait) {
    .chart-item {
        min-height: 160px;
        max-height: 180px;
        padding: 0.75rem;
        min-width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .chart-item h3 {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
        line-height: 1.1;
        padding: 0 0.25rem;
    }

    .chart-wrapper {
        height: 120px;
    }

    .charts-grid {
        gap: 0;
        padding: 1rem;
        overflow: hidden;
        position: relative;
        height: 180px;
    }

    .charts-panel {
        background-color: white;
        padding: 1rem;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
}

/* Modal styles for landscape orientation */
@media (max-width: 926px) and (orientation: landscape) and (max-height: 500px) {
    .modal {
        padding: 0.25rem;
    }

    .modal-content {
        width: 98%;
        max-width: 98%;
        max-height: 95vh;
        border-radius: 6px;
    }

    .modal-body {
        padding: 0.5rem;
        max-height: calc(95vh - 60px);
    }

    .modal-table th,
    .modal-table td {
        font-size: 0.8rem;
        padding: 0.4rem 0.3rem;
        line-height: 1.2;
    }

    .chart-modal .chart-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .chart-modal .chart-modal-body {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .chart-detail-left {
        flex: 1 1 70%;
        min-height: 200px;
    }

    .chart-detail-right {
        flex: 0 1 30%;
        max-width: 30%;
        border-left: 1px solid #e9ecef;
        border-top: none;
        padding-left: 0.5rem;
        padding-top: 0;
        max-height: none;
        overflow-y: auto;
    }

    .chart-modal canvas {
        height: 200px !important;
    }

    .chart-detail-right .stat-item {
        padding: 0.3rem 0.5rem;
        margin: 0.1rem 0;
        font-size: 0.75rem;
    }

    .chart-detail-right .stat-item .label {
        font-size: 0.75rem;
        margin-bottom: 0.1rem;
    }

    .chart-detail-right .stat-item .counts {
        font-size: 0.7rem;
    }
}

/* Mobile optimizations for filter button and legend */
@media (max-width: 767px) {
    .filter-toggle-button {
        padding: 0.3rem 0.6rem;
        font-size: 0.9rem;
        margin-top: 5px;
    }

    .leaflet-control-legend {
        padding: 6px;
        font-size: 11px;
        min-width: 90px;
    }

    .legend-icon {
        width: 14px;
        height: 14px;
        margin-right: 4px;
    }

    .legend-item span {
        font-size: 11px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .leaflet-control-legend {
        padding: 4px 6px !important;
        font-size: 10px !important;
        min-width: 86px !important;
        line-height: 1.15 !important;
    }
    .leaflet-control-legend .legend-item {
        padding: 2px 4px !important;
        margin-bottom: 4px !important;
    }
    .leaflet-control-legend .legend-item:last-child { margin-bottom: 0 !important; }
    .leaflet-control-legend .legend-icon {
        width: 14px !important;
        height: 14px !important;
        margin-right: 4px !important;
    }
    .leaflet-control-legend .legend-item span { font-size: 10px !important; }

    .filter-toggle-button {
        padding: 0.45rem 0.55rem !important;
        font-size: 0.7rem !important;
        line-height: 1 !important;
        border-radius: 4px !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.25) !important;
    }
    .filter-toggle-button strong { font-weight: 600; }
}

@media (orientation: landscape) and (max-height: 600px) {
    .dashboard-container.charts-expanded .charts-panel {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .dashboard-container.charts-expanded .charts-navigation { display: block !important; height: auto !important; padding: 0 !important; }
    .dashboard-container.charts-expanded .charts-scroll { display: none !important; }
    .dashboard-container.charts-expanded .charts-grid {
        display: grid !important;
        position: static !important;
        padding: 0.6rem !important;
        gap: 0.6rem !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        grid-auto-rows: minmax(140px, auto) !important;
        align-items: stretch !important;
        justify-items: stretch !important;
    }
    .dashboard-container.charts-expanded .chart-item {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: none !important;
        min-height: 140px !important;
        max-height: none !important;
        height: 100% !important;
        transform: none !important;
        transition: none !important;
        pointer-events: auto !important;
        opacity: 1 !important;
        padding: 0.6rem !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
    }
    .dashboard-container.charts-expanded .chart-item h3 {
        font-size: 0.75rem !important;
        line-height: 1.15 !important;
        margin-bottom: 0.35rem !important;
        word-break: break-word;
    }
    .dashboard-container.charts-expanded .chart-item .chart-wrapper { height: 70px !important; }
}
