* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    touch-action: none;
}

#map {
    width: 100vw;
    height: 100vh;
    touch-action: pan-x pan-y pinch-zoom;
}

.popup-content {
    font-size: 14px;
    min-width: 220px;
}

.popup-content h3 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 16px;
}

.popup-content p {
    margin: 4px 0;
    color: #555;
    font-size: 13px;
}

.popup-content .price {
    font-size: 18px;
    font-weight: bold;
    color: #e74c3c;
    margin: 8px 0;
}

.popup-content button {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 8px;
    width: 100%;
    font-size: 14px;
    touch-action: manipulation;
}

.popup-content button:active {
    background: #2980b9;
}

.legend {
    position: absolute;
    bottom: 80px;
    right: 10px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    font-size: 12px;
}

.legend h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
}

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

.legend-color {
    width: 18px;
    height: 18px;
    margin-right: 6px;
    border-radius: 3px;
}

.toolbar {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar button {
    flex: 1;
    min-width: 100px;
    padding: 10px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.2s;
}

.toolbar button:active {
    background: #2980b9;
}

.toolbar button.secondary {
    background: #95a5a6;
}

.toolbar button.secondary:active {
    background: #7f8c8d;
}

.toolbar button.finish {
    background: #27ae60;
}

.toolbar button.finish:active {
    background: #229954;
}

.toolbar button.sync-btn {
    background: #9b59b6;
}

.toolbar button.sync-btn:active {
    background: #8e44ad;
}

.toolbar button.sync-btn.syncing {
    background: #e67e22;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 10px;
    margin: 5px 0 10px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.modal-content label {
    font-weight: bold;
    font-size: 13px;
    color: #555;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.btn-save {
    background: #27ae60;
    color: white;
}

.btn-cancel {
    background: #e74c3c;
    color: white;
}

.info-banner {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    background: rgba(52, 152, 219, 0.95);
    color: white;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.info-banner.active {
    display: block;
}

.info-banner.delete-mode {
    background: rgba(231, 76, 60, 0.95);
}

.info-banner .point-counter {
    font-weight: bold;
    font-size: 15px;
    margin-top: 5px;
}

.delete-cursor {
    cursor: crosshair !important;
}

.deletable-polygon {
    cursor: pointer !important;
}

.deletable-polygon:hover {
    filter: brightness(0.7) !important;
}

/* Стилі для табличок з назвами - завжди видимі */
.custom-marker-label {
    pointer-events: none !important;
    white-space: nowrap;
    z-index: 1000;
}

.custom-marker-label div {
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 4px 8px !important;
    border-radius: 3px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4) !important;
    font-size: 11px !important;
    font-weight: bold !important;
    white-space: nowrap !important;
    border: 1px solid rgba(0,0,0,0.2) !important;
    color: #333 !important;
    text-align: center !important;
}

@media (max-width: 768px) {
    .custom-marker div {
        font-size: 9px !important;
        padding: 2px 5px !important;
    }
}

/* Кластеризація міток на низькому зумі */
.marker-cluster {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #3498db;
    border-radius: 20px;
    padding: 5px 10px;
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Стилі для полігонів - збільшуємо прозорість при наведенні */
.leaflet-interactive {
    cursor: pointer;
}

.leaflet-interactive:hover {
    fill-opacity: 0.7 !important;
    stroke-width: 4 !important;
}

/* Стилі для tooltip */
.custom-tooltip {
    background: rgba(44, 62, 80, 0.95);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.custom-tooltip::before {
    display: none;
}

.temp-polygon {
    stroke: #e74c3c;
    stroke-width: 3;
    stroke-dasharray: 10, 5;
    fill: rgba(231, 76, 60, 0.3);
}

.temp-line {
    stroke: #e74c3c;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
}

.sync-status {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(46, 204, 113, 0.95);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 1500;
    display: none;
    animation: slideDown 0.3s ease;
}

.sync-status.error {
    background: rgba(231, 76, 60, 0.95);
}

.sync-status.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}