:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --accent: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover { background: #2563eb; }

.btn-secondary {
    background: rgba(255,255,255,0.15);
    color: white;
    backdrop-filter: blur(10px);
}

.btn-secondary:hover { background: rgba(255,255,255,0.25); }

.btn-outline {
    background: white;
    color: var(--primary);
    border: 2px solid var(--gray-200);
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Main Layout */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    min-height: calc(100vh - 70px);
}

@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
    }
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 15px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 16px 20px; }

/* Form */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control::placeholder { color: var(--gray-300); }

select.form-control {
    cursor: pointer;
    background: white;
}

/* Color picker */
.color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.color-option:hover { transform: scale(1.1); }
.color-option.selected { border-color: var(--primary); }

/* Particelle List */
.particelle-list {
    max-height: 350px;
    overflow-y: auto;
}

.particella-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.particella-item:hover { background: var(--gray-50); }
.particella-item.selected { background: #eff6ff; }

.particella-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.particella-info { flex: 1; min-width: 0; }

.particella-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
}

.particella-detail {
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.particella-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.particella-item:hover .particella-actions { opacity: 1; }

.icon-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    background: var(--gray-100);
}

.icon-btn:hover { background: var(--gray-200); }
.icon-btn.delete:hover { background: #fee2e2; color: var(--danger); }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 10px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* Map Container */
.map-section {
    display: flex;
    flex-direction: column;
}

.map-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.map-toolbar {
    padding: 12px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.map-controls {
    display: flex;
    gap: 6px;
}

.map-wrapper {
    flex: 1;
    min-height: 500px;
    background: linear-gradient(135deg, #e8f4f8 0%, #d4e8d4 100%);
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.map-wrapper.dragging { cursor: grabbing; }

#map-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.marker { cursor: pointer; }
.marker:hover { filter: brightness(1.1); }

.tooltip {
    position: absolute;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
    max-width: 280px;
}

.tooltip.show { opacity: 1; }
.tooltip h4 { color: var(--primary); margin-bottom: 6px; }
.tooltip p { color: var(--gray-500); margin: 3px 0; font-size: 12px; }
.tooltip .coords { 
    font-family: 'SF Mono', Monaco, monospace; 
    background: var(--gray-100); 
    padding: 3px 8px; 
    border-radius: 6px;
    font-size: 11px;
}

.zoom-info {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(255,255,255,0.95);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--gray-500);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-500);
    text-align: center;
    padding: 40px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    padding: 20px;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.show .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    color: var(--primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--gray-200); }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: white;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.3s;
    z-index: 1001;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Responsive */
@media (max-width: 600px) {
    .header-content { flex-direction: column; align-items: stretch; }
    .header-actions { justify-content: center; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .stat-item { padding: 8px; }
    .stat-value { font-size: 18px; }
}

/* Grid lines */
.grid-line { stroke: #c8dcc8; stroke-width: 0.5; }
