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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
}

#app {
    height: 100%;
    position: relative;
}

#map {
    height: 100%;
    width: 100%;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2e7d32;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: transform 0.2s, background-color 0.2s;
}

.fab:hover {
    background: #1b5e20;
    transform: scale(1.05);
}

.fab:active {
    transform: scale(0.95);
}

.fab.active {
    background: #c62828;
}

/* Locate button */
.locate-btn {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    color: #333;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: background-color 0.2s;
}

.locate-btn:hover {
    background: #f5f5f5;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 2000;
}

.modal[hidden] {
    display: none;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@media (min-width: 600px) {
    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: 16px;
        margin: 24px;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: white;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

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

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
    transition: border-color 0.2s, background-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2e7d32;
    background: white;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-group.half {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 10px;
}

/* Buttons */
.btn {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    flex: 1;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #2e7d32;
    color: white;
}

.btn-primary:hover {
    background: #1b5e20;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-danger {
    background: #c62828;
    color: white;
}

.btn-danger:hover {
    background: #b71c1c;
}

/* Journal section */
.journal-section {
    padding: 20px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.journal-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: #555;
}

.journal-list {
    margin-bottom: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.journal-entry {
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #eee;
    position: relative;
}

.journal-entry .entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.journal-entry .date {
    font-size: 0.85rem;
    color: #888;
}

.journal-entry .author {
    font-weight: 500;
    color: #2e7d32;
}

.journal-entry .comment {
    margin-top: 4px;
    white-space: pre-wrap;
}

.journal-entry .delete-entry {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
}

.journal-entry .delete-entry:hover {
    color: #c62828;
}

.journal-form {
    border-top: 1px solid #eee;
    padding-top: 12px;
}

.journal-form .form-group {
    margin-bottom: 10px;
}

.journal-form input,
.journal-form textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
}

.journal-form .btn {
    width: 100%;
}

/* Loading overlay */
.loading {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.loading[hidden] {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #2e7d32;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 4000;
    animation: fadeIn 0.3s ease-out;
}

.toast[hidden] {
    display: none;
}

.toast.error {
    background: #c62828;
}

.toast.success {
    background: #2e7d32;
}

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

/* Tree markers */
.tree-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #2e7d32;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 16px;
}

.tree-marker.selected {
    background: #1565c0;
    transform: scale(1.2);
}

/* Placement marker (draggable) */
.placement-marker {
    width: 40px;
    height: 40px;
    background: #ff9800;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: grab;
}

.placement-marker::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid #ff9800;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
}

.leaflet-popup-content {
    margin: 12px 16px;
    font-size: 14px;
}

.popup-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.popup-info {
    color: #666;
    margin-bottom: 8px;
}

.popup-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
}

.popup-btn:hover {
    background: #1b5e20;
}

/* Add mode cursor */
.add-mode {
    cursor: crosshair !important;
}

.add-mode .leaflet-interactive {
    cursor: crosshair !important;
}