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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #ffffff;
    color: #1f2937;
    line-height: 1.5;
    padding: 2rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    color: #10b981;
    margin-bottom: 0.5rem;
}

header p {
    color: #6b7280;
}

/* Sezioni */
.add-task-section,
.categories-section,
.filters-section,
.tasks-footer {
    margin-bottom: 1.5rem;
}

/* Form aggiungi task */
.add-task-section {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.add-task-section input,
.add-task-section select {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    background: #ffffff;
}

.add-task-section input:focus,
.add-task-section select:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

/* Bottoni */
.btn-primary {
    background: #10b981;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #059669;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Categorie */
.categories-section h3 {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
}

/* Nodo categoria ad albero */
.category-node {
    background: #fafafa;
    transition: background 0.15s;
}

.category-node:hover {
    background: #f3f4f6;
}

.category-node-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    min-height: 2.25rem;
}

.category-node-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.category-node-name {
    flex: 1;
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
}

.category-node-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.category-node:hover .category-node-actions {
    opacity: 1;
}

.cat-add-child-btn {
    background: #10b981;
    color: white;
    border: none;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.cat-add-child-btn:hover {
    background: #059669;
}

.cat-delete-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 0.875rem;
    cursor: pointer;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cat-delete-btn:hover {
    color: #ef4444;
    background: #fee2e2;
}

/* Input sotto-categoria inline */
.subcategory-input-wrapper {
    display: flex;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem 0.5rem;
    align-items: center;
    animation: slideDown 0.15s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.subcategory-input {
    flex: 1;
    padding: 0.375rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    background: white;
    transition: border-color 0.2s;
}

.subcategory-input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

.btn-confirm-subcat {
    background: #10b981;
    color: white;
    border: none;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-confirm-subcat:hover {
    background: #059669;
}

.btn-cancel-subcat {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-cancel-subcat:hover {
    background: #e5e7eb;
    color: #374151;
}

.add-category {
    display: flex;
    gap: 0.5rem;
}

.add-category input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.add-category input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

/* Filtri */
.filter-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.filter-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: #6b7280;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.filter-btn.active {
    background: #10b981;
    color: white;
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cat-filter-btn {
    background: none;
    border: 1px solid #e5e7eb;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
}

.cat-filter-btn.active {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* Task list */
.tasks-list {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s;
}

.task-item:last-child {
    border-bottom: none;
}

.task-item.dragging {
    opacity: 0.5;
    background: #f9fafb;
}

.drag-handle {
    cursor: grab;
    color: #9ca3af;
    font-size: 1.25rem;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.task-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: #10b981;
}

.task-text {
    flex: 1;
    font-size: 1rem;
    color: #1f2937;
}

.task-item.completed .task-text {
    text-decoration: line-through;
    color: #9ca3af;
}

.task-priority {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    background: #f3f4f6;
}

.task-priority.alta {
    background: #fee2e2;
    color: #dc2626;
}

.task-priority.media {
    background: #fed7aa;
    color: #ea580c;
}

.task-priority.bassa {
    background: #d1fae5;
    color: #059669;
}

.task-category {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    background: #f3f4f6;
    color: #374151;
    cursor: default;
}

.delete-task {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.2s;
}

.delete-task:hover {
    color: #ef4444;
}

/* Footer */
.tasks-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: #6b7280;
}

/* Responsive */
@media (max-width: 640px) {
    body {
        padding: 1rem;
    }
    
    .add-task-section {
        flex-direction: column;
    }
    
    .task-item {
        flex-wrap: wrap;
    }
    
    .task-priority, .task-category {
        font-size: 0.7rem;
    }
    
    .category-node-actions {
        opacity: 1;
    }
}