﻿* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #2a2a2a;
    overflow: hidden;
}

#map-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#map-canvas {
    cursor: default;
    display: block;
    touch-action: none;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 25px 50px;
    border-radius: 10px;
    font-size: 18px;
    z-index: 2000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

    #loading.hidden {
        display: none;
    }

#tooltip {
    position: absolute;
    background: rgba(20, 20, 20, 0.95);
    color: white;
    padding: 12px 15px;
    border-radius: 6px;
    pointer-events: none;
    display: none;
    z-index: 1000;
    font-size: 12px;
    max-width: 350px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

    #tooltip .village-name {
        font-weight: bold;
        margin-bottom: 10px;
        font-size: 15px;
        color: #ffd700;
        padding-bottom: 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    }

    #tooltip .info-section {
        margin: 8px 0;
        padding-top: 6px;
    }

    #tooltip .section-title {
        font-weight: bold;
        color: #4a90e2;
        font-size: 11px;
        text-transform: uppercase;
        margin-bottom: 4px;
        letter-spacing: 0.5px;
    }

    #tooltip .info-row {
        margin: 3px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 2px 0;
    }

    #tooltip .label {
        color: #aaa;
        margin-right: 15px;
        font-size: 11px;
    }

    #tooltip .value {
        color: #fff;
        font-weight: 600;
        text-align: right;
    }

    #tooltip .tribe-section {
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 8px;
    }

    #tooltip .player-section {
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 8px;
    }

#controls {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(20, 20, 20, 0.9);
    padding: 15px;
    border-radius: 8px;
    color: white;
    z-index: 100;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

    #controls h3 {
        margin: 0 0 12px 0;
        font-size: 16px;
        text-align: center;
        color: #4a90e2;
        font-weight: 600;
    }

    #controls button {
        display: block;
        width: 100%;
        padding: 10px;
        margin: 6px 0;
        background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
        border: none;
        border-radius: 5px;
        color: white;
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
        transition: all 0.2s ease;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

        #controls button:hover {
            background: linear-gradient(135deg, #357abd 0%, #2868a0 100%);
            transform: translateY(-1px);
            box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
        }

        #controls button:active {
            transform: translateY(0);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        }

#zoom-level {
    text-align: center;
    margin-bottom: 12px;
    font-size: 14px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-weight: 500;
}

#coords-display {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(20, 20, 20, 0.9);
    padding: 12px 18px;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

    #coords-display strong {
        color: #4a90e2;
        font-weight: 600;
    }

#world-info {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(20, 20, 20, 0.9);
    padding: 12px 18px;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

    #world-info .world-name {
        font-size: 16px;
        font-weight: 600;
        color: #4a90e2;
        margin-bottom: 6px;
    }

#village-count {
    color: #aaa;
    font-size: 12px;
}

#toolbar {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20, 20, 20, 0.9);
    padding: 10px;
    border-radius: 8px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-btn {
    display: block;
    width: 50px;
    height: 50px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .tool-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(1.05);
    }

    .tool-btn.active {
        background: #4a90e2;
        border-color: #4a90e2;
        box-shadow: 0 0 10px rgba(74, 144, 226, 0.5);
    }

    .tool-btn:first-child {
        margin-top: 0;
    }

    .tool-btn:last-child {
        margin-bottom: 0;
    }

#color-picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 30, 0.98);
    border-radius: 10px;
    padding: 0;
    width: 80%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    will-change: transform;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: rgba(30, 30, 30, 0.98);
    z-index: 1;
}

    .modal-header h3 {
        margin: 0;
        color: #4a90e2;
        font-size: 16px;
    }

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    transition: color 0.2s;
}

    .close-btn:hover {
        color: #ff6b6b;
    }

.modal-body {
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

.color-block {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    width: 30%;
    margin: 1%;
}

.color-block-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-block-icon {
    font-size: 18px;
}

.color-block-title {
    font-size: 14px;
    font-weight: 600;
    color: #4a90e2;
    margin: 0;
}

.color-block-body {
    padding: 15px;
}

.entity-info {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 12px;
    line-height: 1.5;
    color: #ddd;
}

    .entity-info strong {
        color: #fff;
        display: block;
        margin-bottom: 4px;
    }

.color-picker-section {
    margin-bottom: 12px;
}

.color-picker-label {
    display: block;
    color: #aaa;
    margin-bottom: 8px;
    font-size: 12px;
}

.color-input-display {
    width: 100%;
    height: 45px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    margin-bottom: 10px;
}

.quick-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.category-btn {
    padding: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    background: none;
}

    .category-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        border-color: rgba(255, 255, 255, 0.4);
    }

.color-presets {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.color-preset {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

    .color-preset:hover {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .color-preset.selected {
        border-color: #fff;
        transform: scale(1.1);
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
    }

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-action-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

    .modal-action-btn.confirm {
        background: #27ae60;
    }

        .modal-action-btn.confirm:hover {
            background: #229954;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        }

    .modal-action-btn.cancel {
        background: #95a5a6;
    }

        .modal-action-btn.cancel:hover {
            background: #7f8c8d;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        }

@media (max-width: 600px) {
    .modal-content {
        width: 90%;
        max-width: 450px;
    }

    #toolbar {
        left: 10px;
    }

    .tool-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
}

.checkbox-section {
    margin: 10px 0;
    padding: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

    .checkbox-section label {
        display: flex;
        align-items: center;
        cursor: pointer;
        color: #ddd; 
        font-size: 12px;
    }

    .checkbox-section input[type="checkbox"] {
        margin-right: 8px;
        width: 16px;
        height: 16px;
        accent-color: #4a90e2;
    }

#top-toolbar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.9);
    padding: 8px;
    border-radius: 8px;
    z-index: 100;
    display: flex;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.top-tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

    .top-tool-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-1px);
    }

    .top-tool-btn .icon {
        font-size: 16px;
    }

    .top-tool-btn .badge {
        background: #4a90e2;
        color: white;
        font-size: 11px;
        font-weight: 600;
        padding: 2px 6px;
        border-radius: 10px;
        min-width: 18px;
        text-align: center;
    }

.selected-modal-content {
    width: 90% !important;
    max-width: 1400px !important;
    max-height: 85vh;
}

.modal-body-split {
    display: flex;
    gap: 20px;
    padding: 20px;
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

    .left-panel .tab-content {
        flex: 1;
        overflow-y: auto;
        max-height: calc(85vh - 200px);
    }

.selected-stats-top {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

    .selected-stats-top .stat-item {
        text-align: center;
        flex: 1;
    }

    .selected-stats-top .stat-label {
        display: block;
        color: #aaa;
        font-size: 12px;
        margin-bottom: 5px;
    }

    .selected-stats-top .stat-value {
        display: block;
        color: #4a90e2;
        font-size: 18px;
        font-weight: 600;
    }

.stat-item {
    text-align: center;
    flex: 1; 
}

.filter-panel-vertical {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .filter-panel-vertical label {
        color: #aaa;
        font-size: 13px;
        font-weight: 500;
    }

    .filter-panel-vertical input {
        padding: 8px 12px;
        background: rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        color: white;
        font-size: 13px;
    }

        .filter-panel-vertical input:focus {
            outline: none;
            border-color: #4a90e2;
        }

.filter-btn-vertical {
    padding: 10px 16px;
    background: #4a90e2;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

    .filter-btn-vertical:hover {
        background: #357abd;
    }

.actions-panel-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn-vertical {
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .action-btn-vertical .icon {
        font-size: 16px;
    }

    .action-btn-vertical.copy-btn {
        background: #4a90e2;
    }

        .action-btn-vertical.copy-btn:hover {
            background: #357abd;
        }

    .action-btn-vertical.remove-btn {
        background: #e74c3c;
    }

        .action-btn-vertical.remove-btn:hover {
            background: #c0392b;
        }

    .action-btn-vertical.collapse-btn {
        background: #95a5a6;
    }

        .action-btn-vertical.collapse-btn:hover {
            background: #7f8c8d;
        }

.right-panel {
    width: 250px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-label {
    display: block;
    color: #aaa;
    font-size: 12px;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    color: #4a90e2;
    font-size: 18px;
    font-weight: 600;
}

.selected-tabs {
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
    padding: 10px 15px;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

    .tab-btn:hover {
        color: #fff;
    }

    .tab-btn.active {
        color: #4a90e2;
        border-bottom-color: #4a90e2;
    }

.tab-content {
    flex: 1;
    overflow-y: auto;
    max-height: calc(85vh - 150px);
}

.tab-pane {
    display: none;
}

    .tab-pane.active {
        display: block;
    }

.selected-list {
    padding: 5px 0;
}

.tribe-checkbox, .player-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.tribe-group, .player-group {
    margin-bottom: 10px;
    margin-left: 20px;
    margin-right: 0;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    overflow: hidden;
}

.tribe-group {
    margin-bottom: 15px;
    border: 1px solid rgba(74, 144, 226, 0.2);
}

    .tribe-group .group-header {
        background: rgba(74, 144, 226, 0.1);
    }

    .player-group .group-content:not(.collapsed) {
        max-height: 400px;
        overflow-y: auto;
    }

.player-group .group-header {
    background: rgba(255, 255, 255, 0.05);
}

.group-header {
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.group-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.group-actions {
    display: flex;
    gap: 4px;
    margin-right: 25px;
}

.group-action-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}

    .group-action-btn:hover {
        opacity: 1;
        transform: scale(1.1);
    }

    .group-header::after {
        content: '▼';
        position: absolute;
        right: 15px;
        transition: transform 0.2s;
    }

    .group-header.collapsed::after {
        transform: rotate(-90deg);
    }

    .group-header input[type="checkbox"] {
        flex-shrink: 0;
    }

.group-title {
    font-weight: 600;
    color: #4a90e2;
}

.group-count {
    background: rgba(74, 144, 226, 0.2);
    color: #4a90e2;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 10px;
}

.group-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

    .group-content.collapsed {
        max-height: 0 !important;
    }

    .group-content:not(.collapsed) {
        max-height: none;
    }

.villages-table-container {
    width: 100%;
    overflow-x: auto;
}

.villages-table {
    width: 100%;
    border-collapse: collapse;
    color: #ddd;
    table-layout: fixed;
}

    .villages-table th, .villages-table td {
        padding: 8px 12px;
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .villages-table th {
        background: rgba(255, 255, 255, 0.05);
        font-weight: 600;
        color: #4a90e2;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .villages-table tr {
        transition: background-color 0.15s ease;
    }

    .villages-table tr:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    .villages-table .village-name {
        color: #ddd;
        font-weight: 500;
    }

    .villages-table .village-coords {
        color: #ddd;
        font-family: monospace;
        font-weight: 600; 
        text-align: center; 
    }

    .villages-table .village-player {
        color: #4a90e2;
    }

    .villages-table .village-tribe {
        color: #9b59b6;
    }

    .villages-table .village-points {
        color: #ffd700;
        font-weight: 600;
        text-align: right;
    }

.village-actions {
    text-align: center;
    width: 50px;
}

.village-action-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

    .village-action-btn:hover {
        opacity: 1;
    }

.selectable-header {
    width: 40px;
    text-align: center;
}

    .selectable-header input[type="checkbox"] {
        accent-color: #4a90e2;
    }

.village-select {
    width: 40px;
    text-align: center;
}

    .village-select input[type="checkbox"] {
        accent-color: #4a90e2;
    }

.villages-table tr.selected {
    background: rgba(74, 144, 226, 0.2);
    transition: background-color 0.1s ease;
}

.context-menu {
    position: absolute;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 5px 0;
    min-width: 150px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.context-menu-item {
    padding: 8px 15px;
    color: #ddd;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

    .context-menu-item:hover {
        background: rgba(74, 144, 226, 0.3);
    }

    .context-menu-item i {
        margin-right: 8px;
        width: 16px;
        text-align: center;
    }

.tool-btn, .top-tool-btn, .modal-action-btn {
    will-change: transform;
}

input[type="checkbox"] {
    cursor: pointer;
}

    input[type="checkbox"]:focus {
        outline: 2px solid #4a90e2;
        outline-offset: 2px;
    }

.empty-message {
    text-align: center;
    padding: 40px 20px;
    color: #aaa;
    font-size: 14px;
}

.tab-content::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.group-content::-webkit-scrollbar {
    width: 8px;
}

.tab-content::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track,
.group-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.tab-content::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb,
.group-content::-webkit-scrollbar-thumb {
    background: rgba(74, 144, 226, 0.5);
    border-radius: 4px;
}

    .tab-content::-webkit-scrollbar-thumb:hover,
    .modal-content::-webkit-scrollbar-thumb:hover,
    .group-content::-webkit-scrollbar-thumb:hover {
        background: rgba(74, 144, 226, 0.7);
    }

.filter-btn {
    padding: 8px 16px;
    background: #4a90e2;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

    .filter-btn:hover {
        background: #357abd;
    }

.filter-panel {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

    .filter-panel label {
        color: #aaa;
        font-size: 13px;
        font-weight: 500;
    }

    .filter-panel input {
        padding: 8px 12px;
        background: rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        color: white;
        width: 100px;
        font-size: 13px;
    }

        .filter-panel input:focus {
            outline: none;
            border-color: #4a90e2;
        }

    .filter-panel button {
        padding: 6px 12px;
        background: #4a90e2;
        border: none;
        border-radius: 4px;
        color: white;
        cursor: pointer;
        font-size: 12px;
    }

        .filter-panel button:hover {
            background: #357abd;
        }



#drawing-tools-panel {
    position: absolute;
    left: 90px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20, 20, 20, 0.95);
    padding: 12px;
    border-radius: 10px;
    z-index: 100;
    display: none;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(74, 144, 226, 0.3);
    backdrop-filter: blur(10px);
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.drawing-tools-header {
    color: #4a90e2;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(74, 144, 226, 0.3);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drawing-tools-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.draw-tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

    .draw-tool-btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: radial-gradient(circle, rgba(74, 144, 226, 0.4) 0%, transparent 70%);
        opacity: 0;
        transition: opacity 0.3s;
    }

    .draw-tool-btn:hover::before {
        opacity: 1;
    }

    .draw-tool-btn:hover {
        background: rgba(74, 144, 226, 0.2);
        border-color: rgba(74, 144, 226, 0.5);
        transform: scale(1.08);
        box-shadow: 0 0 15px rgba(74, 144, 226, 0.4);
    }

    .draw-tool-btn:active {
        transform: scale(0.95);
    }

    .draw-tool-btn.active {
        background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
        border-color: #4a90e2;
        box-shadow: 0 0 20px rgba(74, 144, 226, 0.6), 0 4px 12px rgba(0, 0, 0, 0.3);
        animation: pulse 2s infinite;
    }

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(74, 144, 226, 0.6), 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(74, 144, 226, 0.8), 0 6px 16px rgba(0, 0, 0, 0.4);
    }
}

.draw-tool-btn::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.draw-tool-btn:hover::after {
    opacity: 1;
}

.drawing-tools-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

    .drawing-tools-actions .tool-btn {
        width: 46px;
        height: 38px;
        font-size: 18px;
        background: rgba(231, 76, 60, 0.2);
        border-color: rgba(231, 76, 60, 0.3);
    }

        .drawing-tools-actions .tool-btn:hover {
            background: rgba(231, 76, 60, 0.4);
            border-color: rgba(231, 76, 60, 0.6);
            box-shadow: 0 0 15px rgba(231, 76, 60, 0.4);
        }

#tool-draw {
    position: relative;
}

    #tool-draw.active::after {
        content: '✓';
        position: absolute;
        top: 2px;
        right: 2px;
        font-size: 12px;
        background: #27ae60;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        animation: checkmark 0.3s ease-out;
    }

@keyframes checkmark {
    0% {
        transform: scale(0) rotate(-45deg);
    }

    50% {
        transform: scale(1.2) rotate(10deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

@media (max-width: 768px) {
    #drawing-tools-panel {
        left: 10px;
        bottom: 80px;
        top: auto;
        transform: none;
        flex-direction: row;
        animation: slideInBottom 0.3s ease-out;
    }

    @keyframes slideInBottom {
        from {
            opacity: 0;
            transform: translateY(10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .draw-tool-btn {
        width: 42px;
        height: 42px;
    }

        .draw-tool-btn::after {
            left: 50%;
            top: auto;
            bottom: calc(100% + 8px);
            transform: translateX(-50%);
        }
}

@media (max-width: 768px) {
    .color-block {
        width: 100%;
        margin: 0 0 15px 0;
    }

    .modal-body {
        flex-direction: column;
    }

    .selected-stats {
        flex-direction: column;
        gap: 10px;
    }

    .stat-item {
        padding: 10px;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 4px;
    }
}

.actions-panel {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.copy-btn {
    background: #4a90e2;
}

    .copy-btn:hover {
        background: #357abd;
        transform: translateY(-1px);
    }

.remove-btn {
    background: #e74c3c;
}

    .remove-btn:hover {
        background: #c0392b;
        transform: translateY(-1px);
    }

.action-btn .icon {
    font-size: 16px;
}

.collapse-btn {
    background: #95a5a6;
}

    .collapse-btn:hover {
        background: #7f8c8d;
        transform: translateY(-1px);
    }

.modal-body-split {
    display: flex;
    gap: 20px;
    padding: 20px;
}

@media (max-width: 1024px) {
    .modal-body-split {
        flex-direction: column;
    }

    .right-panel {
        width: 100%;
    }
}

.drawing-settings {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

    .setting-row:last-child {
        margin-bottom: 0;
    }

    .setting-row label {
        color: #aaa;
        font-size: 11px;
        min-width: 60px;
        text-transform: uppercase;
    }

#draw-color-picker {
    width: 50px;
    height: 30px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}

#draw-line-width {
    flex: 1;
    accent-color: #4a90e2;
}

#line-width-display {
    color: #4a90e2;
    font-weight: 600;
    font-size: 12px;
    min-width: 20px;
    text-align: center;
}

.drawing-tools-actions {
    display: flex;
    gap: 6px;
}

    .drawing-tools-actions .tool-btn {
        flex: 1;
        width: auto;
        height: 38px;
        font-size: 18px;
    }

#draw-clear-all {
    background: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.3);
}

    #draw-clear-all:hover {
        background: rgba(231, 76, 60, 0.4);
        border-color: rgba(231, 76, 60, 0.6);
        box-shadow: 0 0 15px rgba(231, 76, 60, 0.4);
    }

.eraser-cursor {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><text x="0" y="20" font-size="20">🗑️</text></svg>') 12 12, auto;
}

.pen-cursor {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><text x="0" y="20" font-size="20">✏️</text></svg>') 0 24, crosshair;
}

#main-toolbar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.9);
    padding: 8px 15px;
    border-radius: 8px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 10px;
    min-width: 400px;
}

.toolbar-section {
    position: relative;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

    .toolbar-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-1px);
    }

    .toolbar-btn.active {
        background: rgba(74, 144, 226, 0.3);
        border-color: #4a90e2;
    }

    .toolbar-btn .icon {
        font-size: 16px;
    }

    .toolbar-btn .arrow {
        font-size: 10px;
        transition: transform 0.2s;
    }

    .toolbar-btn.active .arrow {
        transform: rotate(180deg);
    }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 8px;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    color: #ddd;
    font-size: 12px;
    border-radius: 4px;
    transition: background 0.2s;
}

    .dropdown-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .dropdown-item input[type="checkbox"] {
        width: 16px;
        height: 16px;
        accent-color: #4a90e2;
        cursor: pointer;
    }

/* Панель инструментов выделения */
#selection-tools-panel {
    position: absolute;
    left: 90px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20, 20, 20, 0.95);
    padding: 10px;
    border-radius: 8px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(74, 144, 226, 0.3);
}

.selection-tool-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

    .selection-tool-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-1px);
    }

    .selection-tool-btn .icon {
        font-size: 16px;
    }

    .selection-tool-btn .badge {
        background: #4a90e2;
        color: white;
        font-size: 11px;
        font-weight: 600;
        padding: 2px 6px;
        border-radius: 10px;
        min-width: 20px;
        text-align: center;
    }



#analysis-toolbar {
    position: fixed;
    top: 60px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1001;
    max-width: 380px;
}

.analysis-section {
    padding: 15px;
}

.analysis-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

    .analysis-header .icon {
        font-size: 20px;
    }

    .analysis-header .title {
        flex: 1;
        font-weight: 600;
        font-size: 16px;
        color: #333;
    }

.close-btn-small {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

    .close-btn-small:hover {
        background: #f0f0f0;
    }

.analysis-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.time-range-section label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.date-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.separator {
    color: #999;
}

.action-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

    .action-btn.primary {
        background: #4A90E2;
        color: white;
    }

        .action-btn.primary:hover {
            background: #357ABD;
        }

.analysis-stats {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.stat-label {
    color: #666;
}

.stat-value {
    font-weight: 600;
    color: #333;
}

.analysis-types label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
}

.type-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.type-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

    .type-btn:hover {
        border-color: #4A90E2;
        background: #f0f7ff;
    }

    .type-btn.active {
        border-color: #4A90E2;
        background: #e3f2fd;
    }

    .type-btn .icon {
        font-size: 18px;
    }

    .type-btn .name {
        flex: 1;
        font-weight: 500;
        color: #333;
    }

    .type-btn .count {
        background: #e0e0e0;
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: 600;
        color: #666;
    }

    .type-btn.active .count {
        background: #4A90E2;
        color: white;
    }

.gradient-legend {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
}

.legend-title {
    font-weight: 500;
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
}

.gradient-bar {
    height: 30px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.gradient-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, white, #ff0000);
}

.gradient-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

/* Адаптация основной кнопки */
#analysis-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

    #analysis-btn.active {
        background: #4A90E2;
        color: white;
    }

/* Панель анализа отчетов - Темная тема */
#analysis-toolbar {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(20, 20, 20, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1001;
    max-width: 320px;
    backdrop-filter: blur(10px);
}

.toolbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

    .toolbar-header h3 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: #4a90e2;
    }

.toolbar-content {
    padding: 15px;
}

/* Секции */
.filter-section,
.analysis-types-section,
.action-section,
.stats-section,
.legend-section,
.info-section {
    margin-bottom: 20px;
}

    .filter-section h4,
    .analysis-types-section h4,
    .stats-section h4,
    .legend-section h4 {
        margin: 0 0 10px 0;
        font-size: 13px;
        font-weight: 600;
        color: #aaa;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

/* Ввод дат */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

    .input-group label {
        font-size: 12px;
        color: #aaa;
        font-weight: 500;
    }

    .input-group input[type="datetime-local"] {
        padding: 8px 10px;
        background: rgba(0, 0, 0, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        color: white;
        font-size: 13px;
        transition: border-color 0.2s;
    }

        .input-group input[type="datetime-local"]:focus {
            outline: none;
            border-color: #4a90e2;
        }

        /* Цветовая схема для calendar picker в темной теме */
        .input-group input[type="datetime-local"]::-webkit-calendar-picker-indicator {
            filter: invert(1);
            cursor: pointer;
        }

/* Кнопки типов анализа */
.type-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.type-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

    .type-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(74, 144, 226, 0.5);
        transform: translateY(-1px);
    }

    .type-btn.active {
        background: rgba(74, 144, 226, 0.2);
        border-color: #4a90e2;
        box-shadow: 0 0 10px rgba(74, 144, 226, 0.3);
    }

    .type-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

        .type-btn:disabled:hover {
            transform: none;
            border-color: rgba(255, 255, 255, 0.1);
        }

.type-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.type-name {
    flex: 1;
    font-weight: 500;
    text-align: left;
}

.type-count {
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    color: #aaa;
    padding: 3px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.type-btn.active .type-count {
    background: #4a90e2;
    color: white;
}

/* Кнопка загрузки */
.primary-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

    .primary-btn:hover {
        background: linear-gradient(135deg, #357abd 0%, #2868a0 100%);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    }

    .primary-btn:active {
        transform: translateY(0);
    }

    .primary-btn:disabled {
        background: #555;
        cursor: not-allowed;
        box-shadow: none;
    }

    .primary-btn .icon {
        font-size: 16px;
    }

/* Статистика */
.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border-left: 3px solid #4a90e2;
}

.stat-label {
    font-size: 12px;
    color: #aaa;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #4a90e2;
}

/* Легенда градиента */
.gradient-bar {
    height: 30px;
    background: linear-gradient(to right, white, #ff0000);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 8px;
}

.gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #aaa;
}

/* Информационная секция */
.info-section {
    padding: 12px;
    background: rgba(74, 144, 226, 0.1);
    border-radius: 6px;
    border-left: 3px solid #4a90e2;
}

.info-text {
    font-size: 11px;
    color: #ccc;
    margin: 6px 0;
    line-height: 1.6;
}

    .info-text strong {
        color: #fff;
        font-weight: 600;
    }

/* Подсказки */
.hint {
    font-size: 11px;
    color: #777;
    margin: 8px 0 0 0;
    font-style: italic;
}

/* Адаптация кнопки анализа в главной панели */
#analysis-btn.active {
    background: rgba(74, 144, 226, 0.3);
    border-color: #4a90e2;
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    #analysis-toolbar {
        right: 10px;
        top: 70px;
        max-width: calc(100vw - 20px);
    }

    .toolbar-content {
        padding: 12px;
    }

    .type-btn {
        padding: 10px;
    }

    .stat-item {
        padding: 8px 10px;
    }
}

/* Анимация появления */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#analysis-toolbar {
    animation: slideInRight 0.3s ease-out;
}

/* Scrollbar для длинного контента */
.toolbar-content::-webkit-scrollbar {
    width: 6px;
}

.toolbar-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.toolbar-content::-webkit-scrollbar-thumb {
    background: rgba(74, 144, 226, 0.5);
    border-radius: 3px;
}

    .toolbar-content::-webkit-scrollbar-thumb:hover {
        background: rgba(74, 144, 226, 0.7);
    }


.analysis-section {
    border-top: 1px solid rgba(74, 144, 226, 0.3);
    background: rgba(74, 144, 226, 0.05);
}

    .analysis-section .section-title {
        color: #4a90e2;
    }